1 /*---------------------------------------------------------------------------+
4 | Set FPU register tags. |
7 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
8 | E-mail billm@jacobi.maths.monash.edu.au |
11 +---------------------------------------------------------------------------*/
14 #include "fpu_system.h"
15 #include "exception.h"
19 fpu_tag_word
|= 3 << ((top
& 7) * 2);
25 return (fpu_tag_word
>> ((top
& 7) * 2)) & 3;
28 int FPU_gettagi(int stnr
)
30 return (fpu_tag_word
>> (((top
+ stnr
) & 7) * 2)) & 3;
33 int FPU_gettag(int regnr
)
35 return (fpu_tag_word
>> ((regnr
& 7) * 2)) & 3;
38 void FPU_settag0(int tag
)
42 fpu_tag_word
&= ~(3 << (regnr
* 2));
43 fpu_tag_word
|= (tag
& 3) << (regnr
* 2);
46 void FPU_settagi(int stnr
, int tag
)
48 int regnr
= stnr
+ top
;
50 fpu_tag_word
&= ~(3 << (regnr
* 2));
51 fpu_tag_word
|= (tag
& 3) << (regnr
* 2);
54 void FPU_settag(int regnr
, int tag
)
57 fpu_tag_word
&= ~(3 << (regnr
* 2));
58 fpu_tag_word
|= (tag
& 3) << (regnr
* 2);
61 int FPU_Special(FPU_REG
const *ptr
)
63 int exp
= exponent(ptr
);
65 if (exp
== EXP_BIAS
+ EXP_UNDER
)
67 else if (exp
!= EXP_BIAS
+ EXP_OVER
)
69 else if ((ptr
->sigh
== 0x80000000) && (ptr
->sigl
== 0))
74 int isNaN(FPU_REG
const *ptr
)
76 return ((exponent(ptr
) == EXP_BIAS
+ EXP_OVER
)
77 && !((ptr
->sigh
== 0x80000000) && (ptr
->sigl
== 0)));
80 int FPU_empty_i(int stnr
)
82 int regnr
= (top
+ stnr
) & 7;
84 return ((fpu_tag_word
>> (regnr
* 2)) & 3) == TAG_Empty
;
87 int FPU_stackoverflow(FPU_REG
** st_new_ptr
)
89 *st_new_ptr
= &st(-1);
91 return ((fpu_tag_word
>> (((top
- 1) & 7) * 2)) & 3) != TAG_Empty
;
94 void FPU_copy_to_regi(FPU_REG
const *r
, u_char tag
, int stnr
)
96 reg_copy(r
, &st(stnr
));
97 FPU_settagi(stnr
, tag
);
100 void FPU_copy_to_reg1(FPU_REG
const *r
, u_char tag
)
106 void FPU_copy_to_reg0(FPU_REG
const *r
, u_char tag
)
113 fpu_tag_word
&= ~(3 << (regnr
* 2));
114 fpu_tag_word
|= (tag
& 3) << (regnr
* 2);