addiu
Add immediate unsigned (no overflow trap)
Adds a sign-extended immediate to the second register and stores the sum in the first, wrapping on overflow instead of trapping.
Used in
- Exceptions and coprocessor 0MIPS assembly
- Sum of an arrayMIPS assembly
- The largest elementMIPS assembly
- Byte length of a stringMIPS assembly
- Reverse a string in placeMIPS assembly
Forms
addiu , ,
Pseudo-instructions
The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.
-
Set $t1 to ($t2 plus 32-bit immediate), no overflow
-
Set $t1 to $t2 plus the lower 16 bits of label's address
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. imm16- A signed 16-bit immediate,
-32768to32767. imm32- A 32-bit immediate,
-2147483648to4294967295. A pseudo-instruction that takes one uses the register$atas a temporary, so$atloses the value it held. label- A named address in the program, such as the start of a loop or a variable in
.data.
The immediate is a signed 16-bit value sign-extended to 32 bits; no overflow exception is raised. Despite the name the immediate is sign-extended, not zero-extended. The most common add-immediate instruction.
# Add immediate 1 across the signed boundary without trapping. Inspect $t2: 0x80000000.
li $t0, 0x7FFFFFFF
addiu $t2, $t0, 1