One instruction to clear PF (parity flag) is to get an odd number of bits in the results registry

In the x86 assembly, is it possible to clear the parity flag in one and only one instruction that works in any initial register configuration?

This is equivalent to creating a result register with an odd number of bits with any operation that sets flags (explicitly excluding mov).

For contrast, setting the parity flag can be done in one instruction:

cmp bl, bl

And there are many ways to clear the parity flag using two instructions:

and bl, 0 
or  bl, 1

However, the single instruction method remains elusive.

+3
source share
3 answers

.

PF (, al al). , , (, al, 0 al, ffh). , , , .

, . BIOS. MS-DOS, .

+2

:

foo:  cmp byte [foo],0x7F

. cmp 0x80 0x80-0x7F = 0x01.

+3

I think the only way to do this, except mov(I seduce the interview question) is to find (miraculously, admittedly) a pair of registers or registers that will satisfy TEST src, dst. See here , Operation.

There is currently no x86 register / register pair that could satisfy this spring condition.

0
source

Source: https://habr.com/ru/post/1754888/


All Articles