Polytechnic Institute of NYU
Handout No : 2
September 8, 2010
September 29, 2010
- Related portions of Chapters 1, 2, 3 and Appendix A and Appendix B of the Hennessy book
- Related portions of Chapters 1 and 7 of the Jordan book
Solve all homework and exam problems as shown in class and past exam solutions.
Consider the following piece of MIPS code :
Note that this code is a function and the JR instruction is used to return from the function.
takes two clock periods as branch instructions do.
The delayed branch concept is also applied to
Thus, the instruction that follows the JR (the S.D. in location 228 above) is executed after
Then, the instruction pointed by the JR effective address is executed (the instruction pointed
Note that the compiler could not find an independent instruction for the BNEZ delay slot and so
had to place a “DADD
R10, R10, R0” instruction that is equivalent to a NOP instruction.
instruction is pointed by an arrow above.
Also, location 22C does not have an instruction.
is, it is not used.
Write the corresponding piece of high-level code in the style of class discussions and also by
using the names of variables mentioned in the comment section above.
; Load “k”
; Load an element of A
R8, R8, #8
; Update the A pointer
F1, F1, F2
; Multiply “k” and A[i]
R9, R9, #(-1)
; Decrement the loop end counter
; The end of the loop ?
R10, R10, R0
; A NOP instruction
; Return from the function
; Store the result in p
; This location is not used