extsw

Extend Sign Word

extsw RT,RS
extsw. RT,RS

Sign extends the low word (32-bit) to 64 bits.

Details

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.

Pseudocode 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.

Example

extsw r3, r3

Encoding

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

Operands

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