Re: Application of parity flag

From: TS (spamtrap_at_crayne.org)
Date: 10/22/04


Date: Fri, 22 Oct 2004 01:10:35 +0000 (UTC)


>About the only practical use that I can think of testing parity of
>communications data (which is usually handled by hardware).
>
> mov al,<byte to be tested>
> test al,al
> jp <somewhere> ; byte has even parity
> ; byte has odd parity

I guess that creating checksums (Parity=XOR of all bits) is the main
purpose for the parity flag.

There is another useage for the parity flag, which has nothing to do
with parity: FPU comparations (e.g. FCOMI) set PF whenever the
operands are unordered and clear it if they can be compared.

However, you can also use it for creating semi-random numbers or
interesting patterns: I´ve used it for calculating cellular automata
once, and the paritiy of an ever incremented byte also gives a rather
interesting binary sequence...

You might even use PF to check the corresponding bit in a value which
has been loaded into EFLAGS via LAHF, POPF, IRET, a task switch or
whatever.



Relevant Pages

  • Re: xor and parity checking
    ... low half and the parity flag is set correctly (if we are trying to ... determine the parity for something larger than a byte). ... in ax, the "xor ah, al" instruction will set Parity to 1 ... xor 1110_1001 AL=e9;is ODD ...
    (alt.lang.asm)
  • Re: Application of parity flag
    ... parity flag mostly because the Intel 8-bit 8088 had one, ... Having a parity flag in hardware made the overhead of doing this much, ...
    (comp.lang.asm.x86)
  • Re: Use of error correcting codes for file repair
    ... correction built in ... containing the xor or the last 2 xor'ed blocks. ... DDPDDPX, where D is data, P is parity, and X is xor'ed parity (allowing ... possibly every so often storing a block full of checksums (these could be ...
    (comp.compression)
  • Re: Use of error correcting codes for file repair
    ... containing the xor or the last 2 xor'ed blocks. ... DDPDDPX, where D is data, P is parity, and X is xor'ed parity (allowing ... recovery if both 1 data and a parity block are bad for the same set of 3, ... possibly every so often storing a block full of checksums (these could be ...
    (comp.compression)
  • Re: A little story of failed raid5 (3ware 8000 series)
    ... Many RAID systems have checksums in addition to parity. ... ZFS never trusts the disks, ...
    (freebsd-stable)