sgtu rd, rs, rt
# set greater unsigned
rs
are greater than the contents of rt
(or rs
is greater than the immediate value), it sets the destination register to 1; otherwise, it sets the destination register to 0.
sleu rd, rs, rt
# set less or equal unsigned
rs
are less than or equal to the contents of rt
(or rs
is less than or equal to the immediate value) this instruction sets the destination register to one; otherwise, it sets the destination register to zero.
sgeu rd, rs, rt
# set greater or equal unsigned
rs
are greater than or equal to the contents of rt
(or rs
is greater than or equal to the immediate value), this instruction sets the destination register to one; otherwise, it sets the destination register to zero.
sgt |
sgtu |
Fibonacci Numbers |
---|---|---|
.text li $t0, -1 sgt $t1, $t0, 0 # if signed $t0 > 0 # $t1 = 1 # otherwise $t1 = 0 bne $t1, 0, T # if $t1 <> 0 # branch to T li $a0, 1 j put T: li $a0, 2 put: li $v0, 1 syscall |
.text li $t0, -1 sgtu $t1, $t0, 0 # if unsigned $t0 > 0 # $t1 = 1 # otherwise $t1 = 0 bne $t1, 0, T # if $t1 <> 0 # branch to T li $a0, 1 j put T: li $a0, 2 put: li $v0, 1 syscall |
|
Output | Output | Output |
0 1 1 2 3 5 8 ... |
New Year’s Eve is just around the corner (occurring soon). Have you made party plans yet? |