Homework2Solution

Homework2Solution - Homework Assignment #2 MIPS Instructions

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

View Full Document Right Arrow Icon
Homework Assignment #2 – MIPS Instructions CDA 3100, Computer Organization I Submission: A hard copy required.  Problem 1 (30 points) Exercise 2.4.1(p. 182). The following problems deal with translating from C to MIPS. Assume that the variables f,g,h,i, and j are assigned to registers $s0, $s1, $s2, $s3 , and $s4 , respectively. Assume that the base address of the arrays A and B are registers $s6 and $s7 , respectively. a. f=g+h+B[4] b. f=g-A[B[4]] 2.4.1. For the C statements above, what is the corresponding MIPS assembly code? Solution: 2.4.1 a. f=g+h+B[4] add $s0, $s1, $s2 lw $t0, 16($s7) add $s0, $s0, $t0 b. f=g-A[B[4]] lw $t0, 16($s7) sll $t0, $t0, 2 add $t0, $t0, $s6 lw $t0, 0($t0) sub $s0, $s1, $t0 Problem 2 (10 points) Exercise 2.16.1 (p. 194). For these problems, there are various binary values for register $t0 . Given the value for $t0 , you will be asked to evaluate the outcome of different branches. a.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/08/2010 for the course CDA CDA3100 taught by Professor Liu during the Spring '10 term at FSU.

Page1 / 4

Homework2Solution - Homework Assignment #2 MIPS Instructions

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