Home » Embedded Systems

Access Flag register and exchange the content of flag register F with register B | 8085 Microprocessor

Here, we are going to learn how to access Flag register and exchange the content of flag register F with register B | 8085 Microprocessor?
Submitted by Ayush Sharma, on October 29, 2018

Problem statement:

Write an assembly language program in 8085 microprocessor to access Flag register and exchange the content of flag register F with register B.

Assumptions: Initial values of flag register, register B and stack pointer are 00, 3F, and 3FFF respectively.

PSW stands for PROGRAM STATUS WORD. PSW combines accumulator A and flag register F.

Algorithm:

  1. Push the value of PSW in memory stack by help of PUSH instruction
  2. Pop the value of Flag register and store it in register H by help of POP instruction
  3. Move the value of register H in register C
  4. Move the value of register B in register H
  5. Move the value of register C in register B
  6. Push the value of register H in memory stack by help of PUSH instruction
  7. Pop the value of PSW from memory stack using POP instruction

Program:

ADDRESSMNEMONICSCOMMENTS
2000PUSH PSWPush value of accumulator and flag in stack
2001POP HPop value from TOP of memory stack in H
2002MOV C, HC ← H
2003MOV H, BH ← B
2004MOV B, CB ← C
2005PUSH HPush the value of register H
2006POP PSWPop value of flag register and Accumulator
2007HLTEND

Explanation – Registers used A, B, C, H, F

  1. PUSH PSW instruction performs the following task:
    • SP ← SP - 1
    • M[SP] ← A
    • SP ← SP - 1
    • M[SP] ← F
  2. POP H instruction performs the following task:
    • H ← M[SP]
    • SP ← SP + 1
  3. MOV C, H – moves the value of H in register C
  4. MOV H, B – moves the value of B in register H, hence H is updated
  5. MOV B, C – moves the value of C in register B, hence B is updated
  6. PUSH H performs the following task:
    • SP ← SP - 1
    • M[SP] ← H
  7. POP PSW performs the following task:
    • F ← M[SP]
    • SP ← SP + 1
    • A ← M[SP]
    • SP ← SP + 1
  8. HLT – stops executing the program and halts any further execution





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.