title: Assembly Reading User Input to Registers Gives Unexpected Value
body: <p>So I'm learning to use assembly and have written a simple function called _getInput as seen below:</p>
  
  <pre><code> _getInput:
        movq    $0, %rax
        movq    $0, %rdi
        subq    $8, %rsp           
        leaq    -8(%rsp), %rsi
        movq    $8, %rdx
        addq    $8, %rsp
        syscall
        ret
  </code></pre>
  
  <p>I then have a _start function that calls this and saves the entered input to %r8 like so:</p>
  
  <pre><code>_start:
      call _getInput
      movq (%rsi), %r8
  </code></pre>
  
  <p>I've traced through this in GDB to see what the values of the registers are and have a few questions. First off, after I type an input and hit enter, %rsi has a value of 140737488347624. When I then run the next line to copy to %r8, the value of %r8 is 2609. Can someone explain what exactly is happening and where these values are coming from? I was expecting the value to be 49 (the ascii representation of 1), though maybe the new line character complicates this? Thank you!</p>