addi
Addition immediate
Adds a sign-extended 12-bit immediate to t2 and stores the sum in t1.
Used in
- Loads, stores and immediatesRISC-V assembly
- .data, .text and directivesRISC-V assembly
- LoopsRISC-V assembly
- Arithmetic, logic and bitsRISC-V assembly
- Arrays and stringsRISC-V assembly
- The stack and spRISC-V assembly
- jal, ret and the calling conventionRISC-V assembly
- Floating point and the F and D extensionsRISC-V assembly
- When an instruction cannot be carried outRISC-V assembly
- Variables in memory and constantsRISC-V assembly
Forms
addi , ,
Pseudo-instructions
The assembler turns these into one or more real instructions.
-
Set t1 to t2 + lower 12-bit label's address
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. t2- An integer register. It may be the same register as
t1. imm12- A signed 12-bit immediate,
-2048to2047. label- A named address in the program, such as the start of a loop or a variable in
.data.
.text
li t0, 13
# t0=13, immediate 5; addi writes 18 to t2.
addi t2, t0, 5