home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol8n20.zip / MPADD.ASM < prev    next >
Assembly Source File  |  1989-10-13  |  1KB  |  44 lines

  1.         title   MPADD.ASM Multiple-Precision Integer Addition
  2.         page    55,132
  3.  
  4. ; MPADD.ASM     Multiple-Precision Integer Addition
  5. ;               for Intel 8086, 8088, 80286, and
  6. ;               80386 in real mode/16-bit protected mode
  7. ;
  8. ; Copyright (C) 1989 Ziff Davis Communications
  9. ; PC Magazine * Ray Duncan
  10. ;
  11. ; Call with:    DS:SI   = address of source operand
  12. ;               ES:DI   = address of destination operand
  13. ;               CX      = operand length in bytes
  14. ;               Assumes direction flag is clear at entry
  15. ;
  16. ; Returns:      ES:DI   = address of result
  17. ;
  18. ; Destroys:     AL, CX, SI (other registers preserved)
  19.  
  20. _TEXT   segment word public 'CODE'
  21.  
  22.         assume  cs:_TEXT
  23.  
  24.         public  mpadd
  25. mpadd   proc    near
  26.  
  27.         push    di                      ; save address of result
  28.         clc                             ; carry initially clear
  29.  
  30. mpadd1: lodsb                           ; next byte from source
  31.         adc     byte ptr es:[di],al     ; accumulate sum
  32.         inc     di
  33.         loop    mpadd1                  ; until all bytes processed
  34.  
  35.         pop     di                      ; restore address of result
  36.         ret                             ; back to caller
  37.  
  38. mpadd   endp
  39.  
  40. _TEXT   ends
  41.  
  42.         end
  43.  
  44.