movn

Move if not zero

Copies $t2 into $t1 if $t3 is not zero, without a branch.

Forms

  • movn , ,

Operands

$t1
Any general-purpose register, $0 to $31, using its numeric or named spelling, such as $8 or $t0 ($zero is $0; $ra is $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.

Allows branchless conditional assignment — avoids a branch instruction when you only need to update a register conditionally.

# Set condition to make movn copy its source. Inspect $t2: 7.
li $t1, 7
li $t0, 1
movn $t2, $t1, $t0