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"
20 fpu_tag_word |= 3 << ((top & 7)*2);
27 return (fpu_tag_word >> ((top & 7)*2)) & 3;
31 int FPU_gettagi(int stnr)
33 return (fpu_tag_word >> (((top+stnr) & 7)*2)) & 3;
37 int FPU_gettag(int regnr)
39 return (fpu_tag_word >> ((regnr & 7)*2)) & 3;
43 void FPU_settag0(int tag)
47 fpu_tag_word &= ~(3 << (regnr*2));
48 fpu_tag_word |= (tag & 3) << (regnr*2);
52 void FPU_settagi(int stnr, int tag)
56 fpu_tag_word &= ~(3 << (regnr*2));
57 fpu_tag_word |= (tag & 3) << (regnr*2);
61 void FPU_settag(int regnr, int tag)
64 fpu_tag_word &= ~(3 << (regnr*2));
65 fpu_tag_word |= (tag & 3) << (regnr*2);
69 int FPU_Special(FPU_REG const *ptr)
71 int exp = exponent(ptr);
73 if ( exp == EXP_BIAS+EXP_UNDER )
75 else if ( exp != EXP_BIAS+EXP_OVER )
77 else if ( (ptr->sigh == 0x80000000) && (ptr->sigl == 0) )
83 int isNaN(FPU_REG const *ptr)
85 return ( (exponent(ptr) == EXP_BIAS+EXP_OVER)
86 && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)) );
90 int FPU_empty_i(int stnr)
92 int regnr = (top+stnr) & 7;
94 return ((fpu_tag_word >> (regnr*2)) & 3) == TAG_Empty;
98 int FPU_stackoverflow(FPU_REG **st_new_ptr)
100 *st_new_ptr = &st(-1);
102 return ((fpu_tag_word >> (((top - 1) & 7)*2)) & 3) != TAG_Empty;
106 void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr)
108 reg_copy(r, &st(stnr));
109 FPU_settagi(stnr, tag);
112 void FPU_copy_to_reg1(FPU_REG const *r, u_char tag)
118 void FPU_copy_to_reg0(FPU_REG const *r, u_char tag)
125 fpu_tag_word &= ~(3 << (regnr*2));
126 fpu_tag_word |= (tag & 3) << (regnr*2);