extsw
Extend Sign Word
extsw RT,RS
Sign extends the low word (32-bit) to 64 bits.
Encoding
Binary Layout
31
0:5
RS
6:10
RA
11:15
986
16:20
/
21:31
Operands
-
RA
Target -
RS
Source -
RT
Target General Purpose Register
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
The contents of register RS are extended to fill the upper 32 bits of register RA, and the lower 32 bits of RA are filled with a copy of the upper 32 bits of RS.
Operation
if 'extsw' then
s ← (RS)32
RA32:63 ← (RS)32:63
RA0:31 ← 32s
else if 'extsw.' then
s ← (RS)32
RA32:63 ← (RS)32:63
RA0:31 ← 32s
Programming Note
The extsw instruction is commonly used to sign-extend a 32-bit value in RS to a 64-bit value in RA. Ensure that the source register RS contains the correct 32-bit signed integer to avoid unexpected results. This instruction operates at user privilege level and does not generate exceptions under normal circumstances.