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

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