beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / m68k / mc68020 / aorsmul_1.asm
blob4ee30ad9b3086c0d58fb49596f7ada945b50eba8
1 dnl mc68020 mpn_addmul_1, mpn_submul_1 -- add or subtract mpn multiple.
3 dnl Copyright 1992, 1994, 1996, 1999-2002, 2011 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
31 include(`../config.m4')
33 C cycles/limb
34 C 68040: 25
36 ifdef(`OPERATION_addmul_1',`
37 define(M4_inst, addl)
38 define(M4_function_1, mpn_addmul_1)
39 ',`ifdef(`OPERATION_submul_1',`
40 define(M4_inst, subl)
41 define(M4_function_1, mpn_submul_1)
43 `m4_error(`Need OPERATION_addmul_1 or OPERATION_submul_1
44 ')')')
47 C INPUT PARAMETERS
48 C res_ptr (sp + 4)
49 C s1_ptr (sp + 8)
50 C s1_size (sp + 12)
51 C s2_limb (sp + 16)
53 define(res_ptr, `a0')
54 define(s1_ptr, `a1')
55 define(s1_size, `d2')
56 define(s2_limb, `d4')
58 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
60 PROLOGUE(M4_function_1)
62 C Save used registers on the stack.
63 moveml d2-d5, M(-,sp)
65 C Copy the arguments to registers. Better use movem?
66 movel M(sp,20), res_ptr
67 movel M(sp,24), s1_ptr
68 movel M(sp,28), s1_size
69 movel M(sp,32), s2_limb
71 eorw #1, s1_size
72 clrl d1
73 clrl d5
74 lsrl #1, s1_size
75 bcc L(L1)
76 subql #1, s1_size
77 subl d0, d0 C (d0,cy) <= (0,0)
79 L(Loop):
80 movel M(s1_ptr,+), d3
81 mulul s2_limb, d1:d3
82 addxl d0, d3
83 addxl d5, d1
84 M4_inst d3, M(res_ptr,+)
85 L(L1): movel M(s1_ptr,+), d3
86 mulul s2_limb, d0:d3
87 addxl d1, d3
88 addxl d5, d0
89 M4_inst d3, M(res_ptr,+)
91 dbf s1_size, L(Loop)
92 addxl d5, d0
93 subl #0x10000, s1_size
94 bcc L(Loop)
96 C Restore used registers from stack frame.
97 moveml M(sp,+), d2-d5
99 rts
101 EPILOGUE(M4_function_1)