Home/Instructions/Set Less Than Immediate Unsigned
SLTIU

RISC-V SLTIU Instruction Details

Instruction ManualI-type

Set rd to 1 if rs1 is less than the immediate (unsigned), else 0

Instruction Syntax

sltiu rd, rs1, imm
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
RV32IArithmeticCompare

Instruction Encoding

31..20
imm[11:0]
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

SLTIU uses opcode 0010011 (0x13), funct3 011. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.

Format: I-type
opcode: 0010011 (0x13)
funct3: 011 (0x3)

Instruction Behavior

SLTIU compares rs1 (unsigned) with the immediate (sign-extended then treated as unsigned), setting rd to 1 if rs1 < imm, else 0. SLTIU rd,rs1,1 sets rd=1 if rs1==0 (pseudo SEQZ).

Quick Understanding & Search Notes

SLTIU performs unsigned comparison rs1 < sign-extended imm; rd is set to 1 when true and 0 otherwise. It turns a comparison result into an integer value usable by later arithmetic or branches.

The immediate form uses a sign-extended 12-bit immediate.
Signed and unsigned comparisons differ in how the bit patterns are interpreted, not in register width.

Common Usage Scenarios

Comparison & Detection

Understand this scenario with real code like «sltiu x5, x6, 10 # x5 = (x6 < 10) ? 1 : 0 (unsigned)».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

Immediate is first sign-extended then treated as unsigned
vs SLTI: comparison type differs

FAQ

What value does SLTIU write?

It writes 1 when the comparison is true, otherwise 0.

What is the difference between SLT and SLTU?

SLT/SLTI compare as signed integers; SLTU/SLTIU compare as unsigned integers.