CS152-S04-HW2-Solutions

# Computer Organization and Design: The Hardware/Software Interface

• Homework Help
• davidvictor
• 7

This preview shows pages 1–3. Sign up to view the full content.

HW2 solutions 3.10 Pseuodinstructions What is accomplished Minimum sequence of Mips Move \$t5, \$t3 \$t5=\$t3 Add \$t5, \$t3, \$0 Clear \$t5 \$t5=0 Xor \$t5, \$t5, \$t5 Li \$t5, small \$t5=small Addi \$t5, \$0, small Li \$t5, big \$t5=big lui \$t5, big[31:16] Ori \$t5, \$t5, big[15:0] Lw \$t5, big(\$t3) \$t5=mem[\$t3+big] Lui \$t5, big[31:26] Ori \$t5, \$t0, big[15:0] Add \$t3, \$t3, \$t5 Lw \$t5, 0(\$t3) Addi \$t5, \$t3, big \$t5=\$t3+big Lui \$t5, big[31:16] Ori \$t5, big[15:0] Addi \$t5, \$t5, \$t3 Beq \$t5, small, L If \$t5=small, branch to L Addi \$at, \$0, small Beq \$t5, \$at, L Beq \$t5, big, L If \$t5=big, branch to L Lui \$at, big[31:16] Ori \$at, big[15:0] Beq \$at, \$t5, L Ble \$t5, \$t3, L If \$t5<=\$t3, branch to L Slt \$at, \$t3, \$t5 Beq \$at, \$0, L Bge \$t5, \$t3, L If \$t5>=\$t3, branch to L Slt \$at, \$t5, \$3 Beq \$at, \$0, L Bgt \$t5, \$t3, L If \$t5>\$t3, branch to L Slt \$at, \$t3, \$t5 Bne \$at, \$0 L 3.25 You did this for Lab 1. 3.29 sbn temp, temp, .+1 # temp = 0; sbn temp, b, .+1 # temp = -b; sbn a, temp, .+1 # a = a – (-b) = a + b; 3.30 sbn neg_a, neg_a, .+1 # neg_a = 0; sbn neg_a, a, .+1 # neg_a = -a; sbn c, c, .+1 # c = 0; loop: sbn b, one, .+1 # do { b = b – 1; sbn c, neg_a, .+1 # c = c + a; sbn temp, temp, .+1 # temp = 0; sbn temp, b, loop # } while (b > 0);

This preview has intentionally blurred sections. Sign up to view the full version.

Note (1) This solution does not work if b = 0, because the problem description said to assume that a and b are greater than 0. Perfectionist students are likely to write solutions that do work for b = 0 though, so their answers would be an instruction or too long. 4.17 add \$t2, \$t3, \$t4 slt \$t2, \$t2, \$t3 4.23 You need only alter the full adder for the MSB such that the Set output is the value of the full adder output XORed with the Overflow 4.24
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern