Ok, I am having troubles working out an algorithm to do this in x86 assembly. So lets say I have the hex DC 0B FD F4 at memory offset :1027, it is little-endian stored of course(so the serial is really f4 fd 0b dc). It is the serial number of the disk. I need to convert the hex to ASCII vaules so that I can print them.

For the digits if I add 30H to them then the become there respective ASCII charachter. But I am kinda lost from there.

I am using this code to get the first sector of the floppy disk:


MOV AH,02
MOV AL,01
MOV CH,00
MOV CL,01
MOV DX,0000
LEA BX,[1000]
INT 13
INT 20


this is a dump of what is retrieved:


0B79:1000 EB 3C 90 4D 53 44 4F 53-35 2E 30 00 02 01 01 00 .<.MSDOS5.0.....
0B79:1010 02 E0 00 40 0B F0 09 00-12 00 02 00 00 00 00 00 ...@............
0B79:1020 00 00 00 00 00 00 29 DC-0B FD F4 4E 4F 20 4E 41 ......)....NO NA
0B79:1030 4D 45 20 20 20 20 46 41-54 31 32 20 20 20 33 C9 ME FAT12 3.
0B79:1040 8E D1 BC F0 7B 8E D9 B8-00 20 8E C0 FC BD 00 7C ....{.... .....|
0B79:1050 38 4E 24 7D 24 8B C1 99-E8 3C 01 72 1C 83 EB 3A 8N$}$....<.r...:
0B79:1060 66 A1 1C 7C 26 66 3B 07-26 8A 57 FC 75 06 80 CA f..|&f;.&.W.u...
0B79:1070 02 88 56 02 80 C3 10 73-EB 33 C9 8A 46 10 98 F7 ..V....s.3..F...


down at 0b79:1027 for a lenght of 4bytes is the serial number.

Would someone please help me with a code example or something..

Thanks
Posted on 2002-04-30 10:12:48 by Zevlag
IF n > 9

n = n + 'A'
ELSE
n = n + '0'
ENDIF
Posted on 2002-04-30 10:19:32 by bitRAKE
Which base do you want it in? Base16 is pretty easy: get a nibble,
use as index to charbuffer, repeat until there's no more nibbles.
Ie, your charbuffer would be "0123456789ABCDEF", and a nibble
is 4 bits. That should be enough hints :).

You can also do as bitrake suggests if you don't mind conditional
jumps, and there's other methods still.
Posted on 2002-04-30 10:43:57 by f0dder