* stdlib/Makefile (mpn-stuff): New target.
[glibc.git] / sysdeps / m68k / m68020 / submul_1.S
blobcf30029b2f4446f8575167930ff900e0e7e2aca6
1 /* mc68020 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
2    the result from a second limb vector.
4 Copyright (C) 1992, 1994, 1996 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   s1_size       (sp + 12)
27   s2_limb       (sp + 16)
30 #include "sysdep.h"
31 #include "asm-syntax.h"
33         TEXT
34         ALIGN
35         GLOBL   C_SYMBOL_NAME(__mpn_submul_1)
37 C_SYMBOL_NAME(__mpn_submul_1:)
38 PROLOG(__mpn_submul_1)
40 #define res_ptr a0
41 #define s1_ptr a1
42 #define s1_size d2
43 #define s2_limb d4
45 /* Save used registers on the stack.  */
46         moveml  R(d2)-R(d5),MEM_PREDEC(sp)
48 /* Copy the arguments to registers.  Better use movem?  */
49         movel   MEM_DISP(sp,20),R(res_ptr)
50         movel   MEM_DISP(sp,24),R(s1_ptr)
51         movel   MEM_DISP(sp,28),R(s1_size)
52         movel   MEM_DISP(sp,32),R(s2_limb)
54         eorw    #1,R(s1_size)
55         clrl    R(d1)
56         clrl    R(d5)
57         lsrl    #1,R(s1_size)
58         bcc     L(L1)
59         subql   #1,R(s1_size)
60         subl    R(d0),R(d0)     /* (d0,cy) <= (0,0) */
62 L(Loop:)
63         movel   MEM_POSTINC(s1_ptr),R(d3)
64         mulul   R(s2_limb),R(d1):R(d3)
65         addxl   R(d0),R(d3)
66         addxl   R(d5),R(d1)
67         subl    R(d3),MEM_POSTINC(res_ptr)
68 L(L1:)  movel   MEM_POSTINC(s1_ptr),R(d3)
69         mulul   R(s2_limb),R(d0):R(d3)
70         addxl   R(d1),R(d3)
71         addxl   R(d5),R(d0)
72         subl    R(d3),MEM_POSTINC(res_ptr)
74         dbf     R(s1_size),L(Loop)
75         addxl   R(d5),R(d0)
76         subl    #0x10000,R(s1_size)
77         bcc     L(Loop)
79 /* Restore used registers from stack frame.  */
80         moveml  MEM_POSTINC(sp),R(d2)-R(d5)
82         rts
83 EPILOG(__mpn_submul_1)