title: Assembly 8086, LOOP instruction doesn't stop
body: <p>The following code is for assembly 8086, I'm looping using <code>LOOP</code> instruction.</p>
  
  <p>The loop continues forever after <code>CL</code> becomes zero and it changes the <code>CX</code> value to FFFFh.<br>
  But if I change the value of <code>CL</code> to maximum 06h, the loop stops properly.<br>
  Moreover, if I remove first <code>LOOP AGAIN</code> it will work fine.</p>
  
  <pre><code>DATA DB 01001100b
  
  MOV AL, DATA
  MOV CL, 08h
  SUB BL, BL
  SUB DL, DL
  
  AGAIN:
  ROL AL, 1  
  JC SKIP
  INC BL
  LOOP AGAIN
  
  SKIP: 
  INC DL
  LOOP AGAIN
  </code></pre>
  
  <p>I expect it to stop when <code>CL</code> becomes zero. Any idea why it isn't behaving as expected?</p>
  
  <p><strong>UPDATE 1</strong>
  I have noticed when <code>CL</code> (or <code>CX</code> when using 16 bit) reaches 1 and last bit is 0, then the first <code>LOOP AGAIN</code> won't jump up and operation continues to the <em>SKIP</em> part. If I change the last bit of <em>DATA</em> to 1 it will make the <code>JC SKIP</code> and everything works just fine.</p>