{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

QZ1-sol

# QZ1-sol - addi \$a0 \$a0 1 Ans The instruction memory is...

This preview shows page 1. Sign up to view the full content.

1 CSE 341: Computer Organization Spring 2011 Solution to QZ #1 Week of 2/14/11 Quiz 1 Duration: 25 minutes Question 1: (5 points) Write the following sequence of code into MIPS assembler: x = x + y + z - q; Assume that x, y, z, q are stored in registers \$s1-\$s4. Ans: The MIPS assembly sequence is as follows: add \$t0, \$s1, \$s2 add \$t1, \$t0, \$s3 sub \$s1, \$t1, \$s4 Question 2: (5 points) In the snippet of MIPS assembler code below, how many times is instruction memory accessed? How many times is data memory accessed? (Count only accesses to memory, not registers.) lw \$v1, 0(\$a0) addi \$v0, \$v0, 1 sw \$v1, 0(\$a1)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: addi \$a0, \$a0, 1 Ans: The instruction memory is accessed four times (as there are four instructions) and the data memory is accessed twice (once for the lw instruction and another time for the sw instruction). Question 3: (5 points) Instead of using a special hardware multiplier, it is possible to multiply two numbers using shift and add instructions. Suppose we want to put 5 times the value of \$s0 into \$s1, ignoring any overflow that may occur. Show a minimal sequence of MIPS instructions for doing this without using a multiply instruction. Ans: sll \$s1, \$s0, 2 addu \$s1, \$s0, \$s1...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern