li
Load immediate
Puts an immediate value into a register, using one or two instructions as its size needs.
Used in
- Getting started with MIPSMIPS assembly
- The 32 registers and their namesMIPS assembly
- .data, .text and directivesMIPS assembly
- Memory, little endian and alignmentMIPS assembly
- Words, halves and bytesMIPS assembly
- The MIPS instruction setMIPS assembly
- Loads, stores and immediatesMIPS assembly
- Comparing two numbersMIPS assembly
- Memory regions and executable filesMIPS assembly
- Branch on compareMIPS assembly
Forms
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$31). imm- An immediate value: a signed 16-bit value (
-32768to32767), an unsigned 16-bit value (0to65535) or a 32-bit value (-2147483648to4294967295). The assembler chooses a supported encoding for the value and other operands; a pseudoinstruction may expand into several instructions.
# Load a literal directly into $t2; inspect it for 7.
li $t2, 7