I am brand new to assembly programming and I was wondering why the address of a variable is always pushed to the stack instead of the actual variable. For example:
.text:00401270 push ebp
.text:00401271 mov ebp, esp
.text:00401273 sub esp, 80h
.text:00401279 push offset aString1
.text:0040127E call sub_401554
Why is the actual variable never pushed as an argument?
Not all “function” arguments are necessarily passed by reference, but your example is a string, which is passed by reference due to its variable size being inappropriate on the stack.
The specifics of how you call a function and clean up before returning will vary depending upon the calling convention with which you are to interface.
If your callers will always be assembly code you control, you might choose to pass short arguments on the stack, but passing pointers lets you use data structures which are larger and more complicated, and thus more likely candidates for needing hand-coded-assembly optimization.