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