I am currently learning assembly programming on wombat 4, I am looking at Frame pointers. I understand exactly what a frame pointer is: it is a register and are used to access parameters on a stack. But i'm confused on how they affect the program counter and why they are preferred over normal registers.
Could some one explain, please.
Asked By : Xabi
Answered By : uli
As the stack pointer may change while a function is executed, access to the stack is less confusing with a static frame pointer, that is set upon the entry to the function, so relative addressing becomes simpler.
On reason for using the stack to store parameters is that there is usually more memory available than registers. What would you do with a function g(a,b,c,d,e,f) where you have enough registers free to store a–e, but non for f? You would put f on the stack. As the size of the stack is only limited by the available memory using the stack still works for functions with even more parameters.
Modern compilers typically have a flag that controls whether the use of registers for parameter passing is allowed or not.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/1665
0 comments:
Post a Comment
Let us know your responses and feedback