last time i had posted article on non overlapping block transfer. today i am going to post article for overlapping block transfer. two types of block transfer is "destination after source" and "destination before source". Ist will copy the given block of data before provided block replacing some of the starting no. of source block and 2nd one will copy the given block of data after provided block replacing some of the last no. of source block.
these codes are also short enough to understand and write.
here is the code for forward block transfer:
code for destination after source block transfer:-
DATA SEGMENT
ARRAY DB 01H,02H,03H,04H,05H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN:MOV AX,DATA
MOV DS,AX
LEA SI,ARRAY
LEA DI,ARRAY+2
MOV CL,05H
AB:MOV AL,[SI+4]
MOV [DI+4],AL
DEC SI
DEC DI
DEC CL
JNZ AB
MOV AH,4CH
INT 21H
CODE ENDS
END MAIN
save program with a file name for eg block.asm. copy this file to the masm folder now go to directory where you have kept masm folder using dos prompt.
To run this program you have to execute following command on DOS PROMPT
Masm block.asm;
After this type following line.
Link block.obj;
For checking your output execute command
Debug block.exe;
Then type t each time you find sign ‘-‘ on the screen on the left corner until you get command
INT 21H on the middle of the screen. After this type following command in front of sign ‘-‘.
d ds:0000
this will show all memory blocks you can find output after a try.
you can see highlighted no. using yellow color after 1st two no. all no. are replaced using a new sequence. which is the destination block.
code for destination before source block transfer:-
DATA SEGMENT
SOURCE DB 10 DUP(0)
ARRAY DB 01H,02H,03H,04H,05H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN: MOV AX,DATA
MOV DS,AX
LEA SI,ARRAY
LEA DI,ARRAY-2
MOV CL,05H
AB:MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
DEC CL
JNZ AB
MOV AH,4CH
INT 21H
CODE ENDS
END MAIN
follow same procedure as you followed for Ist program then try to find out your no. which you provided in the program in data section.
try to find your output you will find it somewhat like as it is in below image.
In this output window you can check the last two no.s 04 and 05. Only these are the no. which have not been replaced. Except this all no.s of source has been replaced by coping same before source (01,02,03,04,05).
enjoy!!
No comments:
Post a Comment