Professional Documents
Culture Documents
Due: Friday, Jan. 27 (3 PM in ITT 305 mailbox or under my office door, ITT 313)
1. Compare zero-, one-, two-, three-address, and the load-store machines by writing programs to compute
X = C* B - B * C * D;
Y = (X + A * D) / (B - X );
for each of the five machines (3-address, 2-address, 1-address, 0-address, and load-store). The instructions
available for use are as follows. Each program should contain code for both of the above assignment statement and
should not wipe out the values in A, B, C, or D.
“DIV” performs
POP T
POP T2
T3 = T2 / T
PUSH T3
2. Assume 8-bit opcodes, 32-bit absolute addressing, 5-bit register numbers (used only for Load-Store Machine),
and 32-bit (data) operands. Compute the number of bits needed during program execution for each programs from
question 2. Complete the following table.
3 Address 2 Address 1 Address 0 Address Load & Store
Number of program
bits read during 832 864 640 544 454
program execution
Number of bits of
data transferred to 768 1,024 512 384 192
and from memory
Total number of bits
read and written
1,600 1,888 1,152 928 646
during program
execution
3. You are to assume the same 5-stage pipeline discussed in class when answering these questions.
Assume that the first register in an arithmetic operation is the destination register, e.g., in “ADD R3, R2, R1”
register R3 receives the result of adding registers R2 and R1.
a. What would the timing be without bypass-signal paths/forwarding (use “stalls” to solve the data hazard)?
(This code might require more or less that 15 cycles)
Time d
Instructions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
ADD R3, R2, R1 F D E M W
STORE R3, 8(R4) F - - - D E M W
LOAD R4, 16(R3) F D E M W
SUB R3, R4, R1 F - - - D E M W
MUL R6, R3, R4 F - - - D E M W
STORE R6, 4(R5) F - - - D E M W
(Assume that a register cannot be written and the new value read in the same stage.)
Time d
Instructions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ADD R3, R2, R1 F D E M W
STORE R3, 8(R4) F D E M W
LOAD R4, 16(R3) F D E M W
SUB R3, R4, R1 F D - E M W
MUL R6, R3, R4 F - D E M W
STORE R6, 4(R5) F D E M W
(Assume that a register cannot be written and the new value read in the same stage.)
c. Draw ALL the bypass-signal paths needed for the above example.
Decoder
Instr.
Memory M Data Register
Register M
U Memory File
File U
ALU
X
X
M Result Result
U Value Value
X
High-level language program:
X = C* B - B * C * D;
Y = (X + A * D) / (B - X );
MUL X, C, B
MUL T, B, C
MUL T, T, D
SUB X, X, T
MUL T, A, D
ADD Y, X, T
SUB T, B, X
DIV Y, Y, T
2-Address Machine:
MOVE X, C
MUL X, B
MOVE T, B
MUL T, C
MUL T, D
SUB X, T
MOVE Y, A
MUL Y, D
ADD Y, X
MOVE T, B
SUB T, X
DIV Y, T
1-Address Machine:
LOAD B
MUL C
MUL D
STORE X
LOAD C
MUL B
SUB X
STORE X
LOAD B
SUB X
STORE Y
LOAD A
MUL D
ADD X
DIV Y
STORE Y
- /
* * + -
C B * D X * B X
B C A D
Postorder: C B * B C * D * - Postorder: X A D * + B X - /
0-Address Machine:
LOAD R1, C
LOAD R2, B
MUL R6, R1, R2
LOAD R3, D
MUL R5, R2, R1
MUL R5, R5, R3
SUB R6, R6, R5
STORE R6, X
LOAD R4, A
MUL R5, R4, R3
ADD R5, R6, R5
SUB R2, R2, R6
DIV R1, R5, R2
STORE R1, Y