sltu $t4,$v0,45
|
and |
sltui $t4,$v0,45
|
Yes. The first translates into the second.
In addition to implementing new instructions, the extended assembler implements a new addressing mode. This is indexed addressing, a mode of addressing very useful for arrays. Here is an example:
li $t1,2 # index 2 lb $v0,data($t1) # $v0 = data[$t1] . . . data: .byte 6,34,12,-32, 90 # index zero is first
Think of data
as an array
of five bytes.
Then the lb
instruction loads the element
of the array at index 2 (the byte that contains 12)
into $v0
.
The
extended assembler does this the same way we have
done in in past programs:
basic instructions are used to add the index value in
$t1
to the address symbolized by data
.
Here is what the assembler generates for the above code:
ori $t1,$0,2 # index 2 lui $at,4097 # $at register gets address "data" addu $at,$at,$t1 # add index to $at lb $v0,0($at) # $v0 = data[$t1] . . . data: .byte 6,34,12,-32, 90
The assembler generates code that uses register
$at
to calculate the address of the correct byte.
Then, using that address, the byte is loaded into $v0
.
When does the actual address calculation take place?