extsb
Extend Sign Byte
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
Operands
-
RA
Target -
RS
Source -
RT
Target General Purpose Register
Example
extsb r3, r3
Registers Altered
CR0, XERRelated
Across architectures
Sign Extend Byte : how x86, ARM, RISC-V, and PowerISA each do this.
More in Base
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
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.