home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol8n19.zip / DMUL.ASM < prev    next >
Assembly Source File  |  1989-10-02  |  2KB  |  79 lines

  1.  
  2.  
  3.         title   DMUL.ASM Double Precision Unsigned Multiply
  4.         page    55,132
  5.  
  6. ; DMUL.ASM      Double Precision Unsigned Multiply
  7. ;               for 8086, 8088, 80286, and 
  8. ;               80386 in real mode/16-bit protected mode
  9. ;
  10. ; Copyright (C) 1989 Ziff Communications Co.
  11. ; PC Magazine * Ray Duncan
  12. ;
  13. ; Call with:    DX:AX           = double-precision argument 1
  14. ;               CX:BX           = double-precision argument 2           
  15. ;
  16. ; Returns:      DX:CX:BX:AX     = quad-precision product
  17. ;
  18. ; Destroys:     nothing
  19.  
  20. _TEXT   segment word public 'CODE'
  21.  
  22. w0      equ     word ptr [bp-2]         ; local variables
  23. w1      equ     word ptr [bp-4]
  24. w2      equ     word ptr [bp-6]
  25. w3      equ     word ptr [bp-8]
  26.  
  27.         assume  cs:_TEXT
  28.  
  29.         public  dmul
  30. dmul    proc    near
  31.  
  32.         push    si                      ; save registers
  33.         push    di
  34.         push    bp                      ; set up stack frame
  35.         mov     bp,sp                   ; for forming result
  36.         sub     sp,8
  37.  
  38.         mov     di,dx                   ; save copy of argument 1
  39.         mov     si,ax
  40.  
  41.         mul     bx                      ; arg1 low * arg2 low
  42.         mov     w0,ax
  43.         mov     w1,dx
  44.  
  45.         mov     ax,di                   ; arg1 high * arg2 high
  46.         mul     cx
  47.         mov     w2,ax
  48.         mov     w3,dx
  49.  
  50.         mov     ax,di                   ; arg1 high * arg2 low
  51.         mul     bx
  52.         add     w1,ax                   ; accumulate result
  53.         adc     w2,dx
  54.         adc     w3,0
  55.  
  56.         mov     ax,si                   ; arg1 low * arg2 high
  57.         mul     cx
  58.         add     w1,ax                   ; accumulate result
  59.         adc     w2,dx
  60.         adc     w3,0
  61.  
  62.         pop     dx                      ; load quad-precision result
  63.         pop     cx
  64.         pop     bx
  65.         pop     ax
  66.  
  67.         pop     bp                      ; restore registers
  68.         pop     di
  69.         pop     si
  70.         ret                             ; and exit
  71.  
  72. dmul    endp
  73.  
  74. _TEXT   ends
  75.  
  76.         end
  77.  
  78.  
  79.