Parity flag

From Wikipedia, the free encyclopedia

In computer processors the parity flag indicates if the number of set bits is odd or even in the binary representation of the result of the last operation. It is normally a single bit in a processor status register.

For example, assume a machine where a set parity flag indicates even parity. If the result of the last operation were 26 (11010 in binary), the parity flag would be 0 since the number of set bits is odd. Similarly, if the result were 102 (1100110 in binary) then the parity flag would be 1.

[edit] Example (x86 Processor Family)

The parity flag is changed in the x86 processor family by the following instructions (from an 80386 Intel manual):

  • All arithmetic instructions;
  • Compare instruction (equivalent to a subtract instruction without storing the result);
  • Logical instructions - XOR, AND, OR;
  • the TEST instruction (equivalent to the AND instruction without storing the result).
  • the POPF instruction