hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/m68k/m680x0/sub_n.S

Packit 6c4009
/* mc68020 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
Packit 6c4009
   store difference in a third limb vector.
Packit 6c4009
Packit 6c4009
Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit 6c4009
Packit 6c4009
This file is part of the GNU MP Library.
Packit 6c4009
Packit 6c4009
The GNU MP Library is free software; you can redistribute it and/or modify
Packit 6c4009
it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
the Free Software Foundation; either version 2.1 of the License, or (at your
Packit 6c4009
option) any later version.
Packit 6c4009
Packit 6c4009
The GNU MP Library is distributed in the hope that it will be useful, but
Packit 6c4009
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 6c4009
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit 6c4009
License for more details.
Packit 6c4009
Packit 6c4009
You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
along with the GNU MP Library.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
  INPUT PARAMETERS
Packit 6c4009
  res_ptr	(sp + 4)
Packit 6c4009
  s1_ptr	(sp + 8)
Packit 6c4009
  s2_ptr	(sp + 16)
Packit 6c4009
  size		(sp + 12)
Packit 6c4009
*/
Packit 6c4009
Packit 6c4009
#include "sysdep.h"
Packit 6c4009
#include "asm-syntax.h"
Packit 6c4009
Packit 6c4009
	TEXT
Packit 6c4009
ENTRY(__mpn_sub_n)
Packit 6c4009
/* Save used registers on the stack.  */
Packit 6c4009
	movel	R(d2),MEM_PREDEC(sp)
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
	movel	R(a2),MEM_PREDEC(sp)
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
	cfi_rel_offset (R(d2), 4)
Packit 6c4009
	cfi_rel_offset (R(a2), 0)
Packit 6c4009
Packit 6c4009
/* Copy the arguments to registers.  Better use movem?  */
Packit 6c4009
	movel	MEM_DISP(sp,12),R(a2)
Packit 6c4009
	movel	MEM_DISP(sp,16),R(a0)
Packit 6c4009
	movel	MEM_DISP(sp,20),R(a1)
Packit 6c4009
	movel	MEM_DISP(sp,24),R(d2)
Packit 6c4009
Packit 6c4009
	eorw	#1,R(d2)
Packit 6c4009
	lsrl	#1,R(d2)
Packit 6c4009
	bcc	L(L1)
Packit 6c4009
	subql	#1,R(d2)	/* clears cy as side effect */
Packit 6c4009
Packit 6c4009
L(Loop:)
Packit 6c4009
	movel	MEM_POSTINC(a0),R(d0)
Packit 6c4009
	movel	MEM_POSTINC(a1),R(d1)
Packit 6c4009
	subxl	R(d1),R(d0)
Packit 6c4009
	movel	R(d0),MEM_POSTINC(a2)
Packit 6c4009
L(L1:)	movel	MEM_POSTINC(a0),R(d0)
Packit 6c4009
	movel	MEM_POSTINC(a1),R(d1)
Packit 6c4009
	subxl	R(d1),R(d0)
Packit 6c4009
	movel	R(d0),MEM_POSTINC(a2)
Packit 6c4009
Packit 6c4009
	dbf	R(d2),L(Loop)		/* loop until 16 lsb of %4 == -1 */
Packit 6c4009
	subxl	R(d0),R(d0)	/* d0 <= -cy; save cy as 0 or -1 in d0 */
Packit 6c4009
	subl	#0x10000,R(d2)
Packit 6c4009
	bcs	L(L2)
Packit 6c4009
	addl	R(d0),R(d0)	/* restore cy */
Packit 6c4009
	bra	L(Loop)
Packit 6c4009
Packit 6c4009
L(L2:)
Packit 6c4009
	negl	R(d0)
Packit 6c4009
Packit 6c4009
/* Restore used registers from stack frame.  */
Packit 6c4009
	movel	MEM_POSTINC(sp),R(a2)
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (R(a2))
Packit 6c4009
	movel	MEM_POSTINC(sp),R(d2)
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (R(d2))
Packit 6c4009
Packit 6c4009
	rts
Packit 6c4009
END(__mpn_sub_n)