yes it is easy
you divide the 10 base number out of 5 or any base you want then take the remainder as the left digit redo with the dividend
like the code below
mov eax, (the wished number)
mov cx, 14
a:
xor edx, edx (or extend the sign by cxd instruction i think)
div word ptr 5
shl edx,12
shld memory, edx, 4
mov edx, eax
loop a:
this is example the result is the memory value clear it before use
mov cx, 14 14 if base 5 it must be changed if not 5
sorry i gave you a false code example, because i usually did; dividing by ten's power (to convert from hex to decimal and display a bounded num) and put remainder in memory from left to right.
yesterday my brain was off; i mixed the both ideas
ok, never mind
in your case you must divide by the base then you put the remainder in memory from right to left.
the right code is:
mov eax, (wished number)
a:
xor edx, edx
div word ptr 5 (base)
mov memory, dl
inc memory(memory=num after converting)
cmp eax, 0
jz b:
mov eax, edx
jmp a:
b:
nb1: number of 3 digit in decimal base gives number of 7 digit at least in binary base; converting is giving a new representation to any number so you should give memory enough size
nb2: num in base 5 is represented by 0 1 2 3 4 ; you can leave the remainder in nibble you don't need a byte for each digit however if the base is > 8 you should use bytes
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.