root/kernel/FPU-emu/fpu_emu.h

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

INCLUDED FROM


   1 /*---------------------------------------------------------------------------+
   2  |  fpu_emu.h                                                                |
   3  |                                                                           |
   4  | Copyright (C) 1992    W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   5  |                       Australia.  E-mail apm233m@vaxc.cc.monash.edu.au    |
   6  |                                                                           |
   7  +---------------------------------------------------------------------------*/
   8 
   9 
  10 #ifndef _FPU_EMU_H_
  11 #define _FPU_EMU_H_
  12 
  13 #ifdef __ASSEMBLER__
  14 #include "fpu_asm.h"
  15 #define Const(x)        $##x
  16 #else
  17 #define Const(x)        x
  18 #endif
  19 
  20 #define EXP_BIAS        Const(0)
  21 #define EXP_OVER        Const(0x4000)    /* smallest invalid large exponent */
  22 /* #define EXP_MAX              Const(16384) */
  23 #define EXP_UNDER       Const(-0x3fff)   /* largest invalid small exponent */
  24 /* #define      EXP_MIN         Const(-16384) */
  25 
  26 #define SIGN_POS        Const(0)
  27 #define SIGN_NEG        Const(1)
  28 
  29 /* Keep the order TW_Valid, TW_Zero, TW_Denormal */
  30 #define TW_Valid        Const(0)        /* valid */
  31 #define TW_Zero         Const(1)        /* zero */
  32 /* The following fold to 2 (Special) in the Tag Word */
  33 #define TW_Denormal     Const(4)        /* De-normal */
  34 #define TW_Infinity     Const(5)        /* + or - infinity */
  35 #define TW_NaN          Const(6)        /* Not a Number */
  36 
  37 #define TW_Empty        Const(7)        /* empty */
  38 
  39 
  40 
  41 #ifndef __ASSEMBLER__
  42 
  43 typedef void (*FUNC)();
  44 
  45 #define REG     struct  reg
  46 
  47 struct reg {
  48   char sign;
  49   char tag;
  50 /*  short exp; *****/
  51   long exp;
  52   unsigned sigl;
  53   unsigned sigh;
  54 };
  55 
  56 #define st(x)   ( regs[((top+x) &7 )] )
  57 
  58 #define STACK_OVERFLOW  (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
  59 #define NOT_EMPTY(i)    (st(i).tag != TW_Empty)
  60 #define NOT_EMPTY_0     (st0_tag ^ TW_Empty)
  61 
  62 extern unsigned char FPU_modrm;
  63 extern unsigned char FPU_rm;
  64 
  65 extern  char    st0_tag;
  66 extern  REG     *st0_ptr;
  67 
  68 extern void  *FPU_data_address;
  69 extern unsigned long FPU_entry_eip;
  70 
  71 extern  REG  FPU_loaded_data;
  72 
  73 #define pop()   { st0_ptr->tag = TW_Empty; \
  74                                   top++; st0_ptr = &(regs[top&7]); }
  75 
  76 /* push() does not affect the tags */
  77 #define push()  { top--; st0_ptr = st_new_ptr; }
  78 
  79 
  80 #define reg_move(x, y) { \
  81                  *(short *)&((y)->sign) = *(short *)&((x)->sign); \
  82                  *(long *)&((y)->exp) = *(long *)&((x)->exp); \
  83                  *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
  84 
  85 
  86 /*----- Prototypes for functions written in assembler -----*/
  87 /* extern void reg_move(REG *a, REG *b); */
  88 
  89 extern void mul64(long long *a, long long *b, long long *result);
  90 extern void poly_div2(long long *x);
  91 extern void poly_div4(long long *x);
  92 extern void poly_div16(long long *x);
  93 extern void polynomial(unsigned accum[], unsigned x[],
  94                        unsigned short terms[][4], int n);
  95 extern void normalize(REG *x);
  96 extern void reg_div(REG *arg1, REG *arg2, REG *answ);
  97 extern void reg_u_sub(REG *arg1, REG *arg2, REG *answ);
  98 extern void reg_u_mul(REG *arg1, REG *arg2, REG *answ);
  99 extern void reg_u_div(long long *arg1, long long *arg2, REG *answ);
 100 extern void reg_u_add(REG *arg1, REG *arg2, REG *answ);
 101 extern void wm_sqrt(REG *n);
 102 extern unsigned shrx(void *l, unsigned x);
 103 extern unsigned shrxs(void *v, unsigned x);
 104 extern unsigned long div_small(unsigned long long *x, unsigned long y);
 105 
 106 #ifndef MAKING_PROTO
 107 #include "fpu_proto.h"
 108 #endif
 109 
 110 #endif __ASSEMBLER__
 111 
 112 #endif _FPU_EMU_H_

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