问题描述
I am reading definitions over and over again and I still not getting what are SP and LR in ARM? I understand PC (it shows next instruction's address), SP and LR probably are similar, but I just don't get what it is. Could you please help me?
edit: if you could explain it with examples, it would be superb.
edit: finally figured out what LR is for, still not getting what SP is for.
LR is link register used to hold the return address for a function call.
SP is stack pointer. The stack is generally used to hold "automatic" variables and context/parameters across function calls. Conceptually you can think of the "stack" as a place where you "pile" your data. You keep "stacking" one piece of data over the other and the stack pointer tells you how "high" your "stack" of data is. You can remove data from the "top" of the "stack" and make it shorter.
From the ARM architecture reference:
This link gives an example of a trivial subroutine.
这篇关于ARM中的SP(堆栈)和LR是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!