Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Guidelines and Assumptions These apply to all programs in this course from here except when otherwise stated (though they will not be explicitly repeated).

General Guidelines and Assumptions
These apply to all programs in this course from here except when otherwise stated (though they will not be explicitly repeated).
All variables (and array/struct elements) are 32-bit signed 2s complement integers.
Overflows and bounds errors do not occur (i.e., you do not need to handle such cases).
We also have the following style requirements (most of these are adapted from industry standards):
You may only use allowed assembly language instructions. The reasons for this will become evident when we get to the hardware part of the semester.
Undocumented programs will not be graded. Documentation includes register allocations at the top of the code and meaningful comments for each line.
Follow all register conventions after all, your OS will crash otherwise!
Answers that work but are significantly worse than the best solution will not get full credit.
For this homework, you may use only the instructions covered in Sections 2.12.3. Your assembly should implement the C code direction i.e., do not optimize the C code to change the order of operations
or reduce computations.
Write MIPS assembly code implementing the following C/C++ statement:
s = 8 - 13*m + s;
One way of doing the multiply without a multiply instruction is by using many add instructions (m+m+. . .+m), but you should do it with fewer additions.
Hint: We know how to express any integer as a sum of powers of 2 (e.g., 7 = 1+2+4), and we also know
how to multiply by powers of 2 using repeated addition. This gives us a method to multiply by any integer c
(applying distributivity), and this technique is in fact an underlying principle of many hardware multipliers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago