Add (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 'addu' when overflow should be silently ignored.
add
Operands
$reg, $reg, [$reg / imm]Variants
- Add (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 'addu' when overflow should be silently ignored. add $t1,$t2,$t3
- ADDition : set $t1 to ($t2 plus 16-bit immediate) add $t1,$t2,-100
- ADDition : set $t1 to ($t2 plus 32-bit immediate) add $t1,$t2,100000
# Add two initialized values. Inspect $t2: it should contain 12.
li $t0, 7
li $t1, 5
add $t2, $t0, $t1
# Optional overflow variation: uncomment these lines before the normal completion point.
# li $t0, 0x7FFFFFFF
# li $t1, 1
# add $t2, $t0, $t1
# Expected: signed integer overflow stops execution.