I am thinking about how a function call works in assembler. Currently I think it works like:
push arguments on stack
push eip register on stack and setting new eip value over jump # call instruction
# callee's code
push ebp register on stack
working in the function
returning from function
pop ebp
pop eip # ret instruction
so but now I am thinking about it, how does assembler save the current stack pointer?
For example if I have some local variables the esp(stack pointer) goes down and if I come back to the main function assembler has to set the esp pointer to the right place but how does this work ?
Have a look at the Calling conventions page on wikipedia.