addmul_1.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
  2. add the product to a second limb vector.
  3. Copyright (C) 1995-2019 Free Software Foundation, Inc.
  4. This file is part of the GNU MP Library.
  5. The GNU MP Library is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or (at your
  8. option) any later version.
  9. The GNU MP Library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with the GNU MP Library. If not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <sysdep.h>
  17. /* INPUT PARAMETERS
  18. res_ptr $4
  19. s1_ptr $5
  20. size $6
  21. s2_limb $7
  22. */
  23. #ifdef __PIC__
  24. .option pic2
  25. #endif
  26. ENTRY (__mpn_addmul_1)
  27. .set noreorder
  28. #ifdef __PIC__
  29. .cpload t9
  30. #endif
  31. .set nomacro
  32. /* warm up phase 0 */
  33. lw $8,0($5)
  34. /* warm up phase 1 */
  35. addiu $5,$5,4
  36. #if __mips_isa_rev < 6
  37. multu $8,$7
  38. #else
  39. mulu $11,$8,$7
  40. muhu $12,$8,$7
  41. #endif
  42. addiu $6,$6,-1
  43. beq $6,$0,L(LC0)
  44. move $2,$0 /* zero cy2 */
  45. addiu $6,$6,-1
  46. beq $6,$0,L(LC1)
  47. lw $8,0($5) /* load new s1 limb as early as possible */
  48. L(Loop): lw $10,0($4)
  49. #if __mips_isa_rev < 6
  50. mflo $3
  51. mfhi $9
  52. #else
  53. move $3,$11
  54. move $9,$12
  55. #endif
  56. addiu $5,$5,4
  57. addu $3,$3,$2 /* add old carry limb to low product limb */
  58. #if __mips_isa_rev < 6
  59. multu $8,$7
  60. #else
  61. mulu $11,$8,$7
  62. muhu $12,$8,$7
  63. #endif
  64. lw $8,0($5) /* load new s1 limb as early as possible */
  65. addiu $6,$6,-1 /* decrement loop counter */
  66. sltu $2,$3,$2 /* carry from previous addition -> $2 */
  67. addu $3,$10,$3
  68. sltu $10,$3,$10
  69. addu $2,$2,$10
  70. sw $3,0($4)
  71. addiu $4,$4,4
  72. bne $6,$0,L(Loop) /* should be "bnel" */
  73. addu $2,$9,$2 /* add high product limb and carry from addition */
  74. /* cool down phase 1 */
  75. L(LC1): lw $10,0($4)
  76. #if __mips_isa_rev < 6
  77. mflo $3
  78. mfhi $9
  79. #else
  80. move $3,$11
  81. move $9,$12
  82. #endif
  83. addu $3,$3,$2
  84. sltu $2,$3,$2
  85. #if __mips_isa_rev < 6
  86. multu $8,$7
  87. #else
  88. mulu $11,$8,$7
  89. muhu $12,$8,$7
  90. #endif
  91. addu $3,$10,$3
  92. sltu $10,$3,$10
  93. addu $2,$2,$10
  94. sw $3,0($4)
  95. addiu $4,$4,4
  96. addu $2,$9,$2 /* add high product limb and carry from addition */
  97. /* cool down phase 0 */
  98. L(LC0): lw $10,0($4)
  99. #if __mips_isa_rev < 6
  100. mflo $3
  101. mfhi $9
  102. #else
  103. move $3,$11
  104. move $9,$12
  105. #endif
  106. addu $3,$3,$2
  107. sltu $2,$3,$2
  108. addu $3,$10,$3
  109. sltu $10,$3,$10
  110. addu $2,$2,$10
  111. sw $3,0($4)
  112. j $31
  113. addu $2,$9,$2 /* add high product limb and carry from addition */
  114. END (__mpn_addmul_1)