Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /*---------------------------------------------------------------------------+ | fpu_etc.c | | | | Implement a few FPU instructions. | | | | Copyright (C) 1992,1993,1994 | | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, | | Australia. E-mail billm@vaxc.cc.monash.edu.au | | | | | +---------------------------------------------------------------------------*/ #include "fpu_system.h" #include "exception.h" #include "fpu_emu.h" #include "status_w.h" #include "reg_constant.h" static void fchs(FPU_REG *st0_ptr) { if ( st0_ptr->tag ^ TW_Empty ) { st0_ptr->sign ^= SIGN_POS^SIGN_NEG; clear_C1(); } else stack_underflow(); } static void fabs(FPU_REG *st0_ptr) { if ( st0_ptr->tag ^ TW_Empty ) { st0_ptr->sign = SIGN_POS; clear_C1(); } else stack_underflow(); } static void ftst_(FPU_REG *st0_ptr) { switch (st0_ptr->tag) { case TW_Zero: setcc(SW_C3); break; case TW_Valid: if (st0_ptr->sign == SIGN_POS) setcc(0); else setcc(SW_C0); #ifdef DENORM_OPERAND if ( (st0_ptr->exp <= EXP_UNDER) && (denormal_operand()) ) { #ifdef PECULIAR_486 /* This is weird! */ if (st0_ptr->sign == SIGN_POS) setcc(SW_C3); #endif PECULIAR_486 return; } #endif DENORM_OPERAND break; case TW_NaN: setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */ EXCEPTION(EX_Invalid); break; case TW_Infinity: if (st0_ptr->sign == SIGN_POS) setcc(0); else setcc(SW_C0); break; case TW_Empty: setcc(SW_C0|SW_C2|SW_C3); EXCEPTION(EX_StackUnder); break; default: setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */ EXCEPTION(EX_INTERNAL|0x14); break; } } static void fxam(FPU_REG *st0_ptr) { int c=0; switch (st0_ptr->tag) { case TW_Empty: c = SW_C3|SW_C0; break; case TW_Zero: c = SW_C3; break; case TW_Valid: /* This will need to be changed if TW_Denormal is ever used. */ if ( st0_ptr->exp <= EXP_UNDER ) c = SW_C2|SW_C3; /* Denormal */ else c = SW_C2; break; case TW_NaN: c = SW_C0; break; case TW_Infinity: c = SW_C2|SW_C0; break; } if (st0_ptr->sign == SIGN_NEG) c |= SW_C1; setcc(c); } static FUNC_ST0 const fp_etc_table[] = { fchs, fabs, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal, ftst_, fxam, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal }; void fp_etc() { (fp_etc_table[FPU_rm])(&st(0)); } |