Page 177 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 177
Unit 12: The Stacks
12.4.3 Modify Flag Content using PUSH/POP Notes
• Let, We want to Reset the Zero Flag
• 8085 Flag :
• Program:
• LXI SP FFFF
• PUSH PSW
• POP H
• MOV A L
• ANI BFH (BFH= 1011 1111) * Masking
• MOV L A
• PUSH H
• POP PSW
Give the basic concept of stack implementation.
Example: Write a program to clear all the flags and load OOH in the accumulator (A) and-
demonstrate that the zero flag is not affected by the data transfer instruction.
Solution: In this problem we have to examine the zero flag after instructions have been executed.
There is no direct method of observing these flags and so they are stored on the stack using the
PUSH PSW. The contents of the flag register can be retrieved in any one of the registers by using
the instruction POP, and the flags can be displayed at an output port. The assembly language
program for thee above stated problem is as follows:
Machine Opcode Operands Comments
Code (Hex.)
31 LXI SP, XX99H ; Initialize the stack
99
XX
2E MVI L, OOH ; Clear L
00
E5 PUSH H ; Place (L) on stack
Fl POP PSW ; Clear flags
3E MVI A, OOH ; Load OOH
00
F5 PUSH PSW ; Save flags on stack
El POP H ; Retrieve flags in L
7D MOV A, L
D3 OUT PORT 0 ; Display flags
LOVELY PROFESSIONAL UNIVERSITY 171