- 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
Exchange of blocks in Z-80
In this section we will see how we can use the Zilog Z-80 Microprocessor to Exchange the contents of each element from two different blocks.
The number of items in each block are given at location 5000H, and the blocks are at position 5050H and 5070H.
So before swapping the items in the memory is looking like this
Address | Value |
---|---|
5000H | 04H |
. . . | |
5050H | 89H |
5051H | 7AH |
5052H | 2FH |
5053H | 56H |
. . . | |
5070H | AFH |
5071H | A9H |
5072H | FBH |
5073H | 21H |
. . . |
Now, we are writing a program at location 8000H to exchange the block contents.
Program
Address | Hex Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
8000 | 21 00 50 | LD HL, 5000H | Load the HL pair with 5000H | |
8003 | DD 21 50 50 | LD IX, 5050H | Set the index register with 5050H | |
8007 | DD 7E 00 | LD A, (IX+00H) | Load Acc with IX + 00H | |
800A | DD 46 20 | LD B, (IX+20H) | Load B with IX + 20H | |
800D | DD 70 00 | LOOP | LD (IX+00H), B | Load B register content at IX + 00H |
8010 | DD 77 20 | LD (IX+20H), A | Load Acc content at IX + 20H | |
8013 | DD 23 | INC IX | Increase the IX register | |
8015 | 35 | DEC (HL) | Decrease the memory content, pointer by HL pair | |
8016 | C2 07 80 | JP NZ, LOOP | Jump to Loop, when zero flag is off | |
8019 | 76 | HALT | Stop the program |
Output
Address | Value |
---|---|
5000H | 04H |
. . . | |
5050H | AFH |
5051H | A9H |
5052H | FBH |
5053H | 21H |
. . . | |
5070H | 89H |
5071H | 7AH |
5072H | 2FH |
5073H | 56H |
. . . |
Advertisements