title: what does the cmpq instruction do?
body: <p>I was reading the following definition for syscall:</p>
  
  <pre><code>.text
  .globl syscall
  .type   syscall,%function
  .align 16
  syscall:
      movq %rdi, %rax     /* Syscall number -&gt; rax.  */
      movq %rsi, %rdi     /* shift arg1 - arg5.  */
      movq %rdx, %rsi
      movq %rcx, %rdx
      movq %r8, %r10
      movq %r9, %r8
      movq 8(%rsp),%r9    /* arg6 is on the stack.  */
      syscall         /* Do the system call.  */
      cmpq $-4095, %rax   /* Check %rax for error.  */
      jae __syscall_error     /* Branch forward if it failed.  */
      ret         /* Return to caller.  */
  
  .size syscall,.-syscall
  </code></pre>
  
  <p>I saw it explained that the line <code>cmpq $-4095 %rax</code> determines whether %rax contains a value between -1 and -4095.  How does it do that?  What exactly does the cmpq instruction do?</p>