Hi, I was wondering how I could convert an Ascii value into a Hex value? For example, I'm reading a string in from a file which looks like 1DC632FD. I read 1 byte into ah and 1 byte into al so eax holds the value 3144. (1 = Asc 31, D = Asc 44) How would I go about converting this value back to 1D? Thanks for the help :) Regards, Bl00dBaTH
Posted on 2001-06-09 18:30:00 by Bl00dBaTH
You might find something in a library. If you do it yourself, it's just a matter of arithmetic, something like:

PackAX:
   call PackAH
   call PackAH
   shl al,4
   shr ax,4
   ret

PackAH: 
   xchg al,ah ;careful with the order of terms
   sub al,"0"
   ;jc nondigit
   cmp al,10
   jnc AnyRet
   sub al,"A"-1-"9"
   ;cmp al,16
   ;jnc nondigit
   ;cmp al,11
   ;jc nondigit
AnyRet: ret
You might need handlers for nondigits; they are remmed out here. Also, the above assumes the text is in upper case. For a string of more than two digits, I would prefer to loop through them one at a time, rather than two at a time. This message was edited by Larry Hammick, on 6/10/2001 1:50:54 AM
Posted on 2001-06-10 01:21:00 by Larry Hammick