- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 transfer a block in reverse order
Here we will see how we transfer a block of data in reverse order using 8085.
Problem Statement
Write 8085 program to transfer a block of N-bytes in reverse order. The block is stored at location 8001 onwards, the size of the block is stored at 8000. The block will be moved at location 9000 onwards.
Discussion
To solve this problem, we are taking the size of the block at first. The DE register pair is set to point at destination address 9000H. The HL pair is set to point to the last element of the block. If the block size is 0A, then the last block will be at 800A. At first HL is pointing to 8000, and took the block size from there and store to C. Now add C with the L register to get the last block address. Now take each element from memory pointed by HL, and store it back to the memory pointed by the DE. Then increase the DE, and decrease the HL. Thus the entire block will be moved in reverse direction.
Input
Address | Data |
---|---|
… | … |
8000 | 0A |
8001 | 11 |
8002 | 22 |
8003 | 33 |
8004 | 44 |
8005 | 55 |
8006 | 66 |
8007 | 77 |
8008 | 88 |
8009 | 99 |
800A | AA |
… | … |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 00, 80 | | LXI H,8000 | Point to 8000 to get block size |
F003 | 4E | | MOV C,M | Take the block size into C |
F004 | 11, 00 90 | | LXI D,9000 | Point to the destination address |
F007 | 7D | | MOV A,L | Load L into A |
F008 | 81 | | ADD C | Add C to point to last address of block |
F009 | 6F | | MOV L,A | Store A to L again |
F00A | 7E | LOOP | MOV A,M | Load memory to A |
F00B | 12 | | STAX D | Store A into destination pointed by DE |
F00C | 13 | | INX D | Point destination to next address |
F00D | 2B | | DCX H | Point source to previous address |
F00E | 0D | | DCR C | Decrease C by 1 |
F00F | C2, 0A, F0 | | JNZ LOOP | if Z is not set jump to LOOP |
F012 | 76 | | HLT | Terminate the program |
Output
Address | Data |
---|---|
… | … |
9000 | AA |
9001 | 99 |
9002 | 88 |
9003 | 77 |
9004 | 66 |
9005 | 55 |
9006 | 44 |
9007 | 33 |
9008 | 22 |
9009 | 11 |
… | … |
- Related Articles
- 8085 program to exchange a block of bytes in memory
- 8085 program to reverse 8 bit number
- 8085 program to reverse 16 bit number
- 8086 program to transfer a block of bytes by using string instruction
- C# Program to display a string in reverse alphabetic order
- C++ program to concatenate strings in reverse order
- 8086 program to transfer a block of 4 bytes by using string instructions
- Data transfer schemes in 8085
- 8085 Program to perform selection sort in ascending order
- 8085 Program to perform selection sort in descending order
- 8085 Program to perform bubble sort in ascending order
- 8085 Program to perform bubble sort in descending order
- Status check data transfer in 8085
- Interrupt-driven data transfer in 8085
- Program to perform bubble sort in ascending order in 8085 Microprocessor
