## SBFM

Signed Bitfield Move is usually accessed via one of its aliases, which are always preferred for disassembly.

If <imms> is greater than or equal to <immr>, this copies a bitfield of (<imms>-<immr>+1) bits starting from bit position <immr> in the source register to the least significant bits of the destination register.

If <imms> is less than <immr>, this copies a bitfield of (<imms>+1) bits from the least significant bits of the source register to bit position (regsize-<immr>) of the destination register, where regsize is the destination register size of 32 or 64 bits.

In both cases the destination bits below the bitfield are set to zero, and the bits above the bitfield are set to a copy of the most significant bit of the bitfield.

This instruction is used by the aliases ASR (immediate), SBFIZ, SBFX, SXTB, SXTH, and SXTW.

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |

sf | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | N | immr | imms | Rn | Rd | ||||||||||||||||||

opc |

integer d = UInt(Rd); integer n = UInt(Rn); integer datasize = if sf == '1' then 64 else 32; boolean inzero; boolean extend; integer R; integer S; bits(datasize) wmask; bits(datasize) tmask; case opc of when '00' inzero = TRUE; extend = TRUE; // SBFM when '01' inzero = FALSE; extend = FALSE; // BFM when '10' inzero = TRUE; extend = FALSE; // UBFM when '11' UNDEFINED; if sf == '1' && N != '1' then UNDEFINED; if sf == '0' && (N != '0' || immr<5> != '0' || imms<5> != '0') then UNDEFINED; R = UInt(immr); S = UInt(imms); (wmask, tmask) = DecodeBitMasks(N, imms, immr, FALSE);

### Assembler Symbols

<Wd> |
Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. |

<Wn> |
Is the 32-bit name of the general-purpose source register, encoded in the "Rn" field. |

<Xd> |
Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. |

<Xn> |
Is the 64-bit name of the general-purpose source register, encoded in the "Rn" field. |

### Alias Conditions

Alias | Of variant | Is preferred when |
---|---|---|

ASR (immediate) | 32-bit | imms == '011111' |

ASR (immediate) | 64-bit | imms == '111111' |

SBFIZ | UInt(imms) < UInt(immr) | |

SBFX | BFXPreferred(sf, opc<1>, imms, immr) | |

SXTB | immr == '000000' && imms == '000111' | |

SXTH | immr == '000000' && imms == '001111' | |

SXTW | immr == '000000' && imms == '011111' |

### Operation

bits(datasize) dst = if inzero then Zeros() else X[d]; bits(datasize) src = X[n]; // perform bitfield move on low bits bits(datasize) bot = (dst AND NOT(wmask)) OR (ROR(src, R) AND wmask); // determine extension bits (sign, zero or dest register) bits(datasize) top = if extend then Replicate(src<S>) else dst; // combine extension bits and result bits X[d] = (top AND NOT(tmask)) OR (bot AND tmask);

### Operational information

If PSTATE.DIT is 1:

- The execution time of this instruction is independent of:
- The values of the data supplied in any of its registers.
- The values of the NZCV flags.

- The response of this instruction to asynchronous exceptions does not vary based on:
- The values of the data supplied in any of its registers.
- The values of the NZCV flags.