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

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