This preview shows page 1. Sign up to view the full content.
Unformatted text preview: egisters. There is clearly a trade-off between the number of values that can be held in registers and the number of registers remaining for intermediate results during expression evaluation (remembering that registers are also needed to hold the addresses of operands that must be fetched from memory). Optimizing this trade-off is a major task for the compiler, as is sorting out the right order to load and combine operands to achieve the result prescribed by the operator precedence defined in the language. The 3-address instruction format used by the ARM gives the compiler the maximum flexibility in how it preserves or re-uses registers during expression evaluation. Thumb instructions are generally 2-address, which restricts the compiler's freedom to some extent, and the smaller number of general registers also makes its job harder (and will result in less efficient code). A procedure will normally work with operands that are presented in one of the following ways, and can be accessed as indicated: ARM support Accessing operands Expressions 169 Pointer arithmetic 1. As an argument passed through a register. The value is already in a register, so no further work is necessary. 2. As an argument passed on the stack. Stack pointer (r13) relative addressing with an immediate offset known at compile-time allows the operand to be collected with a single LDR. 3. As a constant in the procedure's literal pool. PC-relative addressing, again with an immediate offset known at compile-time, gives access with a single LDR. 4. As a local variable. Local variables are allocated space on the stack and are accessed by a stack pointer relative LDR. 5. As a global variable. Global (and static) variables are allocated space in the static area and are accessed by static base relative addressing. The static base is usually in r9 (see the 'ARM Procedure Call Standard' on page 176). If the value that is passed is a pointer, an additional LDR (with an immediate offset) may be required to access an operand within the structure that it points to. Arithmetic on pointers depends on the size of the data type tha...
View Full Document
- Spring '09