Q. Write an 8085 program and draw a flowchart to Transfer block of N-bytes from source to destination.(8085 Microprocessor Program)
|2000||MVI||C, 05H||0E||Initialize reg. C to 05H, i.e. number of bytes.|
|2002||LXI||H, 3000H||21||Initialize H-L pair to source memory location.|
|2005||LXI||D, 3500H||11||Initialize D-E pair to destination memory location.|
|2008||MOV||A, M||7E||Move the byte from source to accumulator.|
|2009||STAX||D||12||Store the byte from the accumulator to the destination.|
|200A||INX||H||23||Increment the source pointer H-L pair.|
|200B||INX||D||13||Increment the destination pointer D-E pair.|
|200C||DCR||C||0D||Decrement counter C.|
|200D||JNZ||2008H||C2||Jump to address 2008H if the counter is not zero.|
- This program transfers a block of N-bytes from source to destination. The source bytes start from memory location 3000H and needs to be transferred to memory locations 3500H onwards.
- In order to transfer these bytes, first, the counter must be initialized to the number of bytes to transfer.
- Then, H-L pair is initialized to point to the source memory location and D-E pair is initialized to point to destination memory location.
- The first byte is moved from source to accumulator and then from there to destination.
- The H-L pair and D-E pair are incremented to point to the next respective memory locations.
- The counter is decremented and checked whether it has become zero.
- If it hasn’t become zero, it means that there are bytes remaining to be transferred. In this case, the control jumps back to move the next byte from source to destination.
- This process continues until counter becomes zero, i.e. all the bytes have been transferred.