This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: LSU EE 4720 Homework 1 Solution Due: 3 March 2010 Problem 1: Re-write each code fragment below so that it uses fewer instructions (but still does the same thing). Note: In the original assignment the branch instruction was blt r1, r0 TARG . # Fragment 1 lw r1, 0(r2) addi r2, r2, 4 lw r3, 0(r2) addi r2, r2, 4 # # SOLUTION lw r1, 0(r2) lw r3, 4(r2) addi r2, r2, 8 # Fragment 2 sub r1, r2, r3 bne r1, r0 TARG add r1, r5, r6 # # SOLUTION bne r2, r3 TARG add r1, r5, r6 # Fragment 3 ori r1, r0, 0x1234 sll r1, r1, 16 ori r1, r1, 0x5678 # # SOLUTION lui r1, 0x1234 ori r1, r1, 0x5678 1 Problem 2: The MIPS code below runs on the illustrated implementation. Assume that the number of iterations is very large. format immed IR Addr 25:21 20:16 IF ID EX WB ME rsv rtv IMM NPC ALU Addr Data Data Addr D In +1 PC Mem Port Addr Data Out Addr Data In Mem Port Data Out rtv ALU MD dst dst dst Decode dest. reg NPC = 30 2 2’b0 + 15:0 25:0 29:26 29:0 0 1 15:0 LOOP: lw r3, 0(r1) addi r2, r2, 1 beq r3, r4 LOOP lw r1, 4(r1) ( a...
View Full Document
This note was uploaded on 12/11/2011 for the course EE 4720 taught by Professor Staff during the Fall '08 term at LSU.
- Fall '08