]>
Commit | Line | Data |
---|---|---|
2b30df17 RM |
1 | /* mc68020 __mpn_add_n -- Add two limb vectors of the same length > 0 and store |
2 | sum in a third limb vector. | |
3 | ||
04277e02 | 4 | Copyright (C) 1992-2019 Free Software Foundation, Inc. |
2b30df17 RM |
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 | |
f01ec467 AJ |
9 | it under the terms of the GNU Lesser General Public License as published by |
10 | the Free Software Foundation; either version 2.1 of the License, or (at your | |
2b30df17 RM |
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 | |
f01ec467 | 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
2b30df17 RM |
16 | License for more details. |
17 | ||
f01ec467 | 18 | You should have received a copy of the GNU Lesser General Public License |
ab84e3ff | 19 | along with the GNU MP Library. If not, see <http://www.gnu.org/licenses/>. */ |
2b30df17 RM |
20 | |
21 | /* | |
22 | INPUT PARAMETERS | |
23 | res_ptr (sp + 4) | |
24 | s1_ptr (sp + 8) | |
25 | s2_ptr (sp + 16) | |
26 | size (sp + 12) | |
27 | */ | |
28 | ||
3de9f02e | 29 | #include "sysdep.h" |
2b30df17 RM |
30 | #include "asm-syntax.h" |
31 | ||
32 | TEXT | |
56d7f029 | 33 | ENTRY(__mpn_add_n) |
2b30df17 | 34 | /* Save used registers on the stack. */ |
3de9f02e | 35 | movel R(d2),MEM_PREDEC(sp) |
50e73d13 | 36 | cfi_adjust_cfa_offset (4) |
3de9f02e | 37 | movel R(a2),MEM_PREDEC(sp) |
50e73d13 AS |
38 | cfi_adjust_cfa_offset (4) |
39 | cfi_rel_offset (R(d2), 4) | |
40 | cfi_rel_offset (R(a2), 0) | |
2b30df17 RM |
41 | |
42 | /* Copy the arguments to registers. Better use movem? */ | |
3de9f02e RM |
43 | movel MEM_DISP(sp,12),R(a2) |
44 | movel MEM_DISP(sp,16),R(a0) | |
45 | movel MEM_DISP(sp,20),R(a1) | |
46 | movel MEM_DISP(sp,24),R(d2) | |
47 | ||
48 | eorw #1,R(d2) | |
49 | lsrl #1,R(d2) | |
50 | bcc L(L1) | |
51 | subql #1,R(d2) /* clears cy as side effect */ | |
52 | ||
53 | L(Loop:) | |
54 | movel MEM_POSTINC(a0),R(d0) | |
55 | movel MEM_POSTINC(a1),R(d1) | |
56 | addxl R(d1),R(d0) | |
57 | movel R(d0),MEM_POSTINC(a2) | |
58 | L(L1:) movel MEM_POSTINC(a0),R(d0) | |
59 | movel MEM_POSTINC(a1),R(d1) | |
60 | addxl R(d1),R(d0) | |
61 | movel R(d0),MEM_POSTINC(a2) | |
62 | ||
63 | dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */ | |
64 | subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */ | |
65 | subl #0x10000,R(d2) | |
66 | bcs L(L2) | |
67 | addl R(d0),R(d0) /* restore cy */ | |
68 | bra L(Loop) | |
69 | ||
70 | L(L2:) | |
71 | negl R(d0) | |
2b30df17 RM |
72 | |
73 | /* Restore used registers from stack frame. */ | |
3de9f02e | 74 | movel MEM_POSTINC(sp),R(a2) |
50e73d13 AS |
75 | cfi_adjust_cfa_offset (-4) |
76 | cfi_restore (R(a2)) | |
3de9f02e | 77 | movel MEM_POSTINC(sp),R(d2) |
50e73d13 AS |
78 | cfi_adjust_cfa_offset (-4) |
79 | cfi_restore (R(d2)) | |
2b30df17 RM |
80 | |
81 | rts | |
56d7f029 | 82 | END(__mpn_add_n) |