0
93kviews
Explain program status register of 8051 microcontroller?
1 Answer
9
7.2kviews

The program status word (PSW) register is an 8-bit register, it is also referred to as the flag register the PSW register is 8-bit wide only 6-bit of it are used by the 8051, the two unused bits are user definable flags, four of the flags are called conditional flags, meaning that they indicate some conditions that results after an instruction is executed, these four are CY(carry), AC(auxiliary carry), P(parity) and OV(overflow) the bits PSW.3 and PSW.4 are designated as RS0 and RS1 register selection bit and are used to change the bank register.

enter image description here

RS 1 RS 0 Register Bank
1 0 Register bank 0
0 1 Register bank 1
1 0 Register bank 2
1 1 Register bank 3

CY (carry flag):

  • This flag is set whenever there is a carry out from the D.7 bit
  • This flag bit is affected after 8 bit addition or subtraction
  • It can also be set to 1 or 0 directly by an instruction such as " SET BC" and "CLRC"

AC(Auxiliary flag):

  • If there is a carry from D3 to D4 during ADD or SUB operation this bit is set otherwise it is cleared
  • This flag is used by instruction that perform BCD (binary coded decimal) arithmetic

P (parity flag):

  • The parity flag reflect the number of 1's in the A (accumulator) register only
  • if the A register contains an odd number of 1's then p=1 therefore p=0 if A has an even number 1's.

OV (overflow flag):

  • This flag is set whenever the result of a signed number operation is too large causing the high order bit to overflow into the sign bit
  • the carry flag is used to detect error in unsigned arithmetic operations
  • the overflow flag is only used to detect error in signed arithmetic operations.
Please log in to add an answer.