bfi

Bit Field Insert

BFI<c> <Rd>, <Rn>, #<lsb>, #<width>

Copies a bitfield into a register.

Pseudocode Operation

width ← msb - lsb + 1
mask ← ((1 << width) - 1)
source_bits ← (Rn AND mask) << lsb
dest_mask ← NOT((mask << lsb))
Rd ← (Rd AND dest_mask) OR source_bits

Example

BFI r0, r1, #0, #width

Encoding

Binary Layout
cond
31:28
0111110
27:21
msb
20:16
Rd
15:12
lsb
11:7
001
6:4
Rn
3:0
 
Format Data Proc
Opcode 0x07C00010
Extension A32 (Base)

Operands

  • Rd
    Destination general-purpose register
  • Rn
    First source / base general-purpose register
  • lsb
    Start

Related

Other forms of bfi

  • bfi Bit Field Insert (Thumb)

More in A32 (Base)

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0x07C00010 BFI{<c>}{<q>} <Rd>, <Rn>, #<lsb>, #<width> A32 cond | 0111110 | msb | Rd | lsb | 001 | Rn
0xF3600000 BFI{<c>}{<q>} <Rd>, <Rn>, #<lsb>, #<width> T32 11110 | 0 | 11 | 01 | 1 | 0 | Rn | 0 | imm3 | Rd | imm2 | 0 | msb

Description

Bit Field Insert copies any number of low order bits from a register into the same number of adjacent bits at any position in the destination register.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    R[d]<msbit:lsbit> = R[n]<(msbit-lsbit):0>;
    // Other bits of R[d] are unchanged