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.
Here is an example of how registers are saved on the stack prior to a call and then popped back to restore their content.