1dnl SPARC mpn_submul_1 -- Multiply a limb vector with a limb and subtract 2dnl the result from a second limb vector. 3 4dnl Copyright 1992-1994, 2000 Free Software Foundation, Inc. 5 6dnl This file is part of the GNU MP Library. 7dnl 8dnl The GNU MP Library is free software; you can redistribute it and/or modify 9dnl it under the terms of either: 10dnl 11dnl * the GNU Lesser General Public License as published by the Free 12dnl Software Foundation; either version 3 of the License, or (at your 13dnl option) any later version. 14dnl 15dnl or 16dnl 17dnl * the GNU General Public License as published by the Free Software 18dnl Foundation; either version 2 of the License, or (at your option) any 19dnl later version. 20dnl 21dnl or both in parallel, as here. 22dnl 23dnl The GNU MP Library is distributed in the hope that it will be useful, but 24dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 25dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26dnl for more details. 27dnl 28dnl You should have received copies of the GNU General Public License and the 29dnl GNU Lesser General Public License along with the GNU MP Library. If not, 30dnl see https://www.gnu.org/licenses/. 31 32 33include(`../config.m4') 34 35C INPUT PARAMETERS 36C res_ptr o0 37C s1_ptr o1 38C size o2 39C s2_limb o3 40 41ASM_START() 42PROLOGUE(mpn_submul_1) 43 C Make S1_PTR and RES_PTR point at the end of their blocks 44 C and put (- 4 x SIZE) in index/loop counter. 45 sll %o2,2,%o2 46 add %o0,%o2,%o4 C RES_PTR in o4 since o0 is retval 47 add %o1,%o2,%o1 48 sub %g0,%o2,%o2 49 50 cmp %o3,0xfff 51 bgu L(large) 52 nop 53 54 ld [%o1+%o2],%o5 55 mov 0,%o0 56 b L(0) 57 add %o4,-4,%o4 58L(loop0): 59 subcc %o5,%g1,%g1 60 ld [%o1+%o2],%o5 61 addx %o0,%g0,%o0 62 st %g1,[%o4+%o2] 63L(0): wr %g0,%o3,%y 64 sra %o5,31,%g2 65 and %o3,%g2,%g2 66 andcc %g1,0,%g1 67 mulscc %g1,%o5,%g1 68 mulscc %g1,%o5,%g1 69 mulscc %g1,%o5,%g1 70 mulscc %g1,%o5,%g1 71 mulscc %g1,%o5,%g1 72 mulscc %g1,%o5,%g1 73 mulscc %g1,%o5,%g1 74 mulscc %g1,%o5,%g1 75 mulscc %g1,%o5,%g1 76 mulscc %g1,%o5,%g1 77 mulscc %g1,%o5,%g1 78 mulscc %g1,%o5,%g1 79 mulscc %g1,0,%g1 80 sra %g1,20,%g4 81 sll %g1,12,%g1 82 rd %y,%g3 83 srl %g3,20,%g3 84 or %g1,%g3,%g1 85 86 addcc %g1,%o0,%g1 87 addx %g2,%g4,%o0 C add sign-compensation and cy to hi limb 88 addcc %o2,4,%o2 C loop counter 89 bne L(loop0) 90 ld [%o4+%o2],%o5 91 92 subcc %o5,%g1,%g1 93 addx %o0,%g0,%o0 94 retl 95 st %g1,[%o4+%o2] 96 97L(large): 98 ld [%o1+%o2],%o5 99 mov 0,%o0 100 sra %o3,31,%g4 C g4 = mask of ones iff S2_LIMB < 0 101 b L(1) 102 add %o4,-4,%o4 103L(loop): 104 subcc %o5,%g3,%g3 105 ld [%o1+%o2],%o5 106 addx %o0,%g0,%o0 107 st %g3,[%o4+%o2] 108L(1): wr %g0,%o5,%y 109 and %o5,%g4,%g2 110 andcc %g0,%g0,%g1 111 mulscc %g1,%o3,%g1 112 mulscc %g1,%o3,%g1 113 mulscc %g1,%o3,%g1 114 mulscc %g1,%o3,%g1 115 mulscc %g1,%o3,%g1 116 mulscc %g1,%o3,%g1 117 mulscc %g1,%o3,%g1 118 mulscc %g1,%o3,%g1 119 mulscc %g1,%o3,%g1 120 mulscc %g1,%o3,%g1 121 mulscc %g1,%o3,%g1 122 mulscc %g1,%o3,%g1 123 mulscc %g1,%o3,%g1 124 mulscc %g1,%o3,%g1 125 mulscc %g1,%o3,%g1 126 mulscc %g1,%o3,%g1 127 mulscc %g1,%o3,%g1 128 mulscc %g1,%o3,%g1 129 mulscc %g1,%o3,%g1 130 mulscc %g1,%o3,%g1 131 mulscc %g1,%o3,%g1 132 mulscc %g1,%o3,%g1 133 mulscc %g1,%o3,%g1 134 mulscc %g1,%o3,%g1 135 mulscc %g1,%o3,%g1 136 mulscc %g1,%o3,%g1 137 mulscc %g1,%o3,%g1 138 mulscc %g1,%o3,%g1 139 mulscc %g1,%o3,%g1 140 mulscc %g1,%o3,%g1 141 mulscc %g1,%o3,%g1 142 mulscc %g1,%o3,%g1 143 mulscc %g1,%g0,%g1 144 rd %y,%g3 145 addcc %g3,%o0,%g3 146 addx %g2,%g1,%o0 147 addcc %o2,4,%o2 148 bne L(loop) 149 ld [%o4+%o2],%o5 150 151 subcc %o5,%g3,%g3 152 addx %o0,%g0,%o0 153 retl 154 st %g3,[%o4+%o2] 155EPILOGUE(mpn_submul_1) 156