sub

Operands

$reg, $reg, [$reg / imm]

Subtract (signed, overflow trap) : Sets $t1 = $t2 - $t3 using signed 32-bit arithmetic. Raises an overflow exception if the true result does not fit in 32 bits. Use 'subu' when overflow should be silently ignored.

Variants

  • Subtract (signed, overflow trap) : Sets $t1 = $t2 - $t3 using signed 32-bit arithmetic. Raises an overflow exception if the true result does not fit in 32 bits. Use 'subu' when overflow should be silently ignored. sub $t1,$t2,$t3
  • SUBtraction : set $t1 to ($t2 minus 16-bit immediate) sub $t1,$t2,-100
  • SUBtraction : set $t1 to ($t2 minus 32-bit immediate) sub $t1,$t2,100000
# Initialize both inputs, then execute sub with initialized inputs. Inspect $t2: 4.
li $t0, 7
li $t1, 3
sub $t2, $t0, $t1