home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / BCDASM.ZIP / BCDASM / SRC / BCDSWAP.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-06-03  |  807 b   |  39 lines

  1.     title    BCDASM -- Copyright 1997, Morten Elling
  2.     subttl    Exchange (swap) two packed signed BCD numbers
  3.  
  4.     include    model.inc
  5.     include    modelt.inc
  6.     include    bcd.ash
  7.  
  8.     @CODESEG
  9.  
  10. ;//////////////////////////////////////////////////////////////////////
  11. ;//    Name    bcdSwap
  12. ;//    Desc    Exchange (swap) two packed signed BCD numbers.
  13. ;//
  14. ;//
  15. ;//    Entry    Passed args
  16. ;//    Exit    Contents of numbers exchanged.
  17. ;//        Acc undefined.
  18.  
  19. bcdSwap proc
  20. arg    dstBCD    :dataptr, \    ; Addr of 1st BCD
  21.     srcBCD    :dataptr, \    ; Addr of 2nd BCD
  22.     BCDsz    :@uint        ; Byte size of each BCD
  23. @uses    ds,es,rsi,rdi,rcx,rax
  24. ;.
  25.     mov   rcx, [BCDsz]
  26.     @LDS  rsi, [srcBCD]
  27.     @LES  rdi, [dstBCD]
  28.     @alignn
  29. @@swp:    mov   al, [rsi]
  30.     xchg  al, @ES [rdi]
  31.     mov   [rsi], al
  32.     inc   rsi
  33.     inc   rdi
  34.     dec   rcx
  35.     jnz   @@swp
  36.     RET
  37. bcdSwap endp
  38.  
  39.     END