home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0302.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-11-19  |  962 b   |  32 lines

  1. .MODEL TPASCAL
  2. .CODE
  3. Swap PROC FAR
  4.      PUBLIC Swap
  5.      ARG one : DWORD, two : DWORD, MoveSize : WORD
  6.  
  7.      push ds              ; Save DS
  8.      mov  cx, MoveSize    ; Place the number of bytes to move into CX
  9.      cmp  cx,0            ; If there are no bytes to move
  10.      jz   Done            ;   then QUIT
  11.      cld                  ; Clear the direction flag for LODSB/STOSB
  12.      lds  si, one         ; Make DS:SI point to ONE
  13.      les  di, two         ; Make ES:DI point to TWO
  14. Looper:
  15.      mov  al,BYTE PTR ds:si  ; Move one byte from ONE to AL
  16.      mov  bl,BYTE PTR es:di  ; Move one byte from TWO to BL
  17.  
  18.      mov  BYTE PTR ds:si, bl ; Move AL to TWO
  19.      mov  BYTE PTR es:di, al ; Move BL to ONE
  20.  
  21.      inc  si              ; Add 1 to SI
  22.      inc  di              ; Add 1 to DI
  23.      loop Looper          ; If there are still bytes to move, loop again
  24.  
  25. Done:
  26.      pop  ds              ; restore DS
  27.      ret
  28. Swap ENDP
  29.  
  30. ENDS
  31. END
  32.