Home/Instructions/Bit Extract
BEXT

RISC-V BEXT Instruction Details

Instruction ManualR-type

Extract single bit by register index

Instruction Syntax

bext rd, rs1, rs2

rd and rs1 select x0–x31; sources are read before writeback, and x0 writes are discarded.

The low 5 (RV32) or 6 (RV64) rs2 bits select the index; other bits are ignored.

Requires Zbs on RV32/RV64; the result is 0 or 1, without preserving the bit position.

BZbsBit ManipulationSingle-Bit Operation

Instruction Behavior

Zbs bext extracts one rs1 bit selected by the low log2(XLEN) bits of rs2; rd is 0 or 1.

BEXT Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rd
rs1
rs2
bext
,
,
Execution Context

This example uses fixed initial register values and PC=0x2000; instruction fetch succeeds, with no asynchronous interrupt or extra extension checks. Exception branches stop ordinary commit; post-trap PC and handler state are EEI-dependent.

a0(x10)
0x00001000
a6(x16)
0xFFFFFFF0
31..25
24..20
19..15
14..12
11..7
6..0
0100100
funct7
10000
rs2
01010
rs1
101
funct3
00101
rd
0110011
opcode
Execution Data Path
instruction
0x490552B3
opcode
0110011 -> OP
funct3
101 -> BEXT
funct7
0100100 -> single-bit operation selector
rd / rs1 / rs2
t0(x5) / a0(x10)=0x00001000 / a6(x16)=0xFFFFFFF0
rs2[4:0]
0xFFFFFFF0 & 31 -> index=16
single-bit extract
Not computed
x5
t0(x5) = 0x00003001; pc = 0x00002000
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x490552B3
syntax : bext t0(x5), a0(x10), a6(x16)
Pending result: Not computed
Current architectural state
t0(x5) = 0x00003001; pc = 0x00002000

This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.

Quick Understanding & Search Notes

Zbs bext extracts one rs1 bit selected by the low log2(XLEN) bits of rs2; rd is 0 or 1.

Zbs instruction for RV32 and RV64.
The register-index form uses only the low log2(XLEN) bits of rs2 to select the bit.
bext/bexti returns 0 or 1; it does not preserve the original bit position.

Common Usage Scenarios

Address & Pointer

RV32/RV64 Zbs, x11=0xff and x12=35: RV32 extracts bit 3 to x10=1; RV64 extracts bit 35 to x10=0.

Bit Operations & Masks

RV32/RV64 Zbs, x11=0xff and x12=35: RV32 extracts bit 3 to x10=1; RV64 extracts bit 35 to x10=0.

Comparison & Detection

RV32/RV64 Zbs, x11=0xff and x12=35: RV32 extracts bit 3 to x10=1; RV64 extracts bit 35 to x10=0.

Pre-Use Checklist

Syntax Check
  • rd and rs1 select x0–x31; sources are read before writeback, and x0 writes are discarded.
  • The low 5 (RV32) or 6 (RV64) rs2 bits select the index; other bits are ignored.
Semantic Check
  • Requires Zbs on RV32/RV64; the result is 0 or 1, without preserving the bit position.

Pitfalls / Common Confusions

The register-index form uses only the low log2(XLEN) bits of rs2 to select the bit.
bext/bexti returns 0 or 1; it does not preserve the original bit position.