標志寄存器
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.
在8085微處理器中編寫匯編語言程序以訪問標志寄存器,并與寄存器B交換標志寄存器F的內容。
Assumptions: Initial values of flag register, register B and stack pointer are 00, 3F, and 3FFF respectively.
假設:標志寄存器,寄存器B和堆棧指針的初始值分別為00、3F和3FFF。
PSW stands for PROGRAM STATUS WORD. PSW combines accumulator A and flag register F.
PSW代表程序狀態字。 PSW將累加器A和標志寄存器F組合在一起。
Algorithm:
算法:
Push the value of PSW in memory stack by help of PUSH instruction
通過PUSH指令將PSW的值壓入存儲器堆棧
Pop the value of Flag register and store it in register H by help of POP instruction
彈出標志寄存器的值,并借助POP指令將其存儲在寄存器H中
Move the value of register H in register C
將寄存器H的值移到寄存器C中
Move the value of register B in register H
將寄存器B的值移到寄存器H中
Move the value of register C in register B
將寄存器C的值移到寄存器B中
Push the value of register H in memory stack by help of PUSH instruction
通過PUSH指令將寄存器H的值壓入存儲器堆棧
Pop the value of PSW from memory stack using POP instruction
使用POP指令從存儲器堆棧中彈出PSW的值
Program:
程序:
ADDRESS | MNEMONICS | COMMENTS |
2000 | PUSH PSW | Push value of accumulator and flag in stack |
2001 | POP H | Pop value from TOP of memory stack in H |
2002 | MOV C, H | C ← H |
2003 | MOV H, B | H ← B |
2004 | MOV B, C | B ← C |
2005 | PUSH H | Push the value of register H |
2006 | POP PSW | Pop value of flag register and Accumulator |
2007 | HLT | END |
地址 | 記憶 | 注釋 |
2000 | 推PSW | 將累加器的值和標志壓入堆棧 |
2001 | POP H | 從H中的內存堆棧的TOP彈出值 |
2002年 | MOV C,H | C←H |
2003年 | MOV H,B | H←B |
2004年 | MOV B,C | B←C |
2005年 | 推H | 推送寄存器H的值 |
2006年 | POP PSW | 標志寄存器和累加器的彈出值 |
2007年 | HLT | 結束 |
Explanation – Registers used A, B, C, H, F
說明–使用的寄存器A,B,C,H,F
PUSH PSW instruction performs the following task:
PUSH PSW指令執行以下任務:
- SP ← SP - 1
- M[SP] ← A
- SP ← SP - 1
- M[SP] ← F
POP H instruction performs the following task:
POP H指令執行以下任務:
- H ← M[SP]
- SP ← SP + 1
MOV C, H – moves the value of H in register C
MOV C,H –將H的值移動到寄存器C中
MOV H, B – moves the value of B in register H, hence H is updated
MOV H,B –移動寄存器H中B的值,因此H被更新
MOV B, C – moves the value of C in register B, hence B is updated
MOV B,C –移動寄存器B中C的值,因此B被更新
PUSH H performs the following task:
PUSH H執行以下任務:
- SP ← SP - 1
- M[SP] ← H
POP PSW performs the following task:
POP PSW執行以下任務:
- F ← M[SP]
- SP ← SP + 1
- A ← M[SP]
- SP ← SP + 1
HLT – stops executing the program and halts any further execution
HLT –停止執行程序,并停止任何進一步的執行
翻譯自: https://www.includehelp.com/embedded-system/access-flag-register-and-exchange-the-content-of-flag-register-f-with-register-b-using-8085-microprocessor.aspx
標志寄存器