title: How do I use scanf in x86-64 AT&T Assembler?
body: <p>I can't figure out how to call scanf properly. My current code adds 0x30 to my answer for some reason.</p>
  <p>This is my current code</p>
  <pre><code>.file &quot;get_int.s&quot;
  .section .rodata
  .text
  .globl get_int
      .type get_int, @function
  scanf_line:
      .string &quot;Test %d&quot;
  get_int:
      pushq %rbp          #save caller's rbp
      movq %rsp, %rbp     #set function's frame pointerr
  
      movq $0, %rax            #initalize return to 0
      movq $scanf_line, %rdi   #push scanf_line into 1st arg
      call scanf               #call scanf C function
  
  exit:
  
      leave
      ret
  .size get_int, .-get_int
  </code></pre>
  <p>If I were to enter decimal 5 I would get back 0x35 or decimal 53 in the rsi register.</p>