Readings. I will cover the text (H&P) in pretty much this order. So if you know where I am, you should be able to stay ahead of me on the reading.1-1.7 (skim), 1.8-1.10, 1.11 (okay, just always read fallacies and pitfalls, and always at least skim the historical perspective, but I’ll quit typing them in). B.1-B.11 (skim B.8). A.1-A.10 (skim A.7), 2.1-2.11,3.1-3.9 (skim 3.4, 3.6), C.1-C.8 (skim C.5), 5.1-5.8 (skim 5.4). 4.1-4.2 (skim 4.2).
Homework should be typed. Please put your name only on the first page.
for (i=0; i<= 100; i++)
{A[i] = B[i] + C;}
give the assembly in MIPS code. Assume i is in register R1, that the starting address of Array A is in R2, the address of array B is in R3, that the address of C is in R4. What is the dynamic instruction count of this code?
lw R3, 100(R5)
add R6, R3, R2
sub R9, R3, R8
lw R1, 2000(R9)
add R5, R4, R3
addi R7, R1, #8
loop: lw R1, 100(R2)
addi R1, R1, #1
sw R1, 0(R2)
addi R2, R2, #4
sub R4, R3, R2
bnez R4, loop
add R1, R2, R3
sub R5, R2, R3
and R7, R5, R2
lw R8, 1000(R5)
beq R7, R15, label:
nop
add R6, R7, R5
sub R5, R7, R5
lw R9, 2000(R2)
...
label: add R9, R7, R5
addi R5, R0, #0
...
for (j=0;j<10,000;j++) { for (i=0;i<7;i++) { // seven iterations ... if (A[i] = = 0) { // branch A ... } } // loop back branch B } // loop back branch C
loop:l.d F2, 1000(r2) add.d F6, F2, F4 add.d F10, F6, F8 addi r2, r2, #8 add.d F12, F2, F14 lw r3, 2000(r5) beqz r3, loop