8085 Block movement with overlap


In this program, we will see how to move blocks of data from one place to another.

Problem Statement

Write 8085 Assembly language program to move a data block. The blocks are assumed to be overlapping. The block size is given, the block is starting from Xand we have to move it to the location Y.

Discussion

The overlapping block movement is tricky; we need to use some special tricks to move a block in overlapping address locations. Here the block is starting at position X, we have to move it to position Y. The location Y is inside the block. So Y < X + block size.

In this program, the data are stored at location 8010H, and we will place it 8014H. The block size is stored at location 8000H.

To move a block into some overlapping locations, we will start from the end element of the block. So at first the last element of the block is moved, then the previous bytes are moved.  

Input

Address
Data
.
.
.
.
.
.
8000
07
.
.
.
.
.
.
8010
11
8011
22
8012
33
8013
44
8014
55
8015
66
8016
77
.
.
.
.
.
.

Flow Diagram

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
21, 00, 80


LXI H, 8000H
Load the location to find block size
F003
4E


MOV C, M
store block size into C register
F004
06, 00


MVI B,00H
clear B register
F006
21,10, 80


LXI H,8010H
load the source address to HL pair
F009
11, 14, 80


LXI D, 8014H
load the destination address to DE pair
F00C
09


DAD B
Add BC with HL to point next location of the end of the source block
F00D
2B


DCX H
Point last element
F00E
EB


XCHG
Swap DE and HL pair content
F00F
09


DAD B
Add BC with HL to point next location of the end of dest block
F010
2B


DCX H
Point last element
F011
EB


XCH G
Swap DE and HL pair content
F012
7E
LOOP
MOV A, M
Load Acc with the memory element
F013
12


STAX D
Store acc content to the memory pointed by D
F014
1B


DCX D
Decrease DE register pair
F015
2B


DCX H
Decrease HL register pair
F016
0D


DCR C
Decrease C register
F017
C2, 12, F0


JNZ LOOP
Jump to Loop
F01A
76


HLT
Terminate the program


Output:

Address
Data
.
.
.
.
.
.
8000
07
.
.
.
.
.
.
8010
11
8011
22
8012
33
8013
44
8014
11
8015
22
8016
33
8017
44
8018
55
8019
66
801A
77

Updated on: 27-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements