-
100%
For this question, check all that apply.
MIPS is not a CISC architecture, but a RISC with a simple
and highly regular instruction set.
Which of the following attributes correctly describe
the MIPS instruction set?
Arithmetic instructions allow 3 registers: two sources and one destination
One operand in an arithmetic instruction can come directly from memory
There are special instructions for managing stack frames
add $t1,$0,$t0 copies the value from $t0 into $t1
Instruction encoding is fixed length
-
100%
An array a of 32-bit integers is specified as shown
below. On the MIPS architecture, suppose &(a[0])
is 2000. What value is in memory location 2008?
int a[8] = { 110, 300, 600, 1200, 2400, 4800, 9600, 19200 };
-
100%
Which of the following segments of C code best describes what
the following MIPS assembly code does?
la $t0, x
lw $t1, 0($t0)
la $t2, y
lw $t3, 0($t2)
l1: bne $t1, $0, l2
addu $t1, $t1, $t3
l2: sw $t1, 0($t0)
while (x!=0) { x=x+y; }
while (x==0) { x=x+y; }
if (x!=0) { x=x+y; }
if (x==0) { x=x+y; }
x=x+y;
-
100%
This MIPS/SPIM program includes a
subroutine called myadd that performs
x=(y+z);. In the space below, replace the
myadd subroutine with one named myor that
will make x have the value it would get if C code like
x=(y|z); were executed, i.e., the result of bitwise
ORing y with z. You should test
your routine using SPIM
before you submit it, which will require merging it with a test
framework like the one used in this MIPS/SPIM
program -- but only submit the myor routine here.
Remember that you can and should comment your code, especially
if there are any known bugs. Half off for documented bugs. :-)
-
50%
50%
This (now familiar) MIPS/SPIM program
includes a subroutine called myadd that performs
x=y+z;. In the space below, replace the myadd
subroutine with one named myabs that will compute
x=abs(y);, the absolute value of y.
You should test your routine using SPIM
before you submit it.
Here's C code suggesting how you might do this.
extern int x, y;
void
myabs(void)
{
int t0 = y;
if (t0 < 0) t0 = -t0;
x = t0;
}
-
100%
Averaging is very commonly used to smooth noisy data.
This MIPS/SPIM program includes a
subroutine called myadd that performs
x=(y+z);. In the space below, replace the
myadd subroutine with one named myavg that
will replace x with the average of the two word values
starting at location y.
The two words can be the ones called
y and z in the previous coding
problems and in your support code, but your code should not
reference them that way in your solution; y[k] is the
kth word -- you should reference the words by varying
k from 0 to 1. You should test your routine using SPIM
before you submit it, which will require merging it with a test
framework like the one used in this MIPS/SPIM
program -- but only submit the myavg routine here.
(Hint: $rd=$rt/2 can be computed using
an arithmetic shift right: sra $rd,$rt,1,
which is described on page 14 of the SPIM manual
PDF.)
-
100%
In MIPS assembly language, is la $t0,0x12345678 an instruction?
What does it do?
-
50%
50%
In the space below, write MIPS code for a leaf subroutine
mymul that will compute z=x*y;. Hint: use
addu because add detects overflow. You
should test your routine using SPIM before you submit it.
Although there are many ways to do a multiply, here's C code for
one of them that you might want to use:
extern int x, y, z;
void
mymul(void)
{
/* do z = x * y the hard way... */
int t0 = 0;
int t1 = 1;
int t2 = x;
int t3 = y;
while (t1 != 0) {
if ((t1 & t3) != 0) {
t0 += t2;
}
t1 += t1;
t2 += t2;
}
z = t0;
}
-
100%
For this question, check all that apply.
MIPS is not a CISC architecture, but a RISC with a simple
and highly regular instruction set.
Which of the following attributes correctly describe
the MIPS instruction set?
(Yes, this looks very familiar....)
Arithmetic instructions allow 3 registers: two sources and one destination
To operate on a value from memory, you must load it into a register first
There are special instructions for managing stack frames
or $t1,$t0,$0 copies the value from $t0 into $t1
Instruction encoding is variable length
-
50%
50%
Using only MIPS integer
instructions, write a function that will make x =
-y where x and y are floating-point
numbers. Your function only needs to handle normal float
values correctly, not NaN, etc.

-
100%
In multiplying an integer, X, by 15 using the basic
shift-and-add algorithms discussed in class and in the book,
what is the minimum number of addition/subtraction operations
that must be performed? Show the values that are added or
subtracted: use (X<<Y) to represent the
value of X shifted by Y bit positions.
Hint: use Booth's algorithm.
-
100% For IEEE 754 floating-point
addition, does a+(b+c) always give the same result as
(a+b)+c? Explain. Assume that the values of
a, b, and c are ordinary
floating-point values (not infinity, etc.) and that the addition
does not go out of the representable range.
-
100%
For this question, check all that apply.
In the single-cycle design shown in the above (rather large and
very familiar) figure, which of the following signals that
are "don't cares" when executing a MIPS sw instruction?
Branch
ALUSrc
RegWrite
MemWrite
MemtoReg
-
100%
For this question, check all that apply.
In the single-cycle design shown in the above (rather large and
very familiar) figure, suppose that ALUSrc=0 and MemRead=0.
Which of the following MIPS instructions which might be executing?
lw $t0,4($t1)
sw $t0,4($t1)
beq $t0,$t1,l
andi $t0,$t1,2
add $t0,$t1,$t2
-
100%
What is the logic formula for Y?