I started learning assembly today and I copied and pasted a program that displays hello world. I tried to modify it to use C function system("PAUSE") and I made this:

[section .data]

hello: db 'Hello, world!',10,0
pause: db 'PAUSE',10,0

[section .text]

global _main
extern _printf
extern _system

_main:

push hello
call _printf
add esp,4

push pause
call _system
add esp,8

mov eax,0
ret

It does display "Press any key to continue" but when I press any key it freezes. What did I do wrong?

Never mind! It works now. I changed add esp,8 to add esp,4

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.