BEXT

Bit Extract

BEXT rd, rs1, rs2

Extracts the value of a single bit (0 or 1) at the index specified by rs2. The result is placed in the LSB of rd.

Encoding

Binary Layout
0100100
31:25
rs2
24:20
rs1
19:15
101
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x48005033
Extension Zbs

Operands

  • rd
    Dest (0 or 1)
  • rs1
    Source
  • rs2
    Index

Example

BEXT x10, x11, x12

// x10 = (x11 >> x12) & 1

Related

More in Zbs

Description

BEXT extracts the single bit of rs1 selected by the lower log2(XLEN) bits of rs2, zero-extending to XLEN and writing to rd.

Operation

R[rd] = (R[rs1] >> (R[rs2] & (XLEN-1))) & 1;