How can I convert a number between 0 and 255 to it's hex value? For example 174 would result in "AE".

Posted on 2002-09-03 08:42:34 by Delight
masm32.lib -> dwtoh
Posted on 2002-09-03 09:06:47 by bazik
I knew about dw2hex, but I'm wondering if someone know how to do it only using registers. Since the number fits inside a byte, I thought there must be a better way of doing it than using dw2hex.

Thanks anyway!
Posted on 2002-09-03 09:17:35 by Delight
Hi Delight

;AL contains byte
xor ah,ah
ror ax,4
shr ah,4
cmp al,10
sbb al,69h
ror eax,8
cmp al,10
sbb al,69h
rol eax,8
;AX contains ascii hex, ready to store in a string buffer
;Else xchg al,ah

Posted on 2002-09-03 09:22:40 by KetilO
Thank you very much, sir! :cool:
Posted on 2002-09-03 12:58:58 by Delight