mul_Xsig.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*---------------------------------------------------------------------------+
  3. | mul_Xsig.S |
  4. | |
  5. | Multiply a 12 byte fixed point number by another fixed point number. |
  6. | |
  7. | Copyright (C) 1992,1994,1995 |
  8. | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
  9. | Australia. E-mail [email protected] |
  10. | |
  11. | Call from C as: |
  12. | void mul32_Xsig(Xsig *x, unsigned b) |
  13. | |
  14. | void mul64_Xsig(Xsig *x, unsigned long long *b) |
  15. | |
  16. | void mul_Xsig_Xsig(Xsig *x, unsigned *b) |
  17. | |
  18. | The result is neither rounded nor normalized, and the ls bit or so may |
  19. | be wrong. |
  20. | |
  21. +---------------------------------------------------------------------------*/
  22. .file "mul_Xsig.S"
  23. #include "fpu_emu.h"
  24. .text
  25. SYM_FUNC_START(mul32_Xsig)
  26. pushl %ebp
  27. movl %esp,%ebp
  28. subl $16,%esp
  29. pushl %esi
  30. movl PARAM1,%esi
  31. movl PARAM2,%ecx
  32. xor %eax,%eax
  33. movl %eax,-4(%ebp)
  34. movl %eax,-8(%ebp)
  35. movl (%esi),%eax /* lsl of Xsig */
  36. mull %ecx /* msl of b */
  37. movl %edx,-12(%ebp)
  38. movl 4(%esi),%eax /* midl of Xsig */
  39. mull %ecx /* msl of b */
  40. addl %eax,-12(%ebp)
  41. adcl %edx,-8(%ebp)
  42. adcl $0,-4(%ebp)
  43. movl 8(%esi),%eax /* msl of Xsig */
  44. mull %ecx /* msl of b */
  45. addl %eax,-8(%ebp)
  46. adcl %edx,-4(%ebp)
  47. movl -12(%ebp),%eax
  48. movl %eax,(%esi)
  49. movl -8(%ebp),%eax
  50. movl %eax,4(%esi)
  51. movl -4(%ebp),%eax
  52. movl %eax,8(%esi)
  53. popl %esi
  54. leave
  55. RET
  56. SYM_FUNC_END(mul32_Xsig)
  57. SYM_FUNC_START(mul64_Xsig)
  58. pushl %ebp
  59. movl %esp,%ebp
  60. subl $16,%esp
  61. pushl %esi
  62. movl PARAM1,%esi
  63. movl PARAM2,%ecx
  64. xor %eax,%eax
  65. movl %eax,-4(%ebp)
  66. movl %eax,-8(%ebp)
  67. movl (%esi),%eax /* lsl of Xsig */
  68. mull 4(%ecx) /* msl of b */
  69. movl %edx,-12(%ebp)
  70. movl 4(%esi),%eax /* midl of Xsig */
  71. mull (%ecx) /* lsl of b */
  72. addl %edx,-12(%ebp)
  73. adcl $0,-8(%ebp)
  74. adcl $0,-4(%ebp)
  75. movl 4(%esi),%eax /* midl of Xsig */
  76. mull 4(%ecx) /* msl of b */
  77. addl %eax,-12(%ebp)
  78. adcl %edx,-8(%ebp)
  79. adcl $0,-4(%ebp)
  80. movl 8(%esi),%eax /* msl of Xsig */
  81. mull (%ecx) /* lsl of b */
  82. addl %eax,-12(%ebp)
  83. adcl %edx,-8(%ebp)
  84. adcl $0,-4(%ebp)
  85. movl 8(%esi),%eax /* msl of Xsig */
  86. mull 4(%ecx) /* msl of b */
  87. addl %eax,-8(%ebp)
  88. adcl %edx,-4(%ebp)
  89. movl -12(%ebp),%eax
  90. movl %eax,(%esi)
  91. movl -8(%ebp),%eax
  92. movl %eax,4(%esi)
  93. movl -4(%ebp),%eax
  94. movl %eax,8(%esi)
  95. popl %esi
  96. leave
  97. RET
  98. SYM_FUNC_END(mul64_Xsig)
  99. SYM_FUNC_START(mul_Xsig_Xsig)
  100. pushl %ebp
  101. movl %esp,%ebp
  102. subl $16,%esp
  103. pushl %esi
  104. movl PARAM1,%esi
  105. movl PARAM2,%ecx
  106. xor %eax,%eax
  107. movl %eax,-4(%ebp)
  108. movl %eax,-8(%ebp)
  109. movl (%esi),%eax /* lsl of Xsig */
  110. mull 8(%ecx) /* msl of b */
  111. movl %edx,-12(%ebp)
  112. movl 4(%esi),%eax /* midl of Xsig */
  113. mull 4(%ecx) /* midl of b */
  114. addl %edx,-12(%ebp)
  115. adcl $0,-8(%ebp)
  116. adcl $0,-4(%ebp)
  117. movl 8(%esi),%eax /* msl of Xsig */
  118. mull (%ecx) /* lsl of b */
  119. addl %edx,-12(%ebp)
  120. adcl $0,-8(%ebp)
  121. adcl $0,-4(%ebp)
  122. movl 4(%esi),%eax /* midl of Xsig */
  123. mull 8(%ecx) /* msl of b */
  124. addl %eax,-12(%ebp)
  125. adcl %edx,-8(%ebp)
  126. adcl $0,-4(%ebp)
  127. movl 8(%esi),%eax /* msl of Xsig */
  128. mull 4(%ecx) /* midl of b */
  129. addl %eax,-12(%ebp)
  130. adcl %edx,-8(%ebp)
  131. adcl $0,-4(%ebp)
  132. movl 8(%esi),%eax /* msl of Xsig */
  133. mull 8(%ecx) /* msl of b */
  134. addl %eax,-8(%ebp)
  135. adcl %edx,-4(%ebp)
  136. movl -12(%ebp),%edx
  137. movl %edx,(%esi)
  138. movl -8(%ebp),%edx
  139. movl %edx,4(%esi)
  140. movl -4(%ebp),%edx
  141. movl %edx,8(%esi)
  142. popl %esi
  143. leave
  144. RET
  145. SYM_FUNC_END(mul_Xsig_Xsig)