sxtb

Signed Extend Byte (Thumb)

SXTB <Rd>, <Rm>

Sign-extends byte to word (Thumb).

Pseudocode Operation

Rd = SignExtend(Rm[7:0], 32)

Example

SXTB r0, r2

Encoding

Binary Layout
10110010
15:8
0
7
1
6
Rm
5:3
Rd
2:0
 
Format Thumb Data Proc
Opcode 0xB240
Extension T32 (Thumb)

Operands

  • Rd
    Destination general-purpose register
  • Rm
    Second source / offset general-purpose register

Related

Other forms of sxtb

  • sxtb Signed Extend Byte (A32)
  • sxtb Sign Extend Byte

Across architectures

Sign Extend Byte : how x86, ARM, RISC-V, and PowerISA each do this.

More in T32 (Thumb)

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0x06AF0070 SXTB{<c>}{<q>} {<Rd>,} <Rm> {, ROR #<amount>} A32 cond | 01101 | 0 | 10 | 1111 | Rd | rotate | 0 | 0 | 0111 | Rm
0xB240 SXTB{<c>}{<q>} {<Rd>,} <Rm> T32 10110010 | 0 | 1 | Rm | Rd
0xFA4FF080 SXTB{<c>}.W {<Rd>,} <Rm> T32 111110100 | 10 | 0 | 1111 | 1111 | Rd | 1 | 0 | rotate | Rm

Description

Signed Extend Byte extracts an 8-bit value from a register, sign-extends it to 32 bits, and writes the result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit value.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    rotated = ROR(R[m], rotation);
    R[d] = SignExtend(rotated<7:0>, 32);