teq

Trap if equal

Raises a trap exception if $t1 equals $t2, which halts execution in this simulator.

Forms

  • teq ,

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.

In MARS this halts execution. On real hardware it triggers a trap handler. Useful as a guarded assertion or to catch forbidden conditions (e.g., division by zero guard).

# This named trap is expected to stop execution when its predicate is true.
li $t0, 5
li $t1, 5
teq $t0, $t1
li $t2, 99 # not reached