您可以使用 LAHF 指令将标志寄存器的低 8 位复制到 ah(LAHF 指令不需要参数)现在 AH 的位将是:
(7) 128: Signflag
(6) 64: Equal/Zero-Flag
(5) 32: reserved for future purposes
(4) 16: Auxiliary-Flag
(3) 8: reserved for future purposes
(2) 4: parity-Flag
(1) 2: reserved for future purposes
(0) 1: Carry-Flag
如果要将孔标志寄存器复制到 ax,请使用以下代码:
pushf
pop ax
现在 AX 的位将是:
15: reserved for future purposes
14: Nested-Task
13: I/O Privileged Level
12: I/O Privileged Level
11: Overflow-Flag
10: Direction-Flag (see also: STD, CLD)
9: Interrupt enable (see also: STI, CLI)
8: Trap-Flag (Trap mode)
7: Signflag
6: Equal/Zero-Flag
5: reserved for future purposes
4: Auxiliary-Flag
3: reserved for future purposes
2: parity-Flag
1: reserved for future purposes
0: Carry-Flag
要检查单个字节,请使用 TEST 指令(如果您的汇编程序支持 TEST 指令)或使用以下代码:
shr ax, (bitposition) ;replace "bitposition" by the position of the flag (for example 2 for the parity flag)
and ax, 1; If the flag wasn't set, ax will be zero otherwise, if the flag was set, ax will be 1.
或者,如果您使用 LAHF:
shr al, (bitposition)
and al, 1; If the flag wasn't set, al will be zero otherwise, if the flag was set, al will be 1.