source: trunk/minix/lib/float/shifter.c@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.1 KB
Line 
1/*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4*/
5
6/* $Header: /cvsup/minix/src/lib/float/shifter.c,v 1.1.1.1 2005/04/21 14:56:11 beng Exp $ */
7
8# include "FP_types.h"
9
10void
11b64_sft(e1,n)
12B64 *e1;
13int n;
14{
15 if (n > 0) {
16 if (n > 63) {
17 e1->l_32 = 0;
18 e1->h_32 = 0;
19 return;
20 }
21 if (n >= 32) {
22 e1->l_32 = e1->h_32;
23 e1->h_32 = 0;
24 n -= 32;
25 }
26 if (n > 0) {
27 e1->l_32 >>= n;
28 if (e1->h_32 != 0) {
29 e1->l_32 |= (e1->h_32 << (32 - n));
30 e1->h_32 >>= n;
31 }
32 }
33 return;
34 }
35 n = -n;
36 if (n > 0) {
37 if (n > 63) {
38 e1->l_32 = 0;
39 e1->h_32 = 0;
40 return;
41 }
42 if (n >= 32) {
43 e1->h_32 = e1->l_32;
44 e1->l_32 = 0;
45 n -= 32;
46 }
47 if (n > 0) {
48 e1->h_32 <<= n;
49 if (e1->l_32 != 0) {
50 e1->h_32 |= (e1->l_32 >> (32 - n));
51 e1->l_32 <<= n;
52 }
53 }
54 }
55}
56
57void
58b64_lsft(e1)
59B64 *e1;
60{
61 /* shift left 1 bit */
62 e1->h_32 <<= 1;
63 if (e1->l_32 & 0x80000000L) e1->h_32 |= 1;
64 e1->l_32 <<= 1;
65}
66
67void
68b64_rsft(e1)
69B64 *e1;
70{
71 /* shift right 1 bit */
72 e1->l_32 >>= 1;
73 if (e1->h_32 & 1) e1->l_32 |= 0x80000000L;
74 e1->h_32 >>= 1;
75}
Note: See TracBrowser for help on using the repository browser.