Tom Kelliher, CS 220
Dec. 1, 2003
Conditional execution.
add a, b, c # This, BTW, is a comment. sub a, a, b addi a, a, 100 and a, b, c andi a, a, 32000De-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);
Operands are registers.
Properties of registers:
Implications: size of address space, datapath width.
Recall:
f = (g + h) - (i + j);Assume f through j are in
$1
through $5
,
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];
Base, offset addressing, using constant offsets, is similarly useful for accessing members of structures.
Example instruction: add $s2, $s0, $s1
Fields:
Op/Func Rd, Rs, Rt
Notes:
Example instruction: lw $s0 8($s1)
Fields:
Offset range?
Op/Func Rt, address(Rs)
Notes:
addi $1, $2, 123
.