# `movsxb`

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

**Move byte with sign extension**

Category: Arithmetic

Sign-extends the byte source to the width of the destination register and copies the result there.

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

- `movsxb reg, r/m8` (16, 32, 64)
  - `movsxb reg16, r/m8`
  - `movsxb reg32, r/m8`
  - `movsxb reg64, r/m8`
- `movsxb ax, al` · 8086 and later

## Operands

- `reg`: The destination register, usually wider than the source, as in `movsxb eax, bl`.
- `r/m8`: An 8-bit general-purpose register or byte in memory, for example `al` or `byte [rsi]`. The high-byte registers `ah`, `bh`, `ch` and `dh` cannot be used in an instruction that also uses a 64-bit operand, `spl`, `bpl`, `sil`, `dil`, or `r8` to `r15` at any size.

## Description

It reads an 8-bit register or memory value and sign-extends it into a 16-, 32- or 64-bit destination register. For example, `movsxb rax, [rdi]` reads one byte. A 32-bit destination clears the upper half of its 64-bit register after producing the 32-bit result.

## Example

```x86
global _start

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

        movsxb rax, bl

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