home *** CD-ROM | disk | FTP | other *** search
- .MODEL TPASCAL
- .CODE
- Swap PROC FAR
- PUBLIC Swap
- ARG one : DWORD, two : DWORD, MoveSize : WORD
-
- push ds ; Save DS
- mov cx, MoveSize ; Place the number of bytes to move into CX
- cmp cx,0 ; If there are no bytes to move
- jz Done ; then QUIT
- cld ; Clear the direction flag for LODSB/STOSB
- lds si, one ; Make DS:SI point to ONE
- les di, two ; Make ES:DI point to TWO
- Looper:
- mov al,BYTE PTR ds:si ; Move one byte from ONE to AL
- mov bl,BYTE PTR es:di ; Move one byte from TWO to BL
-
- mov BYTE PTR ds:si, bl ; Move AL to TWO
- mov BYTE PTR es:di, al ; Move BL to ONE
-
- inc si ; Add 1 to SI
- inc di ; Add 1 to DI
- loop Looper ; If there are still bytes to move, loop again
-
- Done:
- pop ds ; restore DS
- ret
- Swap ENDP
-
- ENDS
- END
-