Code:
; Transfer block of data from the source address
; to destination address and vice versa [Overlapping block transfer]
.MODEL SMALL
.STACK 100H
.DATA
ARR1 DW 1122H , 3344H , 5566H , 7788H , 9900H
ARR2 DW 5 DUP(0)
.CODE
MOV AX , @DATA ; Initializing data segment
MOV DS , AX
MOV CX , 5 ; Initializing word counter
MOV SI , OFFSET ARR1
MOV DI , OFFSET ARR2
ADD SI , 8 ; Set memory pointers to
ADD DI , 8 ; last numbers for source and destination
UP:
MOV AX , [SI] ; Read number for source array
MOV [DI] , AX ; Write number to destination array to the last of array
SUB SI , 2 ; Decrement source memory pointer
SUB DI , 2 ; Decrement destination memory pointer
LOOP UP
MOV AH , 4CH ; Service Routine for Exit
INT 21H
END
; Transfer block of data from the source address
; to destination address and vice versa [Overlapping block transfer]
.MODEL SMALL
.STACK 100H
.DATA
ARR1 DW 1122H , 3344H , 5566H , 7788H , 9900H
ARR2 DW 5 DUP(0)
.CODE
MOV AX , @DATA ; Initializing data segment
MOV DS , AX
MOV CX , 5 ; Initializing word counter
MOV SI , OFFSET ARR1
MOV DI , OFFSET ARR2
ADD SI , 8 ; Set memory pointers to
ADD DI , 8 ; last numbers for source and destination
UP:
MOV AX , [SI] ; Read number for source array
MOV [DI] , AX ; Write number to destination array to the last of array
SUB SI , 2 ; Decrement source memory pointer
SUB DI , 2 ; Decrement destination memory pointer
LOOP UP
MOV AH , 4CH ; Service Routine for Exit
INT 21H
END