8085 program to exchange a block of bytes in memory

MicrocontrollerMicroprocessor8085

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

AddressData
......
800006
......
801000
801111
801222
801333
801444
801555
......
901084
901163
901212
901347
901448
9015AD
......


Flow Diagram

Program

AddressHEX CodesLabelsMnemonicsComments
F00021, 10, 80
LXI H, 8000H   Point 8000Hto get byte count
F0034E
MOV C,MLoad Count from memory
F00421, 10, 80
LXI H,8010HPoint first block address
F00711, 10, 90
LXI D,9010HPoint second block address
F00A46LOOPMOV B, MTake element from first block to B
F00B1A
LDAX D  Take element from second block to Acc
F00C77
MOV M, AStore Acc content to second block
F00D78
MOV A, BLoad B to A
F00E12
STAX D  Store into second block
F00F23
INX H   Point to next address of first block
F01013
INX D   Point to next address of second block
F0110D
DCR C   Decrease the count variable
F012C2, 0A, F0
JNZ LOOP    When block is not completed, jump to LOOP
F01576
HLTTerminate the program


Output

AddressData
......
801084
801163
801212
801347
801448
8015AD
......
901000
901111
901222
901333
901444
901555
......
raja
Published on 17-Jan-2019 12:41:25
Advertisements