I'm using a x86 emulator and I'm trying to write a short program that receives an integer and converts it to binary. However, I run it step by step and check the memory (and the ax register as it is updated) I can see that the ax register evolves as it follows: 14 -> 7 -> 3 -> 32769 (Instead of 1). Why is this happening? I've tried using EAX and ECX instead of ax and cx but it still wont give me the correct result. Am I missing something really obvious?
value: dw 14
binary: dw 0
mov ax,0
mov cx,0
mov dx,0
;CONVERTING 14 TO BINARY
CONVERSION:
mov ax,[valor]
mov cx,2
div cx
push dx
mov [valor],ax
cmp ax,0
jne CONVERSION
pop [binary]