title: Assembly Division
body: <p>In my program, a hex number is divided by ten and the remainder is checked.</p>
  
  <p>First division is performed well; however, after the second division, the program goes wrong. I am new to assembly, and I couldn't find where the problem is...</p>
  
  <p>Here is the code segment:</p>
  
  <pre><code>ORG 1000
  
      MOV AX, 0x04B4 (1204 decimal value )
      MOV BX, 0x000A ( 10 decimal value )
      MOV CX, 0x0000
  
      DIV BX ( After this part, AX is 120 decimal and DX 4 decimal )
  
      CMP DX, 0x0000
      JE eq1
  
      ADD CX, 0x0002
      JMP con1
  
      eq1:    ADD CX, 0x0001  
  
      con1:
  
      DIV BX ( But, after this division AX becomes 6677 ( 26231 decimal and DX remains 4 decimal )
      CMP DX, 0x0000
  </code></pre>
  
  <p>Thanks for help!</p>