title: 8086 assembly on DOSBox: Bug with idiv instruction?
body: <p>I was helping a friend of mine debug his program, and we narrowed it down to an issue which occurs even here:</p>
  
  <pre><code>.MODEL small
  .STACK 16
  .CODE
  start:
      mov ax, 044c0h
      mov bl, 85
      idiv bl
  exit:
      mov ax, 4c00h
      int 21h
  
  end start
  </code></pre>
  
  <p>After assembling it with tasm 4.1, and running it on DOSBox 0.74, it goes into an infinite loop. When inspecting it with turbo debugger one can see it happens after the <code>idiv</code> instruction, which for some reason modifies the <code>cs</code> and <code>ip</code> registers, and after two seemingly random instructions restores them to point to the <code>idiv</code> line, executing it again ad infinitum. </p>
  
  <p>Does anyone have any explanation for this?</p>