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.

95 lines
2.2 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. // TITLE("Large Integer Arithmetic")
  10. //++
  11. //
  12. // Module Name:
  13. //
  14. // largeint.s
  15. //
  16. // Abstract:
  17. //
  18. // This module implements routines for performing extended integer
  19. // arithmetic.
  20. //
  21. // Author:
  22. //
  23. // William K. Cheung (wcheung) 08-Feb-1996
  24. //
  25. // Environment:
  26. //
  27. // Any mode.
  28. //
  29. // Revision History:
  30. //
  31. // 09-Feb-1996 Updated to EAS 2.1
  32. //
  33. //--
  34. #include "ksia64.h"
  35. .file "largeint.s"
  36. //++
  37. //
  38. // LARGE_INTEGER
  39. // RtlExtendedMagicDivide (
  40. // IN LARGE_INTEGER Dividend,
  41. // IN LARGE_INTEGER MagicDivisor,
  42. // IN CCHAR ShiftCount
  43. // )
  44. //
  45. // Routine Description:
  46. //
  47. // This function divides a signed large integer by an unsigned large integer
  48. // and returns the signed large integer result. The division is performed
  49. // using reciprocal multiplication of a signed large integer value by an
  50. // unsigned large integer fraction which represents the most significant
  51. // 64-bits of the reciprocal divisor rounded up in its least significant bit
  52. // and normalized with respect to bit 63. A shift count is also provided
  53. // which is used to truncate the fractional bits from the result value.
  54. //
  55. // Arguments:
  56. //
  57. // Dividend (a0) - Supplies the dividend value.
  58. //
  59. // MagicDivisor (a1) - Supplies the magic divisor value which
  60. // is a 64-bit multiplicative reciprocal.
  61. //
  62. // Shiftcount (a2) - Supplies the right shift adjustment value.
  63. //
  64. // Return Value:
  65. //
  66. // The large integer result is returned as the function value in v0.
  67. //
  68. //--
  69. LEAF_ENTRY(RtlExtendedMagicDivide)
  70. cmp.gt pt0, pt1 = r0, a0
  71. ;;
  72. (pt0) sub a0 = r0, a0
  73. ;;
  74. setf.sig ft0 = a0
  75. setf.sig ft1 = a1
  76. ;;
  77. zxt1 a2 = a2
  78. xma.hu ft2 = ft0, ft1, f0
  79. ;;
  80. getf.sig v0 = ft2
  81. ;;
  82. shr v0 = v0, a2
  83. ;;
  84. (pt0) sub v0 = r0, v0
  85. LEAF_RETURN
  86. LEAF_EXIT(RtlExtendedMagicDivide)