Aim: To write a program to move a block of memory from one location to another. Five numbers stored in memory locations starting from 4500H must be moved to 4600H onwards.
Algorithm
1. Set byte counter.
2. Get the number from the source and copy it in destination.
3. Decrement counter and repeat the above step until the byte counter is reset.
Program
4100: 79 0A MOV R1,05H ; Length of block in R1
4102: 90 45 00 MOV DPTR,#4500H ; First address in DPTR
4105: E0 NEXT: MOVX A,@DPTR ; First no. in Acc.
4106: 75 83 46 MOV DPH,46 ; 4600H in DPTR
4102: 90 45 00 MOV DPTR,#4500H ; First address in DPTR
4105: E0 NEXT: MOVX A,@DPTR ; First no. in Acc.
4106: 75 83 46 MOV DPH,46 ; 4600H in DPTR
4109: F0 MOVX @DPTR,A ; Number moved to 4600H
410A:75 83 45 MOV DPH,45H ; 4500H in DPTR
410D:A3 INC DPTR ; Points next location
410E: D9 F5 DJNZ R1,NEXT (4105H) ; Continue till counter is reset
4110: 80 FE HLT: SJMP HLT (4110H) ; Halt
410A:75 83 45 MOV DPH,45H ; 4500H in DPTR
410D:A3 INC DPTR ; Points next location
410E: D9 F5 DJNZ R1,NEXT (4105H) ; Continue till counter is reset
4110: 80 FE HLT: SJMP HLT (4110H) ; Halt
Procedure
1. Enter the program in memory locations starting from 4100H.
2. Enter five numbers in memory locations starting from 4500H.
3. Execute the program and verify the result in memory locations starting from 4600H.
1. Enter the program in memory locations starting from 4100H.
2. Enter five numbers in memory locations starting from 4500H.
3. Execute the program and verify the result in memory locations starting from 4600H.
Test data
Input: 4500: 01 02 03 04 05
Output: 4600: 01 02 03 04 05
0 comments
Post a Comment