title: Comparing a char to a constant in assembly
body: <p>Overall, I am trying to compare the value of the first element of an array passed into my assembly function from a c++ program with a constant value and preform a jump if they are equal.  </p>
  
  <p>I can view the value of <code>%rdi</code> in gdb with <code>x /c $rdi</code> and it outputs <code>0x7fffffffde80:    97 'a'</code> I would expect that <code>cmp $97, %rdi</code> and then preforming a jump if they are equal would work, but alas the comparison fails as if these two values are not equal. </p>
  
  <p>I've built a small test program demonstrating what I am attempting to do. The program should get stuck in an infinite loop if the first element of the array being passed in is not an 'a', otherwise it should exit normally. when ran though, I get stuck in an infinite loop regardless of the values passed in the array.</p>
  
  <p>Any insight onto what is going on here would be very much appreciated.</p>
  
  <p>In my driver cpp:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  extern int _asmTest(char c[]) __asm__("_asmTest");
  
  
  int main() 
  {
      char arr[2] = {'a','b'};  
      int test = _asmTest(arr);
      std::cout &lt;&lt; "First element was 'a'" &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>In my asm: </p>
  
  <pre><code>.global _asmTest
  .text
  
  _asmTest:
      push   %rbp
      mov    %rsp, %rbp
  
      # Go to infinite loop if arg1's first element is not 'a'
      loop:
      cmp    $97, %rdi
      je     continue
      jmp    loop   
  
      continue:
      mov    %rbp, %rsp
      pop    %rbp
      ret
  </code></pre>