| label | Opcode | Operands | Comment | ||
|---|---|---|---|---|---|
| loop: | LD | R1, 0 (R2) | # load R1 from address of value in R2 + 0 | ||
| DADDI | R1, R1, 1 | # R1 = R1 + 1 | |||
| SD | R1, 0 (R2) | # store R1 from address of value in R2 + 0 | |||
| DADDI | R2, R2, 4 | # R2 = R2 + 4 | |||
| DSUB | R4, R3, R2 | # R4 = R3 + R2 | |||
| BNEZ | R4, loop | # if( R4 != 0 ) goto loop |
Assume that the initial value of R3 is R2 + 396
Throughout this exercise use the classic MIPS five-stage integer pipeline (see figure C.1) and assume all memory accesses take 1 clock cycle.
If all memory references take 1 cycle, how many cycles does the loop take to execute.
See attached sheet for the answer to this question as a sample of what I'm looking for.
If all memory references take 1 cycle, how many cycles does the loop take to execute.
| Opcode | Operands |
|---|---|
| LD | R1, 45 (R2) |
| DADD | R7, R1, R5 |
| DSUB | R8, R1, R6 |
| OR | R9, R5, R1 |
| BNEZ | R7, target |
| DADD | R10, R8, R5 |
| XOR | R2, R3, R4 |