LAHF

Load Status Flags into AH Register

Opcodes

Hex Mnemonic Encoding Long Mode Legacy Mode Description
9F LAHF A Invalid* Valid Load: AH = EFLAGS(SF:ZF:0:AF:0:PF:1:CF).

Instruction Operand Encoding

Op/En Operand 0 Operand 1 Operand 2 Operand 3
A NA NA NA NA

Description

This instruction executes as described above in compatibility mode and legacy mode. It is valid in 64-bit mode only if CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1.

Pseudo Code

IF 64-Bit Mode
	IF CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1;
		AH = RFLAGS(SF:ZF:0:AF:0:PF:1:CF);
	ELSE
		#UD;
	FI;
ELSE
	AH = EFLAGS(SF:ZF:0:AF:0:PF:1:CF);
FI;

Flags Affected

None. The state of the flags in the EFLAGS register is not affected.

Exceptions

64-Bit Mode Exceptions

Exception Description
#UD If CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 0. If the LOCK prefix is used.

Compatibility Mode Exceptions

Same exceptions as in protected mode.

Virtual-8086 Mode Exceptions

Same exceptions as in protected mode.

Real-Address Mode Exceptions

Same exceptions as in protected mode.

Protected Mode Exceptions

Exception Description
#UD If the LOCK prefix is used.