fpu_tags.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*---------------------------------------------------------------------------+
  2.  |  fpu_tags.c                                                               |
  3.  |                                                                           |
  4.  |  Set FPU register tags.                                                   |
  5.  |                                                                           |
  6.  | Copyright (C) 1997                                                        |
  7.  |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
  8.  |                  E-mail   billm@jacobi.maths.monash.edu.au                |
  9.  |                                                                           |
  10.  |                                                                           |
  11.  +---------------------------------------------------------------------------*/
  12. #include "fpu_emu.h"
  13. #include "fpu_system.h"
  14. #include "exception.h"
  15. void FPU_pop(void)
  16. {
  17.   fpu_tag_word |= 3 << ((top & 7)*2);
  18.   top++;
  19. }
  20. int FPU_gettag0(void)
  21. {
  22.   return (fpu_tag_word >> ((top & 7)*2)) & 3;
  23. }
  24. int FPU_gettagi(int stnr)
  25. {
  26.   return (fpu_tag_word >> (((top+stnr) & 7)*2)) & 3;
  27. }
  28. int FPU_gettag(int regnr)
  29. {
  30.   return (fpu_tag_word >> ((regnr & 7)*2)) & 3;
  31. }
  32. void FPU_settag0(int tag)
  33. {
  34.   int regnr = top;
  35.   regnr &= 7;
  36.   fpu_tag_word &= ~(3 << (regnr*2));
  37.   fpu_tag_word |= (tag & 3) << (regnr*2);
  38. }
  39. void FPU_settagi(int stnr, int tag)
  40. {
  41.   int regnr = stnr+top;
  42.   regnr &= 7;
  43.   fpu_tag_word &= ~(3 << (regnr*2));
  44.   fpu_tag_word |= (tag & 3) << (regnr*2);
  45. }
  46. void FPU_settag(int regnr, int tag)
  47. {
  48.   regnr &= 7;
  49.   fpu_tag_word &= ~(3 << (regnr*2));
  50.   fpu_tag_word |= (tag & 3) << (regnr*2);
  51. }
  52. int FPU_Special(FPU_REG const *ptr)
  53. {
  54.   int exp = exponent(ptr);
  55.   if ( exp == EXP_BIAS+EXP_UNDER )
  56.     return TW_Denormal;
  57.   else if ( exp != EXP_BIAS+EXP_OVER )
  58.     return TW_NaN;
  59.   else if ( (ptr->sigh == 0x80000000) && (ptr->sigl == 0) )
  60.     return TW_Infinity;
  61.   return TW_NaN;
  62. }
  63. int isNaN(FPU_REG const *ptr)
  64. {
  65.   return ( (exponent(ptr) == EXP_BIAS+EXP_OVER)
  66.    && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)) );
  67. }
  68. int FPU_empty_i(int stnr)
  69. {
  70.   int regnr = (top+stnr) & 7;
  71.   return ((fpu_tag_word >> (regnr*2)) & 3) == TAG_Empty;
  72. }
  73. int FPU_stackoverflow(FPU_REG **st_new_ptr)
  74. {
  75.   *st_new_ptr = &st(-1);
  76.   return ((fpu_tag_word >> (((top - 1) & 7)*2)) & 3) != TAG_Empty;
  77. }
  78. void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr)
  79. {
  80.   reg_copy(r, &st(stnr));
  81.   FPU_settagi(stnr, tag);
  82. }
  83. void FPU_copy_to_reg1(FPU_REG const *r, u_char tag)
  84. {
  85.   reg_copy(r, &st(1));
  86.   FPU_settagi(1, tag);
  87. }
  88. void FPU_copy_to_reg0(FPU_REG const *r, u_char tag)
  89. {
  90.   int regnr = top;
  91.   regnr &= 7;
  92.   reg_copy(r, &st(0));
  93.   fpu_tag_word &= ~(3 << (regnr*2));
  94.   fpu_tag_word |= (tag & 3) << (regnr*2);
  95. }