title: Why did mov dx,0 fix this division routine?
body: <p>A simple loop to find the largest divisor, which would be the integer of the root, in this case dropping out at 5 in a 345 triangle</p>
  
  <pre><code>mov ax,3                        
  mul ax                          
  push ax                         
  mov ax,4                        
  mul ax                          
  pop bx                          
  add ax,bx                       
  push ax    ;save 25 decimal for repeated loops                        
  mov bx,1                        
  mov bp,sp                       
  
  agin                            
  mov dx,0      ;fixed problem                  
  mov ax,[bp]   ;25 decimal                  
  inc bx        ;starts at 2                  
  div bx                          
  cmp bx,ax                       
  jb agin                         
  
  out
  </code></pre>
  
  <p>However, weird things happened when the program went from 2 to 3, I got hex555D instead of 8 (8*3)</p>
  
  <p>Putting mov dx,0 in fixed it and returned things to normal</p>
  
  <p>I have no idea why, no flags changed</p>
  
  <p>Anyone know why? is this a signed/unsigned issue?</p>