Computer Organization and Design: The Hardware/Software Interface

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

View Full Document Right Arrow Icon
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);
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

CS152-S04-HW2-Solutions - HW2 solutions 3.10...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online