Let us suppose that the 16 data are stored starting from
9000H and we are to move the data into location starting from 9100H.
Algorithm:
- Start.
- Load into register pair HL from memory location 9000H which is the source location.
- Load into register pair DE from 9100H which is the destination location.
- Move 10 into register C which acts as counter (16 in decimal = 10 in hexadecimal).
- Move content of memory M into accumulator A.
- Store content of accumulator into register pair DE.
- Increment register pair HL by 1.
- Increment register pair DE by 1.
- Decrement register C by 1.
- If no zero is present, go to step 5 else go to 11.
- Terminate the program.
Program Code:
LXI H, 9000H
LXI D, 9100H
MVI C, 10H
UP:
MOV A, M
STAX D
INX H
INX D
DCR C
JNZ UP
HLT
The HL register
pair is loaded with memory location 9000H which is the source and the DE register
pair is loaded with memory location 9100H which is the destination. Now, 10H
(which means 16 in decimal) is moved into register C which is used as counter. Now,
the content of memory M is moved into accumulator A and now the content of accumulator
is stored into memory location pointed by the DE register pair. The register
pair HL is incremented by 1 so that it points to the next data item and the DE
register pair is also incremented by 1 so that it points to the next location
of memory where the data is to be moved. The counter is decrement by 1. The
data now pointed is again moved into accumulator and the content of accumulator
is stored into memory location pointed by the DE register pair. The HL and DE
register pair are again incremented by 1 and the counter is decremented by 1.
These steps are
repeated as long as the counter is greater than 0.
Output:
Example |
Here, the 16 data’s starting from memory address 9000H is
moved into memory address starting from 9100H. Now, since memory address 9010
and 9011 are the 17th and 18th data so they are not copied
into memory address 9110 and 9111.
thank u..............
ReplyDelete