root/kernel/FPU-emu/fpu_aux.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fclex
  2. finit
  3. finit_
  4. fstsw_ax
  5. fstsw_
  6. fnop
  7. fp_nop
  8. fld_i_
  9. fxch_i
  10. ffree_
  11. ffreep
  12. fst_i_
  13. fstp_i

   1 /*---------------------------------------------------------------------------+
   2  |  fpu_aux.c                                                                |
   3  |                                                                           |
   4  | Code to implement some of the FPU auxiliary instructions.                 |
   5  |                                                                           |
   6  | Copyright (C) 1992,1993                                                   |
   7  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   8  |                       Australia.  E-mail apm233m@vaxc.cc.monash.edu.au    |
   9  |                                                                           |
  10  |                                                                           |
  11  +---------------------------------------------------------------------------*/
  12 
  13 #include "fpu_system.h"
  14 #include "exception.h"
  15 #include "fpu_emu.h"
  16 #include "status_w.h"
  17 
  18 
  19 
  20 static void fclex(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22   status_word &= ~(SW_B|SW_ES|SW_SF|SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE);
  23   FPU_entry_eip = ip_offset;               /* We want no net effect */
  24 }
  25 
  26 /* Needs to be externally visible */
  27 void finit()
     /* [previous][next][first][last][top][bottom][index][help] */
  28 {
  29   int r;
  30   control_word = 0x037e;
  31   status_word = 0;
  32   top = 0;
  33   for (r = 0; r < 8; r++)
  34     {
  35       regs[r].sign = 0;
  36       regs[r].tag = TW_Empty;
  37       regs[r].exp = 0;
  38       regs[r].sigh = 0;
  39       regs[r].sigl = 0;
  40     }
  41   FPU_entry_eip = ip_offset;               /* We want no net effect */
  42 }
  43 
  44 static FUNC finit_table[] = {
  45   Un_impl, Un_impl, fclex, finit, Un_impl, Un_impl, Un_impl, Un_impl
  46 };
  47 
  48 void finit_()
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50   (finit_table[FPU_rm])();
  51 }
  52 
  53 
  54 static void fstsw_ax(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  55 {
  56 
  57   status_word &= ~SW_TOP;
  58   status_word |= (top&7) << SW_TOPS;
  59 
  60   *(short *) &FPU_EAX = status_word;
  61 
  62 }
  63 
  64 static FUNC fstsw_table[] = {
  65   fstsw_ax, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
  66 };
  67 
  68 void fstsw_()
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70   (fstsw_table[FPU_rm])();
  71 }
  72 
  73 
  74 
  75 static void fnop(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  76 {
  77 }
  78 
  79 FUNC fp_nop_table[] = {
  80   fnop, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
  81 };
  82 
  83 void fp_nop()
     /* [previous][next][first][last][top][bottom][index][help] */
  84 {
  85   (fp_nop_table[FPU_rm])();
  86 }
  87 
  88 
  89 void fld_i_()
     /* [previous][next][first][last][top][bottom][index][help] */
  90 {
  91   FPU_REG *st_new_ptr;
  92 
  93   if ( STACK_OVERFLOW )
  94     { stack_overflow(); return; }
  95 
  96   /* fld st(i) */
  97   if ( NOT_EMPTY(FPU_rm) )
  98     { reg_move(&st(FPU_rm), st_new_ptr); push(); }
  99   else
 100     {
 101       if ( control_word & EX_Invalid )
 102         {
 103           /* The masked response */
 104           push();
 105           stack_underflow();
 106         }
 107       else
 108         EXCEPTION(EX_StackUnder);
 109     }
 110 
 111 }
 112 
 113 
 114 void fxch_i()
     /* [previous][next][first][last][top][bottom][index][help] */
 115 {
 116   /* fxch st(i) */
 117   FPU_REG t;
 118   register FPU_REG *sti_ptr = &st(FPU_rm);
 119   reg_move(FPU_st0_ptr, &t);
 120   reg_move(sti_ptr, FPU_st0_ptr);
 121   reg_move(&t, sti_ptr);
 122 }
 123 
 124 
 125 void ffree_()
     /* [previous][next][first][last][top][bottom][index][help] */
 126 {
 127   /* ffree st(i) */
 128   st(FPU_rm).tag = TW_Empty;
 129 }
 130 
 131 
 132 void ffreep()
     /* [previous][next][first][last][top][bottom][index][help] */
 133 {
 134   /* ffree st(i) + pop - unofficial code */
 135   st(FPU_rm).tag = TW_Empty;
 136   pop();
 137 }
 138 
 139 
 140 void fst_i_()
     /* [previous][next][first][last][top][bottom][index][help] */
 141 {
 142   /* fst st(i) */
 143   reg_move(FPU_st0_ptr, &st(FPU_rm));
 144 }
 145 
 146 
 147 void fstp_i()
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149   /* fstp st(i) */
 150   reg_move(FPU_st0_ptr, &st(FPU_rm));
 151   pop();
 152 }
 153 

/* [previous][next][first][last][top][bottom][index][help] */