Flags Register
Flags Register
Main registers | ||||||||||||||||
A | Flags | AF (accumulator and flags) | ||||||||||||||
B | C | BC | ||||||||||||||
D | E | DE | ||||||||||||||
H | L | HL (indirect address) | ||||||||||||||
Index registers | ||||||||||||||||
SP | Stack Pointer | |||||||||||||||
Program counter | ||||||||||||||||
PC | Program Counter | |||||||||||||||
Status register | ||||||||||||||||
S | Z | I | H | - | P | - | C | Flags |
The ALU influences a number of flip flops called flags which store information related to the results of arithmetic and logical operations. Taken together this flags constitute a flag register. The Flag register is a Special Purpose Register and is completely different from the other registers in a microprocessor. Flag register is an 8-bit register accessible to the user through instruction. Each bit in the flag register has a specific function. The other 3 are left vacant and are in the future Intel versions. Therefore, 8085 has five flags - Sign flag, Zero flag, Auxiliary carry flag, Parity flag and the Carry flag. Only 5 bits out of 8 bits are used as shown below:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
S | Z | X | AC | X | P | X | CY |
The three crossed bit are redundant bits and not used. They can be either ‘0’ or ‘1’ but normally they are forced to be zero. The other five bits are affected as a result of execution of an instruction. All instructions do not affect these flags e.g. data transfer operation do not affect these flags. The meaning and the effect of these flags are as follows.
- CY (Carry) Flag Bit:
One Byte Number | |||
Upper Nibble | Lower Nibble | ||
1 Carry | |||
Add + | 1000 | 1010 | |
1101 | 1100 | ||
Sum | 1 | 0110 | 0110 |
- P (Parity) Flag Bit:
- AC (Auxiliary Carry) Flag Bit:
It occupies the 4th bit of the flag register. This bit is set if there is a carry from 3rd bit to 4th bit of accumulator during addition operation otherwise it is reset. The AC flag is useful for BCD arithmetic and is used in a particular instruction known as DAA (Decimal Adjust Accumulator).
One Byte Number | ||
Upper Nibble | Lower Nibble | |
1 Auxiliary Carry | ||
Add + | 1000 | 1010 |
0101 | 1100 | |
Sum | 1110 | 0110 |
- Z (Zero) Flag Bit:
Zero flag occupies the 6th bit of the flag register. Zero flag bit is SET if the result of an operation is zero, otherwise it is RESET.
- Sign Flag Bit:
Sign flag occupies the 7th bit of the flag register which is also known as the Most Significant Bit (MSB). It helps the programmer to know whether the number stored in the accumulator is positive or negative. A set '1' (binary number) sign flag represents a negative number, where as a reset '0' (binary number) flag means a positive number.
REFERENCES
- R. S. Gaonkar, Microprocessor Architecture, Programming, and Applications with the 8085, Fifth Edition, Penram International Publishing (India) Private Limited.
- S Ghoshal, Microprocessor Based System Design, Macmillan India Limited, 1996.
- M. Mano, Digital Logic and Computer Design, Prentice – Hall India.
- B. Ram - Fundamentals of Microprocessor and Microcontrollers.
- “Microprocessors: Principles and Applications” by A Pal.
- “Microprocessors and Microcontrollers : Architecture, Programming and Interfacing Using 8085, 8086 and 8051” by Soumitra Kumar Mandal.
- “Introduction to Microprocessors and Microcontrollers” by Crisp John Crisp.
- “Microprocessors And Microcontrollers” by A Nagoor Kani.
- “Microprocessors And Microcontrollers : Architecture, Programming and System Design 8085, 8086, 8051, 8096” by Krishna Kant.
- “8 - Bit Microprocessor” by Vibhute
Comments
Post a Comment