This preview shows pages 1–2. 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: 15 September 2010 Problem 1: Diagnose or fix the MIPS-I problems below. ( a ) Explain why the code fragment below will not complete execution. Fix the problem, assuming that the load addresses are correct. (Problems such as this occur when operating on data prepared on a different system.) lw r1, 0(r2) lw r3, 6(r2) MIPS loads and stores must be to aligned addresses, meaning that the address must be a multiple of the data size. In this case the data size is 4 (because the instructions are lw ). Because they both use the same base register, r2 , at most one of the load addresses can be a multiple of 4. The code below fixes the problem by using lb instead of lw and sliding the bytes into the respective destination registers. A faster solution is possible: based on the two least-significant bits of r2 and branch to one of four routines. (For example, if the two-least significant bits were zero then lw r1, 0(r2) would work and two lhu could be used for 6(r2)...
View Full Document
- Fall '08