xref: /onnv-gate/usr/src/lib/libc/sparc/gen/lsub.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216812Sraf
226812Sraf/*
236812Sraf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
246812Sraf * Use is subject to license terms.
256812Sraf */
266812Sraf
270Sstevel@tonic-gate/*	Copyright (c) 1988 AT&T	*/
280Sstevel@tonic-gate/*	  All Rights Reserved	*/
290Sstevel@tonic-gate
30*7298SMark.J.Nelson@Sun.COM	.file	"lsub.s"
310Sstevel@tonic-gate
320Sstevel@tonic-gate/*
330Sstevel@tonic-gate * Double long subtraction routine.  Ported from pdp 11/70 version
340Sstevel@tonic-gate * with considerable effort.  All supplied comments were ported.
350Sstevel@tonic-gate * Ported from m32 version to sparc. No comments about difficulty.
360Sstevel@tonic-gate *
370Sstevel@tonic-gate *	dl_t
380Sstevel@tonic-gate *	lsub (lop, rop)
390Sstevel@tonic-gate *		dl_t	lop;
400Sstevel@tonic-gate *		dl_t	rop;
410Sstevel@tonic-gate */
420Sstevel@tonic-gate
436812Sraf#include "SYS.h"
440Sstevel@tonic-gate
450Sstevel@tonic-gate	ENTRY(lsub)
460Sstevel@tonic-gate
470Sstevel@tonic-gate	ld	[%o7+8],%o4		! Instruction at ret-addr should be a
480Sstevel@tonic-gate	cmp     %o4,8			! 'unimp 8' indicating a valid call.
490Sstevel@tonic-gate	be	1f			! if OK, go forward.
500Sstevel@tonic-gate	nop				! delay instruction.
510Sstevel@tonic-gate	jmp	%o7+8			! return
520Sstevel@tonic-gate	nop				! delay instruction.
530Sstevel@tonic-gate
540Sstevel@tonic-gate1:
550Sstevel@tonic-gate	ld	[%o0+0],%o2		! fetch lop.dl_hop
560Sstevel@tonic-gate	ld	[%o0+4],%o3		! fetch lop.dl_lop
570Sstevel@tonic-gate	ld	[%o1+0],%o4		! fetch rop.dl_hop
580Sstevel@tonic-gate	ld	[%o1+4],%o5		! fetch rop.dl_lop
590Sstevel@tonic-gate	subcc	%o3,%o5,%o3		! lop.dl_lop - rop.dl_lop (set carry)
600Sstevel@tonic-gate	subxcc	%o2,%o4,%o2		! lop.dl_hop - rop.dl_hop - <carry>
610Sstevel@tonic-gate	ld	[%sp+(16*4)],%o0	! address to store result into
620Sstevel@tonic-gate	st	%o2,[%o0]		! store result.dl_hop
630Sstevel@tonic-gate	jmp	%o7+12			! return
640Sstevel@tonic-gate	st	%o3,[%o0+4]		! store result.dl_lop
650Sstevel@tonic-gate
660Sstevel@tonic-gate	SET_SIZE(lsub)
67