2

When I try to divide a number by two I get "Divide by zero" error.

Current status:

Current registers status

AX = 0009

I have this line

Two DW 2

And when I am trying to do

DIV Two

I get this error:

Error divide by zero

What is the problem?

fuz
  • 88,405
  • 25
  • 200
  • 352
benzi
  • 19
  • 2

1 Answers1

2

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.

fuz
  • 88,405
  • 25
  • 200
  • 352