title: Win32 NASM HelloWorld using Prinft results in AccessViolation
body: <p>just read lots of tutorials and thought I'd give it a try with NASM on Windows. I tried several simple "Hello World" versions, one of which should use the _printf function to print the text to stdout.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>; Build by doing:
  ; nasm -f win32 -o test.o test.asm
  ; link /SUBSYSTEM:CONSOLE libcmt.lib test.o
  
  section .text
      global _start   
      extern _printf 
  
  _start:
      push msg      ; Push msg on stack
      call _printf  ; Call printf
      add  esp, 4   ; Reset the stack 
  
      ; return 0
      xor eax, eax
      ret
  
  ; Our string, null terminated
  msg: db "Hello World ", 13,10,0
  </code></pre>
  
  <p>I built it as described using "nasm -f win32 -o test.o test.asm" and linked it with the Microsoft Visual Studio 2013 linker. Works well so far, but as soon as I try to run the executable I get an access violation. Exact linker command used:</p>
  
  <pre><code>link /subsystem:console /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib" /nodefaultlib /entry:start test.o libcmt.lib kernel32.lib
  </code></pre>
  
  <p>I did my best using OllyDBG to get to the error, but that didn't help either. Maybe someone here got an idea?...</p>
  
  <p>Regards</p>