I am making a simple program to convert hexadecimal numbers to decimal through repeated division method.
xor rbx,rbx
xor rdx,rdx
mov bx,0Ah
divide:
div bx
flag11:
push rdx
dec r8
jnz divide
The input given was 1234.The value in rax after conversion from ascii to hex was
rax 0x1234 4660
which is correct.The division process went smoothly for the first two runs,but after the third division,this is what happened:
rax 0x999e 39326
Insted of a 4,there's a random value in the register.Why is this happening and how can I fix it?