Blame mpn/m68k/aors_n.asm

Packit 5c3484
dnl  mc68020 mpn_add_n, mpn_sub_n -- add or subtract limb vectors
Packit 5c3484
Packit 5c3484
dnl  Copyright 1992, 1994, 1996, 1999-2003, 2005 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
dnl  This file is part of the GNU MP Library.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
dnl  it under the terms of either:
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU Lesser General Public License as published by the Free
Packit 5c3484
dnl      Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
dnl      option) any later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU General Public License as published by the Free Software
Packit 5c3484
dnl      Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
dnl      later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or both in parallel, as here.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
dnl  for more details.
Packit 5c3484
dnl
Packit 5c3484
dnl  You should have received copies of the GNU General Public License and the
Packit 5c3484
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
dnl  see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
include(`../config.m4')
Packit 5c3484
Packit 5c3484
C         cycles/limb
Packit 5c3484
C 68040:      6
Packit 5c3484
Packit 5c3484
ifdef(`OPERATION_add_n',`
Packit 5c3484
  define(M4_inst,       addxl)
Packit 5c3484
  define(M4_function_n, mpn_add_n)
Packit 5c3484
',`ifdef(`OPERATION_sub_n',`
Packit 5c3484
  define(M4_inst,       subxl)
Packit 5c3484
  define(M4_function_n, mpn_sub_n)
Packit 5c3484
',
Packit 5c3484
`m4_error(`Need OPERATION_add_n or OPERATION_sub_n
Packit 5c3484
')')')
Packit 5c3484
Packit 5c3484
MULFUNC_PROLOGUE(mpn_add_n mpn_sub_n)
Packit 5c3484
Packit 5c3484
Packit 5c3484
C INPUT PARAMETERS
Packit 5c3484
C res_ptr	(sp + 4)
Packit 5c3484
C s1_ptr	(sp + 8)
Packit 5c3484
C s2_ptr	(sp + 12)
Packit 5c3484
C size		(sp + 16)
Packit 5c3484
Packit 5c3484
Packit 5c3484
PROLOGUE(M4_function_n)
Packit 5c3484
Packit 5c3484
C Save used registers on the stack.
Packit 5c3484
	movel	d2, M(-,sp)
Packit 5c3484
	movel	a2, M(-,sp)
Packit 5c3484
Packit 5c3484
C Copy the arguments to registers.  Better use movem?
Packit 5c3484
	movel	M(sp,12), a2
Packit 5c3484
	movel	M(sp,16), a0
Packit 5c3484
	movel	M(sp,20), a1
Packit 5c3484
	movel	M(sp,24), d2
Packit 5c3484
Packit 5c3484
	eorw	#1, d2
Packit 5c3484
	lsrl	#1, d2
Packit 5c3484
	bcc	L(L1)
Packit 5c3484
	subql	#1, d2	C clears cy as side effect
Packit 5c3484
Packit 5c3484
L(Loop):
Packit 5c3484
	movel	M(a0,+), d0
Packit 5c3484
	movel	M(a1,+), d1
Packit 5c3484
	M4_inst	d1, d0
Packit 5c3484
	movel	d0, M(a2,+)
Packit 5c3484
L(L1):	movel	M(a0,+), d0
Packit 5c3484
	movel	M(a1,+), d1
Packit 5c3484
	M4_inst	d1, d0
Packit 5c3484
	movel	d0, M(a2,+)
Packit 5c3484
Packit 5c3484
	dbf	d2, L(Loop)		C loop until 16 lsb of %4 == -1
Packit 5c3484
	subxl	d0, d0			C d0 <= -cy; save cy as 0 or -1 in d0
Packit 5c3484
	subl	#0x10000, d2
Packit 5c3484
	bcs	L(L2)
Packit 5c3484
	addl	d0, d0			C restore cy
Packit 5c3484
	bra	L(Loop)
Packit 5c3484
Packit 5c3484
L(L2):
Packit 5c3484
	negl	d0
Packit 5c3484
Packit 5c3484
C Restore used registers from stack frame.
Packit 5c3484
	movel	M(sp,+), a2
Packit 5c3484
	movel	M(sp,+), d2
Packit 5c3484
Packit 5c3484
	rts
Packit 5c3484
Packit 5c3484
EPILOGUE(M4_function_n)