When I try to divide a number by two I get "Divide by zero" error.
Current status:
AX = 0009
I have this line
Two DW 2
And when I am trying to do
DIV Two
I get this error:
What is the problem?
When I try to divide a number by two I get "Divide by zero" error.
Current status:
AX = 0009
I have this line
Two DW 2
And when I am trying to do
DIV Two
I get this error:
What is the problem?
You need to clear dx
before dividing. Recall, div
divides DX:AX
by the operand, not just DX
. If you do not clear DX
, the resulting quotient does not fit into a 16 bit word, causing the CPU to generate an exception. This is the same exception you get for a division by zero and the debugger doesn't try to tell the two error sources apart.