Upload Tizen:Base source
[external/gmp.git] / mpn / m68k / mc68020 / mul_1.asm
1 dnl  mc68020 mpn_mul_1 -- mpn by limb multiply
2
3 dnl  Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002 Free Software
4 dnl  Foundation, Inc.
5 dnl
6 dnl  This file is part of the GNU MP Library.
7 dnl
8 dnl  The GNU MP Library is free software; you can redistribute it and/or
9 dnl  modify it under the terms of the GNU Lesser General Public License as
10 dnl  published by the Free Software Foundation; either version 3 of the
11 dnl  License, or (at your option) any later version.
12 dnl
13 dnl  The GNU MP Library is distributed in the hope that it will be useful,
14 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 dnl  Lesser General Public License for more details.
17 dnl
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C         cycles/limb
24 C 68040:     24
25
26 C INPUT PARAMETERS
27 C res_ptr       (sp + 4)
28 C s1_ptr        (sp + 8)
29 C s1_size       (sp + 12)
30 C s2_limb       (sp + 16)
31
32
33 define(res_ptr, `a0')
34 define(s1_ptr,  `a1')
35 define(s1_size, `d2')
36 define(s2_limb, `d4')
37
38
39 PROLOGUE(mpn_mul_1)
40
41 C Save used registers on the stack.
42         moveml  d2-d4, M(-,sp)
43
44 C       movel   d2, M(-,sp)
45 C       movel   d3, M(-,sp)
46 C       movel   d4, M(-,sp)
47
48 C Copy the arguments to registers.  Better use movem?
49         movel   M(sp,16), res_ptr
50         movel   M(sp,20), s1_ptr
51         movel   M(sp,24), s1_size
52         movel   M(sp,28), s2_limb
53
54         eorw    #1, s1_size
55         clrl    d1
56         lsrl    #1, s1_size
57         bcc     L(L1)
58         subql   #1, s1_size
59         subl    d0, d0          C (d0,cy) <= (0,0)
60
61 L(Loop):
62         movel   M(s1_ptr,+), d3
63         mulul   s2_limb, d1:d3
64         addxl   d0, d3
65         movel   d3, M(res_ptr,+)
66 L(L1):  movel   M(s1_ptr,+), d3
67         mulul   s2_limb, d0:d3
68         addxl   d1, d3
69         movel   d3, M(res_ptr,+)
70
71         dbf     s1_size, L(Loop)
72         clrl    d3
73         addxl   d3, d0
74         subl    #0x10000, s1_size
75         bcc     L(Loop)
76
77 C Restore used registers from stack frame.
78         moveml  M(sp,+), d2-d4
79
80 C       movel   M(sp,+),d4
81 C       movel   M(sp,+),d3
82 C       movel   M(sp,+),d2
83
84         rts
85
86 EPILOGUE(mpn_mul_1)