home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / math / m36.doc < prev    next >
Encoding:
Text File  |  1988-05-03  |  223.4 KB  |  6,239 lines

  1. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. --mae.mac
  3. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                             EEEEEE  M    M  AAAAAA
  18.                             EE      MM  MM  AA  AA
  19.                             EEEEEE  MM  MM  AAAAAA
  20.                             EE      M MM M  AA  AA
  21.                             EEEEEE  M MM M  AA  AA
  22.  
  23.                         EMULATION OF MACHINE ARITHMETIC 
  24.  
  25.  
  26.  
  27.  
  28.                       M A C R O S C O P I C   D E S I G N
  29.  
  30.  
  31.  
  32.                                  30 JUNE 1985
  33.  
  34.  
  35.  
  36.                                  Prepared for
  37.  
  38.                            Naval Ocean Systems Center,
  39.                             WIS Joint Program Office
  40.  
  41.  
  42.                                  Prepared by
  43.  
  44.                              Ada* Technology Group
  45.                               SYSCON Corportation
  46.                               3990 Sherman Street
  47.                           San Diego, California 92110
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.                   * Ada is a registered trademark of the
  57.              United States Government - Ada Joint Program Office
  58. <FF>
  59.  
  60.  
  61.  
  62.         Table of Contents
  63.         -----------------
  64.  
  65.  
  66.     1.  SOFTWARE ARCHITECTURE
  67.  
  68.         2.  MACROSCOPIC DESIGN ADA PDL
  69.     2.1    MACHINE_ARITHMETIC_EMULATION
  70.         2.2    MAE_INTEGER
  71.         2.3    MAE_SHORT_FLOAT
  72.         2.4    MAE_LONG_FLOAT
  73.         2.5    MAE_BASIC_OPERATIONS
  74.  
  75.  
  76. <FF>
  77.  
  78. 1.  SOFTWARE ARCHITECTURE
  79.  
  80. The software architecture of the EMA packages is illustrated in 
  81. Figure 1-1, which shows the Ada Graphic Notation for the "MAE" 
  82. subsystem.
  83.  
  84.  
  85.          MAE
  86.        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -            
  87.        |                                                         |            
  88.        |                                                         |            
  89.        |                                                         |            
  90.        |                    MACHINE_ARITHMETIC_EMULATION         |            
  91.        |                    ----------------------------         |            
  92.        |                    |                          |         |            
  93.   (target_types)----------->|                          |         |            
  94.        |                    |                          |         |            
  95.   |target_operations|------>|                          |         |            
  96.        |                    |                          |         |            
  97.   <target_exceptions>------>|                          |         |            
  98.        |                    |                          |--+      |            
  99.        |                    ----------------------------  |      |            
  100.        |                                                  |      |            
  101.        |         +----------------------------------------+      |            
  102.        |         |  MAE_INTEGER                                  |            
  103.        |         |  ---------------                              |            
  104.        |         +->|             |                              |            
  105.        |         |  |             |                              |            
  106.        |         |  |             |--+                           |            
  107.        |         |  ---------------  |                           |            
  108.        |         |                   |      MAE_BASIC_OPERATIONS |            
  109.        |         |  MAE_SHORT_FLOAT  |      ----------------     |            
  110.        |         |  ---------------  |      |              |     |            
  111.        |         +->|             |  +----->|              |     |            
  112.        |         |  |             |  |      |              |--+  |            
  113.        |         |  |             |--+      ----------------  |  |            
  114.        |         |  ---------------  |                        |  |            
  115.        |         |                   |            +-----------+  |            
  116.        |         |  MAE_LONG_FLOAT   |            |              |            
  117.        |         |  ---------------  |            +---->|Ada_predefined_ops|  
  118.        |         +->|             |  |                           |            
  119.        |            |             |  |                           |            
  120.        |            |             |--+                           |            
  121.        |            ---------------                              |            
  122.        |                                                         |            
  123.        -----------------------------------------------------------            
  124.  
  125.                 Figure 1-1 Ada Graphic Notation for MAE
  126.  
  127.  
  128. The MAE subsystem consists of the visible package
  129. MACHINE_ARITHMETIC_EMULATION which contains the exported target
  130. types and operations, and four supporting packages.  The lowest
  131. level supporting package is MAE_BASIC_OPERATIONS, which provides the
  132. basic types and operations for emulating machine arithmetic and
  133. implements the operations using the predefined arithmetic operations
  134. of the host system.  The other support packages, MAE_INTEGER,
  135. MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
  136. on one of the exported types, by utilizing MAE_BASIC_OPERATIONS. 
  137.  
  138. The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
  139. relational operations on target integers (TARGET_INTEGER), floating
  140. point numbers (TARGET_SHORT_FLOAT), and double precision floating
  141. point numbers (TARGET_LONG_FLOAT).  The accuracy of the numbers is
  142. given below: 
  143.  
  144.   where N is the number of bits in the Target word
  145.  
  146.      TARGET_INTEGER
  147.         range of -2**(N-1) to 2**(N-1)-1
  148.      TARGET_SHORT_FLOAT
  149.         approximate range of 10**-38 to 10**38 and 0
  150.         exponent => -128 to 127  (8 bits)
  151.         mantissa => (N-9) bit binary fraction
  152.      TARGET_LONG_FLOAT
  153.         approximate range of 10**-38 to 10**38 and 0
  154.         exponent => -128 to 127  (8 bits)
  155.         mantissa => (2*N-9) bit binary fraction
  156.  
  157.   thus for 36 bit words the accuracies are:
  158.  
  159.      TARGET_INTEGER
  160.         range of -2**35 to 2**35-1
  161.      TARGET_SHORT_FLOAT
  162.         approximate range of 10**-38 to 10**38 and 0
  163.         exponent => -128 to 127  (8 bits)
  164.         mantissa => 27 bit binary fraction
  165.      TARGET_LONG_FLOAT
  166.         approximate range of 10**-38 to 10**38 and 0
  167.         exponent => -128 to 127  (8 bits)
  168.         mantissa => 63 bit binary fraction
  169.  
  170. The 36 bit word accuracies are consistent with those given in the 
  171. Honeywell Multics FORTRAN Manual (Order Number AT58) which defines 
  172. the operation of the FORTRAN language on 60 series Honeywell 
  173. hardware.
  174.  
  175. For each of the supported types, the following operations are 
  176. defined:
  177.      addition                   arithmetic comparisons
  178.      subtraction                numerical conversion
  179.      multiplication             unary plus
  180.      division                   unary minus
  181.      remainder                  absolute value
  182.      modulo                     string get
  183.      exponentiation             string put
  184.  
  185. For target integer types the following attributes are defined:
  186.      'first
  187.      'last
  188.      'image
  189.      'value
  190.  
  191. For target floating point types the following attributes are 
  192. defined:
  193.      'digits
  194.      'emax
  195.      'epsilon
  196.      'first
  197.      'large
  198.      'machine_emax
  199.      'machine_emin
  200.      'machine_mantissa
  201.      'machine_overflows
  202.      'machine_radix
  203.      'safe_emax
  204.      'small
  205.  
  206. The supported attributes are called by using the form:
  207.  
  208.      <type name>_<attribute_name>  -- (e.g., TARGET_INTEGER_FIRST)
  209.  
  210. The standard tic (') symbol can not be used, because the emulated
  211. types are not directly derived from host types. Instead the tic
  212. symbol is replaced with an underscore. 
  213.  
  214. The entire set of operations for each of the types is listed in the
  215. interface specification provided in section 4.  The calling format,
  216. parameters, and returned values of all of the aforementioned
  217. operations conform to operations as defined in the package STANDARD
  218. (see the Reference Manual for the Ada Programming Language Appendix
  219. C) for each of the types.  The functionality of the aforementioned
  220. attributes is in accordance with the Ada predefined language
  221. attributes (see the Reference Manual for the Ada Programming
  222. Language Appendix A). 
  223. <FF>
  224.  
  225.  
  226. 2.  MACROSCOPIC DESIGN
  227.  
  228. This section specifies the macroscopic level design of the packages 
  229. providing the Emulation of Machine Arithmetic capability.  The 
  230. design is specified in Ada PDL, which was compiled to verify its 
  231. consistency and syntactical correctness.  The following subsections
  232. specify the Ada PDL of each of the constituent packages in the 
  233. software architecture.
  234.  
  235.  
  236. 2.1  MACHINE_ARITHMETIC_EMULATION
  237.  
  238.  
  239. with MAE_BASIC_OPERATIONS;
  240. with MAE_INTEGER;
  241. with MAE_SHORT_FLOAT;
  242. with MAE_LONG_FLOAT;
  243.  
  244. package MACHINE_ARITHMETIC_EMULATION is
  245. --------------------------------------------------------------------
  246. --  The purpose of this package is to emulate target machine
  247. --  arithmetic on host machines with 16 bit or larger words.
  248. --  This package will export support for target integer, real, 
  249. --  and double precision real numbers.  
  250. --
  251. --  The package emulation packages are currently configured to 
  252. --  support Honeywell 36 bit arithmetic.
  253. --
  254. --  The ranges for the current configuration are as follows:
  255. --
  256. --     TARGET_INTEGER
  257. --        range of -2**35 to 2**35-1
  258. --     TARGET_SHORT_FLOAT
  259. --        approximate range of 10**-38 to 10**38 and 0
  260. --        mantissa => 27 bit binary fraction
  261. --        exponent => -128 to 127
  262. --     TARGET_LONG_FLOAT
  263. --        approximate range of 10**-38 to 10**38 and 0
  264. --        mantissa => 63 bit binary fraction
  265. --        exponent => -128 to 127
  266. --
  267. --  Any errors which occur during use of the arithmetic and
  268. --  boolean functions defined below will result in the
  269. --  raising of the exception "MAE_NUMERIC_ERROR".  The 
  270. --  exception declared in this package is a rename of
  271. --  the predefined exception NUMERIC_ERROR.  This can be
  272. --  changed for programs needing to handle arithmetic
  273. --  exceptions generated by the emulation packages separately.
  274. --
  275.    
  276.  
  277. --------------------------------------------------------------------
  278. -- Parameters within MAE_BASIC_OPERATIONS that need to be available
  279. -- to the user of the Emulation of Machine Arithmetic package
  280. --
  281.    subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
  282.    DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
  283.  
  284.    subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
  285.    SHORT_DEFAULT_AFT : FIELD renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
  286.    LONG_DEFAULT_AFT : FIELD renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
  287.    SHORT_DEFAULT_EXP : FIELD renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
  288.    LONG_DEFAULT_EXP : FIELD renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
  289.  
  290.    --
  291.    -- predefined attributes for the emulated types
  292.    --
  293.       SHORT_FLOAT_DIGITS : INTEGER 
  294.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS; 
  295.       LONG_FLOAT_DIGITS : INTEGER 
  296.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS; 
  297.  
  298.       SHORT_FLOAT_EMAX : INTEGER 
  299.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
  300.       LONG_FLOAT_EMAX : INTEGER
  301.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
  302.  
  303.       SHORT_FLOAT_MACHINE_EMAX : INTEGER 
  304.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
  305.       LONG_FLOAT_MACHINE_EMAX : INTEGER 
  306.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
  307.  
  308.       SHORT_FLOAT_MACHINE_EMIN : INTEGER 
  309.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
  310.       LONG_FLOAT_MACHINE_EMIN : INTEGER 
  311.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
  312.  
  313.       SHORT_FLOAT_MACHINE_MANTISSA : INTEGER 
  314.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
  315.       LONG_FLOAT_MACHINE_MANTISSA : INTEGER
  316.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
  317.  
  318.       SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN 
  319.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
  320.       LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
  321.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
  322.  
  323.       SHORT_FLOAT_MACHINE_RADIX : INTEGER
  324.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
  325.       LONG_FLOAT_MACHINE_RADIX : INTEGER
  326.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
  327.  
  328.       SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
  329.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
  330.       LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
  331.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
  332.  
  333.       SHORT_FLOAT_SAFE_EMAX : INTEGER 
  334.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
  335.       LONG_FLOAT_SAFE_EMAX : INTEGER 
  336.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
  337.  
  338. --------------------------------------------------------------------
  339. -- Visible operations with TARGET_INTEGER
  340. --
  341. -- The follow declaration should be private
  342.  
  343.    subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
  344.  
  345.    -- The defined operators for this type are as follows:
  346.  
  347.    function TARGET_INTEGER_FIRST return TARGET_INTEGER;
  348.    function TARGET_INTEGER_LAST return TARGET_INTEGER;
  349.  
  350.    -- Predefined system function "=" and function "/="
  351.    function "<"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  352.    function "<="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  353.    function ">"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  354.    function ">="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  355.  
  356.    function "+"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  357.    function "-"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  358.    function "abs"  (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  359.  
  360.    function "+"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  361.    function "-"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  362.    function "*"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  363.    function "/"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  364.    function "rem"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  365.    function "mod"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  366.  
  367.    function "**"   (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
  368.                        return TARGET_INTEGER;
  369.  
  370.    function TARGET_INTEGER_VALUE (STRING_PIC : STRING) 
  371.                        return TARGET_INTEGER;
  372.    function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER) 
  373.                        return STRING;
  374.  
  375.    procedure GET (FROM : in STRING;
  376.                   ITEM : out TARGET_INTEGER;
  377.                   LAST : out POSITIVE);
  378.  
  379.    procedure PUT (TO : out STRING;
  380.                   ITEM : in TARGET_INTEGER;
  381.                   BASE : in NUMBER_BASE := DEFAULT_BASE);
  382.  
  383. --------------------------------------------------------------------
  384. -- Visible operations with TARGET_SHORT_FLOAT
  385. --
  386. -- The following declaration should be private
  387.  
  388.    subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
  389.  
  390.    -- The defined operators for this type are as follows:
  391.  
  392.  
  393.    function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
  394.    function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
  395.    function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
  396.    function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
  397.    function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
  398.  
  399.    -- Predefined system function "=" and function "/="
  400.    function "<"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  401.    function "<="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  402.    function ">"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  403.    function ">="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  404.  
  405.    function "+"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  406.    function "-"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  407.    function "abs"  (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  408.  
  409.    function "+"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  410.    function "-"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  411.    function "*"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  412.    function "/"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  413.  
  414.    function "**"   (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER) 
  415.                        return TARGET_SHORT_FLOAT;
  416.  
  417.    procedure GET (FROM : in STRING;
  418.                   ITEM : out TARGET_SHORT_FLOAT;
  419.                   LAST : out POSITIVE);
  420.  
  421.    procedure PUT (TO : out STRING;
  422.                   ITEM : in TARGET_SHORT_FLOAT;
  423.                   AFT : in FIELD := SHORT_DEFAULT_AFT;
  424.                   EXP : in FIELD := SHORT_DEFAULT_EXP);
  425.  
  426. --------------------------------------------------------------------
  427. -- Visible operations with TARGET_LONG_FLOAT
  428. --
  429. -- The following declaration should be private
  430.  
  431.    subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
  432.  
  433.    -- The defined operators for this type are as follows:
  434.  
  435.    function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
  436.    function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
  437.    function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
  438.    function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
  439.    function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
  440.  
  441.    -- Predefined system function "=" and function "/="
  442.    function "<"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  443.    function "<="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  444.    function ">"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  445.    function ">="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  446.  
  447.    function "+"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  448.    function "-"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  449.    function "abs"  (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  450.  
  451.    function "+"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  452.    function "-"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  453.    function "*"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  454.    function "/"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  455.  
  456.    function "**"   (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER) 
  457.                        return TARGET_LONG_FLOAT;
  458.  
  459.    procedure GET (FROM : in STRING;
  460.                   ITEM : out TARGET_LONG_FLOAT;
  461.                   LAST : out POSITIVE);
  462.  
  463.    procedure PUT (TO : out STRING;
  464.                   ITEM : in TARGET_LONG_FLOAT;
  465.                   AFT : in FIELD := LONG_DEFAULT_AFT;
  466.                   EXP : in FIELD := LONG_DEFAULT_EXP);
  467.  
  468. --------------------------------------------------------------------
  469. -- private
  470.  
  471.    -- Note : Derived types are not supported under 
  472.    -- Telesoft version 1.5
  473.  
  474.    -- The types are private to prevent direct manipulation of
  475.    -- the components of the numbers.  The exported types
  476.    -- are declarations of the appropriate types from the
  477.    -- respective package.
  478.  
  479.       -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
  480.  
  481.       -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
  482.  
  483.       -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
  484.  
  485.  
  486. --------------------------------------------------------------------
  487.  
  488. end MACHINE_ARITHMETIC_EMULATION;
  489.  
  490.  
  491. package body MACHINE_ARITHMETIC_EMULATION is
  492. --
  493. -- The package body is implemented by directly calling
  494. -- the corresponding operations in the MAE_INTEGER,
  495. -- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT packages.
  496. --
  497. end MACHINE_ARITHMETIC_EMULATION;
  498.  
  499.  
  500. 2.2  MAE_INTEGER
  501.  
  502.  
  503. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  504.  
  505. package MAE_INTEGER is
  506. -------------------------------------------------------------------
  507.  
  508. -- The purpose of this package is to emulate target machine
  509. -- integer arithmetic on host machines with 16 bit or larger 
  510. -- words.
  511. --
  512. -- The range of the supported type is as follows:
  513. --
  514. --    TARGET_INTEGER
  515. --       range of -2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS
  516. --                        to 
  517. --                 2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS-1
  518. --
  519. -- Any errors which occur during use of the arithmetic and
  520. -- boolean functions defined below will result in the
  521. -- raising of the exception "MAE_NUMERIC_ERROR".  
  522.  
  523. --
  524. -- Visible operations with MAE_INTEGER_TYPE
  525. --
  526.    type MAE_INTEGER_TYPE is private;
  527.  
  528.    -- The defined operators for this type are as follows:
  529.  
  530.    -- predefined system function "=" and function "/="
  531.    function "<"    (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  532.    function "<="   (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  533.    function ">"    (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  534.    function ">="   (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  535.  
  536.    function "+"    (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  537.    function "-"    (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  538.    function "abs"  (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  539.  
  540.    function "+"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  541.    function "-"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  542.    function "*"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  543.    function "/"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  544.    function "rem"  (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  545.    function "mod"  (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  546.  
  547.    function "**"   (LEFT : MAE_INTEGER_TYPE; RIGHT : INTEGER)
  548.                        return MAE_INTEGER_TYPE;
  549.  
  550.    function MAE_INTEGER_TYPE_VALUE(STRING_PIC : STRING)
  551.                                       return MAE_INTEGER_TYPE;
  552.  
  553.    function MAE_INTEGER_TYPE_IMAGE(STORE_PIC : MAE_INTEGER_TYPE)
  554.                                       return STRING;
  555.  
  556.    procedure GET (FROM : in STRING;
  557.                   ITEM : out MAE_INTEGER_TYPE;
  558.                   LAST : out POSITIVE);
  559.  
  560.    procedure PUT (TO : out STRING;
  561.                   ITEM : in MAE_INTEGER_TYPE;
  562.                   BASE : in NUMBER_BASE := DEFAULT_BASE);
  563.  
  564.    function TARGET_INTEGER_FIRST return MAE_INTEGER_TYPE;
  565.  
  566.    function TARGET_INTEGER_LAST return MAE_INTEGER_TYPE;
  567.  
  568. -------------------------------------------------------------------
  569. private
  570.  
  571. -- The declaration of the next variable is to allow
  572. -- the record declaration under the Telesoft version 1.5 compiler.
  573. -- A better declaration would allow the COMP_ARRAY range to be
  574. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  575.  
  576.    type MAE_INTEGER_TYPE is
  577.       record
  578.          SIGN : SIGN_TYPE := POS_SIGN;
  579.          COMPS : SHORT_COMP_ARRAY := INTEGER_COMP_ARRAY;
  580.       end record;
  581.  
  582. -------------------------------------------------------------------
  583. end MAE_INTEGER;
  584.  
  585.  
  586. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  587.  
  588. package body MAE_INTEGER is
  589. --
  590. -- The package body is implemented by using the subprograms
  591. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  592. -- components of the TARGET_INTEGER type, and in conjunction with 
  593. -- procedures to handle Integer specific operations such as 
  594. -- carrying and borrowing.
  595. --
  596. end MAE_INTEGER;
  597.  
  598.  
  599. 2.3  MAE_SHORT_FLOAT
  600.  
  601.  
  602. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  603.  
  604. package MAE_SHORT_FLOAT is
  605. -------------------------------------------------------------------
  606. -- The purpose of this package is to emulate target machine
  607. -- floating point arithmetic on host machines with 16 bit or 
  608. -- larger word size.
  609. --
  610. -- The ranges of the supported type is as follows:
  611. --
  612. --     TARGET_SHORT_FLOAT (Real)
  613. --        approximate range of 10**-38 to 10**38 and 0
  614. --        mantissa => MAE_BASIC_OPERATIONS.TARGET_SHORT_NUM_BITS
  615. --                    bit binary fraction
  616. --        exponent => -128 to 127
  617. --
  618. -- Any errors which occur during use of the arithmetic and
  619. -- boolean functions defined below will result in the
  620. -- raising of the exception "MAE_NUMERIC_ERROR".  
  621.  
  622. --
  623. -- Visible operations with MAE_SHORT_FLOAT_TYPE
  624. --
  625.    type MAE_SHORT_FLOAT_TYPE is private;
  626.  
  627.    -- The defined operators for this type are as follows:
  628.  
  629.    -- predefined system function "=" and function "/="
  630.    function "<"    (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  631.    function "<="   (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  632.    function ">"    (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  633.    function ">="   (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  634.  
  635.    function "+"    (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  636.    function "-"    (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  637.    function "abs"  (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  638.  
  639.    function "+"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  640.                        return MAE_SHORT_FLOAT_TYPE;
  641.    function "-"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  642.                        return MAE_SHORT_FLOAT_TYPE;
  643.    function "*"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  644.                        return MAE_SHORT_FLOAT_TYPE;
  645.    function "/"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  646.                        return MAE_SHORT_FLOAT_TYPE;
  647.  
  648.    function "**"   (LEFT : MAE_SHORT_FLOAT_TYPE; RIGHT : INTEGER)
  649.                        return MAE_SHORT_FLOAT_TYPE;
  650.  
  651.  
  652.    procedure GET (FROM : in STRING;
  653.                   ITEM : out MAE_SHORT_FLOAT_TYPE;
  654.                   LAST : out POSITIVE);
  655.  
  656.    procedure PUT (TO : out STRING;
  657.                   ITEM : in MAE_SHORT_FLOAT_TYPE;
  658.                   AFT : in FIELD := SHORT_DEFAULT_AFT;
  659.                   EXP : in FIELD := SHORT_DEFAULT_EXP);
  660.  
  661.    function TARGET_SHORT_FLOAT_EPSILON return MAE_SHORT_FLOAT_TYPE;
  662.  
  663.    function TARGET_SHORT_FLOAT_LARGE return MAE_SHORT_FLOAT_TYPE;
  664.  
  665.    function TARGET_SHORT_FLOAT_SMALL return MAE_SHORT_FLOAT_TYPE;
  666.  
  667.    function TARGET_SHORT_FLOAT_LAST return MAE_SHORT_FLOAT_TYPE;
  668.  
  669.    function TARGET_SHORT_FLOAT_FIRST return MAE_SHORT_FLOAT_TYPE;
  670.  
  671. -------------------------------------------------------------------
  672. private
  673.  
  674. -- The declaration of the next variable is to allow
  675. -- the record declaration under the Telesoft version 1.5 compiler.
  676. -- A better declaration would allow the COMP_ARRAY range to be
  677. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  678.  
  679.    type MAE_SHORT_FLOAT_TYPE is
  680.       record
  681.          SIGN : SIGN_TYPE := POS_SIGN;
  682.          COMPS : SHORT_COMP_ARRAY := SHORT_FLOAT_COMP_ARRAY;
  683.          EXPONENT : EXPONENT_TYPE := 0;
  684.       end record;
  685.  
  686. -------------------------------------------------------------------
  687. end MAE_SHORT_FLOAT;
  688.  
  689.  
  690. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  691.  
  692. package body MAE_SHORT_FLOAT is
  693. --
  694. -- The package body is implemented by using the subprograms
  695. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  696. -- components of the TARGET_SHORT_FLOAT type, and in conjunction with 
  697. -- procedures to handle Integer specific operations such as 
  698. -- carrying and borrowing.
  699. --
  700. end MAE_SHORT_FLOAT;
  701.  
  702.  
  703. 2.4  MAE_LONG_FLOAT
  704.  
  705.  
  706. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  707.  
  708. package MAE_LONG_FLOAT is
  709. -------------------------------------------------------------------
  710. -- The purpose of this package is to emulate target machine
  711. -- double precision floating point arithmetic on host machines
  712. -- with 16 bit or larger words.
  713. --
  714. -- The ranges of the supported type is as follows:
  715. --
  716. --     TARGET_LONG_FLOAT (Double Precision Real)
  717. --        approximate range of 10**-38 to 10**38 and 0
  718. --        mantissa => MAE_BASIC_OPERATIONS.TARGET_LONG_NUM_BITS
  719. --                    bit binary fraction
  720. --        exponent => -128 to 127
  721. --
  722. --
  723. -- Any errors which occur during use of the arithmetic and
  724. -- boolean functions defined below will result in the
  725. -- raising of the exception "MAE_NUMERIC_ERROR". 
  726.  
  727. -----------------------------------------------------------------
  728. -- Visible operations with MAE_LONG_FLOAT_TYPE
  729. --
  730.    type MAE_LONG_FLOAT_TYPE is private;
  731.  
  732.    -- The defined operators for this type are as follows:
  733.  
  734.    -- predefined system function "=" and function "/="
  735.    function "<"    (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  736.    function "<="   (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  737.    function ">"    (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  738.    function ">="   (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  739.  
  740.    function "+"    (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  741.    function "-"    (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  742.    function "abs"  (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  743.  
  744.    function "+"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  745.                        return MAE_LONG_FLOAT_TYPE;
  746.    function "-"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  747.                        return MAE_LONG_FLOAT_TYPE;
  748.    function "*"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  749.                        return MAE_LONG_FLOAT_TYPE;
  750.    function "/"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  751.                        return MAE_LONG_FLOAT_TYPE;
  752.  
  753.    function "**"   (LEFT : MAE_LONG_FLOAT_TYPE; RIGHT : INTEGER)
  754.                        return MAE_LONG_FLOAT_TYPE;
  755.  
  756.  
  757.    procedure GET (FROM : in STRING;
  758.                   ITEM : out MAE_LONG_FLOAT_TYPE;
  759.                   LAST : out POSITIVE);
  760.  
  761.    procedure PUT (TO : out STRING;
  762.                   ITEM : in MAE_LONG_FLOAT_TYPE;
  763.                   AFT : in FIELD := LONG_DEFAULT_AFT;
  764.                   EXP : in FIELD := LONG_DEFAULT_EXP);
  765.  
  766.    function TARGET_LONG_FLOAT_EPSILON return MAE_LONG_FLOAT_TYPE;
  767.  
  768.    function TARGET_LONG_FLOAT_LARGE return MAE_LONG_FLOAT_TYPE;
  769.  
  770.    function TARGET_LONG_FLOAT_SMALL return MAE_LONG_FLOAT_TYPE;
  771.  
  772.    function TARGET_LONG_FLOAT_LAST return MAE_LONG_FLOAT_TYPE;
  773.  
  774.    function TARGET_LONG_FLOAT_FIRST return MAE_LONG_FLOAT_TYPE;
  775.  
  776.  
  777. -------------------------------------------------------------------
  778. private
  779.  
  780. -- The declaration of the next variable is to allow
  781. -- the record declaration under the Telesoft version 1.5 compiler.
  782. -- A better declaration would allow the COMP_ARRAY range to be
  783. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  784.  
  785.    type MAE_LONG_FLOAT_TYPE is
  786.       record
  787.          SIGN : SIGN_TYPE := POS_SIGN;
  788.          COMPS : LONG_COMP_ARRAY := LONG_FLOAT_COMP_ARRAY;
  789.          EXPONENT : EXPONENT_TYPE := 0;
  790.       end record;
  791.  
  792. -------------------------------------------------------------------
  793. end MAE_LONG_FLOAT;
  794.  
  795.  
  796. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  797.  
  798. package body MAE_LONG_FLOAT is
  799. --
  800. -- The package body is implemented by using the subprograms
  801. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  802. -- components of the TARGET_LONG_FLOAT type, and in conjunction with 
  803. -- procedures to handle Integer specific operations such as 
  804. -- carrying and borrowing.
  805. --
  806. end MAE_LONG_FLOAT;
  807.  
  808.  
  809. 2.5  MAE_BASIC_OPERATIONS
  810.  
  811.  
  812. package MAE_BASIC_OPERATIONS is
  813. -------------------------------------------------------------------
  814. -- The package emulation packages are currently configured 
  815. -- to support Honeywell 36 bit arithmetic.
  816. --
  817. -- The purpose of this package is to provide general machine
  818. -- arithmetic types and function to support integer and floating
  819. -- point variables.  The underlying arithmetic operations will
  820. -- be performed component-wise.  It is assumed that the system
  821. -- provides for integer operations.
  822.  
  823. -------------------------------------------------------------------
  824. -- Here are the declarations of the basic constants and variables.
  825. -- Some of these constants reflect the emulation target and the
  826. -- implementation host (and compiler) dependiencies.
  827. -- It is possible that changing these constants and variables could
  828. -- improve software performance.  They are the basic elements for
  829. -- building the MAE_INTEGER_TYPE and MAE_FLOAT_TYPE types.
  830. --
  831.    -- number of bits in a component
  832.       NO_COMP_BITS : constant INTEGER := 7;
  833.    -- maximum value of a component
  834.       MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
  835.    -- component base value
  836.       BASE_COMP_VALUE : constant INTEGER := MAX_COMP_VALUE+1;
  837.    -- the values associated with a bit position,
  838.    --  initialized in the body of this package
  839.       BIT_VALUE : array (1 .. NO_COMP_BITS) of INTEGER; 
  840.    -- a component, note that the range of a true component is
  841.    -- 0 .. MAX_COMP_VALUE, although intermediate values, obtained
  842.    -- during computations, lie outside the range.
  843.       subtype COMP is INTEGER;
  844.    -- an array of components
  845.       type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
  846.    -- the use of representation specifications could direct the
  847.    --  compiler how to store the array and possibly increase efficiency.
  848.    --  note that the least significant COMP is the first in the
  849.    --  array, and consequently the most significant COMP is the last.
  850.    --
  851.    --  most signif                                     least signif
  852.    --    'last                            . .            'first
  853.    -- --------------  --------------                  --------------  
  854.    -- | 1 2 3 .. n |  | 1 2 3 .. n |      . .         | 1 2 3 .. n |
  855.    -- --------------  --------------                  -------------- 
  856.  
  857.    -- Identification of the caller
  858.       type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
  859.                                LONG_FLOAT_CLASS);
  860.  
  861.    -- Declaration for short comp arrays
  862.       SHORT_NUM_COMPS : constant INTEGER := 6;
  863.       SHORT_NUM_BITS : constant INTEGER := SHORT_NUM_COMPS * NO_COMP_BITS;
  864.       subtype SHORT_COMPONENT_ARRAY is 
  865.                  COMPONENT_ARRAY_TYPE (1 .. SHORT_NUM_COMPS);
  866.       SHORT_ZERO_ARRAY : constant SHORT_COMPONENT_ARRAY :=
  867.                     (1 .. SHORT_NUM_COMPS => 0);
  868.  
  869.       type SHORT_COMP_ARRAY is
  870.          record
  871.             COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
  872.             CLASS_OF_ARRAY : CLASSIFICATION;
  873.             BITS_SHIFTED : INTEGER;
  874.          end record;
  875.  
  876.       INTEGER_COMP_ARRAY : SHORT_COMP_ARRAY :=
  877.                                   (SHORT_ZERO_ARRAY, INTEGER_CLASS, 0);
  878.       SHORT_FLOAT_COMP_ARRAY : SHORT_COMP_ARRAY :=
  879.                                   (SHORT_ZERO_ARRAY, SHORT_FLOAT_CLASS, 0);
  880.  
  881.    -- The emulated target dependent constants for 36 bit storage
  882.       TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
  883.       TARGET_SHORT_NUM_BITS : constant INTEGER := 28;
  884.  
  885.    -- Declaration for long comp arrays
  886.       LONG_NUM_COMPS : constant INTEGER := (2 * SHORT_NUM_COMPS);
  887.       LONG_NUM_BITS : constant INTEGER := LONG_NUM_COMPS * NO_COMP_BITS;
  888.       subtype LONG_COMPONENT_ARRAY is 
  889.                  COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS);
  890.       LONG_ZERO_ARRAY : LONG_COMPONENT_ARRAY :=
  891.                     (1 .. LONG_NUM_COMPS => 0);
  892.  
  893.       type LONG_COMP_ARRAY is
  894.          record
  895.             COMPONENT_ARRAY : LONG_COMPONENT_ARRAY;
  896.             CLASS_OF_ARRAY : CLASSIFICATION;
  897.             BITS_SHIFTED : INTEGER;
  898.          end record;
  899.  
  900.       LONG_FLOAT_COMP_ARRAY : LONG_COMP_ARRAY :=
  901.                    (LONG_ZERO_ARRAY, LONG_FLOAT_CLASS, 0);
  902.    -- The emulated target dependent constants for 72 bit storage
  903.       TARGET_LONG_NUM_BITS : constant INTEGER := 64;
  904.  
  905.    -- Extended array length for LONG multiplication
  906.       subtype EXTRA_COMPONENT_ARRAY is
  907.                  COMPONENT_ARRAY_TYPE  (1 .. LONG_NUM_COMPS*2);
  908.       EXTRA_ZERO_ARRAY : EXTRA_COMPONENT_ARRAY :=
  909.                     (1 .. LONG_NUM_COMPS*2 => 0);
  910.  
  911.    -- Extended array for spaces filling string arrays
  912.       EMPTY_STRING : STRING (1 .. 40) :=
  913.           "                                        ";
  914.  
  915.    -- the sign of a number
  916.       subtype SIGN_TYPE is BOOLEAN;
  917.       NEG_SIGN : constant BOOLEAN := FALSE;
  918.       POS_SIGN : constant BOOLEAN := TRUE;
  919.  
  920.    -- the exponent of a floating type
  921.       subtype EXPONENT_TYPE is INTEGER;
  922.       MIN_EXPONENT_VALUE : constant INTEGER := -128;
  923.       MAX_EXPONENT_VALUE : constant INTEGER := 127;
  924.  
  925.    -- The follow declarations specify the value of the most
  926.    -- significant component for the digits ONE .. TEN and their
  927.    -- corresponding exponents.  The component values can be thought
  928.    -- of as a binary representation(picture) of the most signif
  929.    -- comp.  Applying the binary exponent as left shifts, it is 
  930.    -- easy to see how the digit is obtained.  This allows
  931.    -- for the length of the array to change without affecting
  932.    -- the code in the higher level packages.
  933.       POINT_FIVE : constant INTEGER := 2**(NO_COMP_BITS-1);
  934.       POINT_FIVE_SIX_TWO_FIVE : constant INTEGER :=
  935.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-4);
  936.       POINT_SIX_TWO_FIVE : constant INTEGER :=
  937.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-3);
  938.       POINT_SEVEN_FIVE : constant INTEGER :=
  939.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2);
  940.       POINT_EIGHT_SEVEN_FIVE : constant INTEGER :=
  941.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2) + 2**(NO_COMP_BITS-3);
  942.       DIGIT_PICTURE : constant array (1 .. 10) of INTEGER :=
  943.          (POINT_FIVE,
  944.           POINT_FIVE,
  945.           POINT_SEVEN_FIVE,
  946.           POINT_FIVE,
  947.           POINT_SIX_TWO_FIVE,
  948.           POINT_SEVEN_FIVE,
  949.           POINT_EIGHT_SEVEN_FIVE,
  950.           POINT_FIVE,
  951.           POINT_FIVE_SIX_TWO_FIVE,
  952.           POINT_SIX_TWO_FIVE);
  953.       DIGIT_BINARY_EXPONENT : constant array (1 .. 10) of INTEGER :=
  954.          (1, 2, 2, 3, 3, 3, 3, 4, 4, 4); 
  955.  
  956.    -- predefined attributes
  957.       LOG_2 : constant FLOAT := 0.30103;
  958.       SHORT_FLOAT_DIGITS : constant INTEGER :=
  959.           INTEGER(FLOAT(TARGET_SHORT_NUM_BITS-1)*LOG_2);
  960.       LONG_FLOAT_DIGITS : constant INTEGER :=
  961.           INTEGER(FLOAT(TARGET_LONG_NUM_BITS-1)*LOG_2);
  962.  
  963.       SHORT_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  964.       LONG_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  965.  
  966.       SHORT_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  967.       LONG_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  968.  
  969.       SHORT_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
  970.       LONG_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
  971.  
  972.       SHORT_FLOAT_MACHINE_MANTISSA : INTEGER 
  973.            renames TARGET_SHORT_NUM_BITS;
  974.       LONG_FLOAT_MACHINE_MANTISSA : INTEGER
  975.            renames TARGET_LONG_NUM_BITS;
  976.  
  977.       SHORT_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
  978.       LONG_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
  979.  
  980.       SHORT_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
  981.       LONG_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
  982.  
  983.       SHORT_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
  984.       LONG_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
  985.  
  986.       SHORT_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  987.       LONG_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  988.  
  989.    -- String IO constants
  990.    -- the only base available is base 10
  991.       subtype NUMBER_BASE is INTEGER range 2 .. 16;
  992.       DEFAULT_BASE : constant NUMBER_BASE := 10;
  993.       subtype FIELD is INTEGER range 0 .. INTEGER'last;
  994.  
  995.    -- a telesoft 1.5 restriction that is detected in the package
  996.    -- above this package does not allow
  997.    --   SHORT_DEFAULT_AFT : constant FIELD := SHORT_FLOAT_DIGITS-1;
  998.    --   LONG_DEFAULT_AFT : constant FIELD := LONG_FLOAT_DIGITS-1;
  999.       SHORT_DEFAULT_AFT : constant FIELD := 7;
  1000.       LONG_DEFAULT_AFT : constant FIELD := 17;
  1001.  
  1002.       SHORT_DEFAULT_EXP : constant FIELD := 3;
  1003.       LONG_DEFAULT_EXP : constant FIELD := 3;
  1004.  
  1005.  
  1006. -------------------------------------------------------------------
  1007. -- The exception to be raised for all arithmetic and boolean
  1008. -- expressions functions defined in this package.
  1009. --
  1010.    MAE_NUMERIC_ERROR : EXCEPTION renames STANDARD.NUMERIC_ERROR;
  1011.  
  1012. -------------------------------------------------------------------
  1013. -- Function to determine the number of components for 
  1014. -- the representation.
  1015. --
  1016.    function BITS_TO_COMPS (NO_OF_BITS : INTEGER) return INTEGER;
  1017.  
  1018. -------------------------------------------------------------------
  1019. -- Operations on the sign
  1020. --
  1021.    -- Since the SIGN_TYPE is an BOOLEAN, most of the operations
  1022.    -- are assumed system functions
  1023.   
  1024.    function CHANGE_SIGN (SIGN : SIGN_TYPE) return SIGN_TYPE;
  1025.  
  1026. -------------------------------------------------------------------
  1027. -- Operations on the exponent
  1028. --
  1029.    -- Since the EXPONENT_TYPE is an INTEGER, the operations
  1030.    -- are assumed system functions
  1031.  
  1032. -------------------------------------------------------------------
  1033. -- Operations on the component
  1034. --
  1035.    -- If the variable NO_COMP_BITS is chosen properly, a fact
  1036.    -- on which the entire package design is based, COMP and any
  1037.    -- result of binary operation (except exponentiation which is
  1038.    -- never used with COMP) of two COMPs is an INTEGER.
  1039.    -- Therefore, the operations are assumed system functions 
  1040.  
  1041. -------------------------------------------------------------------
  1042. -- Operations on short component arrays
  1043. --
  1044.    -- Predefined system functions : function "=" and function "/=". 
  1045.    -- Comparisions are handled under variable-sized arrays.
  1046.    -- The array parameters must have the same length and the same
  1047.    -- CLASSIFICATION (both INTEGER_CLASS or both SHORT_FLOAT_CLASS).
  1048.    -- The returning result component array will contain the same
  1049.    -- number of elements.
  1050.    -- For SHORT_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
  1051.    -- the array is set for higher level exponent operation.
  1052.    -- The SHORT_FLOAT_CLASS array will be normalized by these routines.
  1053.    -- Note that the least significant COMP is the first in the
  1054.    -- array, and consequently the most significant COMP is the last.
  1055.  
  1056.    function "+"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  1057.    function "-"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  1058.    function "*"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  1059.    function "/"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  1060.    function "rem"  (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  1061.  
  1062.  
  1063. -------------------------------------------------------------------
  1064. -- Operations on long component arrays
  1065. --
  1066.    -- Predefined system functions : function "=" and function "/=". 
  1067.    -- Comparisions are handled under variable-sized arrays.
  1068.    -- The array parameters must have the same length.
  1069.    -- The returning result component array will contain the same
  1070.    -- number of elements.
  1071.    -- For LONG_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
  1072.    -- the array is set for higher level exponent operation.
  1073.    -- The LONG_FLOAT_CLASS array will be normalized by these routines.
  1074.  
  1075.    function "+"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  1076.    function "-"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  1077.    function "*"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  1078.    function "/"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  1079.  
  1080.  
  1081. -------------------------------------------------------------------
  1082. -- Operations on variable-sized component arrays
  1083. --
  1084.    -- The array parameters are only comprized of components,
  1085.    -- no CLASSIFICATION or BITS_SHIFTED info is included.
  1086.    -- The array will not be normalized by these routines, that
  1087.    -- is the responsiblity of a higher level routine.
  1088.  
  1089.    -- The comparision functions.
  1090.    -- Predefined system functions : function "=" and function "/=". 
  1091.  
  1092.    function "<"    (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  1093.    function "<="   (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  1094.    function ">"    (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  1095.    function ">="   (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  1096.  
  1097.    -- This routine performs a divide by two on the array,
  1098.    -- with rounding to even.
  1099.    procedure DIVIDE_ARRAY_BY_TWO (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
  1100.  
  1101.    -- This routine sets the range of all individual COMPs within
  1102.    -- (0 .. MAX_COMP_VALUE) by looping through the array from the least 
  1103.    -- significant COMP to the most significant COMP, performing
  1104.    -- carries and borrows as necessary.  Since the most significant
  1105.    -- COMP has nowhere to carry or borrow, it is left unbounded.
  1106.    -- This allows the higher level routine to determine if shifting
  1107.    -- must occur, an error exists, or whatever.
  1108.    procedure RANGE_CHECK (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
  1109.  
  1110.    -- This routine shifts to the right and truncates a
  1111.    -- component array.  The BITS variable is the number of bits
  1112.    -- to shift the array and must be positive.
  1113.    procedure ARRAY_TRUNCATION_SHIFT_RIGHT 
  1114.       (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : in NATURAL);
  1115.  
  1116.    -- This routine sets the most significant bit in the array to one
  1117.    -- (normalized), by shifting the array to the left.
  1118.    -- The BITS variable is the number of bits the array was shifted.
  1119.    procedure ARRAY_NORMALIZE
  1120.       (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : out INTEGER);
  1121.  
  1122. -------------------------------------------------------------------
  1123. end MAE_BASIC_OPERATIONS;
  1124. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1125. --userman.rpt
  1126. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.                             EEEEEE  M    M  AAAAAA
  1141.                             EE      MM  MM  AA  AA
  1142.                             EEEEEE  MM  MM  AAAAAA
  1143.                             EE      M MM M  AA  AA
  1144.                             EEEEEE  M MM M  AA  AA
  1145.  
  1146.                         EMULATION OF MACHINE ARITHMETIC 
  1147.  
  1148.  
  1149.  
  1150.  
  1151.                             U S E R ' S    G U I D E
  1152.  
  1153.  
  1154.  
  1155.                                  30 JUNE 1985
  1156.  
  1157.  
  1158.  
  1159.                                  Prepared for
  1160.  
  1161.                            Naval Ocean Systems Center,
  1162.                             WIS Joint Program Office
  1163.  
  1164.  
  1165.                                  Prepared by
  1166.  
  1167.                              Ada* Technology Group
  1168.                               SYSCON Corportation
  1169.                               3990 Sherman Street
  1170.                           San Diego, California 92110
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.                   * Ada is a registered trademark of the
  1180.              United States Government - Ada Joint Program Office
  1181. <FF>
  1182.  
  1183.  
  1184.  
  1185.         Table of Contents
  1186.         -----------------
  1187.  
  1188.  
  1189.     1.  INTRODUCTION
  1190.  
  1191.         1.1  Purpose
  1192.         1.2  Feature Overview
  1193.         1.3  Basic Usage Overview
  1194.         1.4  Software Architecture
  1195.  
  1196.  
  1197.     2.  USE OF THE MACHINE_ARITHMETIC_EMULATION PACKAGE
  1198.  
  1199.         2.1  Installation
  1200.         2.2  Accessing the MACHINE_ARITHMETIC_EMULATION Package
  1201.         2.3  Supported Operations
  1202.         2.4  Interfacing
  1203.         2.5  Exceptions
  1204.  
  1205.         3.  ADAPTING MACHINE ARITHMETIC EMULATION
  1206.  
  1207.         3.1  Target Word Size Specification
  1208.         3.2  Host Word Size Specification and Performance Tuning
  1209.  
  1210.  
  1211.         APPENDIX A.  INTERFACE SPECIFICATION
  1212.  
  1213.         APPENDIX B.  SAMPLE CODE
  1214. <FF>
  1215.  
  1216. 1.  INTRODUCTION
  1217.  
  1218. 1.1  Purpose
  1219.  
  1220. The Emulation of Machine Arithmetic (EMA) software consists of a set
  1221. of Ada packages which support the emulation of machine arithmetic
  1222. for target processors with arbitrary word length on a host processor
  1223. of sixteen (16) bit or larger word size.  The EMA packages utilize
  1224. the general arithmetic capabilities of computer systems to remove
  1225. host specific dependencies.  The packages as delivered are
  1226. configured to emulate 36 bit Honeywell processors (e.g., Honeywell
  1227. 6040 and DPS8). This instantiation of the packages will be highly
  1228. useful in rehosting and/or converting existing application software
  1229. with embedded 36 bit accuracy requirements to the more common 16 and
  1230. 32 bit hosts. 
  1231.  
  1232.  
  1233. 1.2  Feature Overview 
  1234.  
  1235. The EMA packages are written in Ada and use the overloading feature
  1236. to add additional meaning to the arithmetic operations defined in
  1237. the package STANDARD (see the Reference Manual for the Ada
  1238. Programming Language Appendix C).  The additional meanings take the
  1239. form of arithmetic operations for integers, reals, and double
  1240. precision reals on the target (emulated) word type.  The EMA
  1241. packages provide addition, subtraction, multiplication, division,
  1242. exponentiation, arithmetic comparisions, the Ada attributes
  1243. appropriate for the type (e.g., 'FIRST), string GET and PUT
  1244. procedures, and other operations on the target word type. The entire
  1245. set of operations is listed in the interface specification provided
  1246. in Appendix A. 
  1247.  
  1248.  
  1249. 1.3  Basic Usage Overview 
  1250.  
  1251. The EMA packages provide a collection of Ada types, procedures and
  1252. functions, that perform a variety of operations.  Once the user has
  1253. included the MACHINE_ARITHMETIC_EMULATION package via an Ada context
  1254. clause, the subprograms are available to be called and executed. The
  1255. parameters and returned values for the entire set of operations are
  1256. listed in the interface specification provided in Appendix A. 
  1257.  
  1258. 1.4  Software Architecture
  1259.  
  1260. The software architecture of the EMA packages is illustrated in
  1261. Figure 1-1, which shows the Ada Graphic Notation for the "MAE"
  1262. subsystem. 
  1263.  
  1264.  
  1265. <FF>
  1266.  
  1267.          MAE
  1268.        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -            
  1269.        |                                                         |            
  1270.        |                                                         |            
  1271.        |                                                         |            
  1272.        |                    MACHINE_ARITHMETIC_EMULATION         |            
  1273.        |                    ----------------------------         |            
  1274.        |                    |                          |         |            
  1275.   (target_types)----------->|                          |         |            
  1276.        |                    |                          |         |            
  1277.   |target_operations|------>|                          |         |            
  1278.        |                    |                          |         |            
  1279.   <target_exceptions>------>|                          |         |            
  1280.        |                    |                          |--+      |            
  1281.        |                    ----------------------------  |      |            
  1282.        |                                                  |      |            
  1283.        |         +----------------------------------------+      |            
  1284.        |         |  MAE_INTEGER                                  |            
  1285.        |         |  ---------------                              |            
  1286.        |         +->|             |                              |            
  1287.        |         |  |             |                              |            
  1288.        |         |  |             |--+                           |            
  1289.        |         |  ---------------  |                           |            
  1290.        |         |                   |      MAE_BASIC_OPERATIONS |            
  1291.        |         |  MAE_SHORT_FLOAT  |      ----------------     |            
  1292.        |         |  ---------------  |      |              |     |            
  1293.        |         +->|             |  +----->|              |     |            
  1294.        |         |  |             |  |      |              |--+  |            
  1295.        |         |  |             |--+      ----------------  |  |            
  1296.        |         |  ---------------  |                        |  |            
  1297.        |         |                   |            +-----------+  |            
  1298.        |         |  MAE_LONG_FLOAT   |            |              |            
  1299.        |         |  ---------------  |            +---->|Ada_predefined_ops|  
  1300.        |         +->|             |  |                           |            
  1301.        |            |             |  |                           |            
  1302.        |            |             |--+                           |            
  1303.        |            ---------------                              |            
  1304.        |                                                         |            
  1305.        -----------------------------------------------------------            
  1306.  
  1307.                Figure 1-1 Ada Graphic Notation for MAE
  1308.  
  1309.  
  1310. The MAE subsystem consists of the visible package
  1311. MACHINE_ARITHMETIC_EMULATION which contains the exported target
  1312. types and operations, and four supporting packages.  The lowest
  1313. level supporting package is MAE_BASIC_OPERATIONS, which provides the
  1314. basic types and operations for emulating machine arithmetic and
  1315. implements the operations using the predefined arithmetic operations
  1316. of the host system.  The other support packages, MAE_INTEGER,
  1317. MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
  1318. on one of the exported types, by utilizing MAE_BASIC_OPERATIONS. 
  1319. <FF>
  1320.  
  1321. 2.  USE OF THE MACHINE_ARITHMETIC_EMULATION PACKAGE
  1322.  
  1323. 2.1  Installation
  1324.  
  1325. Before the MACHINE_ARITHMETIC_EMULATION package can be utilized, it
  1326. and its supporting packages must first be placed in the user's
  1327. program library.  This can be done by compiling, in the order
  1328. specified, the following packages into the program library: 
  1329.  
  1330.      1) MAE_BASIC_OPERATIONS
  1331.      2) MAE_INTEGER
  1332.      3) MAE_SHORT_FLOAT
  1333.      4) MAE_LONG_FLOAT
  1334.      5) MACHINE_ARITHMETIC_EMULATION
  1335.  
  1336.  
  1337. 2.2  Accessing the MACHINE_ARITHMETIC_EMULATION Package
  1338.  
  1339. The required types and subprograms needed to emulate target machine
  1340. arithmetic are exported by the package MACHINE_ARITHMETIC_EMULATION.
  1341. This package can be accessed via the Ada 'with' and 'use' clauses.
  1342. For example: 
  1343.  
  1344.    with MACHINE_ARITHMETIC_EMULATION;
  1345.    use MACHINE_ARITHMETIC_EMULATION;
  1346.  
  1347.    package body USERS_PACKAGE is
  1348.       .
  1349.       .
  1350.       procedure EXAMPLE is
  1351.          VAR1, VAR2 : TARGET_INTEGER;
  1352.          .
  1353.          .
  1354.       begin
  1355.          VAR1 := VAR1 + VAR2;  -- integer add using target
  1356.          .                     -- arithmetic (e.g., 36 bits)
  1357.          .
  1358.       end EXAMPLE;
  1359.  
  1360.    end USERS_PACKAGE;
  1361.  
  1362.  
  1363. The MACHINE_ARITHMETIC_EMULATION target types and subprograms are
  1364. now available within USERS_PACKAGE.  A more detailed example showing
  1365. the utilization of the MACHINE_ARITHMETIC_EMULATION package is given
  1366. in Appendix B. 
  1367.  
  1368.  
  1369. 2.3  Supported Operations
  1370.  
  1371. The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
  1372. relational operations on target integers (TARGET_INTEGER), floating
  1373. point numbers (TARGET_SHORT_FLOAT), and double precision floating
  1374. point numbers (TARGET_LONG_FLOAT).  The accuracy of the numbers is
  1375. given below: 
  1376.  
  1377.   where N is the number of bits in the Target word
  1378.  
  1379.      TARGET_INTEGER
  1380.         range of -2**(N-1) to 2**(N-1)-1
  1381.      TARGET_SHORT_FLOAT
  1382.         approximate range of 10**-38 to 10**38 and 0
  1383.         exponent => -128 to 127  (8 bits)
  1384.         mantissa => (N-9) bit binary fraction
  1385.      TARGET_LONG_FLOAT
  1386.         approximate range of 10**-38 to 10**38 and 0
  1387.         exponent => -128 to 127  (8 bits)
  1388.         mantissa => (2*N-9) bit binary fraction
  1389.  
  1390.   thus for 36 bit words the accuracies are:
  1391.  
  1392.      TARGET_INTEGER
  1393.         range of -2**35 to 2**35-1
  1394.      TARGET_SHORT_FLOAT
  1395.         approximate range of 10**-38 to 10**38 and 0
  1396.         exponent => -128 to 127  (8 bits)
  1397.         mantissa => 27 bit binary fraction
  1398.      TARGET_LONG_FLOAT
  1399.         approximate range of 10**-38 to 10**38 and 0
  1400.         exponent => -128 to 127  (8 bits)
  1401.         mantissa => 63 bit binary fraction
  1402.  
  1403. The 36 bit word accuracies are consistent with those given in the
  1404. Honeywell Multics FORTRAN Manual (Order Number AT58) which defines
  1405. the operation of the FORTRAN language on 60 series Honeywell
  1406. hardware. 
  1407.  
  1408. For each of the supported types, the following operations are 
  1409. defined:
  1410.      addition
  1411.      subtraction
  1412.      multiplication
  1413.      division
  1414.      remainder
  1415.      modulo
  1416.      exponentiation
  1417.      arithmetic comparisions
  1418.      numerical conversion 
  1419.      unary plus
  1420.      unary minus
  1421.      absolute value
  1422.      string get
  1423.      string put
  1424.  
  1425. For target integer types the following attributes are defined:
  1426.      'first
  1427.      'last
  1428.      'image
  1429.      'value
  1430.  
  1431. For target floating point types the following attributes are 
  1432. defined:
  1433.      'digits
  1434.      'emax
  1435.      'epsilon
  1436.      'first
  1437.      'large
  1438.      'machine_emax
  1439.      'machine_emin
  1440.      'machine_mantissa
  1441.      'machine_overflows
  1442.      'machine_radix
  1443.      'safe_emax
  1444.      'small
  1445.  
  1446. The supported attributes are called by using the form:
  1447.  
  1448.      <type name>_<attribute_name>  -- (e.g., TARGET_INTEGER_FIRST)
  1449.  
  1450. The standard tic (') symbol can not be used, because the emulated
  1451. types are not directly derived from host types. Instead the tic
  1452. symbol is replaced with an underscore. 
  1453.  
  1454. The exceptions which can be raised by using these operations are
  1455. described in Section 2.5. The entire set of operations for each of
  1456. the types is listed in the interface specification provided in
  1457. Appendix A. The calling format, parameters, and returned values of
  1458. all of the aforementioned operations conform to operations as
  1459. defined in the package STANDARD (see the Reference Manual for the
  1460. Ada Programming Language Appendix C) for each of the types.  The
  1461. functionality of the aforementioned attributes is in accordance with
  1462. the Ada predefined language attributes (see the Reference Manual for
  1463. the Ada Programming Language Appendix A). 
  1464.  
  1465.  
  1466. 2.4  Interfacing 
  1467.  
  1468. The MACHINE_ARITHMETIC_EMULATION package interfaces with other
  1469. arithmetic types through a pair of conversion procedures for each
  1470. supported type.  One of the conversion procedures converts a string
  1471. into the numeric type, and the other conversion procedure converts
  1472. the numeric type into a string.  These conversion procedures take
  1473. the form of the standard GET (from a string) and PUT (to a string)
  1474. procedures found in the package TEXT_IO. The GET and PUT procedures
  1475. function exactly as the predefined procedures, and will raise the
  1476. same exceptions when inappropriately used or given invalid data. 
  1477. The Reference Manual for the Ada Programming Language sections
  1478. 14.3.7 and 14.3.8 describe the procedures being implemented. 
  1479.  
  1480. For TARGET_INTEGER the input string must consist of decimal digits
  1481. with an optional leading sign, and without letters, commas, embedded
  1482. spaces, decimal point, exponent and other special characters.
  1483. Leading and trailing spaces are acceptable.  The assumed (and only
  1484. available) base value is ten (decimal). The length of the output
  1485. string for integer types is defined by the length of the string
  1486. object used in the PUT call.  This is accomplished by inserting
  1487. enough leading spaces to fill the string. Zero is returned as the
  1488. single digit "0". 
  1489.  
  1490. For the floating point types (TARGET_SHORT_FLOAT and
  1491. TARGET_LONG_FLOAT) the input string can include both a sign and an
  1492. exponent.  If the number of digits in the mantissa exceeds the
  1493. digits of precision, the number will be rounded. The characters must
  1494. be decimal digits with an optional leading sign, and without
  1495. letters, commas, embedded spaces, and other special characters. A
  1496. decimal point, exponent, and leading and trailing spaces are
  1497. acceptable. The assumed (and only available) base value is ten
  1498. (decimal). The defined format is: 
  1499.  
  1500.      FORE . AFT
  1501.      FORE . AFT E EXP 
  1502.      where 
  1503.         FORE  : decimal digits plus optional leading spaces and 
  1504.                 minus sign
  1505.         .     : a decimal point
  1506.         AFT   : decimal digits with possible trailing zeros
  1507.         E     : the exponent delimiter
  1508.         EXP   : the sign and the exponent with possible leading 
  1509.                 zeros
  1510.  
  1511. The length of the output string for floating point types is defined
  1512. by the length of the string object used in the PUT call.  This is
  1513. accomplished by inserting enough leading spaces to fill the string.
  1514. The number of spaces is determined by the number of digits requested
  1515. in the AFT and EXP calling parameters, and the digits of precision
  1516. of the floating point type.  The default values for AFT and EXP are
  1517. set based on the digits of precision and the maximum value of the
  1518. exponent.  The defined format is same as shown above. 
  1519.  
  1520.  
  1521. 2.5  Exceptions
  1522.  
  1523. Any errors which occur during use of the arithmetic and relational
  1524. subprograms within MACHINE_ARITHMETIC_EMULATION will result in the
  1525. raising of the exception MAE_NUMERIC_ERROR.  After the exception is
  1526. raised, the results of the operation which was in progress are
  1527. undefined. 
  1528.    
  1529. The exception MAE_NUMERIC_ERROR is originally declared in the
  1530. package specification of MAE_BASIC_OPERATIONS, and is defined to
  1531. rename the predefined exception "SYSTEM.NUMERIC_ERROR".  Thus
  1532. programs can handle arithmetic errors in a general fashion, by using
  1533. the exception handler "when NUMERIC_ERROR".  If it is necessary to
  1534. distinguish between numeric errors occuring in the system and in the
  1535. emulation packages, the original declaration of MAE_NUMERIC_ERROR
  1536. can be changed from a renames to a normal exception declaration
  1537. (i.e., "MAE_NUMERIC_ERROR : exception ;") and the packages 
  1538. recompiled.
  1539. <FF>
  1540. 3.  ADAPTING MACHINE ARITHMETIC EMULATION
  1541.  
  1542. 3.1  Target Word Size Specification
  1543.  
  1544. The use of a subset Ada compiler (TeleSoft Version 1.5) prevented
  1545. the use of generics and other generalizing features of the Ada
  1546. language in the EMA implementation. This restriction was overcome by
  1547. defining constants and parameters which control the algorithm (e.g.,
  1548. number of components used to represent the target word). These
  1549. parameters were placed in the MAE_BASIC_OPERATIONS package, and can
  1550. be used to configure the machine arithmetic emulation packages to
  1551. support different target machine word sizes. Configuration is
  1552. considered to be the modification of the packages to emulate word
  1553. sizes (other than the delivered 36 bit emulation) larger than a
  1554. given host machine. 
  1555.  
  1556. To configure the EMA packages to support arithmetic operations for
  1557. word sizes other than 36 bits, it is necessary to alter the values
  1558. of several parameters controlling the execution of the emulation.
  1559. These parameters are: 
  1560.  
  1561.      TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
  1562.      -- This is the number of bits (excluding the sign)
  1563.      -- in the standard integer number.
  1564.  
  1565.      TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
  1566.      -- This is the number of bits of mantissa in the short
  1567.      -- floating point number.
  1568.  
  1569.      TARGET_LONG_NUM_BITS : constant INTEGER := 63;
  1570.      -- This is the number of bits of mantissa in the double
  1571.      -- precision floating point number.  It is assumed to
  1572.      -- be stored in two target words.
  1573.  
  1574.      SHORT_NUM_COMPS : constant INTEGER := 6;
  1575.      -- This is the number of components used to emulate the 
  1576.      -- integer and short floating point number.  This must
  1577.      -- be adjusted to be consistent with the new values of 
  1578.      -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
  1579.      -- The value is given by dividing the number of bits in
  1580.      -- the target word by the number of bits in a component,
  1581.      -- and rounding up to the next integer.
  1582.  
  1583.      LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
  1584.      -- This is the number of components used to emulate the double
  1585.      -- precision floating point number.  This value is 
  1586.      -- automatically adjusted to be consistent with the new 
  1587.      -- value of TARGET_LONG_NUM_BITS.
  1588.  
  1589. The changing of the aforementioned parameters is sufficient to
  1590. 'reprogram' the emulation algorithm to emulate the desired target 
  1591. word size.
  1592.      
  1593.  
  1594. 3.2  Host Word Size Specification and Performance Tuning
  1595.  
  1596. The packages comprising the machine arithmetic emulation were coded
  1597. in machine-independent Ada.  In achieving this level of portability,
  1598. some of the potential, but machine-dependent, performance improving
  1599. techniques were intentionally ommitted from the design.  Several
  1600. methods for improving the performance of the emulation exist which
  1601. rely on utilizing machine and/or compiler dependent features, and
  1602. these methods can be used to tune the performance of the emulation
  1603. when machines and compilers that support the features are available.
  1604. These techniques are discussed in the paragraphs below. 
  1605.  
  1606. Use the maximum number of bits per target word component possible
  1607. for each host/ compiler combination.  The packages support the
  1608. capability to adapt to greater efficiencies available by using the
  1609. host arithmetic capability if it exceeds 16 bits (the restriction of
  1610. the original host compiler). To adapt to a host and compiler
  1611. combination which supports greater than 16 bit integer arithmetic,
  1612. the values of several parameters in the MAE_BASIC_OPERATIONS package
  1613. must be changed. These values are: 
  1614.  
  1615.      NO_COMP_BITS : constant INTEGER := 7;
  1616.      -- This value represented the number of bits in each target
  1617.      -- word component.  It is selected such that arithmetic 
  1618.      -- operations on components will not overflow the supporting 
  1619.      -- host arithmetic.  The value 7 was selected based on the 
  1620.      -- present use of 16 bit integers.  If 32 bit integer arithmetic 
  1621.      -- were available, then this value could be as high as 15.  The 
  1622.      -- greater the number of bits in each component, the fewer the 
  1623.      -- number of components that will be required, and hence the 
  1624.      -- faster the emulation.
  1625.  
  1626.      SHORT_NUM_COMPS : constant INTEGER := 6;
  1627.      -- This is the number of components used to emulate the 
  1628.      -- integer and short floating point number.  This must
  1629.      -- be adjusted to be consistent with the new values of 
  1630.      -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
  1631.      -- The value is given by dividing the number of bits in
  1632.      -- the target word by the number of bits in a component,
  1633.      -- and rounding up to the next integer.
  1634.  
  1635.      LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
  1636.      -- This is the number of components used to emulate the double
  1637.      -- precision floating point number.  This value is 
  1638.      -- automatically adjusted to be consistent with the new 
  1639.      -- value of TARGET_LONG_NUM_BITS.
  1640.  
  1641. Compile the packages using all available compiler optimization
  1642. features.  This should result in significantly improved executable
  1643. code, as a result of the compiler performing a variety of useful
  1644. transformations including the removal of many of the unnecessary
  1645. constraint checks inserted by Ada, and the optimal use of registers
  1646. to reduce load and store operations. 
  1647.  
  1648. Use 'pragma INLINE' to reduce the calling overhead.  This should be
  1649. done for the intermediate packages MAE_INTEGER, MAE_SHORT_FLOAT, and
  1650. MAE_LONG_FLOAT to reduce the calling overhead occuring between these
  1651. packages and the bodies of the exported functions of the package
  1652. MACHINE_ARITHMETIC_EMULATION (which are currently implemented as
  1653. single-statement bodies calling the appropriate procedure of the
  1654. intermediate packages). The pragma INLINE could also be applied to
  1655. certain subprograms of the MAE_BASIC_PACKAGE which are short and/or
  1656. only called once per using subprogram (e.g., CHANGE_SIGN and
  1657. ROUND_TO_HOST). 
  1658.  
  1659. Use 'pragma SUPPRESS' in the arithmetic routines of the package
  1660. MAE_BASIC_OPERATIONS (i.e., '+', '-', '*', '/') to remove
  1661. unnecessary constraint checks.  These constraint checks can be
  1662. eliminated because the number of bits utilized in each component has
  1663. been selected to insure that the host arithmetic operations can not
  1664. cause an arithmetic overflow. 
  1665. <FF>
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.                              APPENDIX A
  1684.  
  1685.  
  1686.  
  1687.                        INTERFACE SPECIFICATION
  1688. <FF>
  1689. -------------------------------------------------------------------------------
  1690. --                                                                           --
  1691. --             Emulation of Machine Arithmetic - a WIS Ada Tool              --
  1692. --                                                                           --
  1693. --                         Ada Technology Group                              --
  1694. --                         SYSCON Corporation                                --
  1695. --                         3990 Sherman Street                               --
  1696. --                         San Diego, CA. 92110                              --
  1697. --                                                                           --
  1698. --                        John Long & John Reddan                            --
  1699. --                                                                           --
  1700. -------------------------------------------------------------------------------
  1701.  
  1702. with MAE_BASIC_OPERATIONS;
  1703. with MAE_INTEGER;
  1704. with MAE_SHORT_FLOAT;
  1705. with MAE_LONG_FLOAT;
  1706.  
  1707. package MACHINE_ARITHMETIC_EMULATION is
  1708. --------------------------------------------------------------------
  1709. --  The purpose of this package is to emulate target machine
  1710. --  arithmetic on host machines with 16-bit or larger words.
  1711. --  This package will export support for target integer, real, 
  1712. --  and double precision real numbers.  
  1713. --
  1714. --  The emulation packages are currently configured to 
  1715. --  support Honeywell 36-bit arithmetic.
  1716. --
  1717. --  The ranges for the current configuration are as follows:
  1718. --
  1719. --     TARGET_INTEGER
  1720. --        range of -2**35 to 2**35-1
  1721. --     TARGET_SHORT_FLOAT
  1722. --        approximate range of 10**-38 to 10**38 and 0
  1723. --        mantissa => 27 bit binary fraction
  1724. --        exponent => -128 to 127
  1725. --     TARGET_LONG_FLOAT
  1726. --        approximate range of 10**-38 to 10**38 and 0
  1727. --        mantissa => 63 bit binary fraction
  1728. --        exponent => -128 to 127
  1729. --
  1730. --  Any errors which occur during use of the arithmetic and
  1731. --  boolean functions defined below will result in the
  1732. --  raising of the exception "MAE_NUMERIC_ERROR".  The 
  1733. --  exception declared in this package is a rename of
  1734. --  the predefined exception NUMERIC_ERROR.  This can be
  1735. --  changed for programs needing to handle arithmetic
  1736. --  exceptions generated by the emulation packages separately.
  1737. --
  1738.    
  1739.  
  1740. --------------------------------------------------------------------
  1741. -- Parameters within MAE_BASIC_OPERATIONS that need to be available
  1742. -- to the user of the Emulation of Machine Arithmetic package:
  1743. --
  1744.    subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
  1745.    DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
  1746.  
  1747.    subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
  1748.    TARGET_SHORT_DEFAULT_AFT : FIELD 
  1749.                  renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
  1750.    TARGET_LONG_DEFAULT_AFT : FIELD 
  1751.                  renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
  1752.    TARGET_SHORT_DEFAULT_EXP : FIELD 
  1753.                  renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
  1754.    TARGET_LONG_DEFAULT_EXP : FIELD 
  1755.                  renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
  1756.  
  1757.    --
  1758.    -- predefined attributes for the emulated types
  1759.    --
  1760.       TARGET_SHORT_FLOAT_DIGITS : INTEGER 
  1761.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS; 
  1762.       TARGET_LONG_FLOAT_DIGITS : INTEGER 
  1763.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS; 
  1764.  
  1765.       TARGET_SHORT_FLOAT_EMAX : INTEGER 
  1766.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
  1767.       TARGET_LONG_FLOAT_EMAX : INTEGER
  1768.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
  1769.  
  1770.       TARGET_SHORT_FLOAT_MACHINE_EMAX : INTEGER 
  1771.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
  1772.       TARGET_LONG_FLOAT_MACHINE_EMAX : INTEGER 
  1773.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
  1774.  
  1775.       TARGET_SHORT_FLOAT_MACHINE_EMIN : INTEGER 
  1776.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
  1777.       TARGET_LONG_FLOAT_MACHINE_EMIN : INTEGER 
  1778.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
  1779.  
  1780.       TARGET_SHORT_FLOAT_MACHINE_MANTISSA : INTEGER 
  1781.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
  1782.       TARGET_LONG_FLOAT_MACHINE_MANTISSA : INTEGER
  1783.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
  1784.  
  1785.       TARGET_SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN 
  1786.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
  1787.       TARGET_LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
  1788.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
  1789.  
  1790.       TARGET_SHORT_FLOAT_MACHINE_RADIX : INTEGER
  1791.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
  1792.       TARGET_LONG_FLOAT_MACHINE_RADIX : INTEGER
  1793.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
  1794.  
  1795.       TARGET_SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
  1796.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
  1797.       TARGET_LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
  1798.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
  1799.  
  1800.       TARGET_SHORT_FLOAT_SAFE_EMAX : INTEGER 
  1801.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
  1802.       TARGET_LONG_FLOAT_SAFE_EMAX : INTEGER 
  1803.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
  1804.  
  1805. --------------------------------------------------------------------
  1806. -- Visible operations with TARGET_INTEGER
  1807. --
  1808. -- The follow declaration should be private
  1809.  
  1810.    subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
  1811.  
  1812.    -- The defined operators for this type are as follows:
  1813.  
  1814.    function TARGET_INTEGER_FIRST return TARGET_INTEGER;
  1815.    function TARGET_INTEGER_LAST return TARGET_INTEGER;
  1816.  
  1817.    -- Predefined system function "=" and function "/="
  1818.    function "<"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  1819.    function "<="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  1820.    function ">"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  1821.    function ">="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  1822.  
  1823.    function "+"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1824.    function "-"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1825.    function "abs"  (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1826.  
  1827.    function "+"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1828.    function "-"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1829.    function "*"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1830.    function "/"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1831.    function "rem"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1832.    function "mod"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  1833.  
  1834.    function "**"   (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
  1835.                        return TARGET_INTEGER;
  1836.  
  1837.    function TARGET_INTEGER_VALUE (STRING_PIC : STRING) 
  1838.                        return TARGET_INTEGER;
  1839.    function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER) 
  1840.                        return STRING;
  1841.  
  1842.    procedure GET (FROM : in STRING;
  1843.                   ITEM : out TARGET_INTEGER;
  1844.                   LAST : out POSITIVE);
  1845.  
  1846.    procedure PUT (TO : out STRING;
  1847.                   ITEM : in TARGET_INTEGER;
  1848.                   BASE : in NUMBER_BASE := DEFAULT_BASE);
  1849.  
  1850. --------------------------------------------------------------------
  1851. -- Visible operations with TARGET_SHORT_FLOAT
  1852. --
  1853. -- The following declaration should be private
  1854.  
  1855.    subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
  1856.  
  1857.    -- The defined operators for this type are as follows:
  1858.  
  1859.  
  1860.    function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
  1861.    function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
  1862.    function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
  1863.    function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
  1864.    function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
  1865.  
  1866.    -- Predefined system function "=" and function "/="
  1867.    function "<"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  1868.    function "<="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  1869.    function ">"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  1870.    function ">="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  1871.  
  1872.    function "+"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1873.    function "-"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1874.    function "abs"  (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1875.  
  1876.    function "+"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1877.    function "-"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1878.    function "*"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1879.    function "/"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  1880.  
  1881.    function "**"   (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER) 
  1882.                        return TARGET_SHORT_FLOAT;
  1883.  
  1884.    procedure GET (FROM : in STRING;
  1885.                   ITEM : out TARGET_SHORT_FLOAT;
  1886.                   LAST : out POSITIVE);
  1887.  
  1888.    procedure PUT (TO : out STRING;
  1889.                   ITEM : in TARGET_SHORT_FLOAT;
  1890.                   AFT : in FIELD := TARGET_SHORT_DEFAULT_AFT;
  1891.                   EXP : in FIELD := TARGET_SHORT_DEFAULT_EXP);
  1892.  
  1893. --------------------------------------------------------------------
  1894. -- Visible operations with TARGET_LONG_FLOAT
  1895. --
  1896. -- The following declaration should be private
  1897.  
  1898.    subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
  1899.  
  1900.    -- The defined operators for this type are as follows:
  1901.  
  1902.    function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
  1903.    function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
  1904.    function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
  1905.    function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
  1906.    function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
  1907.  
  1908.    -- Predefined system function "=" and function "/="
  1909.    function "<"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  1910.    function "<="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  1911.    function ">"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  1912.    function ">="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  1913.  
  1914.    function "+"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1915.    function "-"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1916.    function "abs"  (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1917.  
  1918.    function "+"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1919.    function "-"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1920.    function "*"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1921.    function "/"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  1922.  
  1923.    function "**"   (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER) 
  1924.                        return TARGET_LONG_FLOAT;
  1925.  
  1926.    procedure GET (FROM : in STRING;
  1927.                   ITEM : out TARGET_LONG_FLOAT;
  1928.                   LAST : out POSITIVE);
  1929.  
  1930.    procedure PUT (TO : out STRING;
  1931.                   ITEM : in TARGET_LONG_FLOAT;
  1932.                   AFT : in FIELD := TARGET_LONG_DEFAULT_AFT;
  1933.                   EXP : in FIELD := TARGET_LONG_DEFAULT_EXP);
  1934.  
  1935. --------------------------------------------------------------------
  1936. -- private
  1937.  
  1938.    -- Note : Derived types are not supported under 
  1939.    -- Telesoft version 1.5
  1940.  
  1941.    -- The types are private to prevent direct manipulation of
  1942.    -- the components of the numbers.  The exported types
  1943.    -- are declarations of the appropriate types from the
  1944.    -- respective package.
  1945.  
  1946.       -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
  1947.  
  1948.       -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
  1949.  
  1950.       -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
  1951.  
  1952.  
  1953. --------------------------------------------------------------------
  1954.  
  1955. end MACHINE_ARITHMETIC_EMULATION;
  1956. <FF>
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.                              APPENDIX B
  1975.  
  1976.  
  1977.  
  1978.                              SAMPLE CODE
  1979. <FF>
  1980.  
  1981.  
  1982. --  The following code shows a sample procedure which utilizes
  1983. --  the facilities of the MACHINE_ARITHMETIC_EMULATION package
  1984. --  to perform some simple computations.
  1985.  
  1986. with MACHINE_ARITHMETIC_EMULATION; use MACHINE_ARITHMETIC_EMULATION;
  1987. with TEXT_IO; use TEXT_IO;
  1988.  
  1989. procedure PRINT_SOME_TARGET_SHORT_FLOAT_RESULTS is
  1990. --
  1991. --  This procedure prompts the user for several operands and
  1992. --  then prints the results of selected TARGET_SHORT_FLOAT operations.
  1993. --
  1994.    B_RESULT : BOOLEAN;
  1995.    LAST : POSITIVE;
  1996.    NO_DATA : EXCEPTION;
  1997.    POWER : INTEGER;
  1998.    RESULTS_STRING : STRING (1..TARGET_SHORT_FLOAT_DIGITS+7);
  1999.    SF1, SF2 : TARGET_SHORT_FLOAT;
  2000.    SFRESULT, SFRESULT1 : TARGET_SHORT_FLOAT;
  2001.  
  2002.    procedure GET_TARGET_SHORT_FLOAT_OPERANDS is
  2003.    -- 
  2004.    --  Get two TARGET_SHORT_FLOAT operands plus an Integer number for
  2005.    --  use as a power in a exponentiation operation
  2006.    --   
  2007.       CNT, CNT1 : NATURAL;
  2008.       DONE : BOOLEAN := FALSE;
  2009.       EXIT_MENU : exception;
  2010.       OP_STRING : STRING (1..80);
  2011.    begin
  2012.       loop
  2013.          begin
  2014.             PUT_LINE("MACHINE ARITHMETIC EMULATION");
  2015.             PUT_LINE("TARGET_SHORT_FLOAT OPERATIONS");
  2016.             PUT_LINE("OPERAND INPUT");
  2017.             NEW_LINE;
  2018.             TEXT_IO.PUT("OP1 ? ");
  2019.             GET_LINE(OP_STRING, CNT);
  2020.             if CNT = 0 then
  2021.                raise EXIT_MENU;
  2022.             end if;
  2023.    
  2024.             GET (OP_STRING(1..CNT),SF1,LAST);
  2025.  
  2026.             NEW_LINE;
  2027.             TEXT_IO.PUT("POWER ? ");
  2028.             GET_LINE(OP_STRING, CNT);
  2029.             if CNT = 0 then
  2030.                raise EXIT_MENU;
  2031.             end if;
  2032.  
  2033.             INTEGER_IO.GET (OP_STRING(1..CNT),POWER,CNT1);        
  2034.                -- no INTEGER'value function implemented
  2035.  
  2036.             NEW_LINE;
  2037.             TEXT_IO.PUT("OP2 ? ");
  2038.             GET_LINE(OP_STRING, CNT);
  2039.             if CNT = 0 then
  2040.                raise EXIT_MENU;
  2041.             end if;
  2042.  
  2043.             GET (OP_STRING(1..CNT),SF2,LAST);
  2044.  
  2045.             DONE := TRUE;
  2046.  
  2047.          exception
  2048.             when EXIT_MENU =>
  2049.                raise NO_DATA;
  2050.  
  2051.             when others =>
  2052.                PUT_LINE("*** ILLEGAL DATA ***");
  2053.                NEW_LINE;
  2054.                TEXT_IO.PUT("return to continue ...");
  2055.  
  2056.          end;
  2057.  
  2058.          if DONE then
  2059.             exit;
  2060.          end if;
  2061.       end loop;
  2062.  
  2063.    end GET_TARGET_SHORT_FLOAT_OPERANDS;
  2064.  
  2065.  
  2066. begin
  2067.  
  2068.    -- get the operands
  2069.    GET_TARGET_SHORT_FLOAT_OPERANDS;
  2070.  
  2071.    -- print the results of TARGET_SHORT_FLOAT "+"
  2072.    TEXT_IO.PUT("OP1 + OP2                = ");
  2073.    SFRESULT := SF1 + SF2;
  2074.    PUT(RESULTS_STRING,SFRESULT);
  2075.    PUT_LINE(RESULTS_STRING);
  2076.  
  2077.    -- print the results of TARGET_SHORT_FLOAT "-"
  2078.    TEXT_IO.PUT("OP1 - OP2                = ");
  2079.    SFRESULT := SF1 - SF2;
  2080.    PUT(RESULTS_STRING,SFRESULT);
  2081.    PUT_LINE(RESULTS_STRING);
  2082.  
  2083.    -- print the results of TARGET_SHORT_FLOAT "*"
  2084.    TEXT_IO.PUT("OP1 * OP2                = ");
  2085.    SFRESULT := SF1 * SF2;
  2086.    PUT(RESULTS_STRING,SFRESULT);
  2087.    PUT_LINE(RESULTS_STRING);
  2088.  
  2089.    -- print the results of TARGET_SHORT_FLOAT "/"
  2090.    TEXT_IO.PUT("OP1 / OP2                = ");
  2091.    SFRESULT := SF1 / SF2;
  2092.    PUT(RESULTS_STRING,SFRESULT);
  2093.    PUT_LINE(RESULTS_STRING);
  2094.  
  2095.    -- print the results of TARGET_SHORT_FLOAT ">"
  2096.    TEXT_IO.PUT("OP1 > OP2                = ");
  2097.    B_RESULT := SF1 > SF2;
  2098.    TEXT_IO.PUT(BOOLEAN'image(B_RESULT));
  2099.    NEW_LINE;
  2100.  
  2101.    -- print the results of TARGET_SHORT_FLOAT "**"
  2102.    TEXT_IO.PUT("OP1 ** POWER             = ");
  2103.    SFRESULT1 := SF1 ** POWER;
  2104.    PUT(RESULTS_STRING,SFRESULT1);
  2105.    PUT_LINE(RESULTS_STRING);
  2106.  
  2107. end PRINT_SOME_TARGET_SHORT_FLOAT_RESULTS;
  2108. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2109. --techinfo.rpt
  2110. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.                             EEEEEE  M    M  AAAAAA
  2125.                             EE      MM  MM  AA  AA
  2126.                             EEEEEE  MM  MM  AAAAAA
  2127.                             EE      M MM M  AA  AA
  2128.                             EEEEEE  M MM M  AA  AA
  2129.  
  2130.                         EMULATION OF MACHINE ARITHMETIC 
  2131.  
  2132.  
  2133.  
  2134.  
  2135.               T E C H N I C A L   I N F O R M A T I O N   R E P O R T
  2136.  
  2137.  
  2138.  
  2139.                                  30 JUNE 1985
  2140.  
  2141.  
  2142.  
  2143.                                  Prepared for
  2144.  
  2145.                            Naval Ocean Systems Center,
  2146.                             WIS Joint Program Office
  2147.  
  2148.  
  2149.                                  Prepared by
  2150.  
  2151.                              Ada* Technology Group
  2152.                               SYSCON Corportation
  2153.                               3990 Sherman Street
  2154.                           San Diego, California 92110
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.                   * Ada is a registered trademark of the
  2164.              United States Government - Ada Joint Program Office
  2165. <FF>
  2166.  
  2167.  
  2168.  
  2169.         Table of Contents
  2170.         -----------------
  2171.  
  2172.  
  2173.     1.  INTRODUCTION
  2174.     1.1    Feature Overview
  2175.     1.2    Basic Usage Overview
  2176.  
  2177.     2.  SOFTWARE ARCHITECTURE
  2178.  
  2179.     3.  ALGORITHMS AND DATA STRUCTURES
  2180.     3.1    Requirements
  2181.     3.2    Alternatives and Analysis
  2182.         3.2.1     Alternative Component Architectures
  2183.         3.2.2     Analysis of Component Architectures
  2184.     3.3    Detailed Description of Binary Component Architecture
  2185.  
  2186.         4.  MACROSCOPIC DESIGN
  2187.     4.1    Package MACHINE_ARITHMETIC_EMULATION
  2188.         4.2    Package MAE_INTEGER
  2189.         4.3    Package MAE_SHORT_FLOAT
  2190.         4.4    Package MAE_LONG_FLOAT
  2191.         4.5    Package MAE_BASIC_OPERATIONS
  2192.  
  2193.         5.  ADA ISSUES
  2194.         5.1    Compiler Selection
  2195.         5.2    Compiler Impact on Design and Implementation
  2196.         5.3    Configuring the Program
  2197.         5.3.1     Target Word Size Specification
  2198.         5.3.2     Host Word Size Specification and Performance Tuning
  2199.  
  2200.         6.  TESTING
  2201.         6.1    Unit Testing
  2202.         6.1.1     Approach 
  2203.         6.1.2     Results
  2204.         6.2    Integration Testing
  2205.         6.2.1     Approach 
  2206.         6.2.2     Results
  2207.  
  2208.  
  2209.         Appendices
  2210.  
  2211.         A.  TEST RESULTS
  2212.         A.1    Integer Test Results
  2213.         A.2    Short Float Test Results
  2214.         A.3    Long Float Test Results
  2215.  
  2216. <FF>
  2217.  
  2218.  
  2219.  
  2220. 1.  INTRODUCTION
  2221.  
  2222. 1.1  Feature Overview
  2223.  
  2224. SYSCON Corporation has developed an Emulation of Machine Arithmetic
  2225. (EMA) capability, written in Ada, which supports the emulation of
  2226. machine arithmetic for target processors with arbitrary word length
  2227. on host processors supporting integer arithmetic on 16 bit or larger
  2228. words. This is accomplished by overloading the predefined arithmetic
  2229. operations in package STANDARD (see Appendix C of the Reference
  2230. Manaul for the Ada Programming Language) for target integers, reals,
  2231. and double precision reals. The complete specification of the
  2232. MACHINE_ARITHMETIC_EMULATION package is provided in the Macroscopic
  2233. Design (see Section 4.1). The emulation is accomplished by
  2234. decomposing the target word into components (using Ada record
  2235. structures) easily handled by the host processor's predefined
  2236. arithmetic operations. During the design of the EMA mechanization,
  2237. the computational efficiency and generality (for transportability
  2238. and reusability) of the solution were of primary importance. 
  2239.  
  2240.  
  2241. 1.2  Basic Usage Overview
  2242.  
  2243. In the past, conversion of software from one host to another was
  2244. often extensively complicated by the different precisions of the
  2245. host processors and by underlying assumptions in the original
  2246. software about the precision of the hardware.  This is particularly
  2247. true for computationally oriented applications requiring extensive
  2248. numerical analysis in the design effort, such as the determination
  2249. of computational ordering to maintain sufficient digits of
  2250. precision. 
  2251.  
  2252. Ada provides general capabilities, such as overloading and generics,
  2253. which can be used to minimize the direct dependencies of application
  2254. software on the host processor hardware and software. The EMA
  2255. packages are a specific instance of utilizing this general
  2256. capability to remove host dependencies.  The packages as delivered
  2257. are configured to emulate 36-bit Honeywell processors and, as such,
  2258. will be highly useful in rehosting and/or converting existing WWMCCS
  2259. applications software with embedded 36-bit accuracy requirements to
  2260. more common 16- and 32-bit hosts. This is accomplished by utilizing
  2261. Ada overloading to permit transparent utilization of target (36-bit)
  2262. accuracy on 16- and 32-bit hardware.  Computations of the emulated
  2263. target type are accomplished by incorporating this package via Ada
  2264. 'with' and 'use' clauses, and by changing the operands to the
  2265. appropriate target type defined in the MACHINE_ARITHMETIC_EMULATION
  2266. package. 
  2267. <FF>
  2268.  
  2269.  
  2270. 2.  SOFTWARE ARCHITECTURE
  2271.  
  2272. The software architecture of the EMA packages is illustrated in 
  2273. Figure 2-1, which shows the Ada Graphic Notation for the "MAE" 
  2274. subsystem.
  2275.  
  2276.  
  2277.          MAE
  2278.        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -            
  2279.        |                                                         |            
  2280.        |                                                         |            
  2281.        |                                                         |            
  2282.        |                    MACHINE_ARITHMETIC_EMULATION         |            
  2283.        |                    ----------------------------         |            
  2284.        |                    |                          |         |            
  2285.   (target_types)----------->|                          |         |            
  2286.        |                    |                          |         |            
  2287.   |target_operations|------>|                          |         |            
  2288.        |                    |                          |         |            
  2289.   <target_exceptions>------>|                          |         |            
  2290.        |                    |                          |--+      |            
  2291.        |                    ----------------------------  |      |            
  2292.        |                                                  |      |            
  2293.        |         +----------------------------------------+      |            
  2294.        |         |  MAE_INTEGER                                  |            
  2295.        |         |  ---------------                              |            
  2296.        |         +->|             |                              |            
  2297.        |         |  |             |                              |            
  2298.        |         |  |             |--+                           |            
  2299.        |         |  ---------------  |                           |            
  2300.        |         |                   |      MAE_BASIC_OPERATIONS |            
  2301.        |         |  MAE_SHORT_FLOAT  |      ----------------     |            
  2302.        |         |  ---------------  |      |              |     |            
  2303.        |         +->|             |  +----->|              |     |            
  2304.        |         |  |             |  |      |              |--+  |            
  2305.        |         |  |             |--+      ----------------  |  |            
  2306.        |         |  ---------------  |                        |  |            
  2307.        |         |                   |            +-----------+  |            
  2308.        |         |  MAE_LONG_FLOAT   |            |              |            
  2309.        |         |  ---------------  |            +---->|Ada_predefined_ops|  
  2310.        |         +->|             |  |                           |            
  2311.        |            |             |  |                           |            
  2312.        |            |             |--+                           |            
  2313.        |            ---------------                              |            
  2314.        |                                                         |            
  2315.        -----------------------------------------------------------            
  2316.  
  2317.                 Figure 2-1. Ada Graphic Notation for MAE
  2318.  
  2319.  
  2320. The MAE subsystem consists of the visible package
  2321. MACHINE_ARITHMETIC_EMULATION which contains the exported target
  2322. types and operations, and four supporting packages.  The lowest
  2323. level supporting package is MAE_BASIC_OPERATIONS, which provides the
  2324. basic types and operations for emulating machine arithmetic and
  2325. implements the operations using the predefined arithmetic operations
  2326. of the host system.  The other support packages, MAE_INTEGER,
  2327. MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
  2328. on one of the exported types by utilizing MAE_BASIC_OPERATIONS. 
  2329.  
  2330. The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
  2331. relational operations on target integers (TARGET_INTEGER), floating
  2332. point numbers (TARGET_SHORT_FLOAT), and double precision floating
  2333. point numbers (TARGET_LONG_FLOAT).  The precision of the numbers is
  2334. given below: 
  2335.  
  2336.   where N is the number of bits in the target word
  2337.  
  2338.      TARGET_INTEGER
  2339.         range of -2**(N-1) to 2**(N-1)-1
  2340.      TARGET_SHORT_FLOAT
  2341.         approximate range of 10**-38 to 10**38 and 0
  2342.         exponent => -128 to 127  (8 bits)
  2343.         mantissa => (N-9) bit binary fraction
  2344.      TARGET_LONG_FLOAT
  2345.         approximate range of 10**-38 to 10**38 and 0
  2346.         exponent => -128 to 127  (8 bits)
  2347.         mantissa => (2*N-9) bit binary fraction
  2348.  
  2349.   thus for 36-bit words the precisons are:
  2350.  
  2351.      TARGET_INTEGER
  2352.         range of -2**35 to 2**35-1
  2353.      TARGET_SHORT_FLOAT
  2354.         approximate range of 10**-38 to 10**38 and 0
  2355.         exponent => -128 to 127  (8 bits)
  2356.         mantissa => 27-bit binary fraction
  2357.      TARGET_LONG_FLOAT
  2358.         approximate range of 10**-38 to 10**38 and 0
  2359.         exponent => -128 to 127  (8 bits)
  2360.         mantissa => 63-bit binary fraction
  2361.  
  2362. The precision requirements for the initial configuration of the
  2363. Emulation of Machine Arithmetic are defined by the bit-level storage
  2364. allocation of selected Honeywell processors (mdels 6040, 6060, 6080,
  2365. and DPS8).  The 36-bit word precisions are consistent with those given
  2366. in the Honeywell Multics FORTRAN Manual (Order Number AT58) which
  2367. defines the operation of the FORTRAN language on Honeywell 60 series
  2368. hardware. 
  2369.  
  2370. For each of the supported types, the following operations are 
  2371. defined:
  2372.      addition                   arithmetic comparisons
  2373.      subtraction                numerical conversion
  2374.      multiplication             unary plus
  2375.      division                   unary minus
  2376.      remainder                  absolute value
  2377.      modulo                     string get
  2378.      exponentiation             string put
  2379.  
  2380. For target integer types, the following attributes are defined:
  2381.      'first
  2382.      'last
  2383.      'image
  2384.      'value
  2385.  
  2386. For target floating point types, the following attributes are 
  2387. defined:
  2388.      'digits
  2389.      'emax
  2390.      'epsilon
  2391.      'first
  2392.      'large
  2393.      'machine_emax
  2394.      'machine_emin
  2395.      'machine_mantissa
  2396.      'machine_overflows
  2397.      'machine_radix
  2398.      'safe_emax
  2399.      'small
  2400.  
  2401. The supported attributes are called by using the form:
  2402.  
  2403.      <type name>_<attribute_name>  -- (e.g., TARGET_INTEGER_FIRST)
  2404.  
  2405. The standard tic (') symbol can not be used because the emulated
  2406. types are not directly derived from host types. Instead the tic
  2407. symbol is replaced with an underscore. 
  2408.  
  2409. The entire set of operations for each of the types is listed in the
  2410. interface specification provided in Section 4.  The calling format,
  2411. parameters, and returned values of all of the aforementioned
  2412. operations conform to operations as defined in the package STANDARD
  2413. (see Appendix C of the Reference Manual for the Ada Programming
  2414. Language) for each of the types.  The functionality of the
  2415. aforementioned attributes is in accordance with the Ada predefined
  2416. language attributes (see Appendix A of the Reference Manual for the
  2417. Ada Programming Language). 
  2418. <FF>
  2419.  
  2420. 3.  ALGORITHMS AND DATA STRUCTURES
  2421.  
  2422. 3.1  Requirements
  2423.  
  2424. The purpose of the data structures utilized by the emulation
  2425. packages is to provide a flexible method of storing arithmetic data
  2426. (which exceeds the word size of the host processor) which can be
  2427. efficiently manipulated by an algorithm for emulating machine
  2428. arithmetic.  The requirements for the data structure are as follows:
  2429.  
  2430.      - The data structure must provide the same precision
  2431.        as the emulated type of the target processor.
  2432.      - The implementation of the data structure must be machine 
  2433.        independent (e.g., no representation specifications).
  2434.      - The data structure must be parameterized to provide a 
  2435.        flexible approach for emulating arbitrary word sizes.
  2436.      - The data structure must segment the emulated word to be
  2437.        compatible with 16-bit and larger native operations, and
  2438.        be able to take advantage of the greater power of 32-bit
  2439.        host arithmetic when available.
  2440.      - The data structure must be compatible with computationally
  2441.        efficient algorithms.
  2442.  
  2443. The purpose of the EMA algorithm is to model the arithmetic
  2444. operations of a target processor with longer word lengths than the
  2445. host processor.  This will be done through manipulation of the EMA
  2446. data structures.  The requirements for the algorithm are: 
  2447.  
  2448.      - The algorithm must provide the same precision as the 
  2449.        emulated arithmetic operations of the target processor.
  2450.      - The algorithm must be as time efficient as possible.
  2451.      - The implementation of the algorithm must be machine 
  2452.        independent.
  2453.  
  2454. The precision requirements for the initial configuration of the
  2455. Emulation of Machine Arithmetic are defined by the bit-level storage
  2456. allocation of selected Honeywell processors (mdels 6040, 6060, 6080,
  2457. and DPS8).  The 36-bit word precisions are consistent with those
  2458. given in the Honeywell Multics FORTRAN Manual (Order Number AT58)
  2459. which defines the operation of the FORTRAN language on Honeywell 60
  2460. series hardware. These accuracy requirements are shown in Section 2.
  2461. In implementing the required accuracies, the EMA architecture
  2462. provides parameterized storage allocation in package
  2463. MAE_BASIC_OPERATIONS, which controls the number of bits allocated
  2464. for number constituents (e.g., mantissa and exponent). 
  2465.  
  2466.  
  2467. 3.2  Alternatives and Analysis
  2468.  
  2469. The current architecture was selected after an analysis of possible
  2470. alternative methods, that resulted in the determination that fewer
  2471. operations were required with the binary component architecture. The
  2472. predefined arithmetic operations of the supporting host are used to
  2473. manipulate the components (e.g., components are added with the
  2474. standard Integer '+' operation).  The size of a component is
  2475. selected to preclude host arithmetic overflow when performing
  2476. component arithmetic. Since the number of component manipulations
  2477. required to complete an emulated operation is proportional to the
  2478. number of components, the size of the component is parameterized so
  2479. that it can be made as large as possible. 
  2480.  
  2481. 3.2.1  Alternative Component Architectures
  2482.  
  2483. The following component architectures were considered during the
  2484. selection of the data representations and algorithms to be used by
  2485. the MAE packages: bit array, binary component, and decimal digit. 
  2486. Each of the architectures was considered viable in the sense that it
  2487. could be used to implement an emulation. 
  2488.  
  2489. The bit array architecture is based on a data structure consisting
  2490. of an array of bits which represents the data.  Integers would be a
  2491. simple binary structure with a sign field.  Reals would also be a
  2492. binary structure with an implied decimal point preceding the number,
  2493. a sign field, and an appropriately sized exponent field. 
  2494.  
  2495. The binary component architecture is a modified version of the bit
  2496. array architecture.  It is based on a data structure consisting of
  2497. an array of components representing the data.  The components can be
  2498. thought of being composed of a group of bits.  The size of the
  2499. component is chosen to best match the host system's predefined
  2500. arithmetic operations.  Integers would be a simple component array
  2501. structure with a sign field.  Reals would be an array structure with
  2502. an implied decimal point preceding the number, a sign field, and an
  2503. appropriately sized exponent field. 
  2504.  
  2505. The decimal digit architecture is based on a data structure
  2506. consisting of an array of simple decimal digits representing the
  2507. data.  Integers would be a simple digit array structure with a sign
  2508. field.  Reals would also be an array structure with an implied
  2509. decimal point preceding the number, a sign field, and an
  2510. appropriately sized exponent field. 
  2511.  
  2512. 3.2.2  Analysis of Component Architectures
  2513.  
  2514. Each of the approaches listed in the previous Section was compared
  2515. to determine which method would result in the most time-efficient
  2516. emulation implementation.  The comparison was analytical, using
  2517. known facts concerning the relative performance of certain types of
  2518. instructions and the efficiency and availability of operations in
  2519. Ada to evaluate prototypes of each approach.  The actual utilization
  2520. of performance measurements from coded prototypes was not possible
  2521. because the necessary instrumentation was not available. In making
  2522. this analysis, no assumptions were made concerning the code
  2523. generation and optimization techniques of the host compiler. 
  2524.  
  2525. The bit array architecture requires extensive use of low level bit
  2526. operations to be effective and, assuming their availability, this
  2527. technique was considered likely to be the most efficient.  Shift
  2528. operations, bit testing, and storage mapping are examples of bit
  2529. operations not available in the Ada language which are required if
  2530. the bit array architecture is to be effective.  To obtain the
  2531. necessary bit operations would require the use of machine dependent
  2532. facilities, such as interfacing to assembly language, the use of
  2533. representation clauses, or utilizing assumptions about a compiler's
  2534. method of code generation, which was expressly prohibited by the
  2535. requirements. The lack of these bit mapping facilities led to the
  2536. early rejection of this approach (although it should be noted that
  2537. the bit array architecture is identical to the binary component
  2538. architecture with the group of bits being of size one). 
  2539.  
  2540. The remaining architectures, binary component and decimal digit were
  2541. compared.  A sample integer multiply routine was written in Ada
  2542. using both approaches. The approaches were compared by developing a
  2543. method of counting the operations required to implement the
  2544. algorithms. The method was implemented by inserting statements which
  2545. counted the frequency of selected operations into the code of the
  2546. binary component and decimal digit prototypes.  The component size
  2547. used was seven bits, which limits the value of a component to a
  2548. maximum of 127 and makes the positional value of each component a
  2549. power of 128.  The decimal digit used the range zero through nine.
  2550. For example, a component number (3, 56, 120), a digit number
  2551. (5,6,4,4,0), and the decimal number 56440 are equivalent since 
  2552.  
  2553.      (3, 56, 120) = 3*(128**2) + 56(128**1) + 120(128**0)
  2554.                   = 3*16384 + 56*128 + 120
  2555.                   = 49152 + 7168 + 120
  2556.                   = 56440
  2557.       (5,6,4,4,0) = 5*(10**4) + 6*(10**3) + 4*(10**2) + 4*(10**1) + 0
  2558.        
  2559. Not every statement in the algorithms was counted as an operation. 
  2560. Some of the statements were considered overhead and, being constant
  2561. across architectures, were ignored. For each of the operations
  2562. selected, a rule was derived for determining its weighting factor.
  2563. The selected operations and their weighting factor rules are: 
  2564.  
  2565.      integer compare to zero = (lowest weight)
  2566.      arithmetic compare of integers = 1.5 * integer compare to zero
  2567.      integer increment by one = arithmetic compare of integers
  2568.      integer add/subtract = 2 * integer increment by one
  2569.      modulo/remainder = integer add/subtract
  2570.      integer multiply/divide = 2 * integer modulo/remainder
  2571.      procedure call = integer multiply/divide
  2572.  
  2573. Assigning a weight of two to the integer compare to zero operation,
  2574. yields the following weighting factor values: 
  2575.  
  2576.      integer compare to zero        = 2
  2577.      arithmetic compare of integers = 3
  2578.      integer increment by one       = 3
  2579.      integer add/subtract           = 6
  2580.      modulo/remainder               = 6
  2581.      integer multiply/divide        = 12
  2582.      procedure call                 = 12
  2583.  
  2584. The choice of the weighting factor rules was based on SYSCON's
  2585. understanding of compiler technology (gained through the development
  2586. of compilers and through our IV&V activities relating to the
  2587. development of the Ada Integrated Environment) and software
  2588. development experience (including the Evaluation of Ada as a
  2589. Communications Language for the Defense Communications Agency).
  2590.  
  2591. Some sample results of the tests are shown in Tables 3-1 and 3-2.
  2592. The results show that the binary component architecture code
  2593. required fewer operations than the decimal digit architecure code,
  2594. leading to the conclusion that, in the tested case, the binary
  2595. component approach is more efficient than the bit array and decimal
  2596. digit architectures. 
  2597.  
  2598. The last factor to be considered in the evaluation was the
  2599. tunability of the architectures.  Both of the prototyped
  2600. architectures permit tuning of the algorithms by changing the size
  2601. of the component (number of bits and range of the digits).  The
  2602. binary component architecture size is more flexible (increments of 1
  2603. bit instead of 3-4), and is thus better able to efficiently utilize 
  2604. the host system's facilities.
  2605.  
  2606.  
  2607.            Table 3-1.  Result Summary for Sample Operation
  2608.  
  2609.      ----------------------------------------------------------------
  2610.  
  2611.                   Operation: 2097151 * 2097151
  2612.  
  2613.        binary component  (127, 127, 127) = 2097151
  2614.        decimal digit   ('2','0','9','7','1','5','1') = 2097151
  2615.  
  2616.        This operation would cause maximal intermediate
  2617.        overflows with the binary component architecure, and is 
  2618.        thus a worst case for the binary component architecture.
  2619.  
  2620.      OPERATION        COMPONENT   (*WEIGHT)         DIGIT   (*WEIGHT)
  2621.      ----------------------------------------------------------------
  2622.      procedure call       24         288              6          72
  2623.  
  2624.      mult/divide          18         216             56         672
  2625.  
  2626.      remainder/mod         9          54              -           -
  2627.  
  2628.      add/subtract         33         198            192        1152
  2629.  
  2630.      increment by one     12          36             64         192
  2631.  
  2632.      arith compare        33          99            136         408
  2633.  
  2634.      compare to zero      72         144             84         168
  2635.  
  2636.      ----------------------------------------------------------------
  2637.      TOTAL (*WEIGHT)                1035                       2664
  2638. <FF>
  2639.  
  2640.  
  2641.              Table 3-2.  Result Summary for Sample Operation
  2642.  
  2643.      ----------------------------------------------------------------
  2644.  
  2645.                     Operation: 999999 * 999999.
  2646.  
  2647.        binary component  (61, 4, 63) 
  2648.        decimal digit  ('9','9','9','9','9','9')
  2649.  
  2650.        This operation would cause maximal intermediate 
  2651.        overflows with the decimal digit architecture, and is 
  2652.        thus a worst case for the decimal digit architecture. 
  2653.  
  2654.      OPERATION        COMPONENT   (*WEIGHT)         DIGIT   (*WEIGHT)
  2655.      ----------------------------------------------------------------
  2656.      procedure call       21         252              6          72
  2657.  
  2658.      mult/divide          17         204             57         684
  2659.  
  2660.      remainder/mod         8          48              -           -
  2661.  
  2662.      add/subtract         30         180            447        2682
  2663.  
  2664.      increment by one      8          24            318         948
  2665.  
  2666.      arith compare        30          90            390        1170
  2667.  
  2668.      compare to zero      72         144             84         168
  2669.  
  2670.      ----------------------------------------------------------------
  2671.      TOTAL (*WEIGHT)                 942                       5724
  2672.  
  2673.  
  2674. Thus, in conclusion, the binary component architecture was selected 
  2675. for implementation.  The details of the architecture are presented 
  2676. in the following Section.
  2677.  
  2678.  
  2679. 3.3  Detailed Description of Binary Component Architecture
  2680.  
  2681. The algorithm and data structure selected and refined to meet the
  2682. aforementioned requirements for the Emulation of Machine Arithmetic
  2683. uses a binary component architecture.  The binary component
  2684. architecture splits the integer word and floating point mantissa
  2685. into components which can be manipulated using the predefined
  2686. arithmetic operations of Ada.  The details of the data structures
  2687. are provided in Section 4, MACROSCOPIC DESIGN. The basic data
  2688. structure is summarized in the Ada PDL shown below: 
  2689.  
  2690.  
  2691.      -- number of bits in a component, such that component arithmetic
  2692.      -- can not generate an overflow  
  2693.      -- [currently selected for use with the 16-bit integers]
  2694.         NO_COMP_BITS : constant INTEGER := 7;
  2695.  
  2696.      -- maximum value of a component
  2697.         MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
  2698.      -- a component
  2699.         subtype COMP is INTEGER;    -- 16 bit range assumed
  2700.      -- an array of components
  2701.         type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
  2702.  
  2703.      -- the sign of a number
  2704.         subtype SIGN_TYPE is BOOLEAN;
  2705.  
  2706.      -- identification of the caller
  2707.         type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
  2708.                                LONG_FLOAT_CLASS);
  2709.  
  2710.      -- the exponent of a floating type
  2711.         subtype EXPONENT_TYPE is INTEGER;
  2712.         MIN_EXPONENT_VALUE : constant INTEGER := -128;
  2713.         MAX_EXPONENT_VALUE : constant INTEGER := 127;
  2714.  
  2715.      -- the exponent of a floating type
  2716.         subtype EXPONENT_TYPE is INTEGER;
  2717.  
  2718.      -- this function computes the number of components required
  2719.      -- to store the specified number of bits.
  2720.         function BITS_TO_COMPS (NO_OF_BITS: NATURAL) return NATURAL;
  2721.  
  2722.      -- the number of mantissa bits in TARGET_SHORT_FLOAT
  2723.      -- which control the digits of precision
  2724.         TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
  2725.  
  2726.         subtype SHORT_COMPONENT_ARRAY is COMPONENT_ARRAY_TYPE 
  2727.          (1 .. BITS_TO_COMPS(TARGET_SHORT_NUM_BITS));
  2728.   
  2729.         type SHORT_COMP_ARRAY is
  2730.            record
  2731.               COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
  2732.               CLASS_OF_ARRAY : CLASSIFICATION;
  2733.               BITS_SHIFTED : INTEGER;
  2734.            end record;
  2735.  
  2736.     -- the TARGET_SHORT_FLOAT data structure 
  2737.        type MAE_SHORT_FLOAT_TYPE is
  2738.            record
  2739.               SIGN : SIGN_TYPE := POSITIVE;
  2740.               COMPS : SHORT_COMP_ARRAY;
  2741.               EXPONENT : EXPONENT_TYPE;
  2742.            end record;
  2743.  
  2744.  
  2745. The algorithm is implemented by providing common operations, such as
  2746. addition/subtraction/multiplication/division, on component arrays in
  2747. the lowest level package, MAE_BASIC_OPERATIONS.  The intermediate
  2748. packages (e.g., MAE_SHORT_FLOAT) then implement the exported
  2749. functions in terms of lower level functions on the components of the
  2750. data structure. The basic algorithm is summarized in the Ada code
  2751. segment shown below: 
  2752.  
  2753.    function "+"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  2754.                        return MAE_SHORT_FLOAT_TYPE is
  2755.       -- The purpose of this function is to add two
  2756.       -- MAE_SHORT_FLOAT_TYPEs.
  2757.       RESULT, TEMP : MAE_SHORT_FLOAT_TYPE;
  2758.    begin
  2759.       -- zero check
  2760.       if RIGHT.COMPS.COMPONENT_ARRAY = ZERO.COMPS.COMPONENT_ARRAY then
  2761.          RESULT := LEFT;
  2762.          NORMALIZE_SHORT_FLOAT(RESULT);
  2763.          ROUND_TO_TARGET(RESULT);
  2764.          return RESULT;
  2765.       elsif LEFT.COMPS.COMPONENT_ARRAY = ZERO.COMPS.COMPONENT_ARRAY then
  2766.          RESULT := RIGHT;
  2767.          NORMALIZE_SHORT_FLOAT(RESULT);
  2768.          ROUND_TO_TARGET(RESULT);
  2769.          return RESULT;
  2770.       end if;
  2771.  
  2772.       case (LEFT.SIGN xor RIGHT.SIGN) is
  2773.          -- The signs are different (subtraction)
  2774.          when TRUE =>
  2775.             if LEFT.EXPONENT > RIGHT.EXPONENT then
  2776.                TEMP := ALIGN(RIGHT, LEFT.EXPONENT);
  2777.                RESULT.COMPS := LEFT.COMPS - TEMP.COMPS;
  2778.                RESULT.EXPONENT := LEFT.EXPONENT - 
  2779.                 RESULT.COMPS.BITS_SHIFTED;
  2780.                RESULT.SIGN := LEFT.SIGN;
  2781.             elsif LEFT.EXPONENT < RIGHT.EXPONENT then
  2782.                TEMP := ALIGN(LEFT, RIGHT.EXPONENT);
  2783.                RESULT.COMPS := RIGHT.COMPS - TEMP.COMPS;
  2784.                RESULT.EXPONENT := RIGHT.EXPONENT - 
  2785.                 RESULT.COMPS.BITS_SHIFTED;
  2786.                RESULT.SIGN := RIGHT.SIGN;
  2787.             else
  2788.                if LEFT.COMPS.COMPONENT_ARRAY > RIGHT.COMPS.COMPONENT_ARRAY 
  2789.                 then
  2790.                   RESULT.COMPS := LEFT.COMPS - RIGHT.COMPS;
  2791.                   RESULT.EXPONENT := LEFT.EXPONENT - 
  2792.                    RESULT.COMPS.BITS_SHIFTED;
  2793.                   RESULT.SIGN := LEFT.SIGN;
  2794.                else
  2795.                   RESULT.COMPS := RIGHT.COMPS - LEFT.COMPS;
  2796.                   RESULT.EXPONENT := RIGHT.EXPONENT - 
  2797.                    RESULT.COMPS.BITS_SHIFTED;
  2798.                   RESULT.SIGN := RIGHT.SIGN;
  2799.                end if;
  2800.             end if;
  2801.          -- The signs are the same
  2802.          when FALSE =>
  2803.             if LEFT.EXPONENT > RIGHT.EXPONENT then
  2804.                TEMP := ALIGN(RIGHT, LEFT.EXPONENT);
  2805.                RESULT.COMPS := LEFT.COMPS + TEMP.COMPS;
  2806.                RESULT.EXPONENT := LEFT.EXPONENT - RESULT.COMPS.BITS_SHIFTED;
  2807.                RESULT.SIGN := LEFT.SIGN;
  2808.             elsif LEFT.EXPONENT < RIGHT.EXPONENT then
  2809.                TEMP := ALIGN(LEFT, RIGHT.EXPONENT);
  2810.                RESULT.COMPS := RIGHT.COMPS + TEMP.COMPS;
  2811.                RESULT.EXPONENT := RIGHT.EXPONENT - 
  2812.                 RESULT.COMPS.BITS_SHIFTED;
  2813.                RESULT.SIGN := RIGHT.SIGN;
  2814.             else
  2815.                RESULT.COMPS := LEFT.COMPS + RIGHT.COMPS;
  2816.                RESULT.EXPONENT := LEFT.EXPONENT - RESULT.COMPS.BITS_SHIFTED;
  2817.                RESULT.SIGN := RIGHT.SIGN;
  2818.             end if;
  2819.  
  2820.       end case;
  2821.  
  2822.       RESULT.COMPS.BITS_SHIFTED := 0;
  2823.       if RESULT.COMPS = ZERO.COMPS then
  2824.          RESULT.EXPONENT := 0;
  2825.          RESULT.SIGN := POS_SIGN;
  2826.       end if;
  2827.  
  2828.       ROUND_TO_TARGET(RESULT);
  2829.       return RESULT;
  2830.  
  2831.    exception
  2832.       when others =>
  2833.          raise MAE_NUMERIC_ERROR;
  2834.  
  2835.    end "+";
  2836.   
  2837.  
  2838. The emulated operations, such as multiplication and division on
  2839. floating point numbers, may need to have intermediate results with
  2840. more precision than the operands.  Since extra bits are provided to
  2841. handle the necessary intermediate results and the precision of the
  2842. final result will match the precision of the operands, a rounding
  2843. method was implemented to reduce the intermediate result to the
  2844. precision of the final (exported) result. 
  2845.  
  2846. The "round to nearest" technique, advocated in the IEEE proposed
  2847. Radix-Independent Standard for Floating-Point Arithmetic, was
  2848. chosen. The representable (within the number of bits in the final
  2849. result) value nearest to the intermediate value is delivered.  If
  2850. the two nearest representable values are equally near, then the one
  2851. with its least significant bit equal to zero is delivered. The least
  2852. significant bit refers to the last bit that has importance
  2853. (significance) in the final result. This technique helps to keep
  2854. errors from becoming significant and can be accomplished by checking
  2855. the bits beyond the least significant bit in the intermediate
  2856. result.  The first bit beyond the least significant bit in the
  2857. intermediate result is referred to as the guard bit. The logical
  2858. "or" of all the bits after the guard bit, and within the
  2859. intermediate result range, is referred to as the sticky bit. 
  2860.  
  2861.      Table 3-3 illustrates the status of the least significant bit
  2862. before rounding, in the intermediate result, and in the final result
  2863. (after rounding). 
  2864.  
  2865.  
  2866.                 Table 3-3.  Rounding Technique Summary
  2867.  
  2868.    --------------------------------------------------------------
  2869.  
  2870.         LSB    : the least significant bit
  2871.         GUARD  : the guard bit, first bit beyond LSB
  2872.         STICKY : the logical "or" of all bits beyond GUARD
  2873.  
  2874.  
  2875.                 BEFORE ROUNDING             AFTER ROUNDING
  2876.    
  2877.         LSB   |  GUARD  | STICKY  ||   LSB   | HOW ROUNDED ?
  2878.      --------------------------------------------------------
  2879.          0    |    0    |    0    ||    0    | exact
  2880.          0    |    0    |    1    ||    0    | down (0<x<.5)
  2881.          0    |    1    |    0    ||    0    | down (.5)
  2882.          0    |    1    |    1    ||    1    | up (.5<x<1)
  2883.          1    |    0    |    0    ||    1    | exact
  2884.          1    |    0    |    1    ||    1    | down (0<x<.5)
  2885.          1    |    1    |    0    ||    0*   | up (.5)
  2886.          1    |    1    |    1    ||    0*   | up (.5<x<1)
  2887.  
  2888.          * note that a carry to the bit above the LSB occurs
  2889.  
  2890.          x is the representative value of the bits beyond
  2891.           the LSB proportional to the value of the LSB
  2892.  
  2893.       The references to 0, .5, and 1, are with respect to the
  2894.       least significant bit in the binary representation. 
  2895.       For example, the representative value of the guard bit 
  2896.       is one-half the representative value of the least 
  2897.       significant bit, and the maximum value that can be 
  2898.       represented by the sticky bit is (.499999 ...) times
  2899.       the representative value of the least significant bit.
  2900.      
  2901.    --------------------------------------------------------------
  2902. <FF>
  2903.  
  2904.  
  2905. 4.  MACROSCOPIC DESIGN
  2906.  
  2907. This Section specifies the macroscopic design of the Emulation of
  2908. Machine Arithmetic packages.  The design is specified in Ada PDL,
  2909. which was compiled to verify its consistency and syntactical
  2910. correctness.  The following subsections specify the Ada PDL of each
  2911. of the constituent packages in the software architecture. 
  2912.  
  2913.  
  2914. 4.1  Package MACHINE_ARITHMETIC_EMULATION
  2915.  
  2916.  
  2917. with MAE_BASIC_OPERATIONS;
  2918. with MAE_INTEGER;
  2919. with MAE_SHORT_FLOAT;
  2920. with MAE_LONG_FLOAT;
  2921.  
  2922. package MACHINE_ARITHMETIC_EMULATION is
  2923. --------------------------------------------------------------------
  2924. --  The purpose of this package is to emulate target machine
  2925. --  arithmetic on host machines with 16-bit or larger words.
  2926. --  This package will export support for target integer, real, 
  2927. --  and double precision real numbers.  
  2928. --
  2929. --  The emulation packages are currently configured to 
  2930. --  support Honeywell 36-bit arithmetic.
  2931. --
  2932. --  The ranges for the current configuration are as follows:
  2933. --
  2934. --     TARGET_INTEGER
  2935. --        range of -2**35 to 2**35-1
  2936. --     TARGET_SHORT_FLOAT
  2937. --        approximate range of 10**-38 to 10**38 and 0
  2938. --        mantissa => 27 bit binary fraction
  2939. --        exponent => -128 to 127
  2940. --     TARGET_LONG_FLOAT
  2941. --        approximate range of 10**-38 to 10**38 and 0
  2942. --        mantissa => 63 bit binary fraction
  2943. --        exponent => -128 to 127
  2944. --
  2945. --  Any errors which occur during use of the arithmetic and
  2946. --  boolean functions defined below will result in the
  2947. --  raising of the exception "MAE_NUMERIC_ERROR".  The 
  2948. --  exception declared in this package is a rename of
  2949. --  the predefined exception NUMERIC_ERROR.  This can be
  2950. --  changed for programs needing to handle arithmetic
  2951. --  exceptions generated by the emulation packages separately.
  2952. --
  2953.    
  2954.  
  2955. --------------------------------------------------------------------
  2956. -- Parameters within MAE_BASIC_OPERATIONS that need to be available
  2957. -- to the user of the Emulation of Machine Arithmetic package:
  2958. --
  2959.    subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
  2960.    DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
  2961.  
  2962.    subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
  2963.    TARGET_SHORT_DEFAULT_AFT : FIELD 
  2964.                  renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
  2965.    TARGET_LONG_DEFAULT_AFT : FIELD 
  2966.                  renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
  2967.    TARGET_SHORT_DEFAULT_EXP : FIELD 
  2968.                  renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
  2969.    TARGET_LONG_DEFAULT_EXP : FIELD 
  2970.                  renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
  2971.  
  2972.    --
  2973.    -- predefined attributes for the emulated types
  2974.    --
  2975.       TARGET_SHORT_FLOAT_DIGITS : INTEGER 
  2976.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS; 
  2977.       TARGET_LONG_FLOAT_DIGITS : INTEGER 
  2978.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS; 
  2979.  
  2980.       TARGET_SHORT_FLOAT_EMAX : INTEGER 
  2981.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
  2982.       TARGET_LONG_FLOAT_EMAX : INTEGER
  2983.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
  2984.  
  2985.       TARGET_SHORT_FLOAT_MACHINE_EMAX : INTEGER 
  2986.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
  2987.       TARGET_LONG_FLOAT_MACHINE_EMAX : INTEGER 
  2988.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
  2989.  
  2990.       TARGET_SHORT_FLOAT_MACHINE_EMIN : INTEGER 
  2991.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
  2992.       TARGET_LONG_FLOAT_MACHINE_EMIN : INTEGER 
  2993.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
  2994.  
  2995.       TARGET_SHORT_FLOAT_MACHINE_MANTISSA : INTEGER 
  2996.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
  2997.       TARGET_LONG_FLOAT_MACHINE_MANTISSA : INTEGER
  2998.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
  2999.  
  3000.       TARGET_SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN 
  3001.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
  3002.       TARGET_LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
  3003.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
  3004.  
  3005.       TARGET_SHORT_FLOAT_MACHINE_RADIX : INTEGER
  3006.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
  3007.       TARGET_LONG_FLOAT_MACHINE_RADIX : INTEGER
  3008.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
  3009.  
  3010.       TARGET_SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
  3011.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
  3012.       TARGET_LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
  3013.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
  3014.  
  3015.       TARGET_SHORT_FLOAT_SAFE_EMAX : INTEGER 
  3016.                  renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
  3017.       TARGET_LONG_FLOAT_SAFE_EMAX : INTEGER 
  3018.                  renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
  3019.  
  3020. --------------------------------------------------------------------
  3021. -- Visible operations with TARGET_INTEGER
  3022. --
  3023. -- The follow declaration should be private
  3024.  
  3025.    subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
  3026.  
  3027.    -- The defined operators for this type are as follows:
  3028.  
  3029.    function TARGET_INTEGER_FIRST return TARGET_INTEGER;
  3030.    function TARGET_INTEGER_LAST return TARGET_INTEGER;
  3031.  
  3032.    -- Predefined system function "=" and function "/="
  3033.    function "<"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  3034.    function "<="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  3035.    function ">"    (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  3036.    function ">="   (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
  3037.  
  3038.    function "+"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3039.    function "-"    (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3040.    function "abs"  (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3041.  
  3042.    function "+"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3043.    function "-"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3044.    function "*"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3045.    function "/"    (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3046.    function "rem"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3047.    function "mod"  (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
  3048.  
  3049.    function "**"   (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
  3050.                        return TARGET_INTEGER;
  3051.  
  3052.    function TARGET_INTEGER_VALUE (STRING_PIC : STRING) 
  3053.                        return TARGET_INTEGER;
  3054.    function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER) 
  3055.                        return STRING;
  3056.  
  3057.    procedure GET (FROM : in STRING;
  3058.                   ITEM : out TARGET_INTEGER;
  3059.                   LAST : out POSITIVE);
  3060.  
  3061.    procedure PUT (TO : out STRING;
  3062.                   ITEM : in TARGET_INTEGER;
  3063.                   BASE : in NUMBER_BASE := DEFAULT_BASE);
  3064.  
  3065. --------------------------------------------------------------------
  3066. -- Visible operations with TARGET_SHORT_FLOAT
  3067. --
  3068. -- The following declaration should be private
  3069.  
  3070.    subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
  3071.  
  3072.    -- The defined operators for this type are as follows:
  3073.  
  3074.  
  3075.    function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
  3076.    function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
  3077.    function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
  3078.    function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
  3079.    function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
  3080.  
  3081.    -- Predefined system function "=" and function "/="
  3082.    function "<"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  3083.    function "<="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  3084.    function ">"    (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  3085.    function ">="   (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
  3086.  
  3087.    function "+"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3088.    function "-"    (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3089.    function "abs"  (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3090.  
  3091.    function "+"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3092.    function "-"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3093.    function "*"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3094.    function "/"    (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
  3095.  
  3096.    function "**"   (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER) 
  3097.                        return TARGET_SHORT_FLOAT;
  3098.  
  3099.    procedure GET (FROM : in STRING;
  3100.                   ITEM : out TARGET_SHORT_FLOAT;
  3101.                   LAST : out POSITIVE);
  3102.  
  3103.    procedure PUT (TO : out STRING;
  3104.                   ITEM : in TARGET_SHORT_FLOAT;
  3105.                   AFT : in FIELD := TARGET_SHORT_DEFAULT_AFT;
  3106.                   EXP : in FIELD := TARGET_SHORT_DEFAULT_EXP);
  3107.  
  3108. --------------------------------------------------------------------
  3109. -- Visible operations with TARGET_LONG_FLOAT
  3110. --
  3111. -- The following declaration should be private
  3112.  
  3113.    subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
  3114.  
  3115.    -- The defined operators for this type are as follows:
  3116.  
  3117.    function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
  3118.    function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
  3119.    function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
  3120.    function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
  3121.    function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
  3122.  
  3123.    -- Predefined system function "=" and function "/="
  3124.    function "<"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  3125.    function "<="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  3126.    function ">"    (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  3127.    function ">="   (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
  3128.  
  3129.    function "+"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3130.    function "-"    (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3131.    function "abs"  (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3132.  
  3133.    function "+"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3134.    function "-"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3135.    function "*"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3136.    function "/"    (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
  3137.  
  3138.    function "**"   (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER) 
  3139.                        return TARGET_LONG_FLOAT;
  3140.  
  3141.    procedure GET (FROM : in STRING;
  3142.                   ITEM : out TARGET_LONG_FLOAT;
  3143.                   LAST : out POSITIVE);
  3144.  
  3145.    procedure PUT (TO : out STRING;
  3146.                   ITEM : in TARGET_LONG_FLOAT;
  3147.                   AFT : in FIELD := TARGET_LONG_DEFAULT_AFT;
  3148.                   EXP : in FIELD := TARGET_LONG_DEFAULT_EXP);
  3149.  
  3150. --------------------------------------------------------------------
  3151. -- private
  3152.  
  3153.    -- Note : Derived types are not supported under 
  3154.    -- Telesoft version 1.5
  3155.  
  3156.    -- The types are private to prevent direct manipulation of
  3157.    -- the components of the numbers.  The exported types
  3158.    -- are declarations of the appropriate types from the
  3159.    -- respective package.
  3160.  
  3161.       -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
  3162.  
  3163.       -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
  3164.  
  3165.       -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
  3166.  
  3167.  
  3168. --------------------------------------------------------------------
  3169.  
  3170. end MACHINE_ARITHMETIC_EMULATION;
  3171.  
  3172.  
  3173. package body MACHINE_ARITHMETIC_EMULATION is
  3174. --
  3175. -- The package body is implemented by directly calling
  3176. -- the corresponding operations in the MAE_INTEGER,
  3177. -- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT packages.
  3178. --
  3179. end MACHINE_ARITHMETIC_EMULATION;
  3180.  
  3181.  
  3182. 4.2  Package MAE_INTEGER
  3183.  
  3184.  
  3185. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3186.  
  3187. package MAE_INTEGER is
  3188. -------------------------------------------------------------------
  3189.  
  3190. -- The purpose of this package is to emulate target machine
  3191. -- integer arithmetic on host machines with 16-bit or larger 
  3192. -- words.
  3193. --
  3194. -- The range of the supported type is as follows:
  3195. --
  3196. --    TARGET_INTEGER
  3197. --       range of -2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS
  3198. --                        to 
  3199. --                 2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS-1
  3200. --
  3201. -- Any errors which occur during use of the arithmetic and
  3202. -- boolean functions defined below will result in the
  3203. -- raising of the exception "MAE_NUMERIC_ERROR".  
  3204.  
  3205. --
  3206. -- Visible operations with MAE_INTEGER_TYPE
  3207. --
  3208.    type MAE_INTEGER_TYPE is private;
  3209.  
  3210.    -- The defined operators for this type are as follows:
  3211.  
  3212.    -- predefined system function "=" and function "/="
  3213.    function "<"    (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  3214.    function "<="   (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  3215.    function ">"    (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  3216.    function ">="   (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
  3217.  
  3218.    function "+"    (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3219.    function "-"    (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3220.    function "abs"  (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3221.  
  3222.    function "+"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3223.    function "-"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3224.    function "*"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3225.    function "/"    (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3226.    function "rem"  (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3227.    function "mod"  (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
  3228.  
  3229.    function "**"   (LEFT : MAE_INTEGER_TYPE; RIGHT : INTEGER)
  3230.                        return MAE_INTEGER_TYPE;
  3231.  
  3232.    function MAE_INTEGER_TYPE_VALUE(STRING_PIC : STRING)
  3233.                                       return MAE_INTEGER_TYPE;
  3234.  
  3235.    function MAE_INTEGER_TYPE_IMAGE(STORE_PIC : MAE_INTEGER_TYPE)
  3236.                                       return STRING;
  3237.  
  3238.    procedure GET (FROM : in STRING;
  3239.                   ITEM : out MAE_INTEGER_TYPE;
  3240.                   LAST : out POSITIVE);
  3241.  
  3242.    procedure PUT (TO : out STRING;
  3243.                   ITEM : in MAE_INTEGER_TYPE;
  3244.                   BASE : in NUMBER_BASE := DEFAULT_BASE);
  3245.  
  3246.    function TARGET_INTEGER_FIRST return MAE_INTEGER_TYPE;
  3247.  
  3248.    function TARGET_INTEGER_LAST return MAE_INTEGER_TYPE;
  3249.  
  3250. -------------------------------------------------------------------
  3251. private
  3252.  
  3253. -- The declaration of the next variable is to allow
  3254. -- the record declaration under the Telesoft version 1.5 compiler.
  3255. -- A better declaration would allow the COMP_ARRAY range to be
  3256. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  3257.  
  3258.    type MAE_INTEGER_TYPE is
  3259.       record
  3260.          SIGN : SIGN_TYPE := POS_SIGN;
  3261.          COMPS : SHORT_COMP_ARRAY := INTEGER_COMP_ARRAY;
  3262.       end record;
  3263.  
  3264. -------------------------------------------------------------------
  3265. end MAE_INTEGER;
  3266.  
  3267.  
  3268. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3269.  
  3270. package body MAE_INTEGER is
  3271. --
  3272. -- The package body is implemented by using the subprograms
  3273. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  3274. -- components of the TARGET_INTEGER type, and in conjunction with 
  3275. -- procedures to handle Integer-specific operations such as 
  3276. -- carrying and borrowing.
  3277. --
  3278. end MAE_INTEGER;
  3279.  
  3280.  
  3281. 4.3  Package MAE_SHORT_FLOAT
  3282.  
  3283.  
  3284. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3285.  
  3286. package MAE_SHORT_FLOAT is
  3287. -------------------------------------------------------------------
  3288. -- The purpose of this package is to emulate target machine
  3289. -- floating point arithmetic on host machines with 16-bit or 
  3290. -- larger word size.
  3291. --
  3292. -- The range of the supported type is as follows:
  3293. --
  3294. --     TARGET_SHORT_FLOAT (Real)
  3295. --        approximate range of 10**-38 to 10**38 and 0
  3296. --        mantissa => MAE_BASIC_OPERATIONS.TARGET_SHORT_NUM_BITS
  3297. --                    bit binary fraction
  3298. --        exponent => -128 to 127
  3299. --
  3300. -- Any errors which occur during use of the arithmetic and
  3301. -- boolean functions defined below will result in the
  3302. -- raising of the exception "MAE_NUMERIC_ERROR".  
  3303.  
  3304. --
  3305. -- Visible operations with MAE_SHORT_FLOAT_TYPE
  3306. --
  3307.    type MAE_SHORT_FLOAT_TYPE is private;
  3308.  
  3309.    -- The defined operators for this type are as follows:
  3310.  
  3311.    -- predefined system function "=" and function "/="
  3312.    function "<"    (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  3313.    function "<="   (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  3314.    function ">"    (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  3315.    function ">="   (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
  3316.  
  3317.    function "+"    (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  3318.    function "-"    (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  3319.    function "abs"  (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
  3320.  
  3321.    function "+"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  3322.                        return MAE_SHORT_FLOAT_TYPE;
  3323.    function "-"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  3324.                        return MAE_SHORT_FLOAT_TYPE;
  3325.    function "*"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  3326.                        return MAE_SHORT_FLOAT_TYPE;
  3327.    function "/"    (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE) 
  3328.                        return MAE_SHORT_FLOAT_TYPE;
  3329.  
  3330.    function "**"   (LEFT : MAE_SHORT_FLOAT_TYPE; RIGHT : INTEGER)
  3331.                        return MAE_SHORT_FLOAT_TYPE;
  3332.  
  3333.  
  3334.    procedure GET (FROM : in STRING;
  3335.                   ITEM : out MAE_SHORT_FLOAT_TYPE;
  3336.                   LAST : out POSITIVE);
  3337.  
  3338.    procedure PUT (TO : out STRING;
  3339.                   ITEM : in MAE_SHORT_FLOAT_TYPE;
  3340.                   AFT : in FIELD := SHORT_DEFAULT_AFT;
  3341.                   EXP : in FIELD := SHORT_DEFAULT_EXP);
  3342.  
  3343.    function TARGET_SHORT_FLOAT_EPSILON return MAE_SHORT_FLOAT_TYPE;
  3344.  
  3345.    function TARGET_SHORT_FLOAT_LARGE return MAE_SHORT_FLOAT_TYPE;
  3346.  
  3347.    function TARGET_SHORT_FLOAT_SMALL return MAE_SHORT_FLOAT_TYPE;
  3348.  
  3349.    function TARGET_SHORT_FLOAT_LAST return MAE_SHORT_FLOAT_TYPE;
  3350.  
  3351.    function TARGET_SHORT_FLOAT_FIRST return MAE_SHORT_FLOAT_TYPE;
  3352.  
  3353. -------------------------------------------------------------------
  3354. private
  3355.  
  3356. -- The declaration of the next variable is to allow
  3357. -- the record declaration under the Telesoft version 1.5 compiler.
  3358. -- A better declaration would allow the COMP_ARRAY range to be
  3359. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  3360.  
  3361.    type MAE_SHORT_FLOAT_TYPE is
  3362.       record
  3363.          SIGN : SIGN_TYPE := POS_SIGN;
  3364.          COMPS : SHORT_COMP_ARRAY := SHORT_FLOAT_COMP_ARRAY;
  3365.          EXPONENT : EXPONENT_TYPE := 0;
  3366.       end record;
  3367.  
  3368. -------------------------------------------------------------------
  3369. end MAE_SHORT_FLOAT;
  3370.  
  3371.  
  3372. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3373.  
  3374. package body MAE_SHORT_FLOAT is
  3375. --
  3376. -- The package body is implemented by using the subprograms
  3377. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  3378. -- components of the TARGET_SHORT_FLOAT type, and in conjunction with 
  3379. -- procedures to handle Integer-specific operations such as 
  3380. -- carrying and borrowing.
  3381. --
  3382. end MAE_SHORT_FLOAT;
  3383.  
  3384.  
  3385. 4.4  Package MAE_LONG_FLOAT
  3386.  
  3387.  
  3388. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3389.  
  3390. package MAE_LONG_FLOAT is
  3391. -------------------------------------------------------------------
  3392. -- The purpose of this package is to emulate target machine
  3393. -- double precision floating point arithmetic on host machines
  3394. -- with 16-bit or larger words.
  3395. --
  3396. -- The range of the supported type is as follows:
  3397. --
  3398. --     TARGET_LONG_FLOAT (Double Precision Real)
  3399. --        approximate range of 10**-38 to 10**38 and 0
  3400. --        mantissa => MAE_BASIC_OPERATIONS.TARGET_LONG_NUM_BITS
  3401. --                    bit binary fraction
  3402. --        exponent => -128 to 127
  3403. --
  3404. --
  3405. -- Any errors which occur during use of the arithmetic and
  3406. -- boolean functions defined below will result in the
  3407. -- raising of the exception "MAE_NUMERIC_ERROR". 
  3408.  
  3409. -----------------------------------------------------------------
  3410. -- Visible operations with MAE_LONG_FLOAT_TYPE
  3411. --
  3412.    type MAE_LONG_FLOAT_TYPE is private;
  3413.  
  3414.    -- The defined operators for this type are as follows:
  3415.  
  3416.    -- predefined system function "=" and function "/="
  3417.    function "<"    (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  3418.    function "<="   (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  3419.    function ">"    (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  3420.    function ">="   (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
  3421.  
  3422.    function "+"    (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  3423.    function "-"    (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  3424.    function "abs"  (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
  3425.  
  3426.    function "+"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  3427.                        return MAE_LONG_FLOAT_TYPE;
  3428.    function "-"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  3429.                        return MAE_LONG_FLOAT_TYPE;
  3430.    function "*"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  3431.                        return MAE_LONG_FLOAT_TYPE;
  3432.    function "/"    (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE) 
  3433.                        return MAE_LONG_FLOAT_TYPE;
  3434.  
  3435.    function "**"   (LEFT : MAE_LONG_FLOAT_TYPE; RIGHT : INTEGER)
  3436.                        return MAE_LONG_FLOAT_TYPE;
  3437.  
  3438.  
  3439.    procedure GET (FROM : in STRING;
  3440.                   ITEM : out MAE_LONG_FLOAT_TYPE;
  3441.                   LAST : out POSITIVE);
  3442.  
  3443.    procedure PUT (TO : out STRING;
  3444.                   ITEM : in MAE_LONG_FLOAT_TYPE;
  3445.                   AFT : in FIELD := LONG_DEFAULT_AFT;
  3446.                   EXP : in FIELD := LONG_DEFAULT_EXP);
  3447.  
  3448.    function TARGET_LONG_FLOAT_EPSILON return MAE_LONG_FLOAT_TYPE;
  3449.  
  3450.    function TARGET_LONG_FLOAT_LARGE return MAE_LONG_FLOAT_TYPE;
  3451.  
  3452.    function TARGET_LONG_FLOAT_SMALL return MAE_LONG_FLOAT_TYPE;
  3453.  
  3454.    function TARGET_LONG_FLOAT_LAST return MAE_LONG_FLOAT_TYPE;
  3455.  
  3456.    function TARGET_LONG_FLOAT_FIRST return MAE_LONG_FLOAT_TYPE;
  3457.  
  3458.  
  3459. -------------------------------------------------------------------
  3460. private
  3461.  
  3462. -- The declaration of the next variable is to allow
  3463. -- the record declaration under the Telesoft version 1.5 compiler.
  3464. -- A better declaration would allow the COMP_ARRAY range to be
  3465. -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
  3466.  
  3467.    type MAE_LONG_FLOAT_TYPE is
  3468.       record
  3469.          SIGN : SIGN_TYPE := POS_SIGN;
  3470.          COMPS : LONG_COMP_ARRAY := LONG_FLOAT_COMP_ARRAY;
  3471.          EXPONENT : EXPONENT_TYPE := 0;
  3472.       end record;
  3473.  
  3474. -------------------------------------------------------------------
  3475. end MAE_LONG_FLOAT;
  3476.  
  3477.  
  3478. with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
  3479.  
  3480. package body MAE_LONG_FLOAT is
  3481. --
  3482. -- The package body is implemented by using the subprograms
  3483. -- provided by the MAE_BASIC_OPERATIONS to manipulate the
  3484. -- components of the TARGET_LONG_FLOAT type, and in conjunction with 
  3485. -- procedures to handle Integer-specific operations such as 
  3486. -- carrying and borrowing.
  3487. --
  3488. end MAE_LONG_FLOAT;
  3489.  
  3490.  
  3491. 4.5  Package MAE_BASIC_OPERATIONS
  3492.  
  3493.  
  3494. package MAE_BASIC_OPERATIONS is
  3495. -------------------------------------------------------------------
  3496. -- The emulation packages are currently configured 
  3497. -- to support Honeywell 36-bit arithmetic.
  3498. --
  3499. -- The purpose of this package is to provide general machine
  3500. -- arithmetic types and functions to support integer and floating
  3501. -- point variables.  The underlying arithmetic operations will
  3502. -- be performed component-wise.  It is assumed that the system
  3503. -- provides for integer operations.
  3504.  
  3505. -------------------------------------------------------------------
  3506. -- Here are the declarations of the basic constants and variables.
  3507. -- Some of these constants reflect the emulation target and the
  3508. -- implementation host (and compiler) dependencies.
  3509. -- It is possible that changing these constants and variables could
  3510. -- improve software performance.  They are the basic elements for
  3511. -- building the MAE_INTEGER_TYPE and MAE_FLOAT_TYPE types.
  3512. --
  3513.    -- number of bits in a component
  3514.       NO_COMP_BITS : constant INTEGER := 7;
  3515.    -- maximum value of a component
  3516.       MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
  3517.    -- component base value
  3518.       BASE_COMP_VALUE : constant INTEGER := MAX_COMP_VALUE+1;
  3519.    -- the values associated with a bit position,
  3520.    --  initialized in the body of this package
  3521.       BIT_VALUE : array (1 .. NO_COMP_BITS) of INTEGER; 
  3522.    -- a component, note that the range of a true component is
  3523.    -- 0 .. MAX_COMP_VALUE, although intermediate values, obtained
  3524.    -- during computations, lie outside the range.
  3525.       subtype COMP is INTEGER;
  3526.    -- an array of components
  3527.       type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
  3528.    -- the use of representation specifications could direct the
  3529.    --  compiler how to store the array and possibly increase efficiency.
  3530.    --  note that the least significant COMP is the first in the
  3531.    --  array, and consequently the most significant COMP is the last.
  3532.    --
  3533.    --  most signif                                     least signif
  3534.    --    'last                            . .            'first
  3535.    -- --------------  --------------                  --------------  
  3536.    -- | 1 2 3 .. n |  | 1 2 3 .. n |      . .         | 1 2 3 .. n |
  3537.    -- --------------  --------------                  -------------- 
  3538.  
  3539.    -- Identification of the caller
  3540.       type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
  3541.                                LONG_FLOAT_CLASS);
  3542.  
  3543.    -- Declaration for short comp arrays
  3544.       SHORT_NUM_COMPS : constant INTEGER := 6;
  3545.       SHORT_NUM_BITS : constant INTEGER := SHORT_NUM_COMPS * NO_COMP_BITS;
  3546.       subtype SHORT_COMPONENT_ARRAY is 
  3547.                  COMPONENT_ARRAY_TYPE (1 .. SHORT_NUM_COMPS);
  3548.       SHORT_ZERO_ARRAY : constant SHORT_COMPONENT_ARRAY :=
  3549.                     (1 .. SHORT_NUM_COMPS => 0);
  3550.  
  3551.       type SHORT_COMP_ARRAY is
  3552.          record
  3553.             COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
  3554.             CLASS_OF_ARRAY : CLASSIFICATION;
  3555.             BITS_SHIFTED : INTEGER;
  3556.          end record;
  3557.  
  3558.       INTEGER_COMP_ARRAY : SHORT_COMP_ARRAY :=
  3559.                                   (SHORT_ZERO_ARRAY, INTEGER_CLASS, 0);
  3560.       SHORT_FLOAT_COMP_ARRAY : SHORT_COMP_ARRAY :=
  3561.                                   (SHORT_ZERO_ARRAY, SHORT_FLOAT_CLASS, 0);
  3562.  
  3563.    -- The emulated target dependent constants for 36-bit storage
  3564.       TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
  3565.       TARGET_SHORT_NUM_BITS : constant INTEGER := 28;
  3566.  
  3567.    -- Declaration for long comp arrays
  3568.       LONG_NUM_COMPS : constant INTEGER := (2 * SHORT_NUM_COMPS);
  3569.       LONG_NUM_BITS : constant INTEGER := LONG_NUM_COMPS * NO_COMP_BITS;
  3570.       subtype LONG_COMPONENT_ARRAY is 
  3571.                  COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS);
  3572.       LONG_ZERO_ARRAY : LONG_COMPONENT_ARRAY :=
  3573.                     (1 .. LONG_NUM_COMPS => 0);
  3574.  
  3575.       type LONG_COMP_ARRAY is
  3576.          record
  3577.             COMPONENT_ARRAY : LONG_COMPONENT_ARRAY;
  3578.             CLASS_OF_ARRAY : CLASSIFICATION;
  3579.             BITS_SHIFTED : INTEGER;
  3580.          end record;
  3581.  
  3582.       LONG_FLOAT_COMP_ARRAY : LONG_COMP_ARRAY :=
  3583.                    (LONG_ZERO_ARRAY, LONG_FLOAT_CLASS, 0);
  3584.  
  3585.    -- The emulated target dependent constants for 72-bit storage
  3586.       TARGET_LONG_NUM_BITS : constant INTEGER := 64;
  3587.  
  3588.    -- Extended array length for LONG multiplication
  3589.       subtype EXTRA_COMPONENT_ARRAY is
  3590.                  COMPONENT_ARRAY_TYPE  (1 .. LONG_NUM_COMPS*2);
  3591.       EXTRA_ZERO_ARRAY : EXTRA_COMPONENT_ARRAY :=
  3592.                     (1 .. LONG_NUM_COMPS*2 => 0);
  3593.  
  3594.    -- Extended array for spaces filling string arrays
  3595.       EMPTY_STRING : STRING (1 .. 40) :=
  3596.           "                                        ";
  3597.  
  3598.    -- the sign of a number
  3599.       subtype SIGN_TYPE is BOOLEAN;
  3600.       NEG_SIGN : constant BOOLEAN := FALSE;
  3601.       POS_SIGN : constant BOOLEAN := TRUE;
  3602.    -- the exponent of a floating type
  3603.       subtype EXPONENT_TYPE is INTEGER;
  3604.       MIN_EXPONENT_VALUE : constant INTEGER := -128;
  3605.       MAX_EXPONENT_VALUE : constant INTEGER := 127;
  3606.  
  3607.    -- The follow declarations specify the value of the most
  3608.    -- significant component for the digits ONE .. TEN and their
  3609.    -- corresponding exponents.  The component values can be thought
  3610.    -- of as a binary representation (picture) of the most signif.
  3611.    -- comp.  Applying the binary exponent as left shifts, it is 
  3612.    -- easy to see how the digit is obtained.  This allows
  3613.    -- for the length of the array to change without affecting
  3614.    -- the code in the higher level packages.
  3615.       POINT_FIVE : constant INTEGER := 2**(NO_COMP_BITS-1);
  3616.       POINT_FIVE_SIX_TWO_FIVE : constant INTEGER :=
  3617.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-4);
  3618.       POINT_SIX_TWO_FIVE : constant INTEGER :=
  3619.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-3);
  3620.       POINT_SEVEN_FIVE : constant INTEGER :=
  3621.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2);
  3622.       POINT_EIGHT_SEVEN_FIVE : constant INTEGER :=
  3623.          2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2) + 2**(NO_COMP_BITS-3);
  3624.       DIGIT_PICTURE : constant array (1 .. 10) of INTEGER :=
  3625.          (POINT_FIVE,
  3626.           POINT_FIVE,
  3627.           POINT_SEVEN_FIVE,
  3628.           POINT_FIVE,
  3629.           POINT_SIX_TWO_FIVE,
  3630.           POINT_SEVEN_FIVE,
  3631.           POINT_EIGHT_SEVEN_FIVE,
  3632.           POINT_FIVE,
  3633.           POINT_FIVE_SIX_TWO_FIVE,
  3634.           POINT_SIX_TWO_FIVE);
  3635.       DIGIT_BINARY_EXPONENT : constant array (1 .. 10) of INTEGER :=
  3636.          (1, 2, 2, 3, 3, 3, 3, 4, 4, 4); 
  3637.  
  3638.  
  3639.    -- String IO constants
  3640.    -- the only base available is base 10
  3641.       subtype NUMBER_BASE is INTEGER range 2 .. 16;
  3642.       DEFAULT_BASE : constant NUMBER_BASE := 10;
  3643.       subtype FIELD is INTEGER range 0 .. INTEGER'last;
  3644.  
  3645.    -- a TeleSoft 1.5 restriction that is detected in the package
  3646.    -- above this package does not allow
  3647.    --   SHORT_DEFAULT_AFT : constant FIELD := SHORT_FLOAT_DIGITS-1;
  3648.    --   LONG_DEFAULT_AFT : constant FIELD := LONG_FLOAT_DIGITS-1;
  3649.       SHORT_DEFAULT_AFT : constant FIELD := 7;
  3650.       LONG_DEFAULT_AFT : constant FIELD := 17;
  3651.  
  3652.       SHORT_DEFAULT_EXP : constant FIELD := 3;
  3653.       LONG_DEFAULT_EXP : constant FIELD := 3;
  3654.  
  3655.  
  3656.    -- predefined attributes
  3657.       LOG_2 : constant FLOAT := 0.30103;
  3658.       SHORT_FLOAT_DIGITS : constant INTEGER :=
  3659.           INTEGER((FLOAT(TARGET_SHORT_NUM_BITS-1)*LOG_2)-0.5);
  3660.       LONG_FLOAT_DIGITS : constant INTEGER :=
  3661.           INTEGER((FLOAT(TARGET_LONG_NUM_BITS-1)*LOG_2)-0.5);
  3662.       -- the next declaration is not exported from MAE, it
  3663.       -- is only used in the integer PUT and IMAGE routines
  3664.       INTEGER_DIGITS : constant INTEGER :=
  3665.           INTEGER((FLOAT(TARGET_INTEGER_NUM_BITS)*LOG_2)+0.5);
  3666.  
  3667.       SHORT_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3668.       LONG_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3669.  
  3670.       SHORT_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3671.       LONG_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3672.  
  3673.       SHORT_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
  3674.       LONG_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
  3675.  
  3676.       SHORT_FLOAT_MACHINE_MANTISSA : INTEGER 
  3677.            renames TARGET_SHORT_NUM_BITS;
  3678.       LONG_FLOAT_MACHINE_MANTISSA : INTEGER
  3679.            renames TARGET_LONG_NUM_BITS;
  3680.  
  3681.       SHORT_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
  3682.       LONG_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
  3683.  
  3684.       SHORT_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
  3685.       LONG_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
  3686.  
  3687.       SHORT_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
  3688.       LONG_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
  3689.  
  3690.       SHORT_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3691.       LONG_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
  3692.  
  3693.  
  3694. -------------------------------------------------------------------
  3695. -- The exception to be raised for all arithmetic and boolean
  3696. -- functions defined in this package.
  3697. --
  3698.    MAE_NUMERIC_ERROR : EXCEPTION renames STANDARD.NUMERIC_ERROR;
  3699.  
  3700. -------------------------------------------------------------------
  3701. -- Function to determine the number of components for 
  3702. -- the representation.
  3703. --
  3704.    function BITS_TO_COMPS (NO_OF_BITS : INTEGER) return INTEGER;
  3705.  
  3706. -------------------------------------------------------------------
  3707. -- Operations on the sign
  3708. --
  3709.    -- Since the SIGN_TYPE is a BOOLEAN, most of the operations
  3710.    -- are assumed system functions
  3711.   
  3712.    function CHANGE_SIGN (SIGN : SIGN_TYPE) return SIGN_TYPE;
  3713.  
  3714. -------------------------------------------------------------------
  3715. -- Operations on the exponent
  3716. --
  3717.    -- Since the EXPONENT_TYPE is an INTEGER, the operations
  3718.    -- are assumed system functions
  3719.  
  3720. -------------------------------------------------------------------
  3721. -- Operations on the component
  3722. --
  3723.    -- If the variable NO_COMP_BITS is chosen properly, an assumption
  3724.    -- on which the entire package design is based, COMP and any
  3725.    -- result of binary operation (except exponentiation which is
  3726.    -- never used with COMP) of two COMPs is an INTEGER.
  3727.    -- Therefore, the operations are assumed system functions 
  3728.  
  3729. -------------------------------------------------------------------
  3730. -- Operations on short component arrays
  3731. --
  3732.    -- Predefined system functions : function "=" and function "/=". 
  3733.    -- Comparisons are handled under variable-sized arrays.
  3734.    -- The array parameters must have the same length and the same
  3735.    -- CLASSIFICATION (both INTEGER_CLASS or both SHORT_FLOAT_CLASS).
  3736.    -- The returning result component array will contain the same
  3737.    -- number of elements.
  3738.    -- For SHORT_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
  3739.    -- the array is set for higher level exponent operation.
  3740.    -- The SHORT_FLOAT_CLASS array will be normalized by these routines.
  3741.    -- Note that the least significant COMP is the first in the
  3742.    -- array, and consequently the most significant COMP is the last.
  3743.  
  3744.    function "+"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  3745.    function "-"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  3746.    function "*"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  3747.    function "/"    (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  3748.    function "rem"  (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
  3749.  
  3750.  
  3751. -------------------------------------------------------------------
  3752. -- Operations on long component arrays
  3753. --
  3754.    -- Predefined system functions : function "=" and function "/=". 
  3755.    -- Comparisions are handled under variable-sized arrays.
  3756.    -- The array parameters must have the same length.
  3757.    -- The returning result component array will contain the same
  3758.    -- number of elements.
  3759.    -- For LONG_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
  3760.    -- the array is set for higher level exponent operation.
  3761.    -- The LONG_FLOAT_CLASS array will be normalized by these routines.
  3762.  
  3763.    function "+"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  3764.    function "-"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  3765.    function "*"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  3766.    function "/"    (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
  3767.  
  3768.  
  3769. -------------------------------------------------------------------
  3770. -- Operations on variable-sized component arrays
  3771. --
  3772.    -- The array parameters are only comprised of components,
  3773.    -- no CLASSIFICATION or BITS_SHIFTED info is included.
  3774.    -- The array will not be normalized by these routines, that
  3775.    -- is the responsibility of a higher level routine.
  3776.  
  3777.    -- The comparison functions.
  3778.    -- Predefined system functions : function "=" and function "/=". 
  3779.  
  3780.    function "<"    (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  3781.    function "<="   (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  3782.    function ">"    (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  3783.    function ">="   (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
  3784.  
  3785.    -- This routine performs a divide by two on the array,
  3786.    -- with rounding to even.
  3787.    procedure DIVIDE_ARRAY_BY_TWO (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
  3788.  
  3789.    -- This routine sets the range of all individual COMPs within
  3790.    -- (0 .. MAX_COMP_VALUE) by looping through the array from the least 
  3791.    -- significant COMP to the most significant COMP, performing
  3792.    -- carries and borrows as necessary.  Since the most significant
  3793.    -- COMP has nowhere to carry or borrow, it is left unbounded.
  3794.    -- This allows the higher level routine to determine if shifting
  3795.    -- must occur, an error exists, or whatever.
  3796.    procedure RANGE_CHECK (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
  3797.  
  3798.    -- This routine shifts to the right and truncates a
  3799.    -- component array.  The BITS variable is the number of bits
  3800.    -- to shift the array and must be positive.
  3801.    procedure ARRAY_TRUNCATION_SHIFT_RIGHT 
  3802.       (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : in NATURAL);
  3803.  
  3804.    -- This routine sets the most significant bit in the array to one
  3805.    -- (normalized), by shifting the array to the left.
  3806.    -- The BITS variable is the number of bits the array was shifted.
  3807.    procedure ARRAY_NORMALIZE
  3808.       (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : out INTEGER);
  3809.  
  3810. -------------------------------------------------------------------
  3811. end MAE_BASIC_OPERATIONS;
  3812. <FF>
  3813.  
  3814.  
  3815. 5.  ADA ISSUES
  3816.  
  3817. Ada provides a powerful implementation language that is well suited
  3818. to the writing of generalized computational facilities such as the
  3819. Emulation of Machine Arithmetic. Several significant issues relating
  3820. to the use of Ada are relevent to the development and maintenance of
  3821. the EMA software. These issues are 1) compiler selection, 2) the
  3822. impact of utilizing an incomplete non-production quality Ada
  3823. compiler, 3) the methods of adapting the code to emulate target
  3824. machines with different host and target word lengths, and 4) the
  3825. possible methods of tuning the EMA packages to achieve significantly
  3826. improved performance using machine-dependent facilities. 
  3827.  
  3828. 5.1  Compiler Selection
  3829.  
  3830. The design and development activities of the Emulation of Machine
  3831. Arithmetic project were conducted using the Government mandated
  3832. target compiler, which was the most recent release (at the time) of
  3833. the TeleSoft Ada compiler.  The TeleSoft compiler release which was
  3834. utilized contained two Ada compiler versions:  Version 2.1, which is
  3835. a certified pre-release version of the TeleSoft Ada compiler
  3836. awaiting validation, and Version 1.5, which is an incomplete Ada
  3837. compiler with near-production quality performance in terms of
  3838. compilation speed. 
  3839.  
  3840. The project was initiated using the Version 2.1 compiler in the
  3841. hopes of utilizing full Ada, with its significant advantages for
  3842. developing generalized code. Unfortunately, the performance and
  3843. support facilities of the Version 2.1 compiler were too poor to
  3844. continue using it beyond the Macroscopic design phase.  This
  3845. necessitated a conversion of the project and the design to the
  3846. TeleSoft Version 1.5 compiler.  The following shortcomings were the
  3847. principal factors leading to the decision to disgard the Version 2.1
  3848. compiler: 
  3849.  
  3850.      - Extremely slow compilation speed.  During Macroscopic 
  3851.        design and algorithm evaluation, turnaround times normally
  3852.        exceeded one hour, and averaged over two hours during normal 
  3853.        business hours.  Extrapolating the turnaround time for
  3854.        the full implementation indicated that it was highly probable
  3855.        that only two compilations of the emulation system would be 
  3856.        possible per day.
  3857.      - The program library facility was extremely primitive.  Each
  3858.        time a main program unit was to be recompiled, special 
  3859.        TeleSoft utilities had to be invoked to reset the tables used
  3860.        to track compilation units in the library.  The library reset
  3861.        facility was slow and subject to errors (i.e., it was easy to
  3862.        remove too many or too few units) which would necessitate the
  3863.        reinitialization of the library (including recompilation of
  3864.        all units).
  3865.      - The TeleSoft Ada development system lacked any interactive
  3866.        debugging and tracing facilities.  Thus, debugging is usually
  3867.        reduced to an iterative process consisting of manually
  3868.        inserting trace statements in the code under development, 
  3869.        followed by recompilation, followed by additional testing.
  3870.  
  3871.  
  3872. The primitive state of the debugging facilities in the TeleSoft
  3873. compiler system made rapid and reliable compilation turnaround a
  3874. necessity.  This fact, in combination with the poor compilation
  3875. speed and unreliable program library facilities, made the risk of
  3876. continuing with the Version 2.1 compiler too great. 
  3877.  
  3878.        
  3879. 5.2  Compiler Impact on Design and Implementation
  3880.  
  3881. The TeleSoft Version 1.5 compiler used to develop the packages
  3882. comprising the Emulation of Machine Arithmetic lacks numerous Ada
  3883. features, several of which had a significant impact on the design
  3884. and implementation of the system.  These features are: 
  3885.  
  3886.      - generics
  3887.      - named associations for aggregates and calling parameters
  3888.      - dynamic record constructs
  3889.      - type attributes (incomplete)
  3890.      - universal expressions 
  3891.      - derived types
  3892.      - support for 32-bit Integer arithmetic
  3893.  
  3894. In general, the missing facilities prevented the use of dynamic
  3895. calculations to define, initialize, and manipulate data structure
  3896. components, which eventually led to the development of intermediate
  3897. packages supporting the specific target data types required by this
  3898. project. The following paragraphs give some examples of the impact
  3899. on the design and implementation. 
  3900.  
  3901. The emulation algorithm is designed to use the host machine's native 
  3902. arithmetic to efficiently compute results on the components used to
  3903. make up the emulated target types.  The number of components needed
  3904. is directly related to the number of bits in a component and the
  3905. number of bits of mantissa to be simulated.  In full Ada, the number
  3906. of components, used as a dimension in the emulation data structure,
  3907. can be computed.  For example: 
  3908.  
  3909.      subtype SHORT_COMPONENT_ARRAY_TYPE is 
  3910.         COMPONENT_ARRAY_TYPE (1..BITS_TO_COMPS(TARGET_SHORT_NUM_BITS));
  3911.         -- where BITS_TO_COMPS is a function to compute the number
  3912.         -- of components required to emulate the specified number
  3913.         -- of bits
  3914.  
  3915. This approach is not permitted in TeleSoft 1.5 (the function call
  3916. BITS_TO_COMPS is the problem). This problem was largely overcome by
  3917. using parameters (e.g., named numbers) instead.  Another related
  3918. problem, the initialization of the arrays whose dimensions are
  3919. controlled by the parameters (and originally the function values),
  3920. was overcome by the use of initialization code in package bodies.
  3921. Ideally the initialization would be performed by: 
  3922.  
  3923.      ZERO_VALUED_SHORT_ARRAY : SHORT_COMPONENT_ARRAY_TYPE := 
  3924.         (1..SHORT_COMPONENT_ARRAY_TYPE'last => 0);      
  3925.  
  3926. However, this too is not permitted in TeleSoft 1.5, due to the 
  3927. restriction against named associations.  In fact, array aggregates 
  3928. can only be of positional types, leading to much more complex
  3929. initialization data and code sequences.
  3930.  
  3931. Finally, the lack of generics made it necessary to develop separate
  3932. packages for the target short and long floating point emulations,
  3933. even though the code is virtually identical except for different
  3934. parameters and constant values. 
  3935.  
  3936.  
  3937. 5.3  Configuring the Program
  3938.  
  3939. 5.3.1  Target Word Size Specification
  3940.  
  3941. The use of a subset Ada compiler (TeleSoft Version 1.5) prevented
  3942. the use of generics and other generalizing features of the Ada
  3943. language in the EMA implementation. This restriction was overcome by
  3944. defining constants and parameters which control the algorithm (e.g.,
  3945. number of components used to represent the target word). These
  3946. parameters were placed in the MAE_BASIC_OPERATIONS package, and can
  3947. be used to configure the machine arithmetic emulation packages to
  3948. support different target machine word sizes. Configuration is
  3949. considered to be the modification of the packages to emulate word
  3950. sizes larger than a given host machine and other than the delivered
  3951. 36-bit emulation. 
  3952.  
  3953. To configure the EMA packages to support arithmetic operations for
  3954. word sizes other than 36 bits, it is necessary to alter the values
  3955. of several parameters controlling the execution of the emulation.
  3956. These parameters are: 
  3957.  
  3958.      TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
  3959.      -- This is the number of bits (excluding the sign)
  3960.      -- in the standard integer number.
  3961.  
  3962.      TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
  3963.      -- This is the number of bits of mantissa in the short
  3964.      -- floating point number.
  3965.  
  3966.      TARGET_LONG_NUM_BITS : constant INTEGER := 63;
  3967.      -- This is the number of bits of mantissa in the double
  3968.      -- precision floating point number.  It is assumed to
  3969.      -- be stored in two target words.
  3970.  
  3971.      SHORT_NUM_COMPS : constant INTEGER := 6;
  3972.      -- This is the number of components used to emulate the 
  3973.      -- integer and short floating point number.  This must
  3974.      -- be adjusted to be consistent with the new values of 
  3975.      -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
  3976.      -- The value is given by dividing the number of bits in
  3977.      -- the target word by the number of bits in a component,
  3978.      -- and rounding up to the next integer.
  3979.  
  3980.      LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
  3981.      -- This is the number of components used to emulate the double
  3982.      -- precision floating point number.  This value is 
  3983.      -- automatically adjusted to be consistent with the new 
  3984.      -- value of TARGET_LONG_NUM_BITS.
  3985.  
  3986. The changing of the aforementioned parameters is sufficient to
  3987. 'reprogram' the emulation algorithm to emulate the desired target 
  3988. word size.
  3989.      
  3990.  
  3991. 5.3.2  Host Word Size Specification and Performance Tuning
  3992.  
  3993. The packages comprising the machine arithmetic emulation were coded
  3994. in machine-independent Ada.  To achieve this level of portability,
  3995. some of the potential, but machine-dependent, performance improving
  3996. techniques were intentionally omitted from the design.  Several
  3997. methods for improving the performance of the emulation exist which
  3998. rely on utilizing machine and/or compiler-dependent features, and
  3999. these methods can be used to tune the performance of the emulation
  4000. when machines and compilers that support the features are available.
  4001. These techniques are discussed in the paragraphs below. 
  4002.  
  4003. Use the maximum number of bits per target word component possible
  4004. for each host/compiler combination.  The packages support the
  4005. capability to adapt to the greater efficiencies available by using
  4006. the host arithmetic capability if it exceeds 16 bits (the
  4007. restriction of the TeleSoft Version 1.5 compiler). To adapt to a
  4008. host and compiler combination which supports greater than 16-bit
  4009. integer arithmetic, the values of several parameters in the
  4010. MAE_BASIC_OPERATIONS package must be changed. These values are: 
  4011.  
  4012.      NO_COMP_BITS : constant INTEGER := 7;
  4013.      -- This value represents the number of bits in each target
  4014.      -- word component.  It is selected such that arithmetic 
  4015.      -- operations on components will not overflow the supporting 
  4016.      -- host arithmetic.  The value 7 was selected based on the 
  4017.      -- present use of 16-bit integers.  If 32-bit integer arithmetic 
  4018.      -- were available, then this value could be as high as 15.  The 
  4019.      -- greater the number of bits in each component, the fewer the 
  4020.      -- number of components that will be required, and hence the 
  4021.      -- faster the emulation.
  4022.  
  4023.      SHORT_NUM_COMPS : constant INTEGER := 6;
  4024.      -- This is the number of components used to emulate the 
  4025.      -- integer and short floating point number.  This must
  4026.      -- be adjusted to be consistent with the new values of 
  4027.      -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
  4028.      -- The value is given by dividing the number of bits in
  4029.      -- the target word by the number of bits in a component,
  4030.      -- and rounding up to the next integer.
  4031.  
  4032.      LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
  4033.      -- This is the number of components used to emulate the double
  4034.      -- precision floating point number.  This value is 
  4035.      -- automatically adjusted to be consistent with the new 
  4036.      -- value of TARGET_LONG_NUM_BITS.
  4037.  
  4038. Compile the packages using all available compiler optimization
  4039. features.  This should result in significantly improved executable
  4040. code, as a result of the compiler performing a variety of useful
  4041. transformations including the removal of many of the unnecessary
  4042. constraint checks inserted by Ada, and the optimal use of registers
  4043. to reduce load and store operations. 
  4044.  
  4045. Use 'pragma INLINE' to reduce the calling overhead.  This should be
  4046. done for the intermediate packages MAE_INTEGER, MAE_SHORT_FLOAT, and
  4047. MAE_LONG_FLOAT to reduce the calling overhead occuring between these
  4048. packages and the bodies of the exported functions of the package
  4049. MACHINE_ARITHMETIC_EMULATION (which are currently implemented as
  4050. single-statement bodies calling the appropriate procedure of the
  4051. intermediate packages). The 'pragma INLINE' could also be applied to
  4052. certain subprograms of the MAE_BASIC_PACKAGE which are short and/or
  4053. only called once per using subprogram (e.g., CHANGE_SIGN and
  4054. ROUND_TO_HOST). 
  4055.  
  4056. Use 'pragma SUPPRESS' in the arithmetic routines of the package
  4057. MAE_BASIC_OPERATIONS (i.e., '+', '-', '*', '/') to remove
  4058. unnecessary constraint checks.  These constraint checks can be
  4059. eliminated because the number of bits utilized in each component has
  4060. been selected to insure that the host arithmetic operations can not
  4061. cause an arithmetic overflow. 
  4062. <FF>
  4063.  
  4064. 6.   TESTING
  4065.  
  4066. The testing of the Emulation of Machine Arithmetic packages was
  4067. quite extensive, as is required for software of this type. The
  4068. testing of the EMA packages was subdivided into two phases: unit
  4069. testing which was performed during the development cycle, and
  4070. integration testing which was performed after the development was
  4071. completed. Each of the two phases of testing made an important
  4072. contribution towards the achievement of a reliable emulation. 
  4073.  
  4074. 6.1  Unit Testing
  4075.  
  4076. 6.1.1  Approach 
  4077.  
  4078. The EMA design made unit testing during the development cycle
  4079. extremely important.  Since the design called for a layered package
  4080. structure, the low level code of the package MAE_BASIC_OPERATIONS,
  4081. which provides facilities to all other EMA packages, needed to be
  4082. tested as it was developed. A thorough check of the operations
  4083. within MAE_BASIC_OPERATION was necessary prior to the testing of any
  4084. of the higher level packages, since the higher level subprograms
  4085. depend on correct results from the lower level routines. 
  4086.  
  4087. The first step in unit testing was the generation of compilable Ada
  4088. Program Design Language (PDL) specifications for the packages.  The
  4089. TeleSoft compiler was then used to identify design deficiencies and
  4090. unsupported Ada language features.  As the development of each
  4091. subprogram was completed, each subprogram was hand checked and then
  4092. computer checked by a variety of test programs to insure that it
  4093. produced correct results. The integration of the subprogram, which
  4094. included retesting, verified the completeness and correctness of the
  4095. implementation. 
  4096.  
  4097. 6.1.2  Results
  4098.  
  4099. The testing approach proved to be very valuable in preventing minor
  4100. design flaws and small code errors from expanding into major
  4101. problems. Most design problems were attributed to the utilization of
  4102. non-supported Ada language features. These deficiencies were exposed
  4103. during the generation of the compilable PDL.  Coding errors such as
  4104. rounding problems, missing normalization checks, and selection of
  4105. incorrect components were discovered early in the development cycle
  4106. through the use of test drivers at the unit level. 
  4107.  
  4108.  
  4109. 6.2  Integration Testing
  4110.  
  4111. 6.2.1  Approach 
  4112.  
  4113. Integration testing was performed after development of the EMA
  4114. packages was completed.  The testing covered both the intermediate
  4115. level packages, which support operations on one of the target types,
  4116. and the top level package MACHINE_ARITHMETIC_EMULATION.
  4117.  
  4118. Integration testing began with the development of several individual
  4119. tests which excercised specific code areas.  Subsequently, a main
  4120. driver program was developed which combined the individual test
  4121. programs into one, thereby giving the user the flexibility of
  4122. testing different operations without exiting one program and
  4123. starting another. The driver program has menu selected operations,
  4124. which give the user full control over the operations and operands to
  4125. be utilized.  The results of the tests are displayed on the user's
  4126. terminal, and are optionally logged in a disk file to allow for
  4127. printed results.  The test program also allows the user to output a
  4128. system results trace, that displays the results of the same
  4129. operation using the host system's arithmetic. 
  4130.  
  4131. Because it is not possible to exhaustively test each operation with
  4132. all possible operand values, the choice of operands for testing is
  4133. critical.  The use of randomly selected operands for testing the
  4134. operations would potentially not exercise the EMA packages to the
  4135. necessary extent.  The interesting cases for the three types,
  4136. TARGET_INTEGER, TARGET_SHORT_FLOAT, and TARGET_LONG_FLOAT, were
  4137. determined based on the architecture and requirements of the EMA
  4138. package.  The interesting cases are primarily constructed with
  4139. boundary values, that are numerically or architecturally at the
  4140. limits of the emulation.  The interesting operands are shown in
  4141. Tables 6-1 and 6-2. 
  4142.  
  4143.  
  4144.         Table 6-1.   Interesting Operands For Target Integers
  4145.   -----------------------------------------------------------------
  4146.  
  4147.           ZERO
  4148.           ONE
  4149.           (2**35)-1  : the maximum positive value in the range
  4150.                          integer value = 34359738367
  4151.           (2**35)    : positive maximum plus one, overflow test
  4152.                          integer value = 34359738368
  4153.           (2**34)    : one half positive maximum, overflow test
  4154.                          integer value = 17179869184
  4155.           (2**34)-1  : one half positive maximum minus one,
  4156.                          overflow test
  4157.                          integer value = 17179869183
  4158.           -(2**35)   : the maximum negative value in the range
  4159.                          integer value = -34359738368
  4160.           -(2**34)   : one half negative maximum, overflow test
  4161.                          integer value = -17179869184
  4162.  
  4163. <FF>
  4164.  
  4165.         Table 6-2.   Interesting Operands For Target Floating Point
  4166.   ---------------------------------------------------------------------
  4167.  
  4168.           ZERO
  4169.           ONE
  4170.           (2**127)   : the maximum value in the range
  4171.                          floating value = 1.7014118E+38
  4172.           (2**126)   : one half the maximum value,
  4173.                          overflow testing
  4174.                          floating value = 8.5070592E+37
  4175.           1.0E+31    : a delta value used to cause overflows
  4176.           1.0E+28    : a delta value used to cause overflows
  4177.           (2**-129)  : the smallest value in the range,
  4178.                          since (.5*(2**-128)) = (2**-129)
  4179.                          floating value = 1.469368E-37
  4180.           (2**-128)  : twice the smallest value,
  4181.                          underflow to zero testing
  4182.                          floating value = 2.9387359E-37
  4183.  
  4184.  
  4185. 6.2.2  Results
  4186.  
  4187. The integration testing results included the detection of errors and
  4188. the generation of information on algorithm operation. A large volume
  4189. of printed results was produced, and a sample of them is presented in
  4190. Appendix A. 
  4191.  
  4192. One code error that the test program exposed was an improper
  4193. handling of a divide by zero exception in the exponentiation
  4194. routine. The error was corrected and then retested with correct
  4195. results.  Testing also showed that the slow operation of the test
  4196. program was attributed to the string conversion routines since the
  4197. binary exponent of target floating point types must be changed to a
  4198. decimal exponent within the string.  This led to the subsequent
  4199. tuning of the string conversion routines. 
  4200. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4201. --appdixa.rpt
  4202. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.                              APPENDIX A
  4221.  
  4222.  
  4223.  
  4224.                             TEST RESULTS
  4225. <FF>
  4226.     
  4227.     
  4228.     A.1  Integer Test Results
  4229.     
  4230.     
  4231.                  -- SAMPLE OF OPERATIONS
  4232.     INTEGER OPERATIONS RESULTS
  4233.     
  4234.     OP1                      =            4
  4235.     OP2                      =            2
  4236.     
  4237.     OP1 >= OP2               = TRUE
  4238.     
  4239.     OP1 + OP2                =            6
  4240.     
  4241.     OP1 - OP2                =            2
  4242.     
  4243.     OP1 * OP2                =            8
  4244.     
  4245.     OP1 / OP2                =            2
  4246.     
  4247.     (OP1 / OP2) * OP2        =            4
  4248.     
  4249.     INTEGER OPERATIONS RESULTS
  4250.     
  4251.     OP1                      =            4
  4252.     OP2                      =           -2
  4253.     
  4254.     OP1 >= OP2               = TRUE
  4255.     
  4256.     OP1 + OP2                =            2
  4257.     
  4258.     OP1 - OP2                =            6
  4259.     
  4260.     OP1 * OP2                =           -8
  4261.     
  4262.     OP1 / OP2                =           -2
  4263.     
  4264.     (OP1 / OP2) * OP2        =            4
  4265. <FF>
  4266.     
  4267.                  -- SAMPLE OF OPERATIONS
  4268.     INTEGER OPERATIONS RESULTS
  4269.     
  4270.     OP1                      =           -4
  4271.     OP2                      =            2
  4272.     
  4273.     OP1 >= OP2               = FALSE
  4274.     
  4275.     OP1 + OP2                =           -2
  4276.     
  4277.     OP1 - OP2                =           -6
  4278.     
  4279.     OP1 * OP2                =           -8
  4280.     
  4281.     OP1 / OP2                =           -2
  4282.     
  4283.     (OP1 / OP2) * OP2        =           -4
  4284.     
  4285.     INTEGER OPERATIONS RESULTS
  4286.     
  4287.     OP1                      =           -4
  4288.     OP2                      =           -2
  4289.     
  4290.     OP1 >= OP2               = FALSE
  4291.     
  4292.     OP1 + OP2                =           -6
  4293.     
  4294.     OP1 - OP2                =           -2
  4295.     
  4296.     OP1 * OP2                =            8
  4297.     
  4298.     OP1 / OP2                =            2
  4299.     
  4300.     (OP1 / OP2) * OP2        =           -4
  4301. <FF>
  4302.     
  4303.                  -- ADD/SUBTRACT OPERATIONS
  4304.                  -- WITH ZERO
  4305.     INTEGER OPERATIONS RESULTS
  4306.     
  4307.     OP1                      =            2
  4308.     OP2                      =            0
  4309.     
  4310.     OP1 + OP2                =            2
  4311.     
  4312.     OP1 - OP2                =            2
  4313.     
  4314.     OP2 - OP1                =           -2
  4315.     
  4316.     INTEGER OPERATIONS RESULTS
  4317.     
  4318.     OP1                      =           -2
  4319.     OP2                      =            0
  4320.     
  4321.     OP1 + OP2                =           -2
  4322.     
  4323.     OP1 - OP2                =           -2
  4324.     
  4325.     OP2 - OP1                =            2
  4326.     
  4327.     INTEGER OPERATIONS RESULTS
  4328.     
  4329.     OP1                      =            0
  4330.     OP2                      =            2
  4331.     
  4332.     OP1 + OP2                =            2
  4333.     
  4334.     OP1 - OP2                =           -2
  4335.     
  4336.     OP2 - OP1                =            2
  4337.     
  4338.     INTEGER OPERATIONS RESULTS
  4339.     
  4340.     OP1                      =            0
  4341.     OP2                      =           -2
  4342.     
  4343.     OP1 + OP2                =           -2
  4344.     
  4345.     OP1 - OP2                =            2
  4346.     
  4347.     OP2 - OP1                =           -2
  4348. <FF>
  4349.     
  4350.                  -- MULTIPLY/DIVIDE OPERATIONS
  4351.                  -- WITH ZERO
  4352.     INTEGER OPERATIONS RESULTS
  4353.     
  4354.     OP1                      =            2
  4355.     OP2                      =            0
  4356.     
  4357.     OP1 * OP2                =            0
  4358.     
  4359.     OP1 / OP2                = 
  4360.     *** EXCEPTION CONDITION RAISED ***
  4361.     
  4362.     INTEGER OPERATIONS RESULTS
  4363.     
  4364.     OP1                      =           -2
  4365.     OP2                      =            0
  4366.     
  4367.     OP1 * OP2                =            0
  4368.     
  4369.     OP1 / OP2                = 
  4370.     *** EXCEPTION CONDITION RAISED ***
  4371.     
  4372.     INTEGER OPERATIONS RESULTS
  4373.     
  4374.     OP1                      =            0
  4375.     OP2                      =            2
  4376.     
  4377.     OP1 * OP2                =            0
  4378.     
  4379.     OP1 / OP2                =            0
  4380.     
  4381.     (OP1 / OP2) * OP2        =            0
  4382.     
  4383.     INTEGER OPERATIONS RESULTS
  4384.     
  4385.     OP1                      =            0
  4386.     OP2                      =           -2
  4387.     
  4388.     OP1 * OP2                =            0
  4389.     
  4390.     OP1 / OP2                =            0
  4391.     
  4392.     (OP1 / OP2) * OP2        =            0
  4393. <FF>
  4394.     
  4395.                  -- COMPARISION OPERATIONS
  4396.                  -- WITH ZERO
  4397.     INTEGER OPERATIONS RESULTS
  4398.     
  4399.     OP1                      =            2
  4400.     OP2                      =            0
  4401.     
  4402.     OP1 > OP2                = TRUE
  4403.     
  4404.     OP1 >= OP2               = TRUE
  4405.     
  4406.     OP1 < OP2                = FALSE
  4407.     
  4408.     OP1 <= OP2               = FALSE
  4409.     
  4410.     INTEGER OPERATIONS RESULTS
  4411.     
  4412.     OP1                      =           -2
  4413.     OP2                      =            0
  4414.     
  4415.     OP1 > OP2                = FALSE
  4416.     
  4417.     OP1 >= OP2               = FALSE
  4418.     
  4419.     OP1 < OP2                = TRUE
  4420.     
  4421.     OP1 <= OP2               = TRUE
  4422.     
  4423.     INTEGER OPERATIONS RESULTS
  4424.     
  4425.     OP1                      =            0
  4426.     OP2                      =            2
  4427.     
  4428.     OP1 > OP2                = FALSE
  4429.     
  4430.     OP1 >= OP2               = FALSE
  4431.     
  4432.     OP1 < OP2                = TRUE
  4433.     
  4434.     OP1 <= OP2               = TRUE
  4435.     
  4436.     INTEGER OPERATIONS RESULTS
  4437.     
  4438.     OP1                      =            0
  4439.     OP2                      =           -2
  4440.     
  4441.     OP1 > OP2                = TRUE
  4442.     
  4443.     OP1 >= OP2               = TRUE
  4444.     
  4445.     OP1 < OP2                = FALSE
  4446.     
  4447.     OP1 <= OP2               = FALSE
  4448. <FF>
  4449.     
  4450.                  -- REMAINDER/MODULO OPERATIONS
  4451.                  -- WITH ZERO
  4452.     INTEGER OPERATIONS RESULTS
  4453.     
  4454.     OP1                      =            2
  4455.     OP2                      =            0
  4456.     
  4457.     OP1 rem OP2              = 
  4458.     *** EXCEPTION CONDITION RAISED ***
  4459.     
  4460.     INTEGER OPERATIONS RESULTS
  4461.     
  4462.     OP1                      =           -2
  4463.     OP2                      =            0
  4464.     
  4465.     OP1 rem OP2              = 
  4466.     *** EXCEPTION CONDITION RAISED ***
  4467.     
  4468.     INTEGER OPERATIONS RESULTS
  4469.     
  4470.     OP1                      =            0
  4471.     OP2                      =            2
  4472.     
  4473.     OP1 rem OP2              =            0
  4474.     
  4475.     OP1 mod OP2              =            0
  4476.     
  4477.     INTEGER OPERATIONS RESULTS
  4478.     
  4479.     OP1                      =            0
  4480.     OP2                      =           -2
  4481.     
  4482.     OP1 rem OP2              =            0
  4483.     
  4484.     OP1 mod OP2              =            0
  4485. <FF>
  4486.     
  4487.                  -- EXPONENTIATION OPERATIONS
  4488.                  -- WITH ZERO
  4489.     INTEGER OPERATIONS RESULTS
  4490.     
  4491.     OP1                      =            2
  4492.     POWER                    =      0
  4493.     
  4494.     OP1 ** POWER             =            1
  4495.     
  4496.     INTEGER OPERATIONS RESULTS
  4497.     
  4498.     OP1                      =           -2
  4499.     POWER                    =      0
  4500.     
  4501.     OP1 ** POWER             =            1
  4502.     
  4503.     INTEGER OPERATIONS RESULTS
  4504.     
  4505.     OP1                      =            0
  4506.     POWER                    =      2
  4507.     
  4508.     OP1 ** POWER             =            0
  4509.     
  4510.     INTEGER OPERATIONS RESULTS
  4511.     
  4512.     OP1                      =            0
  4513.     POWER                    =     -2
  4514.     
  4515.     OP1 ** POWER             = 
  4516.     *** EXCEPTION CONDITION RAISED ***
  4517. <FF>
  4518.     
  4519.                  -- EXPONENTIATION OPERATIONS
  4520.                  -- WITH ZERO AND ONE
  4521.     INTEGER OPERATIONS RESULTS
  4522.     
  4523.     OP1                      =            0
  4524.     POWER                    =      0
  4525.     
  4526.     OP1 ** POWER             =            1
  4527.     
  4528.     INTEGER OPERATIONS RESULTS
  4529.     
  4530.     OP1                      =            1
  4531.     POWER                    =      1
  4532.     
  4533.     OP1 ** POWER             =            1
  4534.     
  4535.     INTEGER OPERATIONS RESULTS
  4536.     
  4537.     OP1                      =            1
  4538.     POWER                    =      0
  4539.     
  4540.     OP1 ** POWER             =            1
  4541.     
  4542.     INTEGER OPERATIONS RESULTS
  4543.     
  4544.     OP1                      =           -1
  4545.     POWER                    =      0
  4546.     
  4547.     OP1 ** POWER             =            1
  4548.     
  4549.     INTEGER OPERATIONS RESULTS
  4550.     
  4551.     OP1                      =            0
  4552.     POWER                    =      1
  4553.     
  4554.     OP1 ** POWER             =            0
  4555.     
  4556.     INTEGER OPERATIONS RESULTS
  4557.     
  4558.     OP1                      =            0
  4559.     POWER                    =     -1
  4560.     
  4561.     OP1 ** POWER             = 
  4562.     *** EXCEPTION CONDITION RAISED ***
  4563. <FF>
  4564.     
  4565.                  -- SAMPLE OPERATIONS
  4566.                  -- WITH ZERO AND (2**35)-1
  4567.     INTEGER OPERATIONS RESULTS
  4568.     
  4569.     OP1                      =  34359738367
  4570.     OP2                      =            0
  4571.     
  4572.     OP1 >= OP2               = TRUE
  4573.     
  4574.     OP1 + OP2                =  34359738367
  4575.     
  4576.     OP1 - OP2                =  34359738367
  4577.     
  4578.     OP1 * OP2                =            0
  4579.     
  4580.     OP1 / OP2                = 
  4581.     *** EXCEPTION CONDITION RAISED ***
  4582.     
  4583.     INTEGER OPERATIONS RESULTS
  4584.     
  4585.     OP1                      =            0
  4586.     OP2                      =  34359738367
  4587.     
  4588.     OP1 >= OP2               = FALSE
  4589.     
  4590.     OP1 + OP2                =  34359738367
  4591.     
  4592.     OP1 - OP2                = -34359738367
  4593.     
  4594.     OP1 * OP2                =            0
  4595.     
  4596.     OP1 / OP2                =            0
  4597.     
  4598.     (OP1 / OP2) * OP2        =            0
  4599. <FF>
  4600.     
  4601.                  -- SAMPLE OPERATIONS
  4602.                  -- WITH ZERO AND -(2**35)
  4603.     INTEGER OPERATIONS RESULTS
  4604.     
  4605.     OP1                      = -34359738368
  4606.     OP2                      =            0
  4607.     
  4608.     OP1 >= OP2               = FALSE
  4609.     
  4610.     OP1 + OP2                = -34359738368
  4611.     
  4612.     OP1 - OP2                = -34359738368
  4613.     
  4614.     OP1 * OP2                =            0
  4615.     
  4616.     OP1 / OP2                = 
  4617.     *** EXCEPTION CONDITION RAISED ***
  4618.     
  4619.     INTEGER OPERATIONS RESULTS
  4620.     
  4621.     OP1                      =            0
  4622.     OP2                      = -34359738368
  4623.     
  4624.     OP1 >= OP2               = TRUE
  4625.     
  4626.     OP1 + OP2                = -34359738368
  4627.     
  4628.     OP1 - OP2                = 
  4629.     *** EXCEPTION CONDITION RAISED ***
  4630. <FF>
  4631.     
  4632.                  -- ADD/SUBTRACT OPERATIONS
  4633.                  -- WITH ONE AND (2**35)-1
  4634.     INTEGER OPERATIONS RESULTS
  4635.     
  4636.     OP1                      =  34359738367
  4637.     OP2                      =            1
  4638.     
  4639.     OP1 + OP2                = 
  4640.     *** EXCEPTION CONDITION RAISED ***
  4641.     
  4642.     INTEGER OPERATIONS RESULTS
  4643.     
  4644.     OP1                      =  34359738367
  4645.     OP2                      =           -1
  4646.     
  4647.     OP1 + OP2                =  34359738366
  4648.     
  4649.     OP1 - OP2                = 
  4650.     *** EXCEPTION CONDITION RAISED ***
  4651. <FF>
  4652.     
  4653.                  -- ADD/SUBTRACT OPERATIONS
  4654.                  -- WITH ONE AND -(2**35)
  4655.     INTEGER OPERATIONS RESULTS
  4656.     
  4657.     OP1                      = -34359738368
  4658.     OP2                      =            1
  4659.     
  4660.     OP1 + OP2                = -34359738367
  4661.     
  4662.     OP1 - OP2                = 
  4663.     *** EXCEPTION CONDITION RAISED ***
  4664.     
  4665.     INTEGER OPERATIONS RESULTS
  4666.     
  4667.     OP1                      = -34359738368
  4668.     OP2                      =           -1
  4669.     
  4670.     OP1 + OP2                = 
  4671.     *** EXCEPTION CONDITION RAISED ***
  4672. <FF>
  4673.     
  4674.     
  4675.                  -- ADD/SUBTRACT OPERATIONS
  4676.                  -- WITH (2**34)
  4677.     INTEGER OPERATIONS RESULTS
  4678.     
  4679.     OP1                      =  17179869184
  4680.     OP2                      =  17179869184
  4681.     
  4682.     OP1 + OP2                = 
  4683.     *** EXCEPTION CONDITION RAISED ***
  4684.     
  4685.     INTEGER OPERATIONS RESULTS
  4686.     
  4687.     OP1                      =  17179869184
  4688.     OP2                      = -17179869184
  4689.     
  4690.     OP1 + OP2                =            0
  4691.     
  4692.     OP1 - OP2                = 
  4693.     *** EXCEPTION CONDITION RAISED ***
  4694.     
  4695.     INTEGER OPERATIONS RESULTS
  4696.     
  4697.     OP1                      = -17179869184
  4698.     OP2                      =  17179869184
  4699.     
  4700.     OP1 + OP2                =            0
  4701.     
  4702.     OP1 - OP2                = -34359738368
  4703.     
  4704.     OP2 - OP1                = 
  4705.     *** EXCEPTION CONDITION RAISED ***
  4706.     
  4707.     INTEGER OPERATIONS RESULTS
  4708.     
  4709.     OP1                      = -17179869184
  4710.     OP2                      = -17179869184
  4711.     
  4712.     OP1 + OP2                = -34359738368
  4713.     
  4714.     OP1 - OP2                =            0
  4715.     
  4716.     OP2 - OP1                =            0
  4717. <FF>
  4718.     
  4719.     
  4720.                  -- MULTIPLY/DIVIDE OPERATIONS
  4721.                  -- WITH TWO AND (2**34)
  4722.     INTEGER OPERATIONS RESULTS
  4723.     
  4724.     OP1                      =  17179869184
  4725.     OP2                      =            2
  4726.     
  4727.     OP1 * OP2                = 
  4728.     *** EXCEPTION CONDITION RAISED ***
  4729.     
  4730.     INTEGER OPERATIONS RESULTS
  4731.     
  4732.     OP1                      =  17179869184
  4733.     OP2                      =           -2
  4734.     
  4735.     OP1 * OP2                = -34359738368
  4736.     
  4737.     OP1 / OP2                =  -8589934592
  4738.     
  4739.     (OP1 / OP2) * OP2        =  17179869184
  4740.     
  4741.     INTEGER OPERATIONS RESULTS
  4742.     
  4743.     OP1                      = -17179869184
  4744.     OP2                      =            2
  4745.     
  4746.     OP1 * OP2                = -34359738368
  4747.     
  4748.     OP1 / OP2                =  -8589934592
  4749.     
  4750.     (OP1 / OP2) * OP2        = -17179869184
  4751.     
  4752.     INTEGER OPERATIONS RESULTS
  4753.     
  4754.     OP1                      = -17179869184
  4755.     OP2                      =           -2
  4756.     
  4757.     OP1 * OP2                = 
  4758.     *** EXCEPTION CONDITION RAISED ***
  4759. <FF>
  4760.     
  4761.                  -- MULTIPLY/DIVIDE OPERATIONS
  4762.                  -- WITH TWO AND (2**34)-1
  4763.     INTEGER OPERATIONS RESULTS
  4764.     
  4765.     OP1                      =  17179869183
  4766.     OP2                      =            2
  4767.     
  4768.     OP1 * OP2                =  34359738366
  4769.     
  4770.     OP1 / OP2                =   8589934591
  4771.     
  4772.     (OP1 / OP2) * OP2        =  17179869182
  4773.     
  4774.     INTEGER OPERATIONS RESULTS
  4775.     
  4776.     OP1                      = -17179869183
  4777.     OP2                      =           -2
  4778.     
  4779.     OP1 * OP2                =  34359738366
  4780.     
  4781.     OP1 / OP2                =   8589934591
  4782.     
  4783.     (OP1 / OP2) * OP2        = -17179869182
  4784. <FF>
  4785.     
  4786.                  -- REMAINDER/MODULO OPERATIONS
  4787.                  -- WITH 10 .. 14 AND 5
  4788.     INTEGER OPERATIONS RESULTS
  4789.     
  4790.     OP1                      =           10
  4791.     OP2                      =            5
  4792.     
  4793.     OP1 rem OP2              =            0
  4794.     
  4795.     OP1 mod OP2              =            0
  4796.     
  4797.     INTEGER OPERATIONS RESULTS
  4798.     
  4799.     OP1                      =           11
  4800.     OP2                      =            5
  4801.     
  4802.     OP1 rem OP2              =            1
  4803.     
  4804.     OP1 mod OP2              =            1
  4805.     
  4806.     INTEGER OPERATIONS RESULTS
  4807.     
  4808.     OP1                      =           12
  4809.     OP2                      =            5
  4810.     
  4811.     OP1 rem OP2              =            2
  4812.     
  4813.     OP1 mod OP2              =            2
  4814.     
  4815.     INTEGER OPERATIONS RESULTS
  4816.     
  4817.     OP1                      =           13
  4818.     OP2                      =            5
  4819.     
  4820.     OP1 rem OP2              =            3
  4821.     
  4822.     OP1 mod OP2              =            3
  4823.     
  4824.     INTEGER OPERATIONS RESULTS
  4825.     
  4826.     OP1                      =           14
  4827.     OP2                      =            5
  4828.     
  4829.     OP1 rem OP2              =            4
  4830.     
  4831.     OP1 mod OP2              =            4
  4832. <FF>
  4833.     
  4834.                  -- REMAINDER/MODULO OPERATIONS
  4835.                  -- WITH -10 .. -14 AND 5
  4836.     INTEGER OPERATIONS RESULTS
  4837.     
  4838.     OP1                      =          -10
  4839.     OP2                      =            5
  4840.     
  4841.     OP1 rem OP2              =            0
  4842.     
  4843.     OP1 mod OP2              =            0
  4844.     
  4845.     INTEGER OPERATIONS RESULTS
  4846.     
  4847.     OP1                      =          -11
  4848.     OP2                      =            5
  4849.     
  4850.     OP1 rem OP2              =           -1
  4851.     
  4852.     OP1 mod OP2              =            4
  4853.     
  4854.     INTEGER OPERATIONS RESULTS
  4855.     
  4856.     OP1                      =          -12
  4857.     OP2                      =            5
  4858.     
  4859.     OP1 rem OP2              =           -2
  4860.     
  4861.     OP1 mod OP2              =            3
  4862.     
  4863.     INTEGER OPERATIONS RESULTS
  4864.     
  4865.     OP1                      =          -13
  4866.     OP2                      =            5
  4867.     
  4868.     OP1 rem OP2              =           -3
  4869.     
  4870.     OP1 mod OP2              =            2
  4871.     
  4872.     INTEGER OPERATIONS RESULTS
  4873.     
  4874.     OP1                      =          -14
  4875.     OP2                      =            5
  4876.     
  4877.     OP1 rem OP2              =           -4
  4878.     
  4879.     OP1 mod OP2              =            1
  4880. <FF>
  4881.     
  4882.                  -- REMAINDER/MODULO OPERATIONS
  4883.                  -- WITH 10 .. 14 AND -5
  4884.     INTEGER OPERATIONS RESULTS
  4885.     
  4886.     OP1                      =           10
  4887.     OP2                      =           -5
  4888.     
  4889.     OP1 rem OP2              =            0
  4890.     
  4891.     OP1 mod OP2              =            0
  4892.     
  4893.     INTEGER OPERATIONS RESULTS
  4894.     
  4895.     OP1                      =           11
  4896.     OP2                      =           -5
  4897.     
  4898.     OP1 rem OP2              =            1
  4899.     
  4900.     OP1 mod OP2              =           -4
  4901.     
  4902.     INTEGER OPERATIONS RESULTS
  4903.     
  4904.     OP1                      =           12
  4905.     OP2                      =           -5
  4906.     
  4907.     OP1 rem OP2              =            2
  4908.     
  4909.     OP1 mod OP2              =           -3
  4910.     
  4911.     INTEGER OPERATIONS RESULTS
  4912.     
  4913.     OP1                      =           13
  4914.     OP2                      =           -5
  4915.     
  4916.     OP1 rem OP2              =            3
  4917.     
  4918.     OP1 mod OP2              =           -2
  4919.     
  4920.     INTEGER OPERATIONS RESULTS
  4921.     
  4922.     OP1                      =           14
  4923.     OP2                      =           -5
  4924.     
  4925.     OP1 rem OP2              =            4
  4926.     
  4927.     OP1 mod OP2              =           -1
  4928. <FF>
  4929.     
  4930.                  -- REMAINDER/MODULO OPERATIONS
  4931.                  -- WITH -10 .. -14 AND -5
  4932.     INTEGER OPERATIONS RESULTS
  4933.     
  4934.     OP1                      =          -10
  4935.     OP2                      =           -5
  4936.     
  4937.     OP1 rem OP2              =            0
  4938.     
  4939.     OP1 mod OP2              =            0
  4940.     
  4941.     INTEGER OPERATIONS RESULTS
  4942.     
  4943.     OP1                      =          -11
  4944.     OP2                      =           -5
  4945.     
  4946.     OP1 rem OP2              =           -1
  4947.     
  4948.     OP1 mod OP2              =           -1
  4949.     
  4950.     INTEGER OPERATIONS RESULTS
  4951.     
  4952.     OP1                      =          -12
  4953.     OP2                      =           -5
  4954.     
  4955.     OP1 rem OP2              =           -2
  4956.     
  4957.     OP1 mod OP2              =           -2
  4958.     
  4959.     INTEGER OPERATIONS RESULTS
  4960.     
  4961.     OP1                      =          -13
  4962.     OP2                      =           -5
  4963.     
  4964.     OP1 rem OP2              =           -3
  4965.     
  4966.     OP1 mod OP2              =           -3
  4967.     
  4968.     INTEGER OPERATIONS RESULTS
  4969.     
  4970.     OP1                      =          -14
  4971.     OP2                      =           -5
  4972.     
  4973.     OP1 rem OP2              =           -4
  4974.     
  4975.     OP1 mod OP2              =           -4
  4976. <FF>
  4977.     
  4978.     
  4979.     A.2    Short Float Test Results
  4980.     
  4981.     
  4982.                  -- SAMPLE OF OPERATIONS
  4983.     SHORT_FLOAT OPERATIONS RESULTS
  4984.     
  4985.     OP1                      =  5.0000000E-01
  4986.     OP2                      =  1.0000000E+01
  4987.     
  4988.     OP1 >= OP2               = FALSE
  4989.     
  4990.     OP1 + OP2                =  1.0500000E+01
  4991.     
  4992.     OP1 - OP2                = -9.5000000E+00
  4993.     
  4994.     OP1 * OP2                =  5.0000000E+00
  4995.     
  4996.     OP1 / OP2                =  5.0000000E-02
  4997.     
  4998.     (OP1 / OP2) * OP2        =  5.0000000E-01
  4999.     
  5000.     SHORT_FLOAT OPERATIONS RESULTS
  5001.     
  5002.     OP1                      =  5.0000000E-01
  5003.     OP2                      = -1.0000000E+01
  5004.     
  5005.     OP1 >= OP2               = TRUE
  5006.     
  5007.     OP1 + OP2                = -9.5000000E+00
  5008.     
  5009.     OP1 - OP2                =  1.0500000E+01
  5010.     
  5011.     OP1 * OP2                = -5.0000000E+00
  5012.     
  5013.     OP1 / OP2                = -5.0000000E-02
  5014.     
  5015.     (OP1 / OP2) * OP2        =  5.0000000E-01
  5016. <FF>
  5017.     
  5018.     
  5019.                  -- SAMPLE OF OPERATIONS
  5020.     SHORT_FLOAT OPERATIONS RESULTS
  5021.     
  5022.     OP1                      = -5.0000000E-01
  5023.     OP2                      =  1.0000000E+01
  5024.     
  5025.     OP1 >= OP2               = FALSE
  5026.     
  5027.     OP1 + OP2                =  9.5000000E+00
  5028.     
  5029.     OP1 - OP2                = -1.0500000E+01
  5030.     
  5031.     OP1 * OP2                = -5.0000000E+00
  5032.     
  5033.     OP1 / OP2                = -5.0000000E-02
  5034.     
  5035.     (OP1 / OP2) * OP2        = -5.0000000E-01
  5036.     
  5037.     SHORT_FLOAT OPERATIONS RESULTS
  5038.     
  5039.     OP1                      = -5.0000000E-01
  5040.     OP2                      = -1.0000000E+01
  5041.     
  5042.     OP1 >= OP2               = TRUE
  5043.     
  5044.     OP1 + OP2                = -1.0500000E+01
  5045.     
  5046.     OP1 - OP2                =  9.5000000E+00
  5047.     
  5048.     OP1 * OP2                =  5.0000000E+00
  5049.     
  5050.     OP1 / OP2                =  5.0000000E-02
  5051.     
  5052.     (OP1 / OP2) * OP2        = -5.0000000E-01
  5053. <FF>
  5054.     
  5055.                  -- SAMPLE OF OPERATIONS
  5056.     SHORT_FLOAT OPERATIONS RESULTS
  5057.     
  5058.     OP1                      =  1.0000000E+00
  5059.     OP2                      =  3.0000000E+00
  5060.     
  5061.     OP1 >= OP2               = FALSE
  5062.     
  5063.     OP1 + OP2                =  4.0000000E+00
  5064.     
  5065.     OP1 - OP2                = -2.0000000E+00
  5066.     
  5067.     OP1 * OP2                =  3.0000000E+00
  5068.     
  5069.     OP1 / OP2                =  3.3333333E-01
  5070.     
  5071.     (OP1 / OP2) * OP2        =  1.0000000E+00
  5072.     
  5073.     SHORT_FLOAT OPERATIONS RESULTS
  5074.     
  5075.     OP1                      =  2.0000000E+00
  5076.     OP2                      =  3.0000000E+00
  5077.     
  5078.     OP1 >= OP2               = FALSE
  5079.     
  5080.     OP1 + OP2                =  5.0000000E+00
  5081.     
  5082.     OP1 - OP2                = -1.0000000E+00
  5083.     
  5084.     OP1 * OP2                =  6.0000000E+00
  5085.     
  5086.     OP1 / OP2                =  6.6666667E-01
  5087.     
  5088.     (OP1 / OP2) * OP2        =  2.0000000E+00
  5089. <FF>
  5090.     
  5091.     
  5092.                  -- ADD/SUBTRACT OPERATIONS
  5093.                  -- WITH ZERO
  5094.     SHORT_FLOAT OPERATIONS RESULTS
  5095.     
  5096.     OP1                      =  4.0000000E-01
  5097.     OP2                      =  0.0000000E+00
  5098.     
  5099.     OP1 + OP2                =  4.0000000E-01
  5100.     
  5101.     OP1 - OP2                =  4.0000000E-01
  5102.     
  5103.     OP2 - OP1                = -4.0000000E-01
  5104.     
  5105.     SHORT_FLOAT OPERATIONS RESULTS
  5106.     
  5107.     OP1                      = -4.0000000E-01
  5108.     OP2                      =  0.0000000E+00
  5109.     
  5110.     OP1 + OP2                = -4.0000000E-01
  5111.     
  5112.     OP1 - OP2                = -4.0000000E-01
  5113.     
  5114.     OP2 - OP1                =  4.0000000E-01
  5115.     
  5116.     SHORT_FLOAT OPERATIONS RESULTS
  5117.     
  5118.     OP1                      =  0.0000000E+00
  5119.     OP2                      =  4.0000000E-01
  5120.     
  5121.     OP1 + OP2                =  4.0000000E-01
  5122.     
  5123.     OP1 - OP2                = -4.0000000E-01
  5124.     
  5125.     OP2 - OP1                =  4.0000000E-01
  5126.     
  5127.     SHORT_FLOAT OPERATIONS RESULTS
  5128.     
  5129.     OP1                      =  0.0000000E+00
  5130.     OP2                      = -4.0000000E-01
  5131.     
  5132.     OP1 + OP2                = -4.0000000E-01
  5133.     
  5134.     OP1 - OP2                =  4.0000000E-01
  5135.     
  5136.     OP2 - OP1                = -4.0000000E-01
  5137. <FF>
  5138.     
  5139.     
  5140.                  -- MULTIPLY/DIVIDE OPERATIONS
  5141.                  -- WITH ZERO
  5142.     SHORT_FLOAT OPERATIONS RESULTS
  5143.     
  5144.     OP1                      =  4.0000000E-01
  5145.     OP2                      =  0.0000000E+00
  5146.     
  5147.     OP1 * OP2                =  0.0000000E+00
  5148.     
  5149.     OP1 / OP2                = 
  5150.     *** EXCEPTION CONDITION RAISED ***
  5151.     
  5152.     SHORT_FLOAT OPERATIONS RESULTS
  5153.     
  5154.     OP1                      = -4.0000000E-01
  5155.     OP2                      =  0.0000000E+00
  5156.     
  5157.     OP1 * OP2                =  0.0000000E+00
  5158.     
  5159.     OP1 / OP2                = 
  5160.     *** EXCEPTION CONDITION RAISED ***
  5161.     
  5162.     SHORT_FLOAT OPERATIONS RESULTS
  5163.     
  5164.     OP1                      =  0.0000000E+00
  5165.     OP2                      =  4.0000000E-01
  5166.     
  5167.     OP1 * OP2                =  0.0000000E+00
  5168.     
  5169.     OP1 / OP2                =  0.0000000E+00
  5170.     
  5171.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5172.     
  5173.     SHORT_FLOAT OPERATIONS RESULTS
  5174.     
  5175.     OP1                      =  0.0000000E+00
  5176.     OP2                      = -4.0000000E-01
  5177.     
  5178.     OP1 * OP2                =  0.0000000E+00
  5179.     
  5180.     OP1 / OP2                =  0.0000000E+00
  5181.     
  5182.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5183. <FF>
  5184.     
  5185.     
  5186.                  -- COMPARISION OPERATIONS
  5187.                  -- WITH ZERO
  5188.     SHORT_FLOAT OPERATIONS RESULTS
  5189.     
  5190.     OP1                      =  4.0000000E-01
  5191.     OP2                      =  0.0000000E+00
  5192.     
  5193.     OP1 > OP2                = TRUE
  5194.     
  5195.     OP1 >= OP2               = TRUE
  5196.     
  5197.     OP1 < OP2                = FALSE
  5198.     
  5199.     OP1 <= OP2               = FALSE
  5200.     
  5201.     SHORT_FLOAT OPERATIONS RESULTS
  5202.     
  5203.     OP1                      = -4.0000000E-01
  5204.     OP2                      =  0.0000000E+00
  5205.     
  5206.     OP1 > OP2                = FALSE
  5207.     
  5208.     OP1 >= OP2               = FALSE
  5209.     
  5210.     OP1 < OP2                = TRUE
  5211.     
  5212.     OP1 <= OP2               = TRUE
  5213.     
  5214.     SHORT_FLOAT OPERATIONS RESULTS
  5215.     
  5216.     OP1                      =  0.0000000E+00
  5217.     OP2                      =  4.0000000E-01
  5218.     
  5219.     OP1 > OP2                = FALSE
  5220.     
  5221.     OP1 >= OP2               = FALSE
  5222.     
  5223.     OP1 < OP2                = TRUE
  5224.     
  5225.     OP1 <= OP2               = TRUE
  5226.     
  5227.     SHORT_FLOAT OPERATIONS RESULTS
  5228.     
  5229.     OP1                      =  0.0000000E+00
  5230.     OP2                      = -4.0000000E-01
  5231.     
  5232.     OP1 > OP2                = TRUE
  5233.     
  5234.     OP1 >= OP2               = TRUE
  5235.     
  5236.     OP1 < OP2                = FALSE
  5237.     
  5238.     OP1 <= OP2               = FALSE
  5239. <FF>
  5240.     
  5241.     
  5242.                  -- EXPONENTIATION OPERATIONS
  5243.                  -- WITH ZERO
  5244.     SHORT_FLOAT OPERATIONS RESULTS
  5245.     
  5246.     OP1                      =  4.0000000E-01
  5247.     POWER                    =      0
  5248.     
  5249.     OP1 ** POWER             =  1.0000000E+00
  5250.     
  5251.     OP1 ** -POWER            =  1.0000000E+00
  5252.     
  5253.     RESULT1 * RESULT2        =  1.0000000E+00
  5254.     
  5255.     SHORT_FLOAT OPERATIONS RESULTS
  5256.     
  5257.     OP1                      = -4.0000000E-01
  5258.     POWER                    =      0
  5259.     
  5260.     OP1 ** POWER             =  1.0000000E+00
  5261.     
  5262.     OP1 ** -POWER            =  1.0000000E+00
  5263.     
  5264.     RESULT1 * RESULT2        =  1.0000000E+00
  5265.     
  5266.     SHORT_FLOAT OPERATIONS RESULTS
  5267.     
  5268.     OP1                      =  0.0000000E+00
  5269.     POWER                    =      4
  5270.     
  5271.     OP1 ** POWER             =  0.0000000E+00
  5272.     
  5273.     OP1 ** -POWER            = 
  5274.     *** EXCEPTION CONDITION RAISED ***
  5275. <FF>
  5276.     
  5277.     
  5278.                  -- EXPONENTIATION OPERATIONS
  5279.                  -- WITH ZERO AND ONE
  5280.     SHORT_FLOAT OPERATIONS RESULTS
  5281.     
  5282.     OP1                      =  0.0000000E+00
  5283.     POWER                    =      0
  5284.     
  5285.     OP1 ** POWER             =  1.0000000E+00
  5286.     
  5287.     OP1 ** -POWER            =  1.0000000E+00
  5288.     
  5289.     RESULT1 * RESULT2        =  1.0000000E+00
  5290.     
  5291.     SHORT_FLOAT OPERATIONS RESULTS
  5292.     
  5293.     OP1                      =  1.0000000E+00
  5294.     POWER                    =      0
  5295.     
  5296.     OP1 ** POWER             =  1.0000000E+00
  5297.     
  5298.     OP1 ** -POWER            =  1.0000000E+00
  5299.     
  5300.     RESULT1 * RESULT2        =  1.0000000E+00
  5301.     
  5302.     SHORT_FLOAT OPERATIONS RESULTS
  5303.     
  5304.     OP1                      = -1.0000000E+00
  5305.     POWER                    =      0
  5306.     
  5307.     OP1 ** POWER             =  1.0000000E+00
  5308.     
  5309.     OP1 ** -POWER            =  1.0000000E+00
  5310.     
  5311.     RESULT1 * RESULT2        =  1.0000000E+00
  5312.     
  5313.     SHORT_FLOAT OPERATIONS RESULTS
  5314.     
  5315.     OP1                      = -1.0000000E+00
  5316.     POWER                    =     -1
  5317.     
  5318.     OP1 ** POWER             = -1.0000000E+00
  5319.     
  5320.     OP1 ** -POWER            = -1.0000000E+00
  5321.     
  5322.     RESULT1 * RESULT2        =  1.0000000E+00
  5323.     
  5324.     SHORT_FLOAT OPERATIONS RESULTS
  5325.     
  5326.     OP1                      =  0.0000000E+00
  5327.     POWER                    =      1
  5328.     
  5329.     OP1 ** POWER             =  0.0000000E+00
  5330.     
  5331.     OP1 ** -POWER            = 
  5332.     *** EXCEPTION CONDITION RAISED ***
  5333. <FF>
  5334.     
  5335.     
  5336.                  -- SAMPLE OPERATIONS
  5337.                  -- WITH ZERO AND NEAR (2**127)
  5338.     SHORT_FLOAT OPERATIONS RESULTS
  5339.     
  5340.     OP1                      =  1.7014118E+38
  5341.     OP2                      =  0.0000000E+00
  5342.     
  5343.     OP1 >= OP2               = TRUE
  5344.     
  5345.     OP1 + OP2                =  1.7014118E+38
  5346.     
  5347.     OP1 - OP2                =  1.7014118E+38
  5348.     
  5349.     OP1 * OP2                =  0.0000000E+00
  5350.     
  5351.     OP1 / OP2                = 
  5352.     *** EXCEPTION CONDITION RAISED ***
  5353.     
  5354.     SHORT_FLOAT OPERATIONS RESULTS
  5355.     
  5356.     OP1                      =  0.0000000E+00
  5357.     OP2                      =  1.7014118E+38
  5358.     
  5359.     OP1 >= OP2               = FALSE
  5360.     
  5361.     OP1 + OP2                =  1.7014118E+38
  5362.     
  5363.     OP1 - OP2                = -1.7014118E+38
  5364.     
  5365.     OP1 * OP2                =  0.0000000E+00
  5366.     
  5367.     OP1 / OP2                =  0.0000000E+00
  5368.     
  5369.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5370. <FF>
  5371.     
  5372.     
  5373.                  -- SAMPLE OPERATIONS
  5374.                  -- WITH ZERO AND NEAR -(2**127)
  5375.     SHORT_FLOAT OPERATIONS RESULTS
  5376.     
  5377.     OP1                      = -1.7014118E+38
  5378.     OP2                      =  0.0000000E+00
  5379.     
  5380.     OP1 >= OP2               = FALSE
  5381.     
  5382.     OP1 + OP2                = -1.7014118E+38
  5383.     
  5384.     OP1 - OP2                = -1.7014118E+38
  5385.     
  5386.     OP1 * OP2                =  0.0000000E+00
  5387.     
  5388.     OP1 / OP2                = 
  5389.     *** EXCEPTION CONDITION RAISED ***
  5390.     
  5391.     SHORT_FLOAT OPERATIONS RESULTS
  5392.     
  5393.     OP1                      =  0.0000000E+00
  5394.     OP2                      = -1.7014118E+38
  5395.     
  5396.     OP1 >= OP2               = TRUE
  5397.     
  5398.     OP1 + OP2                = -1.7014118E+38
  5399.     
  5400.     OP1 - OP2                =  1.7014118E+38
  5401.     
  5402.     OP1 * OP2                =  0.0000000E+00
  5403.     
  5404.     OP1 / OP2                =  0.0000000E+00
  5405.     
  5406.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5407. <FF>
  5408.     
  5409.     
  5410.                  -- ADD/SUBTRACT OPERATIONS
  5411.                  -- WITH NEAR (2**127)
  5412.     SHORT_FLOAT OPERATIONS RESULTS
  5413.     
  5414.     OP1                      =  1.7014118E+38
  5415.     OP2                      =  1.0000000E+31
  5416.     
  5417.     OP1 + OP2                = 
  5418.     *** EXCEPTION CONDITION RAISED ***
  5419.     
  5420.     SHORT_FLOAT OPERATIONS RESULTS
  5421.     
  5422.     OP1                      =  1.7014118E+38
  5423.     OP2                      = -1.0000000E+31
  5424.     
  5425.     OP1 + OP2                =  1.7014117E+38
  5426.     
  5427.     OP1 - OP2                = 
  5428.     *** EXCEPTION CONDITION RAISED ***
  5429.     
  5430.     SHORT_FLOAT OPERATIONS RESULTS
  5431.     
  5432.     OP1                      = -1.7014118E+38
  5433.     OP2                      =  1.0000000E+31
  5434.     
  5435.     OP1 + OP2                = -1.7014117E+38
  5436.     
  5437.     OP1 - OP2                = 
  5438.     *** EXCEPTION CONDITION RAISED ***
  5439.     
  5440.     SHORT_FLOAT OPERATIONS RESULTS
  5441.     
  5442.     OP1                      = -1.7014118E+38
  5443.     OP2                      = -1.0000000E+31
  5444.     
  5445.     OP1 + OP2                = 
  5446.     *** EXCEPTION CONDITION RAISED ***
  5447. <FF>
  5448.     
  5449.     
  5450.                  -- MULTIPLY/DIVIDE OPERATIONS
  5451.                  -- WITH TWO AND NEAR (2**126)
  5452.     SHORT_FLOAT OPERATIONS RESULTS
  5453.     
  5454.     OP1                      =  8.5070592E+37
  5455.     OP2                      =  2.0000000E+00
  5456.     
  5457.     OP1 * OP2                = 
  5458.     *** EXCEPTION CONDITION RAISED ***
  5459.     
  5460.     SHORT_FLOAT OPERATIONS RESULTS
  5461.     
  5462.     OP1                      =  8.5070591E+37
  5463.     OP2                      =  2.0000000E+00
  5464.     
  5465.     OP1 * OP2                =  1.7014118E+38
  5466.     
  5467.     OP1 / OP2                =  4.2535296E+37
  5468.     
  5469.     (OP1 / OP2) * OP2        =  8.5070591E+37
  5470. <FF>
  5471.     
  5472.     
  5473.                  -- MULTIPLY/DIVIDE OPERATIONS
  5474.                  -- WITH TWO AND NEAR -(2**126)
  5475.     SHORT_FLOAT OPERATIONS RESULTS
  5476.     
  5477.     OP1                      = -8.5070592E+37
  5478.     OP2                      =  2.0000000E+00
  5479.     
  5480.     OP1 * OP2                = 
  5481.     *** EXCEPTION CONDITION RAISED ***
  5482.     
  5483.     SHORT_FLOAT OPERATIONS RESULTS
  5484.     
  5485.     OP1                      = -8.5070591E+37
  5486.     OP2                      =  2.0000000E+00
  5487.     
  5488.     OP1 * OP2                = -1.7014118E+38
  5489.     
  5490.     OP1 / OP2                = -4.2535296E+37
  5491.     
  5492.     (OP1 / OP2) * OP2        = -8.5070591E+37
  5493. <FF>
  5494.     
  5495.     
  5496.                  -- ADD/SUBTRACT OPERATIONS
  5497.                  -- WITH ZERO AND NEAR (2**-129)
  5498.     SHORT_FLOAT OPERATIONS RESULTS
  5499.     
  5500.     OP1                      =  1.4693680E-39
  5501.     OP2                      =  0.0000000E+00
  5502.     
  5503.     OP1 + OP2                =  1.4693680E-39
  5504.     
  5505.     OP1 - OP2                =  1.4693680E-39
  5506.     
  5507.     OP2 - OP1                = -1.4693680E-39
  5508.     
  5509.     SHORT_FLOAT OPERATIONS RESULTS
  5510.     
  5511.     OP1                      = -1.4693680E-39
  5512.     OP2                      =  0.0000000E+00
  5513.     
  5514.     OP1 + OP2                = -1.4693680E-39
  5515.     
  5516.     OP1 - OP2                = -1.4693680E-39
  5517.     
  5518.     OP2 - OP1                =  1.4693680E-39
  5519. <FF>
  5520.     
  5521.     
  5522.                  -- ADD/SUBTRACT OPERATIONS
  5523.                  -- WITH (2**-128) AND NEAR (2**-129)
  5524.     SHORT_FLOAT OPERATIONS RESULTS
  5525.     
  5526.     OP1                      =  2.9387359E-39
  5527.     OP2                      =  1.4693680E-39
  5528.     
  5529.     OP1 + OP2                =  4.4081039E-39
  5530.     
  5531.     OP1 - OP2                =  0.0000000E+00
  5532.     
  5533.     OP2 - OP1                =  0.0000000E+00
  5534.     
  5535.     SHORT_FLOAT OPERATIONS RESULTS
  5536.     
  5537.     OP1                      =  2.9387359E-39
  5538.     OP2                      = -1.4693680E-39
  5539.     
  5540.     OP1 + OP2                =  0.0000000E+00
  5541.     
  5542.     OP1 - OP2                =  4.4081039E-39
  5543.     
  5544.     OP2 - OP1                = -4.4081039E-39
  5545.     
  5546.     SHORT_FLOAT OPERATIONS RESULTS
  5547.     
  5548.     OP1                      = -2.9387359E-39
  5549.     OP2                      =  1.4693680E-39
  5550.     
  5551.     OP1 + OP2                =  0.0000000E+00
  5552.     
  5553.     OP1 - OP2                = -4.4081039E-39
  5554.     
  5555.     OP2 - OP1                =  4.4081039E-39
  5556.     
  5557.     SHORT_FLOAT OPERATIONS RESULTS
  5558.     
  5559.     OP1                      = -2.9387359E-39
  5560.     OP2                      = -1.4693680E-39
  5561.     
  5562.     OP1 + OP2                = -4.4081039E-39
  5563.     
  5564.     OP1 - OP2                =  0.0000000E+00
  5565.     
  5566.     OP2 - OP1                =  0.0000000E+00
  5567. <FF>
  5568.     
  5569.     
  5570.                  -- MULTIPLY/DIVIDE OPERATIONS
  5571.                  -- WITH TWO AND NEAR (2**-128)
  5572.     SHORT_FLOAT OPERATIONS RESULTS
  5573.     
  5574.     OP1                      =  2.9387358E-39
  5575.     OP2                      =  2.0000000E+00
  5576.     
  5577.     OP1 * OP2                =  5.8774716E-39
  5578.     
  5579.     OP1 / OP2                =  0.0000000E+00
  5580.     
  5581.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5582.     
  5583.     SHORT_FLOAT OPERATIONS RESULTS
  5584.     
  5585.     OP1                      = -2.9387358E-39
  5586.     OP2                      =  2.0000000E+00
  5587.     
  5588.     OP1 * OP2                = -5.8774716E-39
  5589.     
  5590.     OP1 / OP2                =  0.0000000E+00
  5591.     
  5592.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5593.     
  5594.     SHORT_FLOAT OPERATIONS RESULTS
  5595.     
  5596.     OP1                      =  2.9387358E-39
  5597.     OP2                      = -2.0000000E+00
  5598.     
  5599.     OP1 * OP2                = -5.8774716E-39
  5600.     
  5601.     OP1 / OP2                =  0.0000000E+00
  5602.     
  5603.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5604.     
  5605.     SHORT_FLOAT OPERATIONS RESULTS
  5606.     
  5607.     OP1                      = -2.9387358E-39
  5608.     OP2                      = -2.0000000E+00
  5609.     
  5610.     OP1 * OP2                =  5.8774716E-39
  5611.     
  5612.     OP1 / OP2                =  0.0000000E+00
  5613.     
  5614.     (OP1 / OP2) * OP2        =  0.0000000E+00
  5615. <FF>
  5616.     
  5617.     
  5618.     A.3   Long Float Test Results
  5619.     
  5620.     
  5621.                  -- SAMPLE OF OPERATIONS
  5622.     LONG_FLOAT OPERATIONS RESULTS
  5623.     
  5624.     OP1                      =  5.00000000000000000E-01
  5625.     OP2                      =  1.00000000000000000E+01
  5626.     
  5627.     OP1 >= OP2               = FALSE
  5628.     
  5629.     OP1 + OP2                =  1.05000000000000284E+01
  5630.     
  5631.     OP1 - OP2                = -9.50000000000000000E+00
  5632.     
  5633.     OP1 * OP2                =  5.00000000000000000E+00
  5634.     
  5635.     OP1 / OP2                =  5.00000000000000000E-02
  5636.     
  5637.     (OP1 / OP2) * OP2        =  5.00000000000000000E-01
  5638.     
  5639.     LONG_FLOAT OPERATIONS RESULTS
  5640.     
  5641.     OP1                      =  5.00000000000000000E-01
  5642.     OP2                      = -1.00000000000000000E+01
  5643.     
  5644.     OP1 >= OP2               = TRUE
  5645.     
  5646.     OP1 + OP2                = -9.50000000000000000E+00
  5647.     
  5648.     OP1 - OP2                =  1.05000000000000284E+01
  5649.     
  5650.     OP1 * OP2                = -5.00000000000000000E+00
  5651.     
  5652.     OP1 / OP2                = -5.00000000000000000E-02
  5653.     
  5654.     (OP1 / OP2) * OP2        =  5.00000000000000000E-01
  5655. <FF>
  5656.     
  5657.     
  5658.                  -- SAMPLE OF OPERATIONS
  5659.     LONG_FLOAT OPERATIONS RESULTS
  5660.     
  5661.     OP1                      = -5.00000000000000000E-01
  5662.     OP2                      =  1.00000000000000000E+01
  5663.     
  5664.     OP1 >= OP2               = FALSE
  5665.     
  5666.     OP1 + OP2                =  9.50000000000000000E+00
  5667.     
  5668.     OP1 - OP2                = -1.05000000000000284E+01
  5669.     
  5670.     OP1 * OP2                = -5.00000000000000000E+00
  5671.     
  5672.     OP1 / OP2                = -5.00000000000000000E-02
  5673.     
  5674.     (OP1 / OP2) * OP2        = -5.00000000000000000E-01
  5675.     
  5676.     LONG_FLOAT OPERATIONS RESULTS
  5677.     
  5678.     OP1                      = -5.00000000000000000E-01
  5679.     OP2                      = -1.00000000000000000E+01
  5680.     
  5681.     OP1 >= OP2               = TRUE
  5682.     
  5683.     OP1 + OP2                = -1.05000000000000284E+01
  5684.     
  5685.     OP1 - OP2                =  9.50000000000000000E+00
  5686.     
  5687.     OP1 * OP2                =  5.00000000000000000E+00
  5688.     
  5689.     OP1 / OP2                =  5.00000000000000000E-02
  5690.     
  5691.     (OP1 / OP2) * OP2        = -5.00000000000000000E-01
  5692. <FF>
  5693.     
  5694.     
  5695.                  -- SAMPLE OF OPERATIONS
  5696.     LONG_FLOAT OPERATIONS RESULTS
  5697.     
  5698.     OP1                      =  1.00000000000000000E+00
  5699.     OP2                      =  3.00000000000000000E+00
  5700.     
  5701.     OP1 >= OP2               = FALSE
  5702.     
  5703.     OP1 + OP2                =  4.00000000000000000E+00
  5704.     
  5705.     OP1 - OP2                = -2.00000000000000000E+00
  5706.     
  5707.     OP1 * OP2                =  3.00000000000000000E+00
  5708.     
  5709.     OP1 / OP2                =  3.33333333333333333E-01
  5710.     
  5711.     (OP1 / OP2) * OP2        =  1.00000000000000000E+00
  5712.     
  5713.     LONG_FLOAT OPERATIONS RESULTS
  5714.     
  5715.     OP1                      =  2.00000000000000000E+00
  5716.     OP2                      =  3.00000000000000000E+00
  5717.     
  5718.     OP1 >= OP2               = FALSE
  5719.     
  5720.     OP1 + OP2                =  5.00000000000000000E+00
  5721.     
  5722.     OP1 - OP2                = -1.00000000000000000E+00
  5723.     
  5724.     OP1 * OP2                =  6.00000000000000000E+00
  5725.     
  5726.     OP1 / OP2                =  6.66666666666666667E-01
  5727.     
  5728.     (OP1 / OP2) * OP2        =  2.00000000000000000E+00
  5729. <FF>
  5730.     
  5731.     
  5732.                  -- ADD/SUBTRACT OPERATIONS
  5733.                  -- WITH ZERO
  5734.     LONG_FLOAT OPERATIONS RESULTS
  5735.     
  5736.     OP1                      =  4.00000000000000000E-01
  5737.     OP2                      =  0.00000000000000000E+00
  5738.     
  5739.     OP1 + OP2                =  4.00000000000000000E-01
  5740.     
  5741.     OP1 - OP2                =  4.00000000000000000E-01
  5742.     
  5743.     OP2 - OP1                = -4.00000000000000000E-01
  5744.     
  5745.     LONG_FLOAT OPERATIONS RESULTS
  5746.     
  5747.     OP1                      = -4.00000000000000000E-01
  5748.     OP2                      =  0.00000000000000000E+00
  5749.     
  5750.     OP1 + OP2                = -4.00000000000000000E-01
  5751.     
  5752.     OP1 - OP2                = -4.00000000000000000E-01
  5753.     
  5754.     OP2 - OP1                =  4.00000000000000000E-01
  5755.     
  5756.     LONG_FLOAT OPERATIONS RESULTS
  5757.     
  5758.     OP1                      =  0.00000000000000000E+00
  5759.     OP2                      =  4.00000000000000000E-01
  5760.     
  5761.     OP1 + OP2                =  4.00000000000000000E-01
  5762.     
  5763.     OP1 - OP2                = -4.00000000000000000E-01
  5764.     
  5765.     OP2 - OP1                =  4.00000000000000000E-01
  5766.     
  5767.     LONG_FLOAT OPERATIONS RESULTS
  5768.     
  5769.     OP1                      =  0.00000000000000000E+00
  5770.     OP2                      = -4.00000000000000000E-01
  5771.     
  5772.     OP1 + OP2                = -4.00000000000000000E-01
  5773.     
  5774.     OP1 - OP2                =  4.00000000000000000E-01
  5775.     
  5776.     OP2 - OP1                = -4.00000000000000000E-01
  5777. <FF>
  5778.     
  5779.     
  5780.                  -- MULTIPLY/DIVIDE OPERATIONS
  5781.                  -- WITH ZERO
  5782.     LONG_FLOAT OPERATIONS RESULTS
  5783.     
  5784.     OP1                      =  4.00000000000000000E-01
  5785.     OP2                      =  0.00000000000000000E+00
  5786.     
  5787.     OP1 * OP2                =  0.00000000000000000E+00
  5788.     
  5789.     OP1 / OP2                = 
  5790.     *** EXCEPTION CONDITION RAISED ***
  5791.     
  5792.     LONG_FLOAT OPERATIONS RESULTS
  5793.     
  5794.     OP1                      = -4.00000000000000000E-01
  5795.     OP2                      =  0.00000000000000000E+00
  5796.     
  5797.     OP1 * OP2                =  0.00000000000000000E+00
  5798.     
  5799.     OP1 / OP2                = 
  5800.     *** EXCEPTION CONDITION RAISED ***
  5801.     
  5802.     LONG_FLOAT OPERATIONS RESULTS
  5803.     
  5804.     OP1                      =  0.00000000000000000E+00
  5805.     OP2                      =  4.00000000000000000E-01
  5806.     
  5807.     OP1 * OP2                =  0.00000000000000000E+00
  5808.     
  5809.     OP1 / OP2                =  0.00000000000000000E+00
  5810.     
  5811.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  5812.     
  5813.     LONG_FLOAT OPERATIONS RESULTS
  5814.     
  5815.     OP1                      =  0.00000000000000000E+00
  5816.     OP2                      = -4.00000000000000000E-01
  5817.     
  5818.     OP1 * OP2                =  0.00000000000000000E+00
  5819.     
  5820.     OP1 / OP2                =  0.00000000000000000E+00
  5821.     
  5822.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  5823. <FF>
  5824.     
  5825.     
  5826.                  -- COMPARISION OPERATIONS
  5827.                  -- WITH ZERO
  5828.     LONG_FLOAT OPERATIONS RESULTS
  5829.     
  5830.     OP1                      =  4.00000000000000000E-01
  5831.     OP2                      =  0.00000000000000000E+00
  5832.     
  5833.     OP1 > OP2                = TRUE
  5834.     
  5835.     OP1 >= OP2               = TRUE
  5836.     
  5837.     OP1 < OP2                = FALSE
  5838.     
  5839.     OP1 <= OP2               = FALSE
  5840.     
  5841.     LONG_FLOAT OPERATIONS RESULTS
  5842.     
  5843.     OP1                      = -4.00000000000000000E-01
  5844.     OP2                      =  0.00000000000000000E+00
  5845.     
  5846.     OP1 > OP2                = FALSE
  5847.     
  5848.     OP1 >= OP2               = FALSE
  5849.     
  5850.     OP1 < OP2                = TRUE
  5851.     
  5852.     OP1 <= OP2               = TRUE
  5853.     
  5854.     LONG_FLOAT OPERATIONS RESULTS
  5855.     
  5856.     OP1                      =  0.00000000000000000E+00
  5857.     OP2                      =  4.00000000000000000E-01
  5858.     
  5859.     OP1 > OP2                = FALSE
  5860.     
  5861.     OP1 >= OP2               = FALSE
  5862.     
  5863.     OP1 < OP2                = TRUE
  5864.     
  5865.     OP1 <= OP2               = TRUE
  5866.     
  5867.     LONG_FLOAT OPERATIONS RESULTS
  5868.     
  5869.     OP1                      =  0.00000000000000000E+00
  5870.     OP2                      = -4.00000000000000000E-01
  5871.     
  5872.     OP1 > OP2                = TRUE
  5873.     
  5874.     OP1 >= OP2               = TRUE
  5875.     
  5876.     OP1 < OP2                = FALSE
  5877.     
  5878.     OP1 <= OP2               = FALSE
  5879. <FF>
  5880.     
  5881.     
  5882.                  -- EXPONENTIATION OPERATIONS
  5883.                  -- WITH ZERO
  5884.     LONG_FLOAT OPERATIONS RESULTS
  5885.     
  5886.     OP1                      =  4.00000000000000000E-01
  5887.     POWER                    =      0
  5888.     
  5889.     OP1 ** POWER             =  1.00000000000000000E+00
  5890.     
  5891.     OP1 ** -POWER            =  1.00000000000000000E+00
  5892.     
  5893.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5894.     
  5895.     LONG_FLOAT OPERATIONS RESULTS
  5896.     
  5897.     OP1                      = -4.00000000000000000E-01
  5898.     POWER                    =      0
  5899.     
  5900.     OP1 ** POWER             =  1.00000000000000000E+00
  5901.     
  5902.     OP1 ** -POWER            =  1.00000000000000000E+00
  5903.     
  5904.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5905.     
  5906.     LONG_FLOAT OPERATIONS RESULTS
  5907.     
  5908.     OP1                      =  0.00000000000000000E+00
  5909.     POWER                    =      4
  5910.     
  5911.     OP1 ** POWER             =  0.00000000000000000E+00
  5912.     
  5913.     OP1 ** -POWER            = 
  5914.     *** EXCEPTION CONDITION RAISED ***
  5915. <FF>
  5916.     
  5917.     
  5918.                  -- EXPONENTIATION OPERATIONS
  5919.                  -- WITH ZERO AND ONE
  5920.     LONG_FLOAT OPERATIONS RESULTS
  5921.     
  5922.     OP1                      =  0.00000000000000000E+00
  5923.     POWER                    =      0
  5924.     
  5925.     OP1 ** POWER             =  1.00000000000000000E+00
  5926.     
  5927.     OP1 ** -POWER            =  1.00000000000000000E+00
  5928.     
  5929.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5930.     
  5931.     LONG_FLOAT OPERATIONS RESULTS
  5932.     
  5933.     OP1                      =  1.00000000000000000E+00
  5934.     POWER                    =      0
  5935.     
  5936.     OP1 ** POWER             =  1.00000000000000000E+00
  5937.     
  5938.     OP1 ** -POWER            =  1.00000000000000000E+00
  5939.     
  5940.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5941.     
  5942.     LONG_FLOAT OPERATIONS RESULTS
  5943.     
  5944.     OP1                      = -1.00000000000000000E+00
  5945.     POWER                    =      0
  5946.     
  5947.     OP1 ** POWER             =  1.00000000000000000E+00
  5948.     
  5949.     OP1 ** -POWER            =  1.00000000000000000E+00
  5950.     
  5951.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5952.     
  5953.     LONG_FLOAT OPERATIONS RESULTS
  5954.     
  5955.     OP1                      = -1.00000000000000000E+00
  5956.     POWER                    =     -1
  5957.     
  5958.     OP1 ** POWER             = -1.00000000000000000E+00
  5959.     
  5960.     OP1 ** -POWER            = -1.00000000000000000E+00
  5961.     
  5962.     RESULT1 * RESULT2        =  1.00000000000000000E+00
  5963.     
  5964.     LONG_FLOAT OPERATIONS RESULTS
  5965.     
  5966.     OP1                      =  0.00000000000000000E+00
  5967.     POWER                    =      1
  5968.     
  5969.     OP1 ** POWER             =  0.00000000000000000E+00
  5970.     
  5971.     OP1 ** -POWER            = 
  5972.     *** EXCEPTION CONDITION RAISED ***
  5973. <FF>
  5974.     
  5975.     
  5976.                  -- SAMPLE OPERATIONS
  5977.                  -- WITH ZERO AND NEAR (2**127)
  5978.     LONG_FLOAT OPERATIONS RESULTS
  5979.     
  5980.     OP1                      =  1.70141183460000000E+38
  5981.     OP2                      =  0.00000000000000000E+00
  5982.     
  5983.     OP1 >= OP2               = TRUE
  5984.     
  5985.     OP1 + OP2                =  1.70141183460000000E+38
  5986.     
  5987.     OP1 - OP2                =  1.70141183460000000E+38
  5988.     
  5989.     OP1 * OP2                =  0.00000000000000000E+00
  5990.     
  5991.     OP1 / OP2                = 
  5992.     *** EXCEPTION CONDITION RAISED ***
  5993.     
  5994.     LONG_FLOAT OPERATIONS RESULTS
  5995.     
  5996.     OP1                      =  0.00000000000000000E+00
  5997.     OP2                      =  1.70141183460000000E+38
  5998.     
  5999.     OP1 >= OP2               = FALSE
  6000.     
  6001.     OP1 + OP2                =  1.70141183460000000E+38
  6002.     
  6003.     OP1 - OP2                = -1.70141183460000000E+38
  6004.     
  6005.     OP1 * OP2                =  0.00000000000000000E+00
  6006.     
  6007.     OP1 / OP2                =  0.00000000000000000E+00
  6008.     
  6009.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  6010. <FF>
  6011.     
  6012.                  -- SAMPLE OPERATIONS
  6013.                  -- WITH ZERO AND NEAR -(2**127)
  6014.     LONG_FLOAT OPERATIONS RESULTS
  6015.     
  6016.     OP1                      = -1.70141183460000000E+38
  6017.     OP2                      =  0.00000000000000000E+00
  6018.     
  6019.     OP1 >= OP2               = FALSE
  6020.     
  6021.     OP1 + OP2                = -1.70141183460000000E+38
  6022.     
  6023.     OP1 - OP2                = -1.70141183460000000E+38
  6024.     
  6025.     OP1 * OP2                =  0.00000000000000000E+00
  6026.     
  6027.     OP1 / OP2                = 
  6028.     *** EXCEPTION CONDITION RAISED ***
  6029.     
  6030.     LONG_FLOAT OPERATIONS RESULTS
  6031.     
  6032.     OP1                      =  0.00000000000000000E+00
  6033.     OP2                      = -1.70141183460000000E+38
  6034.     
  6035.     OP1 >= OP2               = TRUE
  6036.     
  6037.     OP1 + OP2                = -1.70141183460000000E+38
  6038.     
  6039.     OP1 - OP2                =  1.70141183460000000E+38
  6040.     
  6041.     OP1 * OP2                =  0.00000000000000000E+00
  6042.     
  6043.     OP1 / OP2                =  0.00000000000000000E+00
  6044.     
  6045.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  6046. <FF>
  6047.     
  6048.                  -- ADD/SUBTRACT OPERATIONS
  6049.                  -- WITH NEAR (2**127)
  6050.     LONG_FLOAT OPERATIONS RESULTS
  6051.     
  6052.     OP1                      =  1.70141183460000000E+38
  6053.     OP2                      =  1.00000000000000000E+28
  6054.     
  6055.     OP1 + OP2                = 
  6056.     *** EXCEPTION CONDITION RAISED ***
  6057.     
  6058.     LONG_FLOAT OPERATIONS RESULTS
  6059.     
  6060.     OP1                      =  1.70141183460000000E+38
  6061.     OP2                      = -1.00000000000000000E+28
  6062.     
  6063.     OP1 + OP2                =  1.70141183450000000E+38
  6064.     
  6065.     OP1 - OP2                = 
  6066.     *** EXCEPTION CONDITION RAISED ***
  6067.     
  6068.     LONG_FLOAT OPERATIONS RESULTS
  6069.     
  6070.     OP1                      = -1.70141183460000000E+38
  6071.     OP2                      =  1.00000000000000000E+28
  6072.     
  6073.     OP1 + OP2                = -1.70141183450000000E+38
  6074.     
  6075.     OP1 - OP2                = 
  6076.     *** EXCEPTION CONDITION RAISED ***
  6077.     
  6078.     LONG_FLOAT OPERATIONS RESULTS
  6079.     
  6080.     OP1                      = -1.70141183460000000E+38
  6081.     OP2                      = -1.00000000000000000E+28
  6082.     
  6083.     OP1 + OP2                = 
  6084.     *** EXCEPTION CONDITION RAISED ***
  6085. <FF>
  6086.     
  6087.                  -- MULTIPLY/DIVIDE OPERATIONS
  6088.                  -- WITH TWO AND NEAR (2**126)
  6089.     LONG_FLOAT OPERATIONS RESULTS
  6090.     
  6091.     OP1                      =  8.50705917400000000E+37
  6092.     OP2                      =  2.00000000000000000E+00
  6093.     
  6094.     OP1 * OP2                = 
  6095.     *** EXCEPTION CONDITION RAISED ***
  6096.     
  6097.     LONG_FLOAT OPERATIONS RESULTS
  6098.     
  6099.     OP1                      =  8.50705917300000000E+37
  6100.     OP2                      =  2.00000000000000000E+00
  6101.     
  6102.     OP1 * OP2                =  1.70141183460000000E+38
  6103.     
  6104.     OP1 / OP2                =  4.25352958650000000E+37
  6105.     
  6106.     (OP1 / OP2) * OP2        =  8.50705917300000000E+37
  6107. <FF>
  6108.     
  6109.                  -- MULTIPLY/DIVIDE OPERATIONS
  6110.                  -- WITH TWO AND NEAR -(2**126)
  6111.     LONG_FLOAT OPERATIONS RESULTS
  6112.     
  6113.     OP1                      = -8.50705917400000000E+37
  6114.     OP2                      =  2.00000000000000000E+00
  6115.     
  6116.     OP1 * OP2                = 
  6117.     *** EXCEPTION CONDITION RAISED ***
  6118.     
  6119.     LONG_FLOAT OPERATIONS RESULTS
  6120.     
  6121.     OP1                      = -8.50705917300000000E+37
  6122.     OP2                      =  2.00000000000000000E+00
  6123.     
  6124.     OP1 * OP2                = -1.70141183460000000E+38
  6125.     
  6126.     OP1 / OP2                = -4.25352958650000000E+37
  6127.     
  6128.     (OP1 / OP2) * OP2        = -8.50705917300000000E+37
  6129. <FF>
  6130.     
  6131.                  -- ADD/SUBTRACT OPERATIONS
  6132.                  -- WITH ZERO AND NEAR (2**-129)
  6133.     LONG_FLOAT OPERATIONS RESULTS
  6134.     
  6135.     OP1                      =  1.46936794000000000E-39
  6136.     OP2                      =  0.00000000000000000E+00
  6137.     
  6138.     OP1 + OP2                =  1.46936794000000000E-39
  6139.     
  6140.     OP1 - OP2                =  1.46936794000000000E-39
  6141.     
  6142.     OP2 - OP1                = -1.46936794000000000E-39
  6143.     
  6144.     LONG_FLOAT OPERATIONS RESULTS
  6145.     
  6146.     OP1                      = -1.46936794000000000E-39
  6147.     OP2                      =  0.00000000000000000E+00
  6148.     
  6149.     OP1 + OP2                = -1.46936794000000000E-39
  6150.     
  6151.     OP1 - OP2                = -1.46936794000000000E-39
  6152.     
  6153.     OP2 - OP1                =  1.46936794000000000E-39
  6154. <FF>
  6155.     
  6156.                  -- ADD/SUBTRACT OPERATIONS
  6157.                  -- WITH NEAR (2**-128) AND NEAR (2**-129)
  6158.     LONG_FLOAT OPERATIONS RESULTS
  6159.     
  6160.     OP1                      =  2.93873587000000000E-39
  6161.     OP2                      =  1.46936794000000000E-39
  6162.     
  6163.     OP1 + OP2                =  4.40810381000000000E-39
  6164.     
  6165.     OP1 - OP2                =  0.00000000000000000E+00
  6166.     
  6167.     OP2 - OP1                =  0.00000000000000000E+00
  6168.     
  6169.     LONG_FLOAT OPERATIONS RESULTS
  6170.     
  6171.     OP1                      =  2.93873587000000000E-39
  6172.     OP2                      = -1.46936794000000000E-39
  6173.     
  6174.     OP1 + OP2                =  0.00000000000000000E+00
  6175.     
  6176.     OP1 - OP2                =  4.40810381000000000E-39
  6177.     
  6178.     OP2 - OP1                = -4.40810381000000000E-39
  6179.     
  6180.     LONG_FLOAT OPERATIONS RESULTS
  6181.     
  6182.     OP1                      = -2.93873587000000000E-39
  6183.     OP2                      =  1.46936794000000000E-39
  6184.     
  6185.     OP1 + OP2                =  0.00000000000000000E+00
  6186.     
  6187.     OP1 - OP2                = -4.40810381000000000E-39
  6188.     
  6189.     OP2 - OP1                =  4.40810381000000000E-39
  6190.     
  6191.     LONG_FLOAT OPERATIONS RESULTS
  6192.     
  6193.     OP1                      = -2.93873587000000000E-39
  6194.     OP2                      = -1.46936794000000000E-39
  6195.     
  6196.     OP1 + OP2                = -4.40810381000000000E-39
  6197.     
  6198.     OP1 - OP2                =  0.00000000000000000E+00
  6199.     
  6200.     OP2 - OP1                =  0.00000000000000000E+00
  6201. <FF>
  6202.     
  6203.                  -- MULTIPLY/DIVIDE OPERATIONS
  6204.                  -- WITH TWO AND NEAR (2**-128)
  6205.     LONG_FLOAT OPERATIONS RESULTS
  6206.     
  6207.     OP1                      =  2.93873587000000000E-39
  6208.     OP2                      =  2.00000000000000000E+00
  6209.     
  6210.     OP1 * OP2                =  5.87747174000000000E-39
  6211.     
  6212.     OP1 / OP2                =  0.00000000000000000E+00
  6213.     
  6214.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  6215.     
  6216.     LONG_FLOAT OPERATIONS RESULTS
  6217.     
  6218.     OP1                      = -2.93873587000000000E-39
  6219.     OP2                      =  2.00000000000000000E+00
  6220.     
  6221.     OP1 * OP2                = -5.87747174000000000E-39
  6222.     
  6223.     OP1 / OP2                =  0.00000000000000000E+00
  6224.     
  6225.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  6226.     
  6227.     LONG_FLOAT OPERATIONS RESULTS
  6228.     
  6229.     OP1                      = -2.93873587000000000E-39
  6230.     OP2                      = -2.00000000000000000E+00
  6231.     
  6232.     OP1 * OP2                =  5.87747174000000000E-39
  6233.     
  6234.     OP1 / OP2                =  0.00000000000000000E+00
  6235.     
  6236.     (OP1 / OP2) * OP2        =  0.00000000000000000E+00
  6237.     
  6238.  
  6239.