Tom Kelliher, CS 220
Nov. 17, 1997
Read Chapter 9.
Consider the C code:
a = b + c;Three address:
add a, b, c # SAL lw $8, b($0) # MAL Inefficient. lw $9, c($0) add $8, $8, $9 sw $8, a($0)Two address:
move a, b add a, cOne address (implied operand --- accumulator):
load a add b store cZero address (stack machine):
push a push b add pop c
What are the advantages/disadvantages? Consider the C code:
ave = (a + b + c + d) / 4;How many instructions are required for each number of operands?
Sizes of instructions?
Effective address: location of the operand.
Possible operand locations:
This mode is used for constants.
This is the model we associate with SAL.
Similar to direct mode, but faster and a far smaller ``memory.''
The register is a pointer.
Displacements are signed.
Array, struct access. Not so much array.
Branch instructions use PC-relative addressing, which is similar to Base displacement: