xref: /titanic_50/usr/src/lib/libc/sparc/gen/lshiftl.s (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
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, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*	Copyright (c) 1988 AT&T	*/
23/*	  All Rights Reserved	*/
24
25
26/*       Copyright (c) 1989 by Sun Microsystems, Inc.		*/
27
28.ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
29
30/*
31 * Shift a double long value. Ported from m32 version to sparc.
32 *
33 *	dl_t
34 *	lshiftl (op, cnt)
35 *		dl_t	op;
36 *		int	cnt;
37 */
38
39	.file	"lshiftl.s"
40
41#include <sys/asm_linkage.h>
42
43	ANSI_PRAGMA_WEAK(lshiftl,function)
44
45#include "synonyms.h"
46
47
48	ENTRY(lshiftl)
49
50	ld	[%o7+8],%o4		! Instruction at ret-addr should be a
51	cmp     %o4,8			! 'unimp 8' indicating a valid call.
52	be	1f			! if OK, go forward.
53	nop				! delay instruction.
54	jmp	%o7+8			! return
55	nop				! delay instruction.
56
571:
58	ld	[%o0+0],%o2		! fetch op.dl_hop
59	ld	[%o0+4],%o3		! fetch op.dl_lop
60	subcc	%g0,%o1,%o4		! test cnt < 0 and save reciprocol
61	bz	.done
62	ld	[%sp+(16*4)],%o0	! address to store result into
63	bg	.right			!
64	nop
65					! Positive (or null) shift (left)
66	and	%o1,0x3f,%o1		! Reduce range to 0..63
67	subcc	%o1,32,%o5		! cnt - 32 (also test cnt >= 32)
68	bneg,a	.leftsmall		!
69	add	%o4,32,%o4		! 32 - cnt (actually ((-cnt) + 32)
70	sll	%o3,%o5,%o2		! R.h = R.l << (cnt - 32)
71	ba	.done			!
72	or	%g0,%g0,%o3		! R.l = 0
73
74.leftsmall:
75	srl	%o3,%o4,%o5		! temp = R.l >> (31 - cnt)
76	sll	%o3,%o1,%o3		! R.l = R.l << cnt
77	sll	%o2,%o1,%o2		! R.h = R.h << cnt
78	ba	.done			!
79	or	%o2,%o5,%o2		! R.h = R.h | temp
80
81.right:					! Negative shift (right)
82	and	%o4,0x3f,%o4		! Reduce range to 0..63
83	subcc	%o4,32,%o5		! cnt - 32 (also test cnt >= 32)
84	bneg,a	.rightsmall		!
85	add	%o1,32,%o1		! 32 - cnt (actually ((-cnt) + 32)
86	srl	%o2,%o5,%o3		! R.l = R.h >> (cnt - 32)
87	ba	.done			!
88	or	%g0,%g0,%o2		! R.h = 0
89
90.rightsmall:
91	sll	%o2,%o1,%o5		! temp = R.h << (31 - cnt)
92	srl	%o3,%o4,%o3		! R.l = R.l >> cnt
93	srl	%o2,%o4,%o2		! R.h = R.h >> cnt
94	ba	.done			!
95	or	%o3,%o5,%o3		! R.l = R.l | temp
96
97.done:
98	st	%o2,[%o0+0]		! store result, dl_hop
99	jmp	%o7+12			! return
100	st	%o3,[%o0+4]		! store result, dl_lop
101
102	SET_SIZE(lshiftl)
103