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

  1.     title    BCDASM -- Copyright 1997, Morten Elling
  2.     subttl    Sign-extend a packed signed BCD to double-size
  3.  
  4.     include model.inc
  5.     include modelt.inc
  6.     include bcd.ash
  7.  
  8.     @CODESEG
  9.  
  10. ;//////////////////////////////////////////////////////////////////////
  11. ;//    Name    bcdSx
  12. ;//    Desc    Sign-extend a packed signed BCD number into a
  13. ;//        double-size packed signed BCD (convert to double-size).
  14. ;//
  15. ;//
  16. ;//    Entry    Passed args
  17. ;//    Exit    Double-size packed signed BCD returned to destination.
  18. ;//        Acc undefined.
  19. ;//
  20. ;//    Note    Destination and source may be the same.
  21.  
  22. bcdSx    proc
  23. arg    dstBCD    :dataptr, \    ; Addr of dest BCD (size = 2*srcsz)
  24.     srcBCD    :dataptr, \    ; Addr of source BCD (OK if = dstBCD)
  25.     srcsz    :@uint        ; Byte size of source BCD
  26. @uses    ds,es,rsi,rdi,rcx,rax
  27. ;.
  28.     mov   rcx, [srcsz]
  29.     dec   rcx        ; Copy all but the sign byte
  30.     @LDS  rsi, [srcBCD]
  31.     @LES  rdi, [dstBCD]
  32.     @cld
  33.     rep   movsb
  34.     mov   ah, [rsi]        ; Get the sign byte
  35.     mov   rcx, [srcsz]    ; Zero old sign and high-order
  36.     sub   al, al
  37.     rep   stosb
  38.     mov   al, ah
  39.     stosb            ; Store the sign byte
  40.     RET
  41. bcdSx    endp
  42.  
  43.     END