title: Why "mov rcx, rax" is required when calling printf in x64 assembler?
body: <p>I am trying to learn x64 assembler. I wrote "hello world" and tried to call printf using the following code:</p>
  
  <pre><code>EXTERN printf: PROC
  
  PUBLIC hello_world_asm
  
  .data
  hello_msg db "Hello world", 0
  
  
  .code
  hello_world_asm PROC
  push rbp ; save frame pointer
  mov rbp, rsp ; fix stack pointer
  sub rsp, 8 * (4 + 2) ; shadow space (32bytes)
  
  lea rax, offset hello_msg
  mov rcx, rax ; &lt;---- QUESTION ABOUT THIS LINE
  call printf
  
  ; epilog. restore stack pointer
  mov rsp, rbp
  pop rbp
  ret
  hello_world_asm ENDP
  
  
  END
  </code></pre>
  
  <p>At the beginning I called printf without "mov rcx, rax", which ended up with access violation. Getting all frustrated I just wrote in C++ a call to printf and looked in the disassembler. There I saw the line "mov rcx, rax" which fixed everything, but <em>WHY</em> do I need to move RAX to RCX ??? Clearly I am missing something fundamental.</p>
  
  <p>Thanks for your help!</p>
  
  <p>p.s. a reference to good x64 assembler tutorial is more than welcome :-) couldn't find one.</p>