- Flags are single bit register and used to store the result of certain function after executing instruction. Flags are grouped inside PSW and PCON registers.
- PSW register in 8051 microcontroller contains math flags and PCON contains general user flags.
- Math flags are grouped in PSW of microcontroller 8051 and they are Carry(C), Auxiliary Carry (AC), Over flow (OV), and Parity (P). The general user flags are GF0 and GF1 which are grouped in PCON register.
PSW Register in 8051
- The PSW is accessible fully as an 8-bit register, with the address D0H.
- The bit pattern of this flag register is
Parity bit (P)
- This parity flag bit is used to show the number of 1s in the accumulator only. If the accumulator register contains an odd number of 1s, then this flag set to 1.
- If accumulator contains even number of 1s, then this flag cleared to 0.
Overflow flag (OV)
- This flag is set during ALU operations, to indicate overflow in the result. It is set to 1 if there is a carry out of either the D7 bit or the D6 bit of the accumulator.
- Overflow flag is set when arithmetic operations such as add and subtract result in sign conflict.
- The conditions under which the OV flag is set are as follows:
- Positive + Positive = Negative
- Negative + Negative = Positive
- Positive – Negative = Negative
- Negative – Positive = Positive
- The conditions under which the OV flag is set are as follows:
Register bank select bits (RS1 and RS0)
- These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM as follows.
RS1 | RS0 | Bank Selected | Address of Registers |
0 | 0 | Bank 0 | 00h-07h |
0 | 1 | Bank 1 | 08h-0Fh |
1 | 0 | Bank 2 | 10h-17h |
1 | 1 | Bank 3 | 18h-1Fh |
- These bits are user-programmable. They can be set by the programmer to point to the correct register banks.
- The register bank selection in the programs can be changed using these two bits.
General-purpose flag (F0)
- This is a user-programmable flag; the user can program and store any bit of his/her choice in this flag, using the bit address.
Auxiliary carry flag (AC)
- It is used in association with BCD arithmetic. This flag is set when there is a carry out of the D3 bit of the accumulator.
Carry flag (CY)
- This flag is used to indicate the carry generated after arithmetic operations. It can also be used as an accumulator, to store one of the data bits for bit-related Boolean instructions.
- The 8051 supports bit manipulation instructions.
- This means that in addition to the byte operations, bit operations can also be done using bit data.
- For this purpose, the contents of the PSW are bit-addressable.
Recent posts
Related posts:
- Assembler Directives in 8051 Microcontroller
- Features of 8051 Microcontroller
- Memory Organization of 8051 Microcontroller
- Addressing Modes in 8051 Microcontroller
- Instruction Set in 8051 Microcontroller
- Architecture of 8051 Microcontroller
- Pin Configuration of 8051 Microcontroller
- The Stack and Stack Pointer in 8051 Microcontroller
- Stack Pointer Data Pointer and Program Counter in 8051 Microcontroller
- Functions of Timing and Control Unit of 8051
- Functions of Ports in 8051 Microcontroller
- Port Structure of 8051 Microcontroller
- Reset Circuit of 8051 Microcontroller
- Registers in 8051 Microcontroller
- Boolean Processor in 8051 Microcontroller
- Power Saving Mode in 8051 | 8051 Power Down and Idle Mode
- 8051 Microcontroller Family
- Program Development Steps in ALP
Great information. Lucky me I recently found your blog by accident (stumbleupon). I have book-marked it for later!
I have read a few good stuff here. Definitely price bookmarking for revisiting. I wonder how much attempt you put to make this type of wonderful informative web site.