[M] (a) Give a short sequence of machine instructions for the task “Add the cont
ID: 3763743 • Letter: #
Question
[M] (a) Give a short sequence of machine instructions for the task “Add the contents of
memory locationAto those of location B, and place the answer in location C”. Instructions
Load Ri, LOC
and
Store Ri, LOC
are the only instructions available to transfer data between the memory and the generalpurpose
registers. Add instructions are described in Section 1.3. Do not change the contents
of either location A or B.
(b) Suppose that Move and Add instructions are available with the formats
Move Location1, Location2
and
Add Location1, Location2
These instructions move or add a copy of the operand at the second location to the first
location, overwriting the original operand at the first location. Either or both of the operands
can be in the memory or the general-purpose registers. Is it possible to use fewer instructions
of these types to accomplish the task in part (a)? If yes, give the sequence.
Explanation / Answer
The MIPS architecture provides a specific example for a machine code whose instructions are always 32 bits long. The general type of instruction is given by the op (operation) field, the highest 6 bits. J-type (jump) and I-type (immediate) instructions are fully specified by op. R-type (register) instructions include an additional field funct to determine the exact operation. The fields used in these types are:
rs, rt, and rd indicate register operands; shamt gives a shift amount; and the address or immediate fields contain an operand directly.
For example, adding the registers 1 and 2 and placing the result in register 6 is encoded:
Load a value into register 8, taken from the memory cell 68 cells after the location listed in register 3:
Jumping to the address 1024:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.