Tom Kelliher, CS 240
Jan. 30, 2002
Distribute shell account info for phoenix.
Distribute homework I.
Read 3.5.
Calculating performance.
Conditional instructions in MIPS.
Things to consider:
Consider your favorite HLL. What classes of instructions (operations) are required?
Now, consider a multi-user OS such as Unix? What additional classes of instructions are required?
Any general purpose architecture must support these classes.
Consider the two simplest:
add subConsider an HLL statement:
f = (g + h) - (i + j);
add a, b, c # This, BTW, is a comment. sub a, a, bDe-compile each of the following:
add a, b, c add a, a, d add a, a, eDe-compile further into a single HLL statement.
Compile each of the following:
a = b + c; d = a - e; f = (g + h) - (i + j);
Consider operands within an HLL:
#include <stdio.h>
int main()
{
int foo = 1234;
printf("%d, %p\n", foo, &foo);
return 0;
}
A variable is an abstraction which the compiler/OS binds to a memory
address.
RISC instruction sets don't ordinarily support memory operands. Why not?
Where are the operands? Registers.
Properties of registers:
Other register files: x86, SPARC and the register window (Berkeley RISC, about 128 registers, spilling).
Register renaming: ISA registers vs. physical registers.
Implications: size of address space, datapath width.
MIPS, M68000, x86.
See pg. A-23 for the full register naming convention. Note the limited number of s and t registers.
Our simple convention:
$s0, $s1, etc. for C variables.
$t0, $t1, etc. for temps.
Recall:
f = (g + h) - (i + j);Assume f through j are in
$s0 through $s4,
respectively. Compile the statement.
Base and offset addressing: lw $s0, 8($s1)

Compile the following:
g = h + A[8];where g is in
$s1, h is in $s2, and the base
address of A, an array of 100 words, is in $s3.
Base, offset addressing.
Compile each of the following:
A[12] = h + A[8]; A[j] = h + A[i];
Notes: