title: ASM x64 scanf printf double, GAS
body: <p>I can't figure out why this code isn't working for me. I need to use scanf function for double and then printf for same double.
  When using this code results are not good. What I see are pretty random characters. </p>
  
  <pre><code>.data
  
  d1: .double
  
  
  format: .asciz "%lf\n"
  format2: .asciz "%lf"
  
  .text
  .globl main
  
  main:
  
  subq $8, %rsp
  
  #scanf 
  movq $0, %rax
  movq $d1, %rsi
  movq $format2, %rdi
  call scanf
  addq $16, %rsp
  
  #printf 
  movq $1, %rax
  movsd d1, %xmm0
  movq $format, %rdi
  call printf     
  addq $16, %rsp
  
  #exit
  movq $1, %rdi
  xorq %rax, %rax
  call exit
  </code></pre>