4 ** Header for emfloat.c
7 ** BYTE Magazine's Native Mode benchmarks
8 ** Rick Grehan, BYTE Magazine
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
30 /* Is this a 64 bit architecture? If so, this will define LONG64 */
31 /* Uwe F. Mayer 15 November 1997 */
37 #define u8 unsigned char
38 #define u16 unsigned short
40 #define u32 unsigned int
42 #define u32 unsigned long
44 #define uchar unsigned char
45 #define ulong unsigned long
47 #define MAX_EXP 32767L
48 #define MIN_EXP (-32767L)
50 #define IFPF_IS_ZERO 0
51 #define IFPF_IS_SUBNORMAL 1
52 #define IFPF_IS_NORMAL 2
53 #define IFPF_IS_INFINITY 3
55 #define IFPF_TYPE_COUNT 5
58 #define ZERO_SUBNORMAL 1
60 #define ZERO_INFINITY 3
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
69 #define NORMAL_ZERO 10
70 #define NORMAL_SUBNORMAL 11
71 #define NORMAL_NORMAL 12
72 #define NORMAL_INFINITY 13
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
82 #define NAN_SUBNORMAL 21
84 #define NAN_INFINITY 23
86 #define OPERAND_ZERO 0
87 #define OPERAND_SUBNORMAL 1
88 #define OPERAND_NORMAL 2
89 #define OPERAND_INFINITY 3
93 ** Following already defined in NMGLOBAL.H
95 #define INTERNAL_FPF_PRECISION 4
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];
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,
120 static void SetInternalFPFInfinity(InternalFPF *dest,
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,
134 static void AddSubInternalFPF(uchar operation,InternalFPF *x,
135 InternalFPF *y,InternalFPF *z);
136 static void MultiplyInternalFPF(InternalFPF *x,InternalFPF *y,
138 static void DivideInternalFPF(InternalFPF *x,InternalFPF *y,
140 /* static void LongToInternalFPF(long mylong, */
141 static void Int32ToInternalFPF(int32 mylong,
144 static int InternalFPFToString(char *dest,
151 extern ulong StartStopwatch();
152 extern ulong StopStopwatch(ulong elapsed);
153 /* extern long randwc(long num); */
154 extern int32 randwc(int32 num);