extsh

Extend Sign Halfword

extsh RA, RS

Sign extends the low halfword.

Details

The extsh instruction extends the sign of a halfword in the source register to fill the entire destination register. If the most significant bit (MSB) of the halfword is 1, the destination register is filled with all ones; otherwise, it is filled with all zeros.

Pseudocode Operation

s ← (RS)48
RA48:63 ← (RS)48:63
RA0:47 ← 48s

Programming Note

The extsh instruction is commonly used to sign-extend a halfword value from the source register into the destination register. Ensure that the source register contains a valid halfword value, and be aware that this operation affects the entire 64-bit destination register. This instruction operates at user privilege level and does not generate exceptions under normal circumstances.

Example

extsh r4, r3

Encoding

Binary Layout
31
0
RS
6
RA
11
922
16
/
21
 
Format X-form
Opcode 0x7C000734
Extension Base

Operands

  • RA
    Target
  • RS
    Source