title: Using scanf with x86-64 GAS assembly
body: <p>I have been having loads of issues trying to get a call the the system function scanf to work in my x86 assembly program. Currently I have got it to read from standard in however, it only will read chars without a segfault (I have no idea why, the specifying string is %d). The examples I've seen of scanf in x86 online use quarky or are written with NASM syntax, thus I have tried to adapt them for my program.  </p>
  
  <pre><code>f:
      .string "%d"
  
  _main:
      movq    $0,    %rax    #Clean rax
      movq    $f,    %rdi    #Load string format
      movq    %rcx,  %rsi    #Set storage to rcx (Not sure if this is valid)
      call    scanf
      ret
  </code></pre>
  
  <p>Checking rcx and rax using printf return 1 and 0 respectively after inputting a char or string (only way the program doesn't segfault).</p>
  
  <p>Any insight on how to us scanf properly in x86 gas assembly would be very much appreciated! </p>