Is the immediate zero-extended?
ANDI immediate forms use a 12-bit signed immediate that is sign-extended to XLEN.
Bitwise AND of rs1 with sign-extended 12-bit immediate, result in rd
ANDI performs bitwise AND of rs1 with the sign-extended 12-bit immediate, writing to rd. Used to clear specific bits (masking), extract bit fields, and implement modulo (when immediate is 2^n-1). The immediate is sign-extended first.
Uses the same rhythm as the ADDI page: machine-code fields, fixed-field identification, operand reads, instruction-specific execution, and ISA-visible state update.
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
ANDI is an RV32I/RV64I OP-IMM logical-immediate instruction: imm[11:0] is sign-extended to XLEN, ANDed bit by bit with rs1, and written to rd. It is useful for masks that fit the signed 12-bit immediate.
Understand this scenario with real code like «andi x5, x6, 0xFF # x5 = x6 & 0xFF (extract low byte)».
Understand this scenario with real code like «andi x5, x6, 0xFF # x5 = x6 & 0xFF (extract low byte)».
Understand this scenario with real code like «andi x5, x6, 0xFF # x5 = x6 & 0xFF (extract low byte)».
ANDI immediate forms use a 12-bit signed immediate that is sign-extended to XLEN.
No. ANDI has only a signed 12-bit immediate field; larger masks usually need to be built in a register and then used with AND.