Sunday 2 July 2023

8051 Flag Bits and PSW Register

What is Flag bits and the PSW register?

The 8051 has a flag register to indicate or specify arithmetic conditions or order such as the carry bit. The flag record or register in the 8051 is called the program status word (PSW) register. In this section we discuss or talk about various bits of this register or record and provide some examples of how it is altered.

PSW register, Program Status Word, 8051 pins
Program Status word Image-1

PSW(Program Status Word) register

It is also mention or referred to as the flag register. Although the 8 bits of PSW register or record wide, used by the 8051 of only 6 bits. The two unused bits are exact flags or user-definable. Four of the flags are called depending or conditional flags, meaning that they indicate or specify some depending or conditions that result after an instruction or command are executed. These four are

1.       CY (carry),

2.       P (parity),

3.       AC (auxiliary carry),

4.        and OV (overflow).

CY, the carry flag

This flag is set whenever or anytime there is a carry out from the D7 bit. This flag bit is affected or high-flown after an 8-bit addition or subtraction. It can also be set to 1 or 0 straight or directly by an instruction or command such as “CLR C” and where “SETB C” it is “SETB C” means for “set bit carry” and “CLR C” means for “clear carry”. More about these and other bit-addressable.

AC, the auxiliary carry flag

If there is a move or carry from D3 to D4 during an ADD or SUB working or operation, this bit is set; otherwise, it is remove or cleared. This flag is used by command that perform BCD (binary coded decimal) arithmetic.

P, the parity flag

The parity flag reflects or give back the number of 1s in the A (accumulator) register only. If the A register contains or carry an odd number of 1s, then P=1. Where as P=0 if A has an even number of 1s.

OV, the overflow flag

In general or wide, the carry flag is used to detect or find errors in unsigned arithmetic operations or working. The overflow flag is only used to detect or find errors in signed arithmetic operations.


Computer stuff kit tricks of Topics 71.