CPSC 2310 - DAY 16 OCTOBER 10, 2016 ================================================================================ link register (lr) holds the return address r0-r3 are parameter registers. r4-r11 temporary register variables. Must be preserved REGISTER USAGE -------------- Temporary Variables .Functions should first try to use registers r0-r3 for any required temporary variables, since they do not have to be preserved .Registers r4-r11 are the second choice, but they must be saved at the function entry and restored prior to function return .When more space for temporaries is required, allocate space on the stack Reasons for using registers or stack space for temporary variables instead of creating fixed locations with labels. 1. Memory Conservation: the stack space will be released when the funct. returns so that it can be reused for other needs. 2. Reentrancy: every entry of the function allocates a unique set of memory locations for its temporary variables; therefore, if the funct. is interrupted, and the interrupting code calls (or reenters) the same function, it is ensured that each invocation will modify only its own set of temporary A way to preserve and restore the registers is to push the registers onto the stack immediately upon entering the function, and to pop them back just before the function returns However, since the stack is stored in memory, and since memory cycles are the primary performance bottleneck, it is important to preserve a few registers as possible. r12 may be used by a linker as a scratch register between a routine and any subroutine that calls it