954,479 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

system("PAUSE")

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?

sergent
Posting Pro
598 posts since Apr 2011
Reputation Points: 70
Solved Threads: 22
 

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

sergent
Posting Pro
598 posts since Apr 2011
Reputation Points: 70
Solved Threads: 22
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You