title: Use of TEST instruction with same register
body: <p>Here is some C, found in a textbook I'm learning:</p>
  
  <pre><code>...
  do {
      ...
      n--;
  } while (n &gt; 0)
  ...
  </code></pre>
  
  <p>I assume <code>n</code> is at <code>%edx</code>.</p>
  
  <p>The assembly code produced is: </p>
  
  <pre><code>testl %edx, %edx 
  jle .L5
  </code></pre>
  
  <p>I understand that <code>jle</code> tests for less than or equal to <code>(SF ^ OF) | ZF</code>. However I am unsure how this instruction corresponds to <code>n &gt; 0</code>. Can anyone explain this?</p>