]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/m68k/m68020/submul_1.S
Thu Feb 29 20:55:57 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
[thirdparty/glibc.git] / sysdeps / m68k / m68020 / submul_1.S
CommitLineData
3b84e62e
RM
1/* mc68020 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
2 the result from a second limb vector.
3
4Copyright (C) 1992, 1994 Free Software Foundation, Inc.
5
6This file is part of the GNU MP Library.
7
8The GNU MP Library is free software; you can redistribute it and/or modify
9it under the terms of the GNU Library General Public License as published by
10the Free Software Foundation; either version 2 of the License, or (at your
11option) any later version.
12
13The GNU MP Library is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16License for more details.
17
18You should have received a copy of the GNU Library General Public License
19along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22/*
23 INPUT PARAMETERS
24 res_ptr (sp + 4)
25 s1_ptr (sp + 8)
26 size (sp + 12)
27 s2_limb (sp + 16)
28*/
29
30#include "asm-syntax.h"
31
32 TEXT
33 ALIGN
34 GLOBL ___mpn_submul_1
35
36LAB(___mpn_submul_1)
37
38#define res_ptr a0
39#define s1_ptr a1
40#define size d2
41#define s2_limb d4
42
43/* Save used registers on the stack. */
44 INSN2(movem,l ,MEM_PREDEC(sp),d2-d5)
45
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))
51
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) */
59
60LAB(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(sub,l ,MEM_POSTINC(res_ptr),d3)
66LAB(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(sub,l ,MEM_POSTINC(res_ptr),d3)
71
72 dbf size,Loop
73 INSN2(addx,l ,d0,d5)
74 INSN2(sub,l ,size,#0x10000)
75 bcc Loop
76
77/* Restore used registers from stack frame. */
78 INSN2(movem,l ,d2-d5,MEM_POSTINC(sp))
79
80 rts