{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Activity04 Soln

# Activity04 Soln - SOLUTIONS Activity#04 Last Name First...

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

ECSE-2660 Computer Architecture, Networks, & Operating Systems, Spring 2001 Page 1 of 2 SOLUTIONS Activity #04 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 . (a) Translate the C statement a = ( b – c ) to MIPS code. Assume that a, b, c are associated with registers \$s0, \$s1, \$s2 , respectively. (10%) 5 for valid instruction sub \$s0,\$s1,\$s1 # \$s0=b-c (b) Translate the C statement a = ( b-c )+( b-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 will need 3 instructions: b+b; b+b-c; b+b-c-d. (10%) 5% for any syntactically correct code. add \$s0,\$s1,\$s1 # \$s0=b+b sub \$s0,\$s0,\$s2 # \$s0=\$s0-c=b+b-c sub \$s0,\$s0,\$s3 # \$s0=\$s0-d=b+b-c-d (c) Translate the C statement a = b + C[i] to MIPS code. Assume that C is an array whose base register address (i.e., the address of C[0]) is in \$s1 and that the addresses of a, b, and are in registers \$s2, \$s3, and that i is in \$s4. Use repeated addition to multiply by 4 to obtain the required memory address. The code requires 5 instructions.

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 ]}