17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57257d1b4Sraf * Common Development and Distribution License (the "License"). 67257d1b4Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217257d1b4Sraf 227257d1b4Sraf/* 237257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247257d1b4Sraf * Use is subject to license terms. 257257d1b4Sraf */ 267257d1b4Sraf 277c478bd9Sstevel@tonic-gate/* Copyright (c) 1988 AT&T */ 287c478bd9Sstevel@tonic-gate/* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 30*9a70fc3bSMark J. Nelson .file "lshiftl.s" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate/* 337c478bd9Sstevel@tonic-gate * Shift a double long value. Ported from m32 version to sparc. 347c478bd9Sstevel@tonic-gate * 357c478bd9Sstevel@tonic-gate * dl_t 367c478bd9Sstevel@tonic-gate * lshiftl (op, cnt) 377c478bd9Sstevel@tonic-gate * dl_t op; 387c478bd9Sstevel@tonic-gate * int cnt; 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate 417257d1b4Sraf#include "SYS.h" 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate ENTRY(lshiftl) 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate ld [%o7+8],%o4 ! Instruction at ret-addr should be a 467c478bd9Sstevel@tonic-gate cmp %o4,8 ! 'unimp 8' indicating a valid call. 477c478bd9Sstevel@tonic-gate be 1f ! if OK, go forward. 487c478bd9Sstevel@tonic-gate nop ! delay instruction. 497c478bd9Sstevel@tonic-gate jmp %o7+8 ! return 507c478bd9Sstevel@tonic-gate nop ! delay instruction. 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate1: 537c478bd9Sstevel@tonic-gate ld [%o0+0],%o2 ! fetch op.dl_hop 547c478bd9Sstevel@tonic-gate ld [%o0+4],%o3 ! fetch op.dl_lop 557c478bd9Sstevel@tonic-gate subcc %g0,%o1,%o4 ! test cnt < 0 and save reciprocol 567c478bd9Sstevel@tonic-gate bz .done 577c478bd9Sstevel@tonic-gate ld [%sp+(16*4)],%o0 ! address to store result into 587c478bd9Sstevel@tonic-gate bg .right ! 597c478bd9Sstevel@tonic-gate nop 607c478bd9Sstevel@tonic-gate ! Positive (or null) shift (left) 617c478bd9Sstevel@tonic-gate and %o1,0x3f,%o1 ! Reduce range to 0..63 627c478bd9Sstevel@tonic-gate subcc %o1,32,%o5 ! cnt - 32 (also test cnt >= 32) 637c478bd9Sstevel@tonic-gate bneg,a .leftsmall ! 647c478bd9Sstevel@tonic-gate add %o4,32,%o4 ! 32 - cnt (actually ((-cnt) + 32) 657c478bd9Sstevel@tonic-gate sll %o3,%o5,%o2 ! R.h = R.l << (cnt - 32) 667c478bd9Sstevel@tonic-gate ba .done ! 677c478bd9Sstevel@tonic-gate or %g0,%g0,%o3 ! R.l = 0 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate.leftsmall: 707c478bd9Sstevel@tonic-gate srl %o3,%o4,%o5 ! temp = R.l >> (31 - cnt) 717c478bd9Sstevel@tonic-gate sll %o3,%o1,%o3 ! R.l = R.l << cnt 727c478bd9Sstevel@tonic-gate sll %o2,%o1,%o2 ! R.h = R.h << cnt 737c478bd9Sstevel@tonic-gate ba .done ! 747c478bd9Sstevel@tonic-gate or %o2,%o5,%o2 ! R.h = R.h | temp 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate.right: ! Negative shift (right) 777c478bd9Sstevel@tonic-gate and %o4,0x3f,%o4 ! Reduce range to 0..63 787c478bd9Sstevel@tonic-gate subcc %o4,32,%o5 ! cnt - 32 (also test cnt >= 32) 797c478bd9Sstevel@tonic-gate bneg,a .rightsmall ! 807c478bd9Sstevel@tonic-gate add %o1,32,%o1 ! 32 - cnt (actually ((-cnt) + 32) 817c478bd9Sstevel@tonic-gate srl %o2,%o5,%o3 ! R.l = R.h >> (cnt - 32) 827c478bd9Sstevel@tonic-gate ba .done ! 837c478bd9Sstevel@tonic-gate or %g0,%g0,%o2 ! R.h = 0 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate.rightsmall: 867c478bd9Sstevel@tonic-gate sll %o2,%o1,%o5 ! temp = R.h << (31 - cnt) 877c478bd9Sstevel@tonic-gate srl %o3,%o4,%o3 ! R.l = R.l >> cnt 887c478bd9Sstevel@tonic-gate srl %o2,%o4,%o2 ! R.h = R.h >> cnt 897c478bd9Sstevel@tonic-gate ba .done ! 907c478bd9Sstevel@tonic-gate or %o3,%o5,%o3 ! R.l = R.l | temp 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate.done: 937c478bd9Sstevel@tonic-gate st %o2,[%o0+0] ! store result, dl_hop 947c478bd9Sstevel@tonic-gate jmp %o7+12 ! return 957c478bd9Sstevel@tonic-gate st %o3,[%o0+4] ! store result, dl_lop 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate SET_SIZE(lshiftl) 98