奇偶校验标志与 "one and zero" 混合结果

parity flag getting mixed results with "one and zero"

检查此代码

include 'win32ax.inc'

;.data


.code

start:

mov al,00000001b

add al,00000001b   ;even  =2     pf = 0
add al,00000001b   ;odd   =3     pf = 1
add al,00000001b   ;even  =4     pf = 0
sub al,00000001b   ;odd   =3     pf = 1
sub al,00000001b   ;even  =2     pf = 0
sub al,00000001b   ;odd   =1     pf = 0
sub al,00000001b   ;even  =0     pf = 1

.end start 

最后两条减法指令应该设置PF=1,然​​后PF=0,为什么不呢?

我也在使用 FASM,我正在使用 ollydbg 调试器进行调试。

来自维基百科:

在x86处理器中,奇偶校验标志只反映结果的最低有效字节的奇偶校验,如果1的设置位数为偶数则设置。

所以

result = 0  an even number of ones are set so pf = 1 is the right answer
result = 1 an odd number of ones are set so pf = 0 is the right answer
result = 2 an odd number of ones are set so pf = 0 is the right answer
result = 3 an even number of ones are set so pf = 1 is the right answer

1 = 0b00000001  one bit is set an odd number of bits set pf = 0
3 = 0b00000011 two bits are set pf = 1
7 = 0b00000111 three bits are set pf = 0
12 = 0b00001100 two bits are set pf = 1