Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Application of parity flag

1,347 views
Skip to first unread message

Advait Raut

unread,
Oct 20, 2004, 9:24:58 PM10/20/04
to
Hi,
Please, anybody tell me what are applications of parity flag .

Thank you

Dirk Wolfgang Glomp

unread,
Oct 21, 2004, 6:24:29 AM10/21/04
to
Advait Raut schrieb:

> Hi, Please, anybody tell me what are applications of parity flag.

Applications that use the parity flag?

The parity flag is a bit in the CPU-status-register,
wich is set by a result of a arithmetic instruction
and can be use for following instructions like jp "offset",
to jump when parity flag is set.

Dirk

spam...@crayne.org

unread,
Oct 21, 2004, 7:32:18 AM10/21/04
to

That's a pretty lame explanation.

The parity flag is a bit in the CPU-status-register,

which is set by a result of a arithmetic or logical instruction
when the L/O 8 bits of the result have even parity.
(at least on an 8086/8088, I haven't yet found a description for
any later processor)

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


--
Arargh410 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.

wolfgang kern

unread,
Oct 21, 2004, 7:48:54 AM10/21/04
to

Advait Raut asked:

| Please, anybody tell me what are applications of parity flag.

I scanned all code I've written so far (~14 GB) for JPE/JPO and
found it only in an RS232 driver module and in an very old 8-bit
calculation. Perhaps some modem-drivers use it as well,

but the x86 parity flag works on low 8 bits only, so it's of limited use.
If someone can proof this wrong, please let me know on which CPU.

__
wolfgang

Randall Hyde

unread,
Oct 21, 2004, 12:33:36 PM10/21/04
to

"wolfgang kern" <now...@nevernet.at> wrote in message
news:cl86rp$m7s$3...@newsreader1.utanet.at...

The purpose of the parity flag was to allow some source-level
compatibility with the 8085 processor which also supported a
parity flag. Early on, Intel provided a "source-level converter"
program that translated 8085 source code to 8086 source code
that was semantically identical (and I've actually had to work
with the output of that translator, yuck). In any case, they
needed the parity flag to make the transition from the 8085
to the 8086 occur smoothly.
Cheers,
Randy Hyde

TS

unread,
Oct 21, 2004, 9:10:35 PM10/21/04
to
>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.

Jack Klein

unread,
Oct 22, 2004, 12:02:41 AM10/22/04
to
On Thu, 21 Oct 2004 01:24:58 +0000 (UTC), spam...@crayne.org (Advait
Raut) wrote in comp.lang.asm.x86:

> Hi,
> Please, anybody tell me what are applications of parity flag .
>
> Thank you

As Randall Hyde points out, the 8086 and all its descendents has a
parity flag mostly because the Intel 8-bit 8088 had one, and Intel
wanted to make sure that 8088 code could be easily ported to the new
16-bit processor.

Most likely the main reason that a lot of the early 8-bitters had
parity bits is that in the old, old days there were UARTs that did not
have the ability to do parity generating and checking in hardware, so
the processor had to do it in software.

And for sure there were paper tape punches and readers in the old
days. They used 7 data bits and a parity bit, and the processor had
to do the parity checking in software on many of them.

Having a parity flag in hardware made the overhead of doing this much,
much less than either counting bits or having a look up table.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

Chris Giese

unread,
Oct 22, 2004, 12:01:59 AM10/22/04
to
You can use the parity bit in the x86 FLAGS register to send
and receive 9-bit data via the PC serial port.

To transmit the 9th bit, use "stick" parity in the serial chip
("stuck-at-0" or "stuck-at-1").

To receive, check if the serial port reports a parity error,
and check the parity in software (using FLAGS.PF). Using
these two error conditions, you can re-create the 9th bit.

--
geezer@ | http://my.execpc.com/~geezer
execpc.com | http://my.execpc.com/~geezer/osd

spam...@crayne.org

unread,
Oct 22, 2004, 12:53:42 AM10/22/04
to
On Fri, 22 Oct 2004 04:02:41 +0000 (UTC), Jack Klein
<jack...@spamcop.net> wrote:

>On Thu, 21 Oct 2004 01:24:58 +0000 (UTC), spam...@crayne.org (Advait
>Raut) wrote in comp.lang.asm.x86:
>
>> Hi,
>> Please, anybody tell me what are applications of parity flag .
>>
>> Thank you
>
>As Randall Hyde points out, the 8086 and all its descendents has a
>parity flag mostly because the Intel 8-bit 8088 had one, and Intel
>wanted to make sure that 8088 code could be easily ported to the new
>16-bit processor.

I think you want to change 8088 to 8080, twice. :-)

Both the 8086 and 8088 were 16-bitters, internally.

Charles A. Crayne

unread,
Oct 22, 2004, 1:31:41 AM10/22/04
to
On Fri, 22 Oct 2004 04:53:42 +0000 (UTC)
spam...@crayne.org wrote:

:I think you want to change 8088 to 8080, twice. :-)

That is correct, albeit incomplete. My first personal computer, which used
an 8008, also had a parity flag, and was almost certainly the first Intel
processor to do so.

-- Chuck

0 new messages