initial import
[glibc.git] / sysdeps / m68k / m68020 / addmul_1.S
blob3f244c40b4b29ad8a1f93a69e8629d2b7fd925fb
1 /* mc68020 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
2    the result to a second limb vector.
4 Copyright (C) 1992, 1994 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Library General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
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 Library General Public
16 License for more details.
18 You should have received a copy of the GNU Library 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
23   INPUT PARAMETERS
24   res_ptr       (sp + 4)
25   s1_ptr        (sp + 8)
26   size          (sp + 12)
27   s2_limb       (sp + 16)
30 #include "asm-syntax.h"
32         TEXT
33         ALIGN
34         GLOBL   ___mpn_addmul_1
36 LAB(___mpn_addmul_1)
38 #define res_ptr a0
39 #define s1_ptr a1
40 #define size d2
41 #define s2_limb d4
43 /* Save used registers on the stack.  */
44         INSN2(movem,l   ,MEM_PREDEC(sp),d2-d5)
46 /* Copy the arguments to registers.  Better use movem?  */
47         INSN2(move,l    ,res_ptr,MEM_DISP(sp,20))
48         INSN2(move,l    ,s1_ptr,MEM_DISP(sp,24))
49         INSN2(move,l    ,size,MEM_DISP(sp,28))
50         INSN2(move,l    ,s2_limb,MEM_DISP(sp,32))
52         INSN2(eor,w     ,size,#1)
53         INSN1(clr,l     ,d1)
54         INSN1(clr,l     ,d5)
55         INSN2(lsr,l     ,size,#1)
56         bcc     L1
57         INSN2(subq,l    ,size,#1)
58         INSN2(sub,l     ,d0,d0)         /* (d0,cy) <= (0,0) */
60 LAB(Loop)
61         INSN2(move,l    ,d3,MEM_POSTINC(s1_ptr))
62         INSN2(mulu,l    ,d1:d3,s2_limb)
63         INSN2(addx,l    ,d3,d0)
64         INSN2(addx,l    ,d1,d5)
65         INSN2(add,l     ,MEM_POSTINC(res_ptr),d3)
66 LAB(L1) INSN2(move,l    ,d3,MEM_POSTINC(s1_ptr))
67         INSN2(mulu,l    ,d0:d3,s2_limb)
68         INSN2(addx,l    ,d3,d1)
69         INSN2(addx,l    ,d0,d5)
70         INSN2(add,l     ,MEM_POSTINC(res_ptr),d3)
72         dbf     size,Loop
73         INSN2(addx,l    ,d0,d5)
74         INSN2(sub,l     ,size,#0x10000)
75         bcc     Loop
77 /* Restore used registers from stack frame.  */
78         INSN2(movem,l   ,d2-d5,MEM_POSTINC(sp))
80         rts