01 LDI
Updated 4 Oct 2026
LDI
- The LDI (Load Immediate) instruction is designed to quickly load a constant value (K) into a General Purpose Register (GPR) within a specific range.
Instruction Syntax
LDI Rd, K
Rd: The destination register where the constant value K will be stored.
- Must be one of the upper 16 registers: R16–R31.
K: The immediate value to be loaded into Rd.
- Must be an 8-bit constant value.
- Range: (Values outside this range will result in an error.)
- Decimal: 0−255
- Hexadecimal: 0x00−0xFF
- Binary: 0b000000000–0b11111111
Examples
Valid Instruction:
LDI R20, 0x25
R20: R20 is in the valid register range R16–R31.
K: 0x25 (37 in decimal) is within the valid range for K.
- Effect: Load
0x25 into R20.
Valid Instruction:
LDI R20, 25
R20: R20 is valid.
K: 25 is within the range 0–255.
- Effect: Load
25 (decimal) into R20.
Error Example:
LDI R10, 0x10
R10: R10 is not in the valid register range R16–R31.
- Result: Error.
Error Example:
LDI R25, 0x200
R25: R25 is valid.
K: 0x200 (512 in decimal) exceeds the 8-bit range (0–255).
- Result: Error.