0

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 ?

whyyoucare
  • 29
  • 2
  • 6
  • 2
    What microprocessor or microcontoller are you using? Assembly language details like this may vary widely between different processor families. – Peter Bennett Apr 12 '17 at 21:35
  • 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... – old_timer Apr 13 '17 at 03:59
  • @old_timer it is 8051 – whyyoucare Apr 13 '17 at 14:26
  • 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. – old_timer Apr 13 '17 at 14:28

1 Answers1

1

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\$

Trevor_G
  • 46,364
  • 8
  • 68
  • 151