sp99 homequiz 2 solution

# Computer Organization and Design: The Hardware/Software Interface

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

1 University of California, Berkeley College of Engineering Computer Science Division EECS Spring 1999 John Kubiatowicz Homework Quiz (HW #2) Solutions February 16, 1999 CS152 Computer Architecture and Engineering This quiz covers one of the problems from homework #2. Good Luck! Your Name: SID Number: Discussion Section: Total:

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

View Full Document
2 A better multiply for the Single Instruction Computer In the homework, you were introduced to the “Subtract and branch if negative” instruction: sbn a, b, c # Mem[a] = Mem[a] – Mem[b]; If Mem[a] < 0 goto c; Problem 3.30 asked you to develop a multiply routine that was not particularly efficient. Consider the following alternative for a 16-bit computer. This performs c = a * b, modifying b in the process: c = 0; for (index = 32768; index >= 1; index = index / 2) { If (b >= index) { b = b – index; c = c - index * a; } } c = -c; To implement this, we will assume a macro facility that lets us generate groups of instructions many times. 1. Create a macro called “ inner ” which performs the inner instructions of our multiply. This takes 4
This is the end of the preview. Sign up to access the rest of the 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