当前位置:网站首页>Summary of stack frame in arm assembly

Summary of stack frame in arm assembly

2022-06-25 02:26:00 Hua Weiyun

What is a stack frame ?

1. Stack is a kind of data organization with last in first out , That is to say, those stored later shall be taken out first , Store first and then take out . The bottom of the stack is where the first data in the stack is located , The top of the stack is where the last data is put into the stack .
image.png
image.png

Stack frame (stack frame): Is the part of the stack used by a function , The stack frames of all functions are strung together to form a complete stack . The two boundaries of the stack frame are respectively defined by fp(r11) and sp(r13) To limit .

How do stack frames come into being ? When the stack top pointer sp Less than the pointer at the bottom of the stack fp when , The stack frame is formed .
image.png

The use of stack frames in functions ?

ARM The order of stack pressing is very regular , In order is the current function pointer PC、 Return pointer LR、 Stack pointer SP、 Stack base address FP、 The number of parameters and pointers passed in 、 Local variables and temporary variables .

ARM The following statements are often used for function stack pressing and stack pushing :

stmfd sp!,{r0-r9, lr} ; Full decrement stack , Give the register r0-r9,lr Pressing stack ,sp Decreasing 4.

ldmfd sp!,{r0-r9, pc} ; Full decrement stack , Give the register r0-r9 Out of the stack , And make the program jump back to the call point of the function ,sp Increasing 4.

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206242257161126.html