Comparison Instructions (Cont.)

sgtu rd, rs, rt         # set greater unsigned
Compares two unsigned 32-bit values. If the contents of 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
Compares two unsigned 32-bit values. If the contents of 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
Compares two unsigned 32-bit values. If the contents of 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
     .text 
     li    $v0, 5
     syscall
     # input ≥ 0
     move  $t0, $v0
     li    $a0, 0
     li    $t1, 1
 L1: 
     beq   $t2, 0, L2
     li    $v0, 1
     syscall
     add   $t2, $t1, $a0
     move  $a0, $t1
     move  $t1, $t2
     sub   $t0, $t0, 1
     j     L1
 L2:
Output Output Output







0 1 1 2 3 5 8 ...