remove empty dir
[ghc-hetmet.git] / ghc / rts / gmp / mpn / m68k / add_n.S
1 /* mc68020 __gmpn_add_n -- Add two limb vectors of the same length > 0 and store
2    sum in a third 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   s2_ptr        (sp + 16)
28   size          (sp + 12)
29 */
30
31 #include "asm-syntax.h"
32
33         TEXT
34         ALIGN
35         GLOBL   C_SYMBOL_NAME(__gmpn_add_n)
36
37 C_SYMBOL_NAME(__gmpn_add_n:)
38 PROLOG(__gmpn_add_n)
39 /* Save used registers on the stack.  */
40         movel   R(d2),MEM_PREDEC(sp)
41         movel   R(a2),MEM_PREDEC(sp)
42
43 /* Copy the arguments to registers.  Better use movem?  */
44         movel   MEM_DISP(sp,12),R(a2)
45         movel   MEM_DISP(sp,16),R(a0)
46         movel   MEM_DISP(sp,20),R(a1)
47         movel   MEM_DISP(sp,24),R(d2)
48
49         eorw    #1,R(d2)
50         lsrl    #1,R(d2)
51         bcc     L(L1)
52         subql   #1,R(d2)        /* clears cy as side effect */
53
54 L(Loop:)
55         movel   MEM_POSTINC(a0),R(d0)
56         movel   MEM_POSTINC(a1),R(d1)
57         addxl   R(d1),R(d0)
58         movel   R(d0),MEM_POSTINC(a2)
59 L(L1:)  movel   MEM_POSTINC(a0),R(d0)
60         movel   MEM_POSTINC(a1),R(d1)
61         addxl   R(d1),R(d0)
62         movel   R(d0),MEM_POSTINC(a2)
63
64         dbf     R(d2),L(Loop)           /* loop until 16 lsb of %4 == -1 */
65         subxl   R(d0),R(d0)     /* d0 <= -cy; save cy as 0 or -1 in d0 */
66         subl    #0x10000,R(d2)
67         bcs     L(L2)
68         addl    R(d0),R(d0)     /* restore cy */
69         bra     L(Loop)
70
71 L(L2:)
72         negl    R(d0)
73
74 /* Restore used registers from stack frame.  */
75         movel   MEM_POSTINC(sp),R(a2)
76         movel   MEM_POSTINC(sp),R(d2)
77
78         rts
79 EPILOG(__gmpn_add_n)