From: Benjamin David Lunt on
Hi everyone,

I was going through my files and came across this peice
of code by the late Charles Crayne. Looking up the post,
it was about 3 years ago.

http://groups.google.com/group/alt.lang.asm/browse_thread/thread/485872fe7fc11611/ac8b27b445b18bb4?hl=en&ie=UTF-8&oe=UTF-8&q=hexdd+hexdw+hexdb+crayne

It is amazing what you will find in a temp directory :-)


Charles A. Crayne
As an additional example, I am still using essentially the same routine
which I wrote almost 25 years ago, albeit updated for 32-bit registers:

;hex to ascii routines
;eax value to be converted
;esi ->result string
;returns esi->next position
hexdd: push eax
shr eax,16 ;do high word first
call hexdw
pop eax
hexdw: push eax
shr eax,8 ;do high byte first
call hexdb
pop eax
hexdb: push eax
shr eax,4 ;do high nibble first
call hexdn
pop eax
hexdn: and eax,0fh ;isolate nibble
add al,'0' ;convert to ascii
cmp al,'9' ;valid digit?
jbe hexdn1 ;yes
add al,7 ;use alpha range
hexdn1: mov [esi],al ;store result
inc esi ;next position
ret


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Forever Young Software
http://www.frontiernet.net/~fys/index.htm
http://www.frontiernet.net/~fys/collections.htm
To reply by email, please remove the zzzzzz's

Batteries not included, some assembly required.


From: Alexei A. Frounze on
On Jan 15, 5:57 pm, "Benjamin David Lunt" <zf...(a)frontiernet.net>
wrote:
> Hi everyone,
>
> I was going through my files and came across this peice
> of code by the late Charles Crayne.  Looking up the post,
> it was about 3 years ago.
>
> http://groups.google.com/group/alt.lang.asm/browse_thread/thread/4858...
>
> It is amazing what you will find in a temp directory :-)
>
> Charles A. Crayne
> As an additional example, I am still using essentially the same routine
> which I wrote almost 25 years ago, albeit updated for 32-bit registers:
>
> ;hex to ascii routines
> ;eax    value to be converted
> ;esi    ->result string
> ;returns esi->next position
> hexdd:  push    eax
>         shr     eax,16          ;do high word first
>         call    hexdw
>         pop     eax
> hexdw:  push    eax
>         shr     eax,8           ;do high byte first
>         call    hexdb
>         pop     eax
> hexdb:  push    eax
>         shr     eax,4           ;do high nibble first
>         call    hexdn
>         pop     eax
> hexdn:  and     eax,0fh         ;isolate nibble
>         add     al,'0'          ;convert to ascii
>         cmp     al,'9'          ;valid digit?
>         jbe     hexdn1          ;yes
>         add     al,7            ;use alpha range
> hexdn1: mov     [esi],al        ;store result
>         inc     esi             ;next position
>         ret
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Forever Young Softwarehttp://www.frontiernet.net/~fys/index.htmhttp://www..frontiernet.net/~fys/collections.htm
> To reply by email, please remove the zzzzzz's
>
> Batteries not included, some assembly required.

I still have some of my early Pascal programs from 93/94 and if I dig
up my papers, I'll probably find some Z80 asm code I wrote in 90/91,
which make it at least 20 years old now. I can't compete with those
older than myself, though. :)

Alex
From: James Harris on
On 16 Jan, 01:57, "Benjamin David Lunt" <zf...(a)frontiernet.net> wrote:
....
> ;hex to ascii routines
> ;eax    value to be converted
> ;esi    ->result string
> ;returns esi->next position
> hexdd:  push    eax
>         shr     eax,16          ;do high word first
>         call    hexdw
>         pop     eax
> hexdw:  push    eax
>         shr     eax,8           ;do high byte first
>         call    hexdb
>         pop     eax
> hexdb:  push    eax
>         shr     eax,4           ;do high nibble first
>         call    hexdn
>         pop     eax
> hexdn:  and     eax,0fh         ;isolate nibble
>         add     al,'0'          ;convert to ascii
>         cmp     al,'9'          ;valid digit?
>         jbe     hexdn1          ;yes
>         add     al,7            ;use alpha range
> hexdn1: mov     [esi],al        ;store result
>         inc     esi             ;next position
>         ret

A good example of assembler code going where compiler optimisers fear
to tread!

James
From: Rod Pemberton on
"Benjamin David Lunt" <zfysz(a)frontiernet.net> wrote in message
news:w294n.18448$DY5.6924(a)newsfe08.iad...
>
> I was going through my files and came across this peice
> of code by the late Charles Crayne. Looking up the post,
> it was about 3 years ago.
>
>
http://groups.google.com/group/alt.lang.asm/browse_thread/thread/485872fe7fc11611/ac8b27b445b18bb4?hl=en&ie=UTF-8&oe=UTF-8&q=hexdd+hexdw+hexdb+crayne
>

Hmm, looks like the thread "Faster HexToBuffer Routines" has 45 posts on
a.l.a and 12 on c.l.a.x. While HK's and CC's hex routine posts made it to
ala, it seems my post ended up on clax only:
http://groups.google.com/group/comp.lang.asm.x86/msg/7571b4b71a5d21f7

I have at least six hex assembly routines. Most are some variation of that,
e.g., 32-bit/16-bit etc. Although, I did code one to be much smaller, using
8-bit registers. It's still straightforward code. It won't win a Hugi Size
Compo.


Rod Pemberton


From: Woodster on
On Fri, 15 Jan 2010 18:57:41 -0700, "Benjamin David Lunt"
<zfysz(a)frontiernet.net> wrote:

>hexdn: and eax,0fh ;isolate nibble
> add al,'0' ;convert to ascii
> cmp al,'9' ;valid digit?
> jbe hexdn1 ;yes
> add al,7 ;use alpha range
>hexdn1: mov [esi],al ;store result

A trick I picked up from somewhere long ago:
and eax, 15
cmp al, 10
sbb al, 69h
das