slt
Set on less than (signed)
Sets $t1 to 1 if $t2 is less than $t3 as signed integers, otherwise to 0.
Used in
- Comparing two numbersMIPS assembly
- Maximum and unsigned distanceMIPS assembly
- The largest elementMIPS assembly
- Bubble sortMIPS assembly
Forms
slt , ,
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$31). $t2- A general-purpose register. It may be the same register as
$t1. $t3- A general-purpose register. It may be the same register as
$t1.
Useful for conditional logic without branches. Pair with 'bne $t1,$zero,label' or 'beq $t1,$zero,label' to branch on the result.
# Compare signed and unsigned bit patterns: $t0 is -1 (0xFFFFFFFF), $t1 is 1. Inspect $t2: 1.
li $t0, -1
li $t1, 1
slt $t2, $t0, $t1