MODEL MEDIUM,BASIC
.STACK 20H
.386
.CODE

;SUB RELPAGESWAP(BYVAL DESTSEG,BYVAL SRCSEG)
;STACK
;DEST SEG       =8
;SOURCE SEG     =6
;QB RETURN SEG  =4
;QB RETURN OFF  =2
;BP             =0
;DS:SI		=SRC SEG:SRC OFF
;ES:DI		=DEST SEG:DEST OFF

PUBLIC RELPAGESWAP
RELPAGESWAP PROC

PUSH BP
MOV DX,DS       ;SAVE DS
MOV BP,SP	;POINT STACK POINTER TO BP
MOV ES,[BP+8]   ;POINT ADDRESS OF DEST TO ES
MOV DS,[BP+6]   ;POINT ADDRESS OF SRC TO DS
XOR DI,DI	;ZERO OUT DEST OFFSET
XOR SI,SI	;ZERO OUT SRC OFFSET
MOV CX,16000    ;INIT COUNTER(DOUBLE WORD)
LBL_SWAP_LOOP:
MOV EAX,ES:[DI]
MOV EBX,DS:[SI]
MOV DS:[SI],EAX
MOV ES:[DI],EBX
ADD SI,4
ADD DI,4
DEC CX
JNZ LBL_SWAP_LOOP
MOV DS,DX       ;RESTORE DS
POP BP
RET 4

RELPAGESWAP ENDP

END

