{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

InClassActivity04-sol

# InClassActivity04-sol - 9:49 AM Activity#04(solutions Last...

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

1/29/03 9:49 AM ECSE-2660 Computer Architecture, Networks, & Operating Systems, Spring 2003 Page 1 of 2 Activity #04 (solutions) Last Name First Name Student ID Number email 4.1 4.2 Total Grader Initials 50 points 50 points 100 points Activity 4.1 (First hour) 1. (10 points) Translate the C statement a = (2*b + c) to MIPS code. Assume that a, b, c are associated with registers \$s1, \$s2, \$s3 respectively. Use the add instruction only. Do NOT use any register other than \$s1, \$s2, \$s3. add \$s2,\$s2,\$s2 # \$s2 = b + b = 2*b add \$s1,\$s2,\$s3 # \$s1 = \$s2 + c Grading: 10 pts for correct, 5pts for partial, 1pt for trying. 2. (10 points) Translate the C statement a = b - c + 2*d to MIPS code without using any temporary registers. Assume that the addresses of a, b, c, d are in registers \$s0, \$s1, \$s2, \$s3 , respectively. You just need 3 instructions in the code. Do NOT use instructions other than add and sub . add \$s0, \$s3, \$s3 # \$s0 = d + d = 2*d sub \$s0, \$s0, \$s2 # \$s0 = \$s0 – c = 2*d – c add \$s0, \$s0, \$s1 # \$s0 = \$s0 + d = 2*d – c + b Grading: 10pts for correct, 5pts for any syntactically correct code. The operations can be done in any order.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

InClassActivity04-sol - 9:49 AM Activity#04(solutions Last...

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

View Full Document
Ask a homework question - tutors are online