0
\$\begingroup\$

I am a beginner in assembler language I was reading some stuff online(belongs to a university) and I saw that the P bit in psw after executing this instruction mov a,#03h A=0000 0011B so P=0 first it was difficult to know what is p bit after some research I thought it is parity bit and then you have to count the number of one bits in the result so the number of 1 bit in the result is 2 so it is an even number so P must be equal to one so why is P equal to zero here ?

| improve this question | | | | |
\$\endgroup\$
  • 2
    \$\begingroup\$ What microprocessor or microcontoller are you using? Assembly language details like this may vary widely between different processor families. \$\endgroup\$ – Peter Bennett Apr 12 '17 at 21:35
  • \$\begingroup\$ it could be a Positive flag, the opposite of an N flag which is a negative bit/flag. Without knowing what processor this is we cant really help... \$\endgroup\$ – old_timer Apr 13 '17 at 3:59
  • \$\begingroup\$ @old_timer it is 8051 \$\endgroup\$ – whyyoucare Apr 13 '17 at 14:26
  • \$\begingroup\$ Wikipedia showed the answer: PSW.0: P Parity. Gives the parity (modulo-2 sum of the bits of) the accumulator, A. Positive or negative parity is a simple test as Trevor shows in his answer. \$\endgroup\$ – old_timer Apr 13 '17 at 14:28
1
\$\begingroup\$

It's probably an even parity bit.

The count of all the bits that are ones PLUS the parity bit should be an even number.

Examples:

\$0 0 0 0 0 0 1 1\$ \$Parity = 0\$, \$\Sigma= 2 + 0 = 2\$

\$0 0 0 0 0 0 0 1\$ \$Parity = 1\$, \$\Sigma= 1 + 1 = 2\$

\$0 0 1 0 1 0 1 1\$ \$Parity = 0\$, \$\Sigma= 4 + 0 = 4\$

\$0 1 1 0 0 1 1 1\$ \$Parity = 1\$, \$\Sigma= 5 + 1 = 6\$

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ How do you know if the parity is zero or one \$\endgroup\$ – whyyoucare Apr 13 '17 at 14:30
  • 1
    \$\begingroup\$ @whyyoucare read the second line. \$\endgroup\$ – Trevor_G Apr 13 '17 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.