# `cdqe`

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

**Sign-extend eax into rax**

Category: Arithmetic

Sign-extends eax into rax, filling the upper 32 bits with copies of eax's sign bit so 32-bit signed values work in 64-bit arithmetic.

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

- `cdqe`

## Description

It takes no operands and changes no other register or flags. For example, `eax = 0xffffffff` becomes `rax = -1`. NASM can assemble `movsxd rax, eax` to the same instruction.

## Example

```x86
global _start

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

        cdqe

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