movz

Move if zero

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

Forms

  • movz , ,

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 movz copy its source. Inspect $t2: 7.
li $t1, 7
li $t0, 0
movz $t2, $t1, $t0