3.9.2. SBFX and UBFX

Signed Bit Field Extract and Unsigned Bit Field Extract.

Syntax

SBFX{cond} Rd, Rn, #lsb, #width
UBFX{cond} Rd, Rn, #lsb, #width

Where:

cond

Is an optional condition code. See Conditional execution.

Rd

Is the destination register.

Rn

Is the source register.

lsb

Is the position of the least significant bit of the bit field. lsb must be in the range 0-31.

width

Is the width of the bit field and must be in the range 1-32−lsb.

Operation

SBFX extracts a bit field from one register, sign extends it to 32 bits, and writes the result to the destination register.

UBFX extracts a bit field from one register, zero extends it to 32 bits, and writes the result to the destination register.

Restrictions

Do not use SP and do not use PC.

Condition flags

These instructions do not affect the flags.

Examples

  SBFX  R0, R1, #20, #4  ; Extract bit 20 to bit 23 (4 bits) from R1 and sign 
                         ; extend to 32 bits and then write the result to R0. 
  UBFX  R8, R11, #9, #10 ; Extract bit 9 to bit 18 (10 bits) from R11 and zero 
                         ; extend to 32 bits and then write the result to R8.
Copyright © 2015, 2018 Arm. All rights reserved.ARM DUI 0646C
Non-ConfidentialID121118