extsb

Extend Sign Byte

extsb RT,RS
extsb. RT,RS

Sign extends the low byte of a register to the full width.

Details

The contents of the specified byte (RS)56 are placed into RA56:63, and RA0:55 are filled with a copy of (RS)56.

Pseudocode Operation

if 'extsb' then
    s ← (RS)56
    RA56:63 ← (RS)56:63
    RA0:55 ← 56s
else if 'extsb.' then
    s ← (RS)56
    RA56:63 ← (RS)56:63
    RA0:55 ← 56s

Programming Note

The extsb instruction is commonly used to sign-extend a byte value into a full word. Ensure the source register contains the correct byte to avoid unexpected results. This instruction operates at user privilege level and does not generate exceptions under normal conditions.

Example

extsb r3, r3

Encoding

Binary Layout
31
0
RS
6
RA
11
954
31
/
 
Format X-form
Opcode 0x7C000774
Extension Base
Registers Altered CR0, XER

Operands

  • RA
    Target
  • RS
    Source
  • RT
    Target General Purpose Register