检查此代码
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调试器进行调试。
答案 0 :(得分:1)
:
在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