how to turn a hex code into a dec code
Posted on 2003-06-22 09:11:50 by feizhongshvi
I'd use the windows calculator usually but here's the real deal...



hex numbers: 0 1 2 3 4 5 6 7 8 9 A B C D E F
dec numbers: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Example:

To convert 1AB9 you take the 1st number of the whole number and multiply it by 16 and the power of it's position on which it stands, then you take the second and do the same and on and on...



1AB9 hex number
3210 position

1 * 16 exp 3 + (== 1 * 4096 == 4096)
A * 16 exp 2 + (== 10 * 256 == 2560)
B * 16 exp 1 + (== 11 * 16 == 176)
9 * 16 exp 0 (== 9 * 1 == 9)
-------------------
4096 + 2560 + 176 + 9 = 6841
Posted on 2003-06-22 09:33:33 by JimmyClif
Read this :) Something I have written

But if you are looking for code that converts hex to ascii look into the masmlib or the algo forums.
Posted on 2003-06-22 10:13:06 by roticv
May be the code below is suitable to you

Hex2Dec proc
;Inpit: EAX=code, EDI=lpString
push ecx
push edx
mov ecx,10
push ecx
@@1: xor edx,edx
div ecx
push edx
cmp eax,ecx
jae @@1

@@2: or al,30h
stosb
pop eax
cmp eax,ecx
jb @@2
pop edx
pop ecx
ret
Hex2Dec endp
Posted on 2003-06-27 07:04:12 by MikDay
I use FILD and FBSTP sequention.
Posted on 2003-06-30 12:13:31 by MazeGen
Here's another way, using JimmyClif's sample number 1AB9:

16*116+10=26
16*26+11=427
16*427+9=6841
Posted on 2003-08-12 23:52:22 by PiGeek
Sorry for the typo in the first line!

16* 1+10=26
16* 26+11=427
16*427+ 9=6841
Posted on 2003-08-12 23:53:49 by PiGeek