- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8085 program to find 2's complement of the contents of Flag Register
In this program we will see how to find 2's complement of the content of flag register.
Problem Statement
Write 8085 Assembly language program to find 2's complement of the content of flag register.
Discussion
We cannot access the total flag register directly. To use them we have to push the PSW(Accumulator-Flag) into stack, and then pop it to another register pair, then after complementing the LS byte of that register pair, we have to push it again into the stack, and then pop it to PSW to get it into Flag bits.
Input
Here we are not putting any input directly. If the flag bits are (0100 0001), then the program will generate the complement of it.
Flow Diagram
Program
Address | HEX Codes | Mnemonics | Comments |
---|---|---|---|
F000 | 31, 00, 90 | LXI SP,9000H | Initialize the stack pointer |
F003 | F5 | PUSH PSW | Push A and F content to Stack |
F004 | C1 | POP B | Pop from stack and store to BC |
F005 | 79 | MOV A,C | Take the number from C to A |
F006 | 2F | CMA | Complement the accumulator |
F007 | 4F | MOV C,A | Store A to C |
F008 | 0C | INR C | Increase C by1 to get 2's complement |
F009 | C5 | PUSH B | Push BC into stack |
F00A | F1 | POP PSW | Pop stack content to A and F |
F00B | 76 | HLT | Terminate the program |
Output
After executing the program, the flag content will be (1011 1111)
- Related Articles
- 8085 program to access and exchange the content of Flag register with register B
- 8085 program to count the number of ones in contents of register B
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1's and 2's complement of 16-bit number
- Instructions to complement/set Cy flag in 8085 Microprocessor
- Flag register of 8086 microprocessor
- 8085 program to exchange content of HL register pair with DE register pair
- 8085 Program to add the contents of N word locations
- Swift Program to find the 1's complement of the given number
- Haskell Program to find the 1's complement of the given number
- Register codes of 8085 Microprocessor
- 1's Complement vs 2's Complement
- Program to add the contents of N word locations in 8085 Microprocessor
- Draw a Turing machine to find 2’s complement of a binary number
- 1’s and 2’s complement of a Binary Number?

Advertisements