I
IMSHURKKPWII
Hi all,
I am confused about the methods by which C passes things to other
routines. If I have a routine,
void rt([type] [name1], [type] [name2], ...);
Then I know that the process to call this function is this:
1. Push values onto the stack, from right to left.
2. Push return address onto stack.
3. Set PC = address of rt.
The stack looks like:
---
arg_n
---
arg_n-1
---
....
---
Return Address
---
I noticed that when exiting a function, the stack pointer should be
pointing to the position on the stack where the Return Address is
stored; and when returning to the caller, PC gets set to SP, and then
SP gets incremented by 4 bytes or so-- however long the Return Address
is.
Now I have a problem with this: SP will be pointing to the last
argument on the stack that was pushed by the caller. I've looked at
assembly listings and I can't seem to find any section that is
responsible for actually removing those arguments from the stack once
they've been pushed.
Thanks
-HG.
I am confused about the methods by which C passes things to other
routines. If I have a routine,
void rt([type] [name1], [type] [name2], ...);
Then I know that the process to call this function is this:
1. Push values onto the stack, from right to left.
2. Push return address onto stack.
3. Set PC = address of rt.
The stack looks like:
---
arg_n
---
arg_n-1
---
....
---
Return Address
---
I noticed that when exiting a function, the stack pointer should be
pointing to the position on the stack where the Return Address is
stored; and when returning to the caller, PC gets set to SP, and then
SP gets incremented by 4 bytes or so-- however long the Return Address
is.
Now I have a problem with this: SP will be pointing to the last
argument on the stack that was pushed by the caller. I've looked at
assembly listings and I can't seem to find any section that is
responsible for actually removing those arguments from the stack once
they've been pushed.
Thanks
-HG.