Annotation of OpenXM/src/kan96xx/gmp-2.0.2-ssh-2/mpn/a29k/sub_n.s, Revision 1.1.1.1
1.1 takayama 1: ; 29000 __mpn_sub -- Subtract two limb vectors of the same length > 0 and
2: ; store difference in a third limb vector.
3:
4: ; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
5:
6: ; This file is part of the GNU MP Library.
7:
8: ; The GNU MP Library is free software; you can redistribute it and/or modify
9: ; it under the terms of the GNU Library General Public License as published by
10: ; the Free Software Foundation; either version 2 of the License, or (at your
11: ; option) any later version.
12:
13: ; The GNU MP Library is distributed in the hope that it will be useful, but
14: ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15: ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16: ; License for more details.
17:
18: ; You should have received a copy of the GNU Library General Public License
19: ; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20: ; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21: ; MA 02111-1307, USA.
22:
23:
24: ; INPUT PARAMETERS
25: ; res_ptr lr2
26: ; s1_ptr lr3
27: ; s2_ptr lr4
28: ; size lr5
29:
30: ; We use the loadm/storem instructions and operate on chunks of 8
31: ; limbs/per iteration, until less than 8 limbs remain.
32:
33: ; The 29k has no addition or subtraction instructions that doesn't
34: ; affect carry, so we need to save and restore that as soon as we
35: ; adjust the pointers. gr116 is used for this purpose. Note that
36: ; gr116==0 means that carry should be set.
37:
38: .sect .lit,lit
39: .text
40: .align 4
41: .global ___mpn_sub_n
42: .word 0x60000
43: ___mpn_sub_n:
44: srl gr117,lr5,3
45: sub gr118,gr117,1
46: jmpt gr118,Ltail
47: constn gr116,-1 ; init cy reg
48: sub gr117,gr117,2 ; count for jmpfdec
49:
50: ; Main loop working 8 limbs/iteration.
51: Loop: mtsrim cr,(8-1)
52: loadm 0,0,gr96,lr3
53: add lr3,lr3,32
54: mtsrim cr,(8-1)
55: loadm 0,0,gr104,lr4
56: add lr4,lr4,32
57:
58: subr gr116,gr116,0 ; restore carry
59: subc gr96,gr96,gr104
60: subc gr97,gr97,gr105
61: subc gr98,gr98,gr106
62: subc gr99,gr99,gr107
63: subc gr100,gr100,gr108
64: subc gr101,gr101,gr109
65: subc gr102,gr102,gr110
66: subc gr103,gr103,gr111
67: subc gr116,gr116,gr116 ; gr116 = not(cy)
68:
69: mtsrim cr,(8-1)
70: storem 0,0,gr96,lr2
71: jmpfdec gr117,Loop
72: add lr2,lr2,32
73:
74: ; Code for the last up-to-7 limbs.
75: ; This code might look very strange, but it's hard to write it
76: ; differently without major slowdown.
77:
78: and lr5,lr5,(8-1)
79: Ltail: sub gr118,lr5,1 ; count for CR
80: jmpt gr118,Lend
81: sub gr117,lr5,2 ; count for jmpfdec
82:
83: mtsr cr,gr118
84: loadm 0,0,gr96,lr3
85: mtsr cr,gr118
86: loadm 0,0,gr104,lr4
87:
88: subr gr116,gr116,0 ; restore carry
89:
90: jmpfdec gr117,L1
91: subc gr96,gr96,gr104
92: jmp Lstore
93: mtsr cr,gr118
94: L1: jmpfdec gr117,L2
95: subc gr97,gr97,gr105
96: jmp Lstore
97: mtsr cr,gr118
98: L2: jmpfdec gr117,L3
99: subc gr98,gr98,gr106
100: jmp Lstore
101: mtsr cr,gr118
102: L3: jmpfdec gr117,L4
103: subc gr99,gr99,gr107
104: jmp Lstore
105: mtsr cr,gr118
106: L4: jmpfdec gr117,L5
107: subc gr100,gr100,gr108
108: jmp Lstore
109: mtsr cr,gr118
110: L5: jmpfdec gr117,L6
111: subc gr101,gr101,gr109
112: jmp Lstore
113: mtsr cr,gr118
114: L6: subc gr102,gr102,gr110
115:
116: Lstore: storem 0,0,gr96,lr2
117: subc gr116,gr116,gr116 ; gr116 = not(cy)
118:
119: Lend: jmpi lr0
120: add gr96,gr116,1
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>