# `cwde`

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

**Sign-extend ax into eax**

Category: Arithmetic

Sign-extends ax into eax, filling the upper 16 bits with copies of the sign bit of ax.

386 and later

[Intel's reference: CBW/CWDE/CDQE](https://intel.github.io/SDM/instruction/CBW-CWDE-CDQE.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

- `cwde`

## Description

As a 32-bit register write it also clears the upper half of `rax`, so the result is not a signed 64-bit value: [`cdqe`](https://asm-editor.specy.app/documentation/x86/instruction/cdqe.md) extends `eax` into all of `rax`.

## Example

```x86
global _start

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

        cwde

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