Lecture 14-Software Architecture -Flag Register

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

● SUBJECT : MICROPROCESSOR & INTERFACES

● BRANCH : CSE

● SUBJECT CODE: 4CS3-04

● CREDITS : 3

● IA: 30 MARKS

● ETE : 120 MARKS

● LECTURE : 14

● TOPIC : SOFTWARE ARCHITECTURE-FLAG REGISTER

● FACULTY NAME : DEEPAK SHARMA


● SUBJECT : MICROPROCESSOR & INTERFACE

● BRANCH : CSE

● SUBJECT CODE: 4CS3-04

● CREDITS : 3

● IA: 30 MARKS

● ETE : 120 MARKS

● UNIT : 2

● LECTURE : 14

● TOPIC : SOFTWARE ARCHITECTURE-FLAG REGISTER

● FACULTY NAME : DEEPAK SHARMA


UNIT 2
LECTURE 14

FLAGS :

• As we know that in 8085, mostly ALU Operations output stored in Accumulator. But sometime we want

the status of operation after being executed that is condition of Output

• For Example: Let a student give exam and result declared . Now student does not emphasize on the

scores of subject . It emphasize on the status that is Pass or Fail .

• So we can say that in 8085 we also have some status/condition of Output related to basic ALU

Operation which is indicated by Flag Register or Status Register .

• It is made up of combination of Flip Flops .

• Normally there are 5 Flags in Status Register out of 8 Bits.

• 3 Bits are normally don’t defined . They considered as 0


UNIT 2
LECTURE 14

• These flags have critical importance in the decision-making process of the microprocessor.
• The conditions (set or reset) of the flags are tested through the software instructions. That’s why
it is considered in Software Architecture. User can also access this Flag Register by writing
Instruction for Carry Flag.

• For example, the instruction JC (Jump on Carry) is implemented to change the sequence of a
program when CY flag is set. The thorough understanding of flag is essential in writing assembly
language programs.

They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags.
UNIT 2
LECTURE 14

• It is part of ALU

• The ALU includes five flip-flops, which are set or reset after an operation according to data

conditions of the result in the accumulator and other registers.

• They are called Zero(Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; their bit

positions in the flag register are shown in the Figure below.

• The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags

to test data conditions.


UNIT 2
LECTURE 14

Note: X represent unspecified bits termed as "don't care".


1. Carry flag(CY):
• It is Flip which can be SET or RESET by Instruction
• Store 1 Bit
• Indicate Condition of Output
• Used in Comparison of two numbers , Branching Instruction etc .
• Get affected by ALU Operation Result.
• Also modified by User through Instructions.
• If an operation performed in ALU generates the carry from D7 to next stage then CY flag is set, else it is reset.

MVI A 30 (load 30H in register A)


MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the carry flag to 1 as 30 – 40 generates a carry/borrow.
UNIT 2
LECTURE 14

Auxiliary carry(AC):
• It is Flip which can be SET or RESET by ALU operation
• Store 1 Bit
• Indicate Condition of Output
• The Auxiliary Carry (AC) flag is used only for BCD operations where it represents the presence or
absence of carry from the 4th bit to 5th bit .
• Get affected by ALU Operation Result.
• If an operation performed in ALU generates the carry from lower nibble (D0 to D3) to upper nibble (D4
to D7) AC flag is set, else it resets. Or if during Execution of Operation, if Carry generated on D3 Bit
and transfer to D4 Bit than AC Flag Set.

• MVI A 2B (Load 2BH in register A)


MVI B 39 (Load 39H in register B)
ADD B (A = A + B)
UNIT 2
LECTURE 14

Zero flag(z):
It is Flip which can be SET or RESET by ALU operation
Store 1 Bit
Indicate Condition of Output
Used in Searching a Number, as Counter etc .
UNIT 2
LECTURE 14

• Get affected by ALU Operation Result.


• If an operation performed in ALU results 0 value of entire 8-bits then zero flag is set, else it
resets.
• Note: This is only Single Flag which get affected if ALU Operation affect any Register means if
any General Purpose Register or Accumulator get Zero after ALU Operation. While other Flags
only affected with respect to Accumulator.
UNIT 2
LECTURE 14

Sign flag(s):
• It is Flip which can be SET or RESET by ALU operation
• Store 1 Bit
• Indicate Condition of Output
• Used in defining the status of Signed Number Operation etc .
• Get affected by ALU Operation Result.
• If after ALU Operation of Signed Number & MSB bit =0 then the number is positive, else it is
negative.

UNIT 2
LECTURE 14

Parity flag(p):

• It is Flip which can be SET or RESET by ALU operation

• Store 1 Bit

• Indicate Condition of Output

• Used in Error Detection etc .

• Get affected by ALU Operation Result.

• If the ALU result contains even no. of ones this flag is set and for odd no. of ones this flag is

reset.

You might also like