home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / mint / mntlib24 / flonum.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-03  |  4.8 KB  |  181 lines

  1. #ifndef FLONUM_H
  2. #define FLONUM_H
  3.  
  4. /* Defs and macros for floating point code.  This stuff is heavily based
  5.    on Scott McCauley's code, except that this version works :-} */
  6.  
  7.  
  8. /* These definitions work for machines where an SF value is
  9.    returned in the same register as an int.  */
  10.  
  11. #ifndef SFVALUE  
  12. #define SFVALUE int
  13. #endif
  14.  
  15. #ifndef INTIFY
  16. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  17. #endif
  18.  
  19. /* quasi-IEEE floating point number definitions */
  20.  
  21. #ifndef __TURBOC__
  22. struct bitfloat {
  23.     unsigned long sign : 1;
  24.     unsigned long exp  : 8;
  25.     unsigned long mant : 23;
  26. };
  27.  
  28. struct bitdouble {
  29.     unsigned long sign  : 1;
  30.     unsigned long exp   : 11;
  31.     unsigned long mant1 : 20;
  32.     unsigned long mant2;
  33. };
  34. #endif
  35.  
  36. union double_di {
  37.         double d;
  38.     long   i[2];
  39. };
  40.  
  41. union flt_or_int {
  42.         long  i;
  43.         float f;
  44. };
  45.  
  46. #ifdef WORDS_BIG_ENDIAN
  47. #  define HIGH 0
  48. #  define LOW 1
  49. #else
  50. #  define HIGH 1
  51. #  define LOW 0
  52. #endif
  53.  
  54. /*
  55.  * all float/double/long now coded in assembler, dont define anything
  56.  * below this line
  57.  */
  58. #if 0
  59. /* start of symbolic asm definitions */
  60.  
  61. /* you may have to change the g's to d's if you start getting
  62.    illegal operands from as */
  63.  
  64. #define MUL(a, b) \
  65.     asm volatile ("mulu    %2,%0"     : "=d" (b)    : "0" (b) , "g" (a))
  66.  
  67. #define DIV(a, b) \
  68.     asm volatile ("divu %2,%0"     : "=d" (b)    : "0" (b) , "g" (a))
  69.  
  70. #define SWAP(a)      \
  71.     asm volatile ("swap    %0"     : "=r" (a)     : "0" (a))
  72.  
  73. #define ASL2(r1, r2) { \
  74.     asm volatile ("asll  #1,%0"    : "=d" (r2)     : "0" (r2));    \
  75.     asm volatile ("roxll #1,%0" : "=d" (r1)    : "0" (r1));    \
  76.     }
  77.  
  78. #define ASL3(r1, r2, r3) { \
  79.     asm volatile ("asll  #1,%0" : "=d" (r3)     : "0" (r3));    \
  80.     asm volatile ("roxll #1,%0" : "=d" (r2)     : "0" (r2));    \
  81.     asm volatile ("roxll #1,%0" : "=d" (r1)     : "0" (r1));     \
  82.     }
  83.  
  84. #define ASR2(r1, r2) {    \
  85.     asm volatile ("asrl  #1,%0" : "=d" (r1)     : "0" (r1));    \
  86.     asm volatile ("roxrl #1,%0" : "=d" (r2)     : "0" (r2));    \
  87.     }
  88.  
  89. #define ASR3(r1, r2, r3) { \
  90.     asm volatile ("asrl  #1,%0" : "=d" (r1)     : "0" (r1));    \
  91.     asm volatile ("roxrl #1,%0" : "=d" (r2)     : "0" (r2));    \
  92.     asm volatile ("roxrl #1,%0" : "=d" (r3)     : "0" (r3));    \
  93.     }
  94.  
  95. #define ASR4(r1, r2, r3, r4) { \
  96.     asm volatile ("asrl  #1,%0" : "=d" (r1)     : "0" (r1));    \
  97.     asm volatile ("roxrl #1,%0" : "=d" (r2)     : "0" (r2));    \
  98.     asm volatile ("roxrl #1,%0" : "=d" (r3)    : "0" (r3));    \
  99.     asm volatile ("roxrl #1,%0" : "=d" (r4)     : "0" (r4));    \
  100.     }
  101.  
  102. #define ADD2(r1, r2, r3, r4) { \
  103.     asm volatile ("addl  %2,%0"    : "=g" (r4)     : "0" (r4) , "g" (r2));    \
  104.     asm volatile ("addxl %2,%0"    : "=g" (r3)    : "0" (r3) , "g" (r1));    \
  105.     }
  106.  
  107. /* y <- y - x  */
  108. #define SUB3(x1, x2, x3, y1, y2, y3) { \
  109.     asm volatile ("subl  %2,%0"    : "=g" (y3)    : "0" (y3) , "d" (x3));    \
  110.     asm volatile ("subxl %2,%0"    : "=g" (y2)     : "0" (y2) , "d" (x2)); \
  111.     asm volatile ("subxl %2,%0"    : "=g" (y1)     : "0" (y1) , "d" (x1));    \
  112.     }
  113.  
  114. /* sub4 here is rather complex, as the compiler is overwhelmed by me wanting
  115.    to have 8 data registers allocated for mantissa accumulators.  Help it out
  116.    by declaring a temp that it can move stuff in and out of.  */
  117. #define SUB4(x1, x2, x3, x4, y1, y2, y3, y4) { \
  118.     register long temp = y4;                          \
  119.     asm volatile ("subl  %2,%0"    : "=d" (temp)    : "0" (temp) , "d" (x4)); \
  120.     y4 = temp; temp = y3;                           \
  121.     asm volatile ("subxl %2,%0"    : "=d" (temp)    : "0" (temp) , "d" (x3)); \
  122.     y3 = temp; temp = y2;                          \
  123.     asm volatile ("subxl %2,%0"    : "=d" (temp)    : "0" (temp) , "d" (x2)); \
  124.     y2 = temp; temp = y1;                          \
  125.     asm volatile ("subxl %2,%0"    : "=d" (temp)    : "0" (temp) , "d" (x1)); \
  126.     y1 = temp;                                  \
  127.     }
  128.  
  129. #define NEG(r1, r2) { \
  130.     asm volatile ("negl  %0"    : "=d" (r2)    : "0" (r2));    \
  131.     asm volatile ("negxl %0"     : "=d" (r1)     : "0" (r1));    \
  132.     } 
  133.  
  134. /* switches for which routines to compile.  All the single-float and
  135. long-int arithmetic routines are turned off here, as they were all
  136. done in assembly language last year.  */
  137.  
  138. /*
  139. #define L_umulsi3
  140. #define L_mulsi3
  141. #define L_udivsi3
  142. #define L_divsi3
  143. #define L_umodsi3
  144. #define L_modsi3
  145. #define L_lshrsi3
  146. #define L_lshlsi3
  147. #define L_ashrsi3
  148. #define L_ashlsi3
  149. */
  150. /*    These are now in kai-uwe .s files
  151.   #define L_divdf3
  152.   #define L_muldf3
  153.   #define L_negdf2
  154.   #define L_adddf3
  155.   #define L_subdf3
  156.   #define L_cmpdf2
  157.   #define L_fixunsdfsi
  158.   #define L_floatsidf
  159. */
  160. /*
  161.   these three are now in gnulib2 (were in dflonum.h pre gcc1.36)
  162. #define L_fixunsdfdi
  163. #define L_fixdfdi
  164. #define L_floatdidf
  165.  
  166. #define L_addsf3
  167. #define L_negsf2
  168. #define L_subsf3
  169. #define L_cmpsf2
  170. #define L_mulsf3
  171. #define L_divsf3
  172. */
  173.  
  174. /* These too are now in kai-uwe .s files
  175.    #define L_truncdfsf2
  176.    #define L_extendsfdf2
  177. */
  178. #endif /* #if 0 */
  179.  
  180. #endif /* FLONUM_H */
  181.