devoured elysium
devoured elysium

Reputation: 105067

Calling windows functions in ASM (push/pop question)

I want to call the Sleep function on ASM. So I wrote the following:

push 5000
call Sleep

Although everything went fine, I had the idea that everytime I pushed a value on the stack, I should also pop it(otherwise it'd get all cluttered later in the program?). Should I pop it? How should I do it?

Upvotes: 4

Views: 1843

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993085

Virtually all Win32 API functions use the __stdcall calling convention, where the called function is responsible for popping the argument(s) off the stack. So in the case of Sleep(), you don't have to do anything else than what you've shown.

Upvotes: 5

Related Questions