Solutions to some of the midterm problems: 1. a) int b = 0; int a[4000]; for(int i = 0; i!= 4000; i = i + 8) { b = b + a[i]; } 1. c) li r20, 0 li r19, 16000 li r15, 0 nop nop start: ld r1, 0(r20) nop nop nop add r15, r15, r1 addi r20, r20, 32 nop nop nop sub r3, r19, r20 nop nop nop bnez r3, start 1. d) there are many ways to do it.. but most likely you will need to have something like this: ld r1, 0(r20) ld r10, 32(r20) ld r11, 64(r20) ld r12, 92(r20) addi r20, r20, 128 2. a) CPI = 0.7 * 1 + 0.1 * 2 + 0.2 * 3 = 1.5 b) CPI2 = 0.1 * 1 + 0.1 * 2 + 0.2 * 0.8 * 1 + 0.2 * 0.2 * 3 = 1.18 c) time old / time new = ( 1.5 / (2 * 10^9) ) / ( 1.18 / (1.5 * 10^9)) = 0.9533 ---> the original processor is faster by about 4%.