home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / borland / chap_17 / fpmul.asm < prev    next >
Encoding:
Assembly Source File  |  1995-05-25  |  832 b   |  37 lines

  1.  
  2. ; this function uses 64 bit math to multiply two 32 bit fixed point numbers
  3. ; in 16:16 format
  4.  
  5. .MODEL MEDIUM              ; use medium memory model C function names
  6.  
  7. .386
  8.  
  9. .CODE                        ; begin the code segment
  10.  
  11. PUBLIC _FP_Mul               ; export function name to linker
  12.  
  13.  
  14. _FP_Mul PROC
  15.  
  16. ARG multiplier:DWORD, multiplicand:DWORD
  17.  
  18.     push bp          ; create stack frame
  19.     mov bp,sp
  20.  
  21.     mov eax,multiplicand    ; move into eax multiplicand
  22.     imul multiplier         ; multiply by multiplier, result edx:eax
  23.     shr eax,16              ; need to shift upper 16 bits of eax to right
  24.                             ; so that result is in dx:ax instead of edx:eax
  25.  
  26.     pop bp                  ; fixup stack
  27.     ret                     ; return to caller
  28.  
  29. _FP_Mul ENDP
  30.  
  31. END
  32.  
  33.  
  34.  
  35.  
  36.  
  37.