title: carry flag in cmp instruction x86
body: <p>I'm new to x86 and I'm trying to put the larger integer ( at location 4(%esp) and 8(%esp) ) into register %eax. To my understanding, my cmp command will set the carry flag to 1 or zero, then adc will transfer that flag to the eax register. I can then then obtain the value I want by offsetting 4 + flag * 4 from esp. It seems to work in all cases except with negative values and I'm a bit confused?</p>
  
  <pre><code>movl    4(%esp),          %ecx   
  cmp     8(%esp),          %ecx   
  movl    $0,               %eax   
  adc     $0,               %eax   
  movl    4(%esp, %esp, 4), %eax   
  </code></pre>
  
  <p>p.s. I'm not allowed jumps/braches or fast arithemtic tricks.</p>