remove empty dir
[ghc-hetmet.git] / rts / gmp / mpn / m68k / mc68020 / mul_1.S
1 /* mc68020 __gmpn_mul_1 -- Multiply a limb vector with a limb and store
2    the result in a second limb vector.
3
4 Copyright (C) 1992, 1994, 1996, 1999, 2000 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; 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       (sp + 4)
26   s1_ptr        (sp + 8)
27   s1_size       (sp + 12)
28   s2_limb       (sp + 16)
29 */
30
31 #include "asm-syntax.h"
32
33         TEXT
34         ALIGN
35         GLOBL   C_SYMBOL_NAME(__gmpn_mul_1)
36
37 C_SYMBOL_NAME(__gmpn_mul_1:)
38 PROLOG(__gmpn_mul_1)
39
40 #define res_ptr a0
41 #define s1_ptr a1
42 #define s1_size d2
43 #define s2_limb d4
44
45 /* Save used registers on the stack.  */
46         moveml  R(d2)-R(d4),MEM_PREDEC(sp)
47 #if 0
48         movel   R(d2),MEM_PREDEC(sp)
49         movel   R(d3),MEM_PREDEC(sp)
50         movel   R(d4),MEM_PREDEC(sp)
51 #endif
52
53 /* Copy the arguments to registers.  Better use movem?  */
54         movel   MEM_DISP(sp,16),R(res_ptr)
55         movel   MEM_DISP(sp,20),R(s1_ptr)
56         movel   MEM_DISP(sp,24),R(s1_size)
57         movel   MEM_DISP(sp,28),R(s2_limb)
58
59         eorw    #1,R(s1_size)
60         clrl    R(d1)
61         lsrl    #1,R(s1_size)
62         bcc     L(L1)
63         subql   #1,R(s1_size)
64         subl    R(d0),R(d0)     /* (d0,cy) <= (0,0) */
65
66 L(Loop:)
67         movel   MEM_POSTINC(s1_ptr),R(d3)
68         mulul   R(s2_limb),R(d1):R(d3)
69         addxl   R(d0),R(d3)
70         movel   R(d3),MEM_POSTINC(res_ptr)
71 L(L1:)  movel   MEM_POSTINC(s1_ptr),R(d3)
72         mulul   R(s2_limb),R(d0):R(d3)
73         addxl   R(d1),R(d3)
74         movel   R(d3),MEM_POSTINC(res_ptr)
75
76         dbf     R(s1_size),L(Loop)
77         clrl    R(d3)
78         addxl   R(d3),R(d0)
79         subl    #0x10000,R(s1_size)
80         bcc     L(Loop)
81
82 /* Restore used registers from stack frame.  */
83         moveml  MEM_POSTINC(sp),R(d2)-R(d4)
84 #if 0
85         movel   MEM_POSTINC(sp),R(d4)
86         movel   MEM_POSTINC(sp),R(d3)
87         movel   MEM_POSTINC(sp),R(d2)
88 #endif
89         rts
90 EPILOG(__gmpn_mul_1)