movsx
Move with Sign-Extension
Copies and sign-extends a smaller value to a larger register.
Pseudocode Operation
sign_bit ← src[source_width - 1]; dest ← (source_width < dest_width) ? (sign_extend(src, sign_bit, dest_width)) : src;
Example
Encoding
Operands
-
dest
General-purpose register -
src
Register or memory operand
Related
Across architectures
Sign Extend Byte : how x86, ARM, RISC-V, and PowerISA each do this.
More in Base
Reference
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| 0F BE /r | MOVSX r16, r/m8 | RM | Valid Valid | Move byte to word with sign-extension. | |
| 0F BE /r | MOVSX r32, r/m8 | RM | Valid Valid | Move byte to doubleword with signextension. | |
| REX.W + 0F BE /r | MOVSX r64, r/m8 | RM | Valid N.E. | Move byte to quadword with sign-extension. | |
| 0F BF /r | MOVSX r32, r/m16 | RM | Valid Valid | Move word to doubleword, with signextension. | |
| REX.W + 0F BF /r | MOVSX r64, r/m16 | RM | Valid N.E. | Move word to quadword with sign-extension. | |
| 63 /r2 | MOVSXD r16, r/m16 | RM | Valid N.E. | Move word to word with sign-extension. | |
| 63 /r2 | MOVSXD r32, r/m32 | RM | Valid N.E. | Move doubleword to doubleword with signextension. | |
| REX.W + 63 /r | MOVSXD r64, r/m32 | RM | Valid N.E. | Move doubleword to quadword with signextension. |
Description
Copies the contents of the source operand (register or memory location) to the destination operand (register) and sign extends the value to 16 or 32 bits (see Figure 7-6 in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1). The size of the converted value depends on the operand-size attribute. In 64-bit mode, the instruction’s default operation size is 32 bits. Use of the REX.R prefix permits access to additional registers (R8-R15). Use of the REX.W prefix promotes operation to 64 bits. See the summary chart at the beginning of this section for encoding data and limits.
Operation
DEST := SignExtend(SRC);