What is the primary role of the Link Register (R14/LR) in ARM processors?
Think about what happens when a function or subroutine is called and how the processor knows where to return.
The Link Register (R14/LR) is used to store the return address during a subroutine call. When a function is called, the address of the next instruction is saved in LR so the processor knows where to return after the function finishes.
Which register number corresponds to the Link Register (LR) in ARM architecture?
Registers R13, R14, and R15 have special roles in ARM. LR is one of them.
In ARM architecture, R14 is designated as the Link Register (LR). R13 is the Stack Pointer (SP), and R15 is the Program Counter (PC).
What happens if a function overwrites the Link Register (LR) without saving it first before returning?
Consider what the LR holds and what happens if its value changes unexpectedly.
If the Link Register is overwritten without saving its original value, the return address is lost. When the function tries to return, it jumps to an incorrect address, often causing a crash or unpredictable behavior.
Which statement correctly distinguishes the Link Register (LR) from the Program Counter (PC) in ARM processors?
Think about what each register is used for during program execution and function calls.
The Program Counter (PC) holds the address of the current instruction being executed. The Link Register (LR) stores the return address when a function is called, so the processor knows where to return after the function finishes.
In ARM assembly, when a function A calls function B, which then calls function C, what must be done with the Link Register (LR) to ensure all functions return correctly?
Consider what happens to LR when a function calls another function and how return addresses are preserved.
Because LR holds the return address, each function must save its LR value (usually on the stack) before calling another function. This prevents overwriting LR and ensures each function can return to its caller correctly.
