total 20 points 1. 10 points Accumulator: code data load b 3 4 add c 3 4 store a 3 4 add c 3 4 store b 3 4 neg 1 0 add a 3 4 store d 3 4 22 28 (50) Stack: push b 3 4 push c 3 4 add 1 0 dup 1 0 pop a 3 4 push c 3 4 add 1 0 dup 1 0 pop b 3 4 neg 1 0 push a 3 4 add 1 0 push d 3 4 27 28 (55) Memory-memory: add a, b, c 7 12 add b, a, c 7 12 sub d, a, b 7 12 21 36 (57) Load-store: load $1, b 4 4 load $2, c 4 4 add $3,$1,$2 3 0 store $3, a 4 4 add $1,$2,$3 3 0 store $1, b 4 4 sub $4,$3,$1 3 0 store $4, d 4 4 29 20 (49) code size efficient: memory-memory (code+data) efficient: load-store 2. a:2 points; b:3 points (a) mov R2, R1 rshift R2, 7 and R2, 0x3F (b) and R1, 0xFFC1FFFF ; R1=X...X 000000 X....X lshift R2, 17 and R2, 0x003E0000 ; R2=0...0 XXXXXX 0....0 or R1, R2 3. a:2 points; b:3 points (a) int log_2(int n) { int result; if (n==1) result=0; else result=1+log_2(n/2); return result; } (b)