# `movzx`

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

**Move with zero extension**

Category: Arithmetic

Copies a source into a register, filling added high bits with zeros when the destination is wider.

386 and later

[Intel's reference: MOVZX](https://intel.github.io/SDM/instruction/MOVZX.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), [Ports, memory-mapped devices, and kernel access](https://asm-editor.specy.app/learn/courses/x86/talking-to-the-outside-world/ports-devices-and-the-kernel.md) (x86-64 assembly), [A bouncing ball](https://asm-editor.specy.app/learn/courses/x86/examples/bouncing-ball.md) (x86-64 assembly), [Move a square with the keyboard](https://asm-editor.specy.app/learn/courses/x86/examples/keyboard-control.md) (x86-64 assembly), [Paint with the mouse](https://asm-editor.specy.app/learn/courses/x86/examples/mouse-paint.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

- `movzx reg, r/m` (16, 32, 64)
  - `movzx reg16, r/m8`
  - `movzx reg32, r/m8`
  - `movzx reg64, r/m8`
  - `movzx reg16, r/m16`
  - `movzx reg32, r/m16`
  - `movzx reg64, r/m16`
  - `movzx reg16, r/m32`: 8086 and later
  - `movzx reg64, r/m32`

## Operands

- `reg`: The destination register, usually wider than the source, as in `movzx eax, bl`.
- `r/m`: The source register or memory location, usually narrower than the destination. The high-byte registers `ah`, `bh`, `ch` and `dh` cannot be used when the destination is a 64-bit register or one of `r8` to `r15` at any size.

## Description

For example, `movzx rax, byte [rdi]` turns `0xff` into 255. The source has its own width; it need not match the destination.

For a 32-bit source and 64-bit destination, NASM uses an ordinary 32-bit move: `movzx rax, ebx` has the effect of `mov eax, ebx`, whose write clears the upper half of `rax`. `movzxd` is another spelling for this case.

Some accepted aliases do not widen: `movzx ax, bx` copies a word, while `movzx ax, ebx` retains only the low 16 bits. These leave the rest of `rax` unchanged. The equal-width 32-bit alias is unavailable in 64-bit mode; use `mov eax, ebx` for that copy.

## Example

```x86
global _start

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

        movzx rax, bl

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