hw01_sol(1)

hw01_sol(1) - LSU EE 4720 Homework 1 Solution Due: 15...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 3

hw01_sol(1) - LSU EE 4720 Homework 1 Solution Due: 15...

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

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