- (3.5) [5] In some cases a simple instruction set like MIPS
can synthesize instructions found in richer instruction sets such as
the VAX. The following VAX instruction subtract 1 from register $5,
placing the difference back in register $5, and then branches to
L1 if $5 > 0:
sobgtr $5, L1 # $5 = $5 - 1; if ($5 > 0) goto L1

The operation is described in the comment of the instruction to
help explain the operation. What is the shortest
sequence of MIPS (machine) instructions, that performs the same operation?
- (3.6) [5] Show the single MIPS instruction or minimal sequence
of instructions for this C statement:
a = b + 100;

Assume a corresponds to register $11 and b corresponds to
register $12.
- (3.7) [10] Show the single MIPS instruction or minimal sequence
of instructions for this C statement:
x[10] = x[11] + c;

Assume c corresponds to register $13 and the array x
begins at memory location 4,000,000.
- (3.18) [5] The instruction
beq $2, $3, L1

will compare the contents of $2 and $3 and
branch to L1 if they are equal.
Unfortunately, there is no single instruction that can be used to
compare $2 with an immediate value, such as 14 or -200. Look at the format
for branch instructions and explain why. Write a sequence of MIPS
instructions that will branch to L1 if $2 is equal to 14. Hint:
It only takes two instructions.
- (3.19) [30] Consider the following fragment of C code:
for(i = 0; i <= 100; ++i) {
a[i] = b[i] + c;
}

Assume that a and b are arrays of words at addresses
1500 and 2000, respectively. Register $15 is associated with
variable i and $16 with c. Write the
code for MIPS. How many instructions are executed during the
running of this code? How many memory data references will be
made during execution?
- (4.3-4.5) [11] Convert decimal number 512, -1,023, and
-4,000,000, into 32-bit two's complement binary numbers,
respectively.
- (4.6-4.8) [15] What decimal number does each of the following
two's complement binary number represent?
1111 1111 1111 1111 1111 1110 0000 1100
1111 1111 1111 1111 1111 1111 1111 1111
0111 1111 1111 1111 1111 1111 1111 1111