OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / nbench / emfloat.h
1
2 /*
3 ** emfloat.h
4 ** Header for emfloat.c
5 **
6 ** BYTEmark (tm)
7 ** BYTE Magazine's Native Mode benchmarks
8 ** Rick Grehan, BYTE Magazine
9 **
10 ** Create:
11 ** Revision: 3/95
12 **
13 ** DISCLAIMER
14 ** The source, executable, and documentation files that comprise
15 ** the BYTEmark benchmarks are made available on an "as is" basis.
16 ** This means that we at BYTE Magazine have made every reasonable
17 ** effort to verify that the there are no errors in the source and
18 ** executable code.  We cannot, however, guarantee that the programs
19 ** are error-free.  Consequently, McGraw-HIll and BYTE Magazine make
20 ** no claims in regard to the fitness of the source code, executable
21 ** code, and documentation of the BYTEmark.
22 **  Furthermore, BYTE Magazine, McGraw-Hill, and all employees
23 ** of McGraw-Hill cannot be held responsible for any damages resulting
24 ** from the use of this code or the results obtained from using
25 ** this code.
26 */
27
28 #include <stdio.h>
29
30 /* Is this a 64 bit architecture? If so, this will define LONG64 */
31 /* Uwe F. Mayer 15 November 1997                                 */
32 #include "pointer.h"
33
34 /*
35 ** DEFINES
36 */
37 #define u8 unsigned char
38 #define u16 unsigned short
39 #ifdef LONG64
40 #define u32 unsigned int
41 #else
42 #define u32 unsigned long
43 #endif
44 #define uchar unsigned char
45 #define ulong unsigned long
46
47 #define MAX_EXP 32767L
48 #define MIN_EXP (-32767L)
49
50 #define IFPF_IS_ZERO 0
51 #define IFPF_IS_SUBNORMAL 1
52 #define IFPF_IS_NORMAL 2
53 #define IFPF_IS_INFINITY 3
54 #define IFPF_IS_NAN 4
55 #define IFPF_TYPE_COUNT 5
56
57 #define ZERO_ZERO                       0
58 #define ZERO_SUBNORMAL                  1
59 #define ZERO_NORMAL                     2
60 #define ZERO_INFINITY                   3
61 #define ZERO_NAN                        4
62
63 #define SUBNORMAL_ZERO                  5
64 #define SUBNORMAL_SUBNORMAL             6
65 #define SUBNORMAL_NORMAL                7
66 #define SUBNORMAL_INFINITY              8
67 #define SUBNORMAL_NAN                   9
68
69 #define NORMAL_ZERO                     10
70 #define NORMAL_SUBNORMAL                11
71 #define NORMAL_NORMAL                   12
72 #define NORMAL_INFINITY                 13
73 #define NORMAL_NAN                      14
74
75 #define INFINITY_ZERO                   15
76 #define INFINITY_SUBNORMAL              16
77 #define INFINITY_NORMAL                 17
78 #define INFINITY_INFINITY               18
79 #define INFINITY_NAN                    19
80
81 #define NAN_ZERO                        20
82 #define NAN_SUBNORMAL                   21
83 #define NAN_NORMAL                      22
84 #define NAN_INFINITY                    23
85 #define NAN_NAN                         24
86 #define OPERAND_ZERO                    0
87 #define OPERAND_SUBNORMAL               1
88 #define OPERAND_NORMAL                  2
89 #define OPERAND_INFINITY                3
90 #define OPERAND_NAN                     4
91
92 /*
93 ** Following already defined in NMGLOBAL.H
94 **
95 #define INTERNAL_FPF_PRECISION 4
96 */
97
98 /*
99 ** TYPEDEFS
100 */
101
102 typedef struct
103 {
104         u8 type;        /* Indicates, NORMAL, SUBNORMAL, etc. */
105         u8 sign;        /* Mantissa sign */
106         short exp;      /* Signed exponent...no bias */
107         u16 mantissa[INTERNAL_FPF_PRECISION];
108 } InternalFPF;
109
110 /*
111 ** PROTOTYPES
112 */
113 void SetupCPUEmFloatArrays(InternalFPF *abase,
114         InternalFPF *bbase, InternalFPF *cbase, ulong arraysize);
115 ulong DoEmFloatIteration(InternalFPF *abase,
116         InternalFPF *bbase, InternalFPF *cbase,
117         ulong arraysize, ulong loops);
118 static void SetInternalFPFZero(InternalFPF *dest,
119                         uchar sign);
120 static void SetInternalFPFInfinity(InternalFPF *dest,
121                         uchar sign);
122 static void SetInternalFPFNaN(InternalFPF *dest);
123 static int IsMantissaZero(u16 *mant);
124 static void Add16Bits(u16 *carry,u16 *a,u16 b,u16 c);
125 static void Sub16Bits(u16 *borrow,u16 *a,u16 b,u16 c);
126 static void ShiftMantLeft1(u16 *carry,u16 *mantissa);
127 static void ShiftMantRight1(u16 *carry,u16 *mantissa);
128 static void StickyShiftRightMant(InternalFPF *ptr,int amount);
129 static void normalize(InternalFPF *ptr);
130 static void denormalize(InternalFPF *ptr,int minimum_exponent);
131 void RoundInternalFPF(InternalFPF *ptr);
132 static void choose_nan(InternalFPF *x,InternalFPF *y,InternalFPF *z,
133                 int intel_flag);
134 static void AddSubInternalFPF(uchar operation,InternalFPF *x,
135                 InternalFPF *y,InternalFPF *z);
136 static void MultiplyInternalFPF(InternalFPF *x,InternalFPF *y,
137                         InternalFPF *z);
138 static void DivideInternalFPF(InternalFPF *x,InternalFPF *y, 
139                         InternalFPF *z);
140 /* static void LongToInternalFPF(long mylong, */
141 static void Int32ToInternalFPF(int32 mylong,
142                 InternalFPF *dest);
143 #ifdef DEBUG
144 static int InternalFPFToString(char *dest,
145                 InternalFPF *src);
146 #endif
147
148 /*
149 ** EXTERNALS
150 */
151 extern ulong StartStopwatch();
152 extern ulong StopStopwatch(ulong elapsed);
153 /* extern long randwc(long num); */
154 extern int32 randwc(int32 num);