title: The point of test %eax %eax
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/147173/x86-assembly-testl-eax-against-eax">x86 Assembly - ‘testl’ eax against eax?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm very very new to assembly language programming, and I'm currently trying to read the assembly language generated from a binary.  I've run across </p>
  
  <pre><code> test   %eax,%eax
  </code></pre>
  
  <p>or <code>test %rdi, %rdi</code>, etc. etc. I'm very confused as to what this does.  Isn't the values in <code>%eax, %eax</code> the same?  What is it testing?  I read somewhere that it is doing the <code>AND</code> operation.....but since they are the same value, wouldn't it just return <code>%eax</code>?</p>
  
  <p>The following is just one instance where I found this usage:</p>
  
  <pre><code>   400e6e:       85 c0                   test   %eax,%eax
     400e70:       74 05                   je     400e77 &lt;phase_1+0x23&gt;
  </code></pre>
  
  <p>I thought <code>je</code> jumps if the two values being compared are equal......well, because  <code>%eax</code> is well, itself, in what situation would we NOT jump?</p>
  
  <p>I'm a beginner to programming in general, so I'd appreciate it very much if someone could explain this to me.  Thanks!</p>