In this program we will see how to exchange a block of bytes using 8085.
Write 8085 Assembly language program to exchange a block of data, where block size is given.
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.
|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|