cwde

Sign-extend ax into eax

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

CFPFAFZFSFDFOF –––––––
  • Changes no flag

Forms

  • cwde

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 extends eax into all of rax.

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