extsb.

Extend Sign Byte (Record)

extsb. RT,RS

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

Encoding

Binary Layout
31
0:5
RS
6:10
RA
11:15
954
16:20
/
21:31
 
Format X-form
Opcode 0x7C000774
Extension Base

Operands

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

Example

extsb r3, r3

Registers Altered

CR0, XER

Related

More in Base

Reference

Description

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

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.