message
is the address of that text, not the text itself. When you execute push message
, it decrements the stack pointer by four and puts that address at that location.
Then following the call, it cleans up by simply adding four back to the stack pointer, effectively removing message
from the stack.
In any case, like hordes of C programmers seem to miss, there's no real point using printf
if you're outputting a fixed string followed by a newline, the puts
function is a better choice:
; ----------------------------------------------------------------------------
; helloworld.asm
;
; This is a Win32 console program that writes "Hello, World" on one line and
; then exits. It needs to be linked with a C library.
; ----------------------------------------------------------------------------
global _main
extern _puts
section .text
_main:
push message
call _puts
add esp, 4
ret
message:
db 'Hello, World', 0