Program Status Register PSW of 8051

Program Status Register PSW of 8051
Program Status Register PSW of 8051
The 8051 has a 8-bit PSW register which is alsoknown as Flag register.In the 8-bit register only 6-bits are used by 8051.The two unused bits are user definable bits.In the 6-bits four of them are conditional flags .They are Carry –CY,Auxiliary Carry-AC, Parity-P,and Overflow-OV .These flag bits indicate some conditions that resulted after an instruction was executed.


The bits PSW3 and  PSW4  are  denoted as RS0 and RS1 and these bits are used th select the bank registers of the RAM location. The meaning of various bits of PSW register is shown below.
CY                              PSW.7                       Carry Flag
AC                              PSW.6                       Auxiliary Carry Flag
FO                              PSW.5                        Flag 0 available for general purpose .
RS1                            PSW.4                        Register Bank select bit 1
RS0                            PSW.3                        Register bank select bit 0
OV                             PSW.2                        Overflow flag
---                               PSW.1                        User difinable flag

P                                 PSW.0                       Parity flag .set/cleared by hardware.




The following is a brief explanation of four of the flag bits of the PSW register. The impact of instructions on these registers is then discussed.how the bits of PSW are change after arithmetic & logical operation?


CY, the carry flag
  • This flag is set whenever there is a carry out from the D7 bit. 
  • This flag bit is affected after an 8-bit addition or subtraction. 
  • It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C”where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”.
AC, the auxiliary carry flag
  • If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared. 
  • This flag is used by instructions that perform BCD (binary coded decimal) arithmetic. 
P, the parity flag
  • The parity flag reflects the number of 1 s in the A (accumulator) register only. 
  • If the A register contains an odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of 1s.
OV, the 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. 
  • In general, the carry flag is used to detect errors in unsigned arithmetic operations. 
  • The overflow flag is only used to detect errors in signed arithmetic operations

Comments

Popular posts from this blog

Clock circuit of 8051 Microcontroller Family

8051 reset circuit.