|
11.1 Preparation for Code GenerationVarious methods have been developed for good use of registers. One technique is to store all loop variables in registers (until there are no more registers) since statements inside loops may execute more than once. Another easily implemented technique is to store the variables used the most in registers. For machines with a stack and a stack pointer, operations involving the stack are generally quicker than those involving an access to (non-stack) memory. Thus, another code generation technique is to push all variables in a procedure onto the stack before the procedure is executed, access them from the stack (and two registers). Careful assignment of expressions and variables to registers can increase the efficiency of the resulting compiler. In this module, we will generate code as though there were only one available register.
|