|
|
1.1 root 1: /*---------------------------------------------------------------------------+
2: | fpu_emu.h |
3: | |
4: | Copyright (C) 1992 W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
5: | Australia. E-mail [email protected] |
6: | |
7: +---------------------------------------------------------------------------*/
8:
9:
10: #ifndef _FPU_EMU_H_
11: #define _FPU_EMU_H_
12:
13: #ifdef __ASSEMBLER__
14: #include "fpu_asm.h"
15: #define Const(x) $##x
16: #else
17: #define Const(x) x
18: #endif
19:
20: #define EXP_BIAS Const(0)
21: #define EXP_OVER Const(0x4000) /* smallest invalid large exponent */
22: /* #define EXP_MAX Const(16384) */
23: #define EXP_UNDER Const(-0x3fff) /* largest invalid small exponent */
24: /* #define EXP_MIN Const(-16384) */
25:
26: #define SIGN_POS Const(0)
27: #define SIGN_NEG Const(1)
28:
29: /* Keep the order TW_Valid, TW_Zero, TW_Denormal */
30: #define TW_Valid Const(0) /* valid */
31: #define TW_Zero Const(1) /* zero */
32: /* The following fold to 2 (Special) in the Tag Word */
33: #define TW_Denormal Const(4) /* De-normal */
34: #define TW_Infinity Const(5) /* + or - infinity */
35: #define TW_NaN Const(6) /* Not a Number */
36:
37: #define TW_Empty Const(7) /* empty */
38:
39:
40:
41: #ifndef __ASSEMBLER__
42: #ifndef COHERENT
43: #include <linux/math_emu.h>
44: #endif
45:
46: #ifdef PARANOID
47: extern char emulating;
48: # define RE_ENTRANT_CHECK_OFF emulating = 0;
49: # define RE_ENTRANT_CHECK_ON emulating = 1;
50: #else
51: # define RE_ENTRANT_CHECK_OFF
52: # define RE_ENTRANT_CHECK_ON
53: #endif PARANOID
54:
55: typedef void (*FUNC)();
56: typedef struct _fpem_reg FPU_REG;
57:
58: #define st(x) ( fpregs[((top+x) &7 )] )
59:
60: #define STACK_OVERFLOW (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
61: #define NOT_EMPTY(i) (st(i).tag != TW_Empty)
62: #define NOT_EMPTY_0 (FPU_st0_tag ^ TW_Empty)
63:
64: extern unsigned char FPU_rm;
65:
66: extern char FPU_st0_tag;
67: extern FPU_REG *FPU_st0_ptr;
68:
69: extern void *FPU_data_address;
70:
71: extern FPU_REG FPU_loaded_data;
72:
73: #define pop() { FPU_st0_ptr->tag = TW_Empty; top++; }
74:
75: /* push() does not affect the tags */
76: #define push() { top--; FPU_st0_ptr = st_new_ptr; }
77:
78:
79: #define reg_move(x, y) { \
80: *(short *)&((y)->sign) = *(short *)&((x)->sign); \
81: *(long *)&((y)->exp) = *(long *)&((x)->exp); \
82: *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
83:
84:
85: /*----- Prototypes for functions written in assembler -----*/
86: /* extern void reg_move(FPU_REG *a, FPU_REG *b); */
87:
88: extern void mul64(long long *a, long long *b, long long *result);
89: extern void poly_div2(long long *x);
90: extern void poly_div4(long long *x);
91: extern void poly_div16(long long *x);
92: extern void polynomial(unsigned accum[], unsigned x[],
93: unsigned short terms[][4], int n);
94: extern void normalize(FPU_REG *x);
95: extern void reg_div(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ);
96: extern void reg_u_sub(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ);
97: extern void reg_u_mul(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ);
98: extern void reg_u_div(long long *arg1, long long *arg2, FPU_REG *answ);
99: extern void reg_u_add(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ);
100: extern void wm_sqrt(FPU_REG *n);
101: extern unsigned shrx(void *l, unsigned x);
102: extern unsigned shrxs(void *v, unsigned x);
103: extern unsigned long div_small(unsigned long long *x, unsigned long y);
104:
105: #ifndef MAKING_PROTO
106: #include "fpu_proto.h"
107: #endif
108:
109: #endif __ASSEMBLER__
110:
111: #endif _FPU_EMU_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.