how to turn a hex code into a dec code

I'd use the windows calculator usually but here's the real deal...

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...

```
```

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

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.

But if you are looking for code that converts hex to ascii look into the masmlib or the algo forums.

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

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

I use FILD and FBSTP sequention.

Here's another way, using JimmyClif's sample number 1AB9:

16*116+10=26

16*26+11=427

16*427+9=6841

16*116+10=26

16*26+11=427

16*427+9=6841

Sorry for the typo in the first line!

16* 1+10=26

16* 26+11=427

16*427+ 9=6841

16* 1+10=26

16* 26+11=427

16*427+ 9=6841