< previous page page_125 next page >

Page 125
0125-01.gif
Figure 2.44
Computer architecture and its implementation: the
register set represents a tradeoff between memory
bandwidth and chip area.
could be implemented using a stack with the following code:
d87111c01013bcda00bb8640fdff6754.gif
PUSH C
PUSH D
MPY
PUSH B
ADD
POP A
No value remains in the stack at the end of an expression evaluation, and two stack entries are used during evaluation. The simple evaluation stack has no facility for storing the data values from statement to statement for reuse. A simple register set can accomplish the same objective, managing temporary storage for expression evaluation, yet retain values for use from statement to statement within a procedure. At the end of a procedure, either a stack or a single register set can be used to store argument values for use by the called procedure. The greatest disadvantage of using registers to hold temporaries is that active data values in the register set must be saved (moved to memory) as control passes to new procedures. The called procedure may require use of registers that contain valid data belonging to the calling procedure. This data must also be restored after the return. With early register allocation software, the value of the register set was marginal compared to the value of a stack. The savings in data traffic by keeping results in registers was only marginally better than the save and restore data traffic required on procedure change. Modern register allocators more than overcome the save and restore traffic disadvantage and provide significant advantage for register sets [212]. This is best illustrated by Huck's data cited in Table 2.9. Since the HLL machine assumes a stack, the advantage (read and write ratios < 1) of the register set machines over the HLL demonstrates the effectiveness of modern allocators.

 
< previous page page_125 next page >