# `movsxw`

[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/movsxw

**Move word with sign extension**

Category: Arithmetic

Copies a word source into a register, sign-extending when the destination is wider.

386 and later

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

## 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

- `movsxw reg, r/m16` (16, 32, 64)
  - `movsxw reg16, r/m16`
  - `movsxw reg32, r/m16`
  - `movsxw reg64, r/m16`
- `movsxw eax, ax`

## Operands

- `reg`: The destination register, usually wider than the source, as in `movsxw eax, bx`.
- `r/m16`: A 16-bit general-purpose register or word in memory, for example `ax` or `word [rsi]`.

## Description

It reads 16 bits and sign-extends them into a 32- or 64-bit destination. For example, `movsxw rax, [rdi]` reads two bytes. NASM also accepts a 16-bit destination; that copies the word without widening it. A 32-bit destination clears the upper half of its 64-bit register.

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        movsxw rax, bx

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
