xref: /titanic_41/usr/src/lib/libc/sparc/gen/lshiftl.s (revision 450396635f70344c58b6b1e4db38cf17ff34445c)
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	.file	"lshiftl.s"
31
32/*
33 * Shift a double long value. Ported from m32 version to sparc.
34 *
35 *	dl_t
36 *	lshiftl (op, cnt)
37 *		dl_t	op;
38 *		int	cnt;
39 */
40
41#include "SYS.h"
42
43	ENTRY(lshiftl)
44
45	ld	[%o7+8],%o4		! Instruction at ret-addr should be a
46	cmp     %o4,8			! 'unimp 8' indicating a valid call.
47	be	1f			! if OK, go forward.
48	nop				! delay instruction.
49	jmp	%o7+8			! return
50	nop				! delay instruction.
51
521:
53	ld	[%o0+0],%o2		! fetch op.dl_hop
54	ld	[%o0+4],%o3		! fetch op.dl_lop
55	subcc	%g0,%o1,%o4		! test cnt < 0 and save reciprocol
56	bz	.done
57	ld	[%sp+(16*4)],%o0	! address to store result into
58	bg	.right			!
59	nop
60					! Positive (or null) shift (left)
61	and	%o1,0x3f,%o1		! Reduce range to 0..63
62	subcc	%o1,32,%o5		! cnt - 32 (also test cnt >= 32)
63	bneg,a	.leftsmall		!
64	add	%o4,32,%o4		! 32 - cnt (actually ((-cnt) + 32)
65	sll	%o3,%o5,%o2		! R.h = R.l << (cnt - 32)
66	ba	.done			!
67	or	%g0,%g0,%o3		! R.l = 0
68
69.leftsmall:
70	srl	%o3,%o4,%o5		! temp = R.l >> (31 - cnt)
71	sll	%o3,%o1,%o3		! R.l = R.l << cnt
72	sll	%o2,%o1,%o2		! R.h = R.h << cnt
73	ba	.done			!
74	or	%o2,%o5,%o2		! R.h = R.h | temp
75
76.right:					! Negative shift (right)
77	and	%o4,0x3f,%o4		! Reduce range to 0..63
78	subcc	%o4,32,%o5		! cnt - 32 (also test cnt >= 32)
79	bneg,a	.rightsmall		!
80	add	%o1,32,%o1		! 32 - cnt (actually ((-cnt) + 32)
81	srl	%o2,%o5,%o3		! R.l = R.h >> (cnt - 32)
82	ba	.done			!
83	or	%g0,%g0,%o2		! R.h = 0
84
85.rightsmall:
86	sll	%o2,%o1,%o5		! temp = R.h << (31 - cnt)
87	srl	%o3,%o4,%o3		! R.l = R.l >> cnt
88	srl	%o2,%o4,%o2		! R.h = R.h >> cnt
89	ba	.done			!
90	or	%o3,%o5,%o3		! R.l = R.l | temp
91
92.done:
93	st	%o2,[%o0+0]		! store result, dl_hop
94	jmp	%o7+12			! return
95	st	%o3,[%o0+4]		! store result, dl_lop
96
97	SET_SIZE(lshiftl)
98