addu
Add unsigned (no overflow trap)
Adds $t2 and $t3, or $t2 and an immediate, into $t1 and wraps on overflow instead of trapping.
Used in
- Sum of an arrayMIPS assembly
- The largest elementMIPS assembly
- Reverse a string in placeMIPS assembly
Forms
addu , ,
Pseudo-instructions
The assembler turns these into one or more real instructions.
-
Set $t1 to ($t2 plus 32-bit immediate), no overflow
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$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. imm32- A 32-bit immediate,
-2147483648to4294967295. Pseudoinstruction expansion may overwrite$at, losing its previous value.
No exception is raised on overflow; the result wraps modulo 2^32. Despite the name, this works fine with signed values too when you don't need overflow detection.
# Add 1 to the largest signed positive word without an overflow trap. Inspect $t2: 0x80000000.
li $t0, 0x7FFFFFFF
addu $t2, $t0, 1