# 8085 Program to Exchange 10 bytes

In this program we will see how to exchange a block of 10-byte data using 8085.

### Problem Statement

Write 8085 Assembly language program to exchange a block of data, where block size is 10.

### Discussion

The data are stored at location 8010H to 8019H and 9010H to 9019H. The location 8000H is holding the number of bytes to exchange. In this case number of bytes are 10D so it will be 0AH.

The logic is very simple, The HL and DE register pair is pointing the first and second data block respectively. By taking the data we are just swapping the values of each memory locations. Then repeating this process to swap two blocks completely.

Data
.
.
.
.
.
.
8000
0A
.
.
.
.
.
.
8010
00
8011
11
8012
22
8013
33
8014
44
8015
55
8016
66
8017
77
8018
88
8019
99
.
.
.
.
.
.
9010
84
9011
63
9012
12
9013
47
9014
48
9015
9016
BC
9017
2A
9018
8F
9019
99
.
.
.
.
.
.

### Program

HEX Codes
Labels
Mnemonics
F000
21, 10, 80

LXI H, 8000H
Point 8000Hto get byte count
F003
4E

MOV C, M
F004
21, 10, 80

LXI H,8010H
F007
11, 10, 90

LXI D,9010H
F00A
46
LOOP
MOV B, M
Take element from first block to B
F00B
1A

LDAX D
Take element from second block to Acc
F00C
77

MOV M, A
Store Acc content to second block
F00D
78

MOV A, B
F00E
12

STAX D
Store into second block
F00F
23

INX H
Point to next address of first block
F010
13

INX D
Point to next address of second block
F011
0D

DCR C
Decrease the count variable
F012
C2, 0A, F0

JNZ LOOP
F015
76

HLT
Terminate the program

### Output

Data
.
.
.
.
.
.
8010
84
8011
63
8012
12
8013
47
8014
48
8015
8016
BC
8017
2A
8018
8F
8019
99
.
.
.
.
.
.
9010
00
9011
11
9012
22
9013
33
9014
44
9015
55
9016
66
9017
77
9018
88
9019
99
.
.
.
.
.
.

Updated on: 30-Jul-2019

2K+ Views