home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / ieee / part3 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  5.0 KB

  1. From: genrad!decvax!decwrl!sun!dgh!dgh (David Hough)
  2. Subject: IEEE Calculator (part 3 of 6)
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 3, Issue 5
  7. Submitted by: decvax!decwrl!sun!dgh!dgh (David Hough)
  8.  
  9. #! /bin/sh
  10. : make a directory, cd to it, and run this through sh
  11. echo If this kit is complete, "End of Kit" will echo at the end
  12. echo Extracting calcdouble.h
  13. cat >calcdouble.h <<'End-Of-File'
  14. procedure todouble ( var x : internal ; var y : cdouble ) ; external ;
  15. procedure unpackdouble ( y : cdouble ; var x : internal ) ; external ;
  16.  
  17. End-Of-File
  18. echo Extracting calcsingle.h
  19. cat >calcsingle.h <<'End-Of-File'
  20. procedure tosingle ( var x : internal ; var y : csingle ) ; external ;
  21. procedure unpacksingle ( y : csingle ; var x : internal ) ; external ;
  22. End-Of-File
  23. echo Extracting calctest.h
  24. cat >calctest.h <<'End-Of-File'
  25.  
  26. (* File calctest.h, Version 5 October 1984. *)
  27.  
  28. (* This version of the calculator test unit is a dummy to provide
  29. constant and type declarations only.  *)
  30.  
  31. (* Global constant, type, and variable declarations for  Calc. *)
  32.  
  33. const
  34. stickybit = 66 ; (* position of sticky bit in internal representation *)
  35.  
  36. type
  37.  
  38. arithtype = ( i16, i32, i64, flt32, f64, ext80, unrounded  ) ; 
  39.         (* types of arithmetic operands *)
  40.  
  41. fpmodetype = record (* floating point mode record *)
  42. round : rmode (* roundmodetype *) ;
  43. precision : extprec ;
  44. clos : closure(*type*) ;
  45. norm : denorm ;
  46. end ;
  47.  
  48. fpstype  = record (* complete status of floating point unit *)
  49. mode : fpmodetype ;
  50. curexcep : excepset ; (* Set of exceptions generated by current op.  *)
  51. excep : excepset ;
  52. trap : excepset end ;
  53.  
  54. internal = record (* internal extended format *)
  55. (* unlike external extended, most significant bit represents 0.5,
  56. not 1.0 *)
  57. sign : boolean ;
  58. exponent : integer ; (* range is -2**15 to 2**15-1 *)
  59. significand :   array [0..stickybit] of boolean ; 
  60.         (* bit stickybit-2 is guard ;
  61. bit (stickybit-1) is round ; bit stickybit is sticky *)
  62. end ;
  63.         
  64.         (* Following are temporary calculator internal types which use 
  65.         logical bytes, which may not be the same as the physical bytes
  66.         specified in x80modes.  *)
  67. csingle = array [0..3] of byt ;
  68. cdouble = array [0..7] of byt ;
  69. cextended = array [0..9] of byt ;
  70. cint64 = array [0..7] of byt ;
  71.  
  72. procedure pretest ( var storemode : arithtype )  ;  external ;
  73. procedure swapmode ( var e : fpmodetype ) ;  external ;
  74. procedure swaptrap ( var e : excepset ) ;  external ;
  75. procedure swapexcep ( var e : excepset ) ;  external ;
  76.  
  77. procedure tneg ( x : internal ; var z : internal ) ;  external ;
  78. procedure tabs ( x : internal ; var z : internal ) ;  external ;
  79. procedure tsqrt ( x : internal ; var z : internal ) ;  external ;
  80.  
  81. procedure tadd ( x, y : internal ; var z : internal ) ;  external ;
  82. procedure tsub ( x, y : internal ; var z : internal ) ;  external ;
  83. procedure tmul ( x, y : internal ; var z : internal ) ;  external ;
  84. procedure tdiv ( x, y : internal ; var z : internal ) ;  external ;
  85. procedure trem ( x, y : internal ; var z : internal ) ;  external ;
  86.  
  87. procedure tcompare ( x, y : internal ; var cc : conditioncode ) ;  external ;
  88. procedure tstore ( storagemode : arithtype ; var z : internal ) ;  external ;
  89. procedure tconvert ( x : internal ; var z : internal ; a : arithtype ) ;  external ;
  90.  
  91. procedure tintconvert ( x : internal ; var z : internal ; a : arithtype ) ;  external ;
  92.  
  93. procedure tdisplay ( x : internal ) ;   external ;
  94. procedure tdecbin ( s : fpstring ; var x : internal ; var error : boolean ) ;  external ;
  95.  
  96. procedure ffloat_ ; external ;
  97. procedure ffunc_  ; external ;
  98. procedure sfloat_ ; external ;
  99. procedure sfunc_  ; external ;
  100.  
  101. End-Of-File
  102. echo Extracting oldfplib.h
  103. cat >oldfplib.h <<'End-Of-File'
  104.     const
  105.  
  106.     maxfpstring = 80 ;
  107.  
  108.     invop = invalid;
  109.     overfl = overflow;
  110.     underfl = underflow;
  111.     div0 = divbyzero;
  112.     inxact = inexact;
  113.     cvtovfl = invalid ;
  114.  
  115.     type
  116.  
  117.     byt = 0..255 ;
  118.  
  119.     fpstring = packed array [0..maxfpstring] of char ;
  120.  
  121.     roundtype = ( rnear, rzero, rpos, rneg, rout ) ;
  122.     rmode = rnear .. rneg ;
  123.     closure = (proj, affine) ;
  124.     denorm = ( warning, normalizing ) ;
  125.     extprec = ( xprec, sprec, dprec ) ;
  126.     
  127.     xcpn = exception ;
  128.     excepset = set of exception ;
  129.  
  130.     fp_cc = ( equal, lesser, greater, notord ) ;
  131.     conditioncode = fp_cc ;
  132.  
  133. End-Of-File
  134. echo Extracting sane.h
  135. cat >sane.h <<'End-Of-File'
  136. type
  137.  
  138. longint = integer ;
  139. integer = -32768..32767 ;
  140. single = array [0..1] of integer ;
  141. double = array [0..3] of integer ;
  142. comp = array [0..3] of integer ;
  143. extended = array [0..4] of integer ;
  144.  
  145. environ = integer ;
  146. rounddir = ( tonearest, upward, downward, towardzero ) ;
  147. relop = ( gt, lt, gl, eq, ge, le, gel, unord ) ;
  148. exception = ( invalid, underflow, overflow, divbyzero, inexact ) ;
  149. numclass = ( snan, qnan, infinite, zero, normal, denormal ) ;
  150.  
  151. roundprecision = ( extprecision, dblprecision, realprecision ) ;
  152.  
  153. procedure SetRnd ( r : rounddir ) ; external ;
  154. function GetRnd : rounddir ; external ;
  155. procedure SetXcp ( x : exception; onoff : boolean ); external ;
  156. function TestXcp ( x : exception ) : boolean   ; external ;
  157.  
  158. End-Of-File
  159. echo ""
  160. echo "End of Kit"
  161. exit
  162.  
  163.