Composition of the original
The PSW of 51 single-chip microcomputer is an 8-bit register, which is used to store some status after the instruction is executed. It is usually filled in by the CPU, but the user can also change the status bits Value. The definition of each flag bit is as follows:
Bit7 Cy
Bit6 AC
Bit5 F0
Bit4 RS1
Bit3 RS0
Bit2 OV
Bit1 -
Bit0 P
Main content
1 . CY(Carry):
CY means carry in addition operation and borrow in subtraction operation. If there is carry in addition operation or borrow in subtraction operation, CY is set to 1, otherwise Is 0.
2. AC (Auxiliary Carry):
Basically the same as CY, the difference is that AC represents the progression from the lower 4 bits to the higher 4 bits. , Borrow.
3.F0:
This bit is a flag bit managed by the user, and the user can set it according to his needs.
4. RS1, RS0:
These two bits are used to select the current working register area. 8051 has 8 8-bit registers R0~R7, their addresses in RAM can be determined according to user needs.
RS1 RS0: Address of R0~R7
0 0: 00H~07H
0 1: 08H~0FH
1 0 : 10H~17H
1 1: 18H~1FH
5.OV:
This bit indicates whether the operation has overflowed . If the result of the operation exceeds the range that can be represented by an 8-bit signed number, that is, -128 ~ +127, then OV = 1.
6.P:
P is the parity flag. If the number of 1s in the accumulator A is odd, then P = 1; if the number of 1s in the accumulator A is even, then P = 0.