movsxd
Move doubleword with sign extension
Copies a 32-bit source into a register, sign-extending for a 64-bit destination.
x86-64 and later
Intel's reference: MOVSX/MOVSXD
Used in
- Bytes, words, dwords and qwordsx86-64 assembly
CFPFAFZFSFDFOF –––––––
- Changes no flag
Forms
movsxd rax, eax
Operands
reg- The destination register. Its width is selected independently of the source width; widening uses a larger destination.
r/m32- A 32-bit general-purpose register or doubleword in memory, for example
eaxordword [rsi].
Its usual use is movsxd rax, ecx: copy 32 bits and sign-extend them to 64 bits. Writing eax with an ordinary move would instead clear bits 63–32 of rax.
NASM also accepts 32- and 16-bit destinations: movsxd eax, ecx copies the 32-bit value and clears the upper half of rax; movsxd ax, ecx retains the low 16 bits. Neither widens the source. movsxd rax, eax can use the same encoding as cdqe.
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
movsxd rax, ebx
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall