- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 access and exchange the content of Flag register with register B
In this program we will see how to exchange the content of Flat register with register B.
Write 8085 Assembly language program to swap the content of flag register and the register B.
As we cannot access the flag register content directly, we have to take the help of stack. By using stack, we can push the content of PSW (Accumulator and Flag). Then we can get it back and store into some other registers. Similarly, from other register, we have to push them into stack, then pop it to PSW.
Here if we want to exchange the value of B and F, then at first we have to make a copy of B to C. When we will push the PSW into stack, then pop to BC, the Acc content will be loaded to B, and Flag register content will be loaded to C.
Here we are not providing any additional inputs. We are directly storing a value to B, then swapping it to flag register. In the program the B is containing 45H, after executing the program, 45H will be loaded to Flag register.
|F000||31, 00, 90||LXI SP,9000||Initialize stack pointer|
|F003||06, 45||MVI B,45H||Load B with 45H|
|F005||48||MOV C,B||Save B into C|
|F006||F5||PUSH PSW||Store AF into stack|
|F007||C5||PUSH B||Store BC into stack|
|F008||F1||POP PSW||Pop and store to AF|
|F009||C1||POP B||Pop and store to BC|
|F00A||41||MOV B, C||Move C to B|
|F00B||76||HLT||Terminate the program|
Flag register will be loaded with 45H.
- 8085 program to exchange content of HL register pair with DE register pair
- Flag register of 8086 microprocessor
- 8085 program to find 2's complement of the contents of Flag Register
- 8085 program to count the number of ones in contents of register B
- Register codes of 8085 Microprocessor
- Flags register in 8085 Microprocessor
- Register addressing mode in 8085 Microprocessor
- Instruction register (IR) in 8085 Microprocessor
- Temporary (temp) register in 8085 Microprocessor
- Accumulator or Register A in 8085 Microprocessor
- Register indirect addressing mode in 8085 Microprocessor
- Control register of 8257
- Status register of 8257
- Difference Between Register and Memory
- 8085 Program to Exchange 10 bytes