xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/m68k/mc68020/mul_1.asm (revision ce54336801cf28877c3414aa2fcb251dddd543a2)
1dnl  mc68020 mpn_mul_1 -- mpn by limb multiply
2
3dnl  Copyright 1992, 1994, 1996, 1999-2002 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C         cycles/limb
34C 68040:     24
35
36C INPUT PARAMETERS
37C res_ptr	(sp + 4)
38C s1_ptr	(sp + 8)
39C s1_size	(sp + 12)
40C s2_limb	(sp + 16)
41
42
43define(res_ptr, `a0')
44define(s1_ptr,  `a1')
45define(s1_size, `d2')
46define(s2_limb, `d4')
47
48
49PROLOGUE(mpn_mul_1)
50
51C Save used registers on the stack.
52	moveml	d2-d4, M(-,sp)
53
54C	movel	d2, M(-,sp)
55C	movel	d3, M(-,sp)
56C	movel	d4, M(-,sp)
57
58C Copy the arguments to registers.  Better use movem?
59	movel	M(sp,16), res_ptr
60	movel	M(sp,20), s1_ptr
61	movel	M(sp,24), s1_size
62	movel	M(sp,28), s2_limb
63
64	eorw	#1, s1_size
65	clrl	d1
66	lsrl	#1, s1_size
67	bcc	L(L1)
68	subql	#1, s1_size
69	subl	d0, d0		C (d0,cy) <= (0,0)
70
71L(Loop):
72	movel	M(s1_ptr,+), d3
73	mulul	s2_limb, d1:d3
74	addxl	d0, d3
75	movel	d3, M(res_ptr,+)
76L(L1):	movel	M(s1_ptr,+), d3
77	mulul	s2_limb, d0:d3
78	addxl	d1, d3
79	movel	d3, M(res_ptr,+)
80
81	dbf	s1_size, L(Loop)
82	clrl	d3
83	addxl	d3, d0
84	subl	#0x10000, s1_size
85	bcc	L(Loop)
86
87C Restore used registers from stack frame.
88	moveml	M(sp,+), d2-d4
89
90C	movel	M(sp,+),d4
91C	movel	M(sp,+),d3
92C	movel	M(sp,+),d2
93
94	rts
95
96EPILOGUE(mpn_mul_1)
97