sahf
Store ah into flags
Loads SF, ZF, AF, PF and CF from bits 7, 6, 4, 2 and 0 of ah.
8086 and later
CFPFAFZFSFDFOF ●●●●●––
- ● set from the result
- – not changed
- CF Loaded from AH.
- PF Loaded from AH.
- AF Loaded from AH.
- ZF Loaded from AH.
- SF Loaded from AH.
Forms
sahf
Bits 5, 3 and 1 are ignored, and OF and the rest of rflags are unchanged. In 64-bit mode it needs the LAHF/SAHF feature, which every current x86-64 processor has and a few of the first ones lack. lahf copies the same flags into ah.
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
sahf
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall