Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.8 KiB

  1. page ,132
  2. ;---------------------------Module-Header-------------------------------;
  3. ; Module Name: MULDIV32
  4. ;
  5. ; Copyright (c) 1987 Microsoft Corporation
  6. ;-----------------------------------------------------------------------;
  7. ?WIN = 0
  8. ?PLM = 1
  9. ?NODATA = 0
  10. .xlist
  11. include cmacros.inc
  12. .list
  13. ifndef SEGNAME
  14. SEGNAME equ <_TEXT>
  15. endif
  16. createSeg %SEGNAME, CodeSeg, word, public, CODE
  17. sBegin CodeSeg
  18. .386
  19. assumes cs,CodeSeg
  20. assumes ds,nothing
  21. assumes es,nothing
  22. ;---------------------------Public-Routine------------------------------;
  23. ; muldiv32
  24. ;
  25. ; multiples two 32 bit values and then divides the result by a third
  26. ; 32 bit value with full 64 bit presision
  27. ;
  28. ; lResult = (lNumber * lNumerator) / lDenominator
  29. ;
  30. ; Entry:
  31. ; lNumber = number to multiply by nNumerator
  32. ; lNumerator = number to multiply by nNumber
  33. ; lDenominator = number to divide the multiplication result by.
  34. ;
  35. ; Returns:
  36. ; EAX and DX:AX = result of multiplication and division.
  37. ; Error Returns:
  38. ; none
  39. ; Registers Preserved:
  40. ; DS,ES,ESI,EDI
  41. ;-----------------------------------------------------------------------;
  42. assumes ds,nothing
  43. assumes es,nothing
  44. cProc muldiv32,<PUBLIC,FAR,PASCAL>,<>
  45. ; ParmD ulNumber
  46. ; ParmD ulNumerator
  47. ; ParmD ulDenominator
  48. cBegin
  49. pop edx ; return addr
  50. pop ebx ; ulDenominator
  51. pop ecx ; ulNumerator
  52. pop eax ; ulNumber
  53. push edx ; put back return addr
  54. imul ecx ; edx:eax = (lNumber * lNumerator)
  55. idiv ebx ; eax = (lNumber * lNumerator) / lDenominator
  56. shld edx,eax,16 ; move HIWORD(eax) to dx
  57. cEnd
  58. sEnd CodeSeg
  59. end