I’m still new to assembly and I don’t know many command codes in assembly yet. I want to do a division in a 16-bit register. I want to print its content. I know that I need to convert the content of the register into ASCII for printing but again, my problem is the division. Please help me.
For example, the content of cx is 2012 (integer). What should I do?
mov ax, cx
mov bx, 1000
idiv bx
The above code is wrong, right?
Edit: I noticed that this is signed division
idiv, answer edited accordingly.The above code is wrong in one aspect:
axis not sign-extended todx:ax.Just add
cwd(convert word to doubleword) beforeidiv bx, and then it’s correct. The quotient will be inaxand the remainder will be indx.