{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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)
Image of page 1
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

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern