go to previous page   go to home page   go to next page hear noise

Answer:

if ( !( a < 0 ) ) { ... } 

if ( a >= 0  ) { ... }

The two operators   <   and   >=   cover all possible integer values.


Set on Less Than

The set instructions are used to implement relational operators. However, they do not in themselves alter the flow of control. They set a register to 1 or 0 to show the relation between two values. The slt instruction is used with two's complement integers:

                   #  $s and $t contain
                   #  signed integers
                   #
slt   d,s,t        #  if ( $s < $t )
                   #    d = 1
                   #  else
                   #    d = 0

The sltu instruction is used with unsigned integers:

                   #  $s and $t contain
                   #  unsigned integers
                   #
sltu  d,s,t        #  if ( $s < $t )
                   #    d = 1
                   #  else
                   #    d = 0

QUESTION 3:

A. After the following code executes, what value is in register $7 ?

addiu    $5,$0,-25
addiu    $6,$0,25
slt      $7,$5,$6

B. After the following code executes, what value is in register $7 ?

addiu    $5,$0,-25
addiu    $6,$0,25
sltu     $7,$5,$6