Home/Instructions/Bit Extract Immediate
BEXTI

RISC-V BEXTI Instruction Details

Instruction ManualI-type

Extract single bit by immediate index

Instruction Syntax

bexti rd, rs1, uimm
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.
BZbsBit ManipulationSingle-Bit Operation

Instruction Encoding

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

BEXTI uses opcode 0010011 (0x13), funct3 101, funct7 0100100. 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: 101 (0x5)
funct7: 0100100 (0x24)

Instruction Behavior

bexti is a Zbs single-bit extract instruction. The bit index comes from the immediate field.

Quick Understanding & Search Notes

bexti is a Zbs single-bit extract instruction. The bit index comes from the immediate field.

These instructions are part of a B-extension subset and operate on XLEN-wide integer register values.
The immediate field width depends on XLEN; RV32 encodes 0..31 and RV64 encodes 0..63.
bext/bexti returns 0 or 1; it does not preserve the original bit position.

Common Usage Scenarios

Bit Operations & Masks

Understand this scenario with real code like «bexti x10, x11, 2 ; x10 = (x11 >> 2) & 1».

Comparison & Detection

Understand this scenario with real code like «bexti x10, x11, 2 ; x10 = (x11 >> 2) & 1».

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

The immediate field width depends on XLEN; RV32 encodes 0..31 and RV64 encodes 0..63.
bext/bexti returns 0 or 1; it does not preserve the original bit position.

FAQ

Does bexti access memory?

No. It reads integer register operands and writes rd only.

How is the bit index selected for bexti?

The immediate encodes the bit position directly, with the legal range determined by XLEN.