8085 program to exchange a block of bytes in memory



In this program we will see how to exchange a block of bytes using 8085.

Problem Statement

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

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.

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.

Input

Address Data
... ...
8000 06
... ...
8010 00
8011 11
8012 22
8013 33
8014 44
8015 55
... ...
9010 84
9011 63
9012 12
9013 47
9014 48
9015 AD
... ...


Flow Diagram

Program

Address HEX Codes Labels Mnemonics Comments
F000 21, 10, 80
LXI H, 8000H    Point 8000Hto get byte count
F003 4E
MOV C,M Load Count from memory
F004 21, 10, 80
LXI H,8010H Point first block address
F007 11, 10, 90
LXI D,9010H Point second block address
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 Load B to A
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     When block is not completed, jump to LOOP
F015 76
HLT Terminate the program


Output

Address Data
... ...
8010 84
8011 63
8012 12
8013 47
8014 48
8015 AD
... ...
9010 00
9011 11
9012 22
9013 33
9014 44
9015 55
... ...
Updated on: 2019-07-30T22:30:24+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements