1 | /* mc68020 __mpn_mul_1 -- Multiply a limb vector with a limb and store |
2 | the result in a second limb vector. |
3 | |
4 | Copyright (C) 1992-2024 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 Lesser General Public License as published by |
10 | the Free Software Foundation; either version 2.1 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 Lesser General Public |
16 | License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public License |
19 | along with the GNU MP Library. If not, see <https://www.gnu.org/licenses/>. */ |
20 | |
21 | /* |
22 | INPUT PARAMETERS |
23 | res_ptr (sp + 4) |
24 | s1_ptr (sp + 8) |
25 | s1_size (sp + 12) |
26 | s2_limb (sp + 16) |
27 | */ |
28 | |
29 | #include "sysdep.h" |
30 | #include "asm-syntax.h" |
31 | |
32 | TEXT |
33 | ENTRY(__mpn_mul_1) |
34 | |
35 | #define res_ptr a0 |
36 | #define s1_ptr a1 |
37 | #define s1_size d2 |
38 | #define s2_limb d4 |
39 | |
40 | /* Save used registers on the stack. */ |
41 | moveml R(d2)-R(d4),MEM_PREDEC(sp) |
42 | cfi_adjust_cfa_offset (3*4) |
43 | cfi_rel_offset (R(d2), 0) |
44 | cfi_rel_offset (R(d3), 4) |
45 | cfi_rel_offset (R(d4), 8) |
46 | |
47 | /* Copy the arguments to registers. Better use movem? */ |
48 | movel MEM_DISP(sp,16),R(res_ptr) |
49 | movel MEM_DISP(sp,20),R(s1_ptr) |
50 | movel MEM_DISP(sp,24),R(s1_size) |
51 | movel MEM_DISP(sp,28),R(s2_limb) |
52 | |
53 | eorw #1,R(s1_size) |
54 | clrl R(d1) |
55 | lsrl #1,R(s1_size) |
56 | bcc L(L1) |
57 | subql #1,R(s1_size) |
58 | subl R(d0),R(d0) /* (d0,cy) <= (0,0) */ |
59 | |
60 | L(Loop:) |
61 | movel MEM_POSTINC(s1_ptr),R(d3) |
62 | mulul R(s2_limb),R(d1):R(d3) |
63 | addxl R(d0),R(d3) |
64 | movel R(d3),MEM_POSTINC(res_ptr) |
65 | L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) |
66 | mulul R(s2_limb),R(d0):R(d3) |
67 | addxl R(d1),R(d3) |
68 | movel R(d3),MEM_POSTINC(res_ptr) |
69 | |
70 | dbf R(s1_size),L(Loop) |
71 | clrl R(d3) |
72 | addxl R(d3),R(d0) |
73 | subl #0x10000,R(s1_size) |
74 | bcc L(Loop) |
75 | |
76 | /* Restore used registers from stack frame. */ |
77 | moveml MEM_POSTINC(sp),R(d2)-R(d4) |
78 | cfi_adjust_cfa_offset (-3*4) |
79 | cfi_restore (R(d2)) |
80 | cfi_restore (R(d3)) |
81 | cfi_restore (R(d4)) |
82 | rts |
83 | END(__mpn_mul_1) |
84 | |