# `movsxd`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/movsxd

**Move doubleword with sign extension**

Category: Arithmetic

Copies a 32-bit source into a register, sign-extending for a 64-bit destination.

x86-64 and later

[Intel's reference: MOVSX/MOVSXD](https://intel.github.io/SDM/instruction/MOVSX-MOVSXD.html)

Used in: [Bytes, words, dwords and qwords](https://asm-editor.specy.app/learn/courses/x86/introduction/bytes-words-dwords-and-qwords.md) (x86-64 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | not changed |

## Forms

- `movsxd reg, r/m32` (16, 32, 64)
  - `movsxd reg16, r/m32`
  - `movsxd reg32, r/m32`
  - `movsxd reg64, r/m32`
- `movsxd rax, eax`

## Operands

- `reg`: The destination register, usually wider than the source, as in `movsxd rax, ecx`.
- `r/m32`: A 32-bit general-purpose register or doubleword in memory, for example `eax` or `dword [rsi]`.

## Description

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

## Example

```x86
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
```
