xref: /titanic_51/usr/src/lib/libc/sparc/gen/lsub.s (revision 7257d1b4d25bfac0c802847390e98a464fd787ac)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/*	Copyright (c) 1988 AT&T	*/
28/*	  All Rights Reserved	*/
29
30#pragma ident	"%Z%%M%	%I%	%E% SMI"
31
32	.file	"%M%"
33
34/*
35 * Double long subtraction routine.  Ported from pdp 11/70 version
36 * with considerable effort.  All supplied comments were ported.
37 * Ported from m32 version to sparc. No comments about difficulty.
38 *
39 *	dl_t
40 *	lsub (lop, rop)
41 *		dl_t	lop;
42 *		dl_t	rop;
43 */
44
45#include "SYS.h"
46
47	ENTRY(lsub)
48
49	ld	[%o7+8],%o4		! Instruction at ret-addr should be a
50	cmp     %o4,8			! 'unimp 8' indicating a valid call.
51	be	1f			! if OK, go forward.
52	nop				! delay instruction.
53	jmp	%o7+8			! return
54	nop				! delay instruction.
55
561:
57	ld	[%o0+0],%o2		! fetch lop.dl_hop
58	ld	[%o0+4],%o3		! fetch lop.dl_lop
59	ld	[%o1+0],%o4		! fetch rop.dl_hop
60	ld	[%o1+4],%o5		! fetch rop.dl_lop
61	subcc	%o3,%o5,%o3		! lop.dl_lop - rop.dl_lop (set carry)
62	subxcc	%o2,%o4,%o2		! lop.dl_hop - rop.dl_hop - <carry>
63	ld	[%sp+(16*4)],%o0	! address to store result into
64	st	%o2,[%o0]		! store result.dl_hop
65	jmp	%o7+12			! return
66	st	%o3,[%o0+4]		! store result.dl_lop
67
68	SET_SIZE(lsub)
69