home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-05-03 | 223.4 KB | 6,239 lines |
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --mae.mac
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
-
-
-
-
-
-
-
-
-
-
- EEEEEE M M AAAAAA
- EE MM MM AA AA
- EEEEEE MM MM AAAAAA
- EE M MM M AA AA
- EEEEEE M MM M AA AA
-
- EMULATION OF MACHINE ARITHMETIC
-
-
-
-
- M A C R O S C O P I C D E S I G N
-
-
-
- 30 JUNE 1985
-
-
-
- Prepared for
-
- Naval Ocean Systems Center,
- WIS Joint Program Office
-
-
- Prepared by
-
- Ada* Technology Group
- SYSCON Corportation
- 3990 Sherman Street
- San Diego, California 92110
-
-
-
-
-
-
-
-
- * Ada is a registered trademark of the
- United States Government - Ada Joint Program Office
- <FF>
-
-
-
- Table of Contents
- -----------------
-
-
- 1. SOFTWARE ARCHITECTURE
-
- 2. MACROSCOPIC DESIGN ADA PDL
- 2.1 MACHINE_ARITHMETIC_EMULATION
- 2.2 MAE_INTEGER
- 2.3 MAE_SHORT_FLOAT
- 2.4 MAE_LONG_FLOAT
- 2.5 MAE_BASIC_OPERATIONS
-
-
- <FF>
-
- 1. SOFTWARE ARCHITECTURE
-
- The software architecture of the EMA packages is illustrated in
- Figure 1-1, which shows the Ada Graphic Notation for the "MAE"
- subsystem.
-
-
- MAE
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- | |
- | |
- | |
- | MACHINE_ARITHMETIC_EMULATION |
- | ---------------------------- |
- | | | |
- (target_types)----------->| | |
- | | | |
- |target_operations|------>| | |
- | | | |
- <target_exceptions>------>| | |
- | | |--+ |
- | ---------------------------- | |
- | | |
- | +----------------------------------------+ |
- | | MAE_INTEGER |
- | | --------------- |
- | +->| | |
- | | | | |
- | | | |--+ |
- | | --------------- | |
- | | | MAE_BASIC_OPERATIONS |
- | | MAE_SHORT_FLOAT | ---------------- |
- | | --------------- | | | |
- | +->| | +----->| | |
- | | | | | | |--+ |
- | | | |--+ ---------------- | |
- | | --------------- | | |
- | | | +-----------+ |
- | | MAE_LONG_FLOAT | | |
- | | --------------- | +---->|Ada_predefined_ops|
- | +->| | | |
- | | | | |
- | | |--+ |
- | --------------- |
- | |
- -----------------------------------------------------------
-
- Figure 1-1 Ada Graphic Notation for MAE
-
-
- The MAE subsystem consists of the visible package
- MACHINE_ARITHMETIC_EMULATION which contains the exported target
- types and operations, and four supporting packages. The lowest
- level supporting package is MAE_BASIC_OPERATIONS, which provides the
- basic types and operations for emulating machine arithmetic and
- implements the operations using the predefined arithmetic operations
- of the host system. The other support packages, MAE_INTEGER,
- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
- on one of the exported types, by utilizing MAE_BASIC_OPERATIONS.
-
- The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
- relational operations on target integers (TARGET_INTEGER), floating
- point numbers (TARGET_SHORT_FLOAT), and double precision floating
- point numbers (TARGET_LONG_FLOAT). The accuracy of the numbers is
- given below:
-
- where N is the number of bits in the Target word
-
- TARGET_INTEGER
- range of -2**(N-1) to 2**(N-1)-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (N-9) bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (2*N-9) bit binary fraction
-
- thus for 36 bit words the accuracies are:
-
- TARGET_INTEGER
- range of -2**35 to 2**35-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 27 bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 63 bit binary fraction
-
- The 36 bit word accuracies are consistent with those given in the
- Honeywell Multics FORTRAN Manual (Order Number AT58) which defines
- the operation of the FORTRAN language on 60 series Honeywell
- hardware.
-
- For each of the supported types, the following operations are
- defined:
- addition arithmetic comparisons
- subtraction numerical conversion
- multiplication unary plus
- division unary minus
- remainder absolute value
- modulo string get
- exponentiation string put
-
- For target integer types the following attributes are defined:
- 'first
- 'last
- 'image
- 'value
-
- For target floating point types the following attributes are
- defined:
- 'digits
- 'emax
- 'epsilon
- 'first
- 'large
- 'machine_emax
- 'machine_emin
- 'machine_mantissa
- 'machine_overflows
- 'machine_radix
- 'safe_emax
- 'small
-
- The supported attributes are called by using the form:
-
- <type name>_<attribute_name> -- (e.g., TARGET_INTEGER_FIRST)
-
- The standard tic (') symbol can not be used, because the emulated
- types are not directly derived from host types. Instead the tic
- symbol is replaced with an underscore.
-
- The entire set of operations for each of the types is listed in the
- interface specification provided in section 4. The calling format,
- parameters, and returned values of all of the aforementioned
- operations conform to operations as defined in the package STANDARD
- (see the Reference Manual for the Ada Programming Language Appendix
- C) for each of the types. The functionality of the aforementioned
- attributes is in accordance with the Ada predefined language
- attributes (see the Reference Manual for the Ada Programming
- Language Appendix A).
- <FF>
-
-
- 2. MACROSCOPIC DESIGN
-
- This section specifies the macroscopic level design of the packages
- providing the Emulation of Machine Arithmetic capability. The
- design is specified in Ada PDL, which was compiled to verify its
- consistency and syntactical correctness. The following subsections
- specify the Ada PDL of each of the constituent packages in the
- software architecture.
-
-
- 2.1 MACHINE_ARITHMETIC_EMULATION
-
-
- with MAE_BASIC_OPERATIONS;
- with MAE_INTEGER;
- with MAE_SHORT_FLOAT;
- with MAE_LONG_FLOAT;
-
- package MACHINE_ARITHMETIC_EMULATION is
- --------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- arithmetic on host machines with 16 bit or larger words.
- -- This package will export support for target integer, real,
- -- and double precision real numbers.
- --
- -- The package emulation packages are currently configured to
- -- support Honeywell 36 bit arithmetic.
- --
- -- The ranges for the current configuration are as follows:
- --
- -- TARGET_INTEGER
- -- range of -2**35 to 2**35-1
- -- TARGET_SHORT_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 27 bit binary fraction
- -- exponent => -128 to 127
- -- TARGET_LONG_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 63 bit binary fraction
- -- exponent => -128 to 127
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR". The
- -- exception declared in this package is a rename of
- -- the predefined exception NUMERIC_ERROR. This can be
- -- changed for programs needing to handle arithmetic
- -- exceptions generated by the emulation packages separately.
- --
-
-
- --------------------------------------------------------------------
- -- Parameters within MAE_BASIC_OPERATIONS that need to be available
- -- to the user of the Emulation of Machine Arithmetic package
- --
- subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
- DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
-
- subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
- SHORT_DEFAULT_AFT : FIELD renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
- LONG_DEFAULT_AFT : FIELD renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
- SHORT_DEFAULT_EXP : FIELD renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
- LONG_DEFAULT_EXP : FIELD renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
-
- --
- -- predefined attributes for the emulated types
- --
- SHORT_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS;
- LONG_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS;
-
- SHORT_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
- LONG_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
-
- SHORT_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
- LONG_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
-
- SHORT_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
- LONG_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
-
- SHORT_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
- LONG_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
-
- SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
- LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
-
- SHORT_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
- LONG_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
-
- SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
- LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
-
- SHORT_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
- LONG_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_INTEGER
- --
- -- The follow declaration should be private
-
- subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_INTEGER_FIRST return TARGET_INTEGER;
- function TARGET_INTEGER_LAST return TARGET_INTEGER;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "abs" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "+" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "*" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "/" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "rem" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "mod" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "**" (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
- return TARGET_INTEGER;
-
- function TARGET_INTEGER_VALUE (STRING_PIC : STRING)
- return TARGET_INTEGER;
- function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER)
- return STRING;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_INTEGER;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_INTEGER;
- BASE : in NUMBER_BASE := DEFAULT_BASE);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_SHORT_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
-
- function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "abs" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "**" (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER)
- return TARGET_SHORT_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_SHORT_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_SHORT_FLOAT;
- AFT : in FIELD := SHORT_DEFAULT_AFT;
- EXP : in FIELD := SHORT_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_LONG_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "abs" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "**" (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER)
- return TARGET_LONG_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_LONG_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_LONG_FLOAT;
- AFT : in FIELD := LONG_DEFAULT_AFT;
- EXP : in FIELD := LONG_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- private
-
- -- Note : Derived types are not supported under
- -- Telesoft version 1.5
-
- -- The types are private to prevent direct manipulation of
- -- the components of the numbers. The exported types
- -- are declarations of the appropriate types from the
- -- respective package.
-
- -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
-
- -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
-
- -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
-
-
- --------------------------------------------------------------------
-
- end MACHINE_ARITHMETIC_EMULATION;
-
-
- package body MACHINE_ARITHMETIC_EMULATION is
- --
- -- The package body is implemented by directly calling
- -- the corresponding operations in the MAE_INTEGER,
- -- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT packages.
- --
- end MACHINE_ARITHMETIC_EMULATION;
-
-
- 2.2 MAE_INTEGER
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_INTEGER is
- -------------------------------------------------------------------
-
- -- The purpose of this package is to emulate target machine
- -- integer arithmetic on host machines with 16 bit or larger
- -- words.
- --
- -- The range of the supported type is as follows:
- --
- -- TARGET_INTEGER
- -- range of -2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS
- -- to
- -- 2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS-1
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- --
- -- Visible operations with MAE_INTEGER_TYPE
- --
- type MAE_INTEGER_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "-" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "abs" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "-" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "*" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "/" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "rem" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "mod" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
-
- function "**" (LEFT : MAE_INTEGER_TYPE; RIGHT : INTEGER)
- return MAE_INTEGER_TYPE;
-
- function MAE_INTEGER_TYPE_VALUE(STRING_PIC : STRING)
- return MAE_INTEGER_TYPE;
-
- function MAE_INTEGER_TYPE_IMAGE(STORE_PIC : MAE_INTEGER_TYPE)
- return STRING;
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_INTEGER_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_INTEGER_TYPE;
- BASE : in NUMBER_BASE := DEFAULT_BASE);
-
- function TARGET_INTEGER_FIRST return MAE_INTEGER_TYPE;
-
- function TARGET_INTEGER_LAST return MAE_INTEGER_TYPE;
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_INTEGER_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : SHORT_COMP_ARRAY := INTEGER_COMP_ARRAY;
- end record;
-
- -------------------------------------------------------------------
- end MAE_INTEGER;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_INTEGER is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_INTEGER type, and in conjunction with
- -- procedures to handle Integer specific operations such as
- -- carrying and borrowing.
- --
- end MAE_INTEGER;
-
-
- 2.3 MAE_SHORT_FLOAT
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_SHORT_FLOAT is
- -------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- floating point arithmetic on host machines with 16 bit or
- -- larger word size.
- --
- -- The ranges of the supported type is as follows:
- --
- -- TARGET_SHORT_FLOAT (Real)
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => MAE_BASIC_OPERATIONS.TARGET_SHORT_NUM_BITS
- -- bit binary fraction
- -- exponent => -128 to 127
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- --
- -- Visible operations with MAE_SHORT_FLOAT_TYPE
- --
- type MAE_SHORT_FLOAT_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
- function "-" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
- function "abs" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "-" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "*" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "/" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
-
- function "**" (LEFT : MAE_SHORT_FLOAT_TYPE; RIGHT : INTEGER)
- return MAE_SHORT_FLOAT_TYPE;
-
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_SHORT_FLOAT_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_SHORT_FLOAT_TYPE;
- AFT : in FIELD := SHORT_DEFAULT_AFT;
- EXP : in FIELD := SHORT_DEFAULT_EXP);
-
- function TARGET_SHORT_FLOAT_EPSILON return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_LARGE return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_SMALL return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_LAST return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_FIRST return MAE_SHORT_FLOAT_TYPE;
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_SHORT_FLOAT_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : SHORT_COMP_ARRAY := SHORT_FLOAT_COMP_ARRAY;
- EXPONENT : EXPONENT_TYPE := 0;
- end record;
-
- -------------------------------------------------------------------
- end MAE_SHORT_FLOAT;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_SHORT_FLOAT is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_SHORT_FLOAT type, and in conjunction with
- -- procedures to handle Integer specific operations such as
- -- carrying and borrowing.
- --
- end MAE_SHORT_FLOAT;
-
-
- 2.4 MAE_LONG_FLOAT
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_LONG_FLOAT is
- -------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- double precision floating point arithmetic on host machines
- -- with 16 bit or larger words.
- --
- -- The ranges of the supported type is as follows:
- --
- -- TARGET_LONG_FLOAT (Double Precision Real)
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => MAE_BASIC_OPERATIONS.TARGET_LONG_NUM_BITS
- -- bit binary fraction
- -- exponent => -128 to 127
- --
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- -----------------------------------------------------------------
- -- Visible operations with MAE_LONG_FLOAT_TYPE
- --
- type MAE_LONG_FLOAT_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
- function "-" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
- function "abs" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "-" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "*" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "/" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
-
- function "**" (LEFT : MAE_LONG_FLOAT_TYPE; RIGHT : INTEGER)
- return MAE_LONG_FLOAT_TYPE;
-
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_LONG_FLOAT_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_LONG_FLOAT_TYPE;
- AFT : in FIELD := LONG_DEFAULT_AFT;
- EXP : in FIELD := LONG_DEFAULT_EXP);
-
- function TARGET_LONG_FLOAT_EPSILON return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_LARGE return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_SMALL return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_LAST return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_FIRST return MAE_LONG_FLOAT_TYPE;
-
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_LONG_FLOAT_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : LONG_COMP_ARRAY := LONG_FLOAT_COMP_ARRAY;
- EXPONENT : EXPONENT_TYPE := 0;
- end record;
-
- -------------------------------------------------------------------
- end MAE_LONG_FLOAT;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_LONG_FLOAT is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_LONG_FLOAT type, and in conjunction with
- -- procedures to handle Integer specific operations such as
- -- carrying and borrowing.
- --
- end MAE_LONG_FLOAT;
-
-
- 2.5 MAE_BASIC_OPERATIONS
-
-
- package MAE_BASIC_OPERATIONS is
- -------------------------------------------------------------------
- -- The package emulation packages are currently configured
- -- to support Honeywell 36 bit arithmetic.
- --
- -- The purpose of this package is to provide general machine
- -- arithmetic types and function to support integer and floating
- -- point variables. The underlying arithmetic operations will
- -- be performed component-wise. It is assumed that the system
- -- provides for integer operations.
-
- -------------------------------------------------------------------
- -- Here are the declarations of the basic constants and variables.
- -- Some of these constants reflect the emulation target and the
- -- implementation host (and compiler) dependiencies.
- -- It is possible that changing these constants and variables could
- -- improve software performance. They are the basic elements for
- -- building the MAE_INTEGER_TYPE and MAE_FLOAT_TYPE types.
- --
- -- number of bits in a component
- NO_COMP_BITS : constant INTEGER := 7;
- -- maximum value of a component
- MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
- -- component base value
- BASE_COMP_VALUE : constant INTEGER := MAX_COMP_VALUE+1;
- -- the values associated with a bit position,
- -- initialized in the body of this package
- BIT_VALUE : array (1 .. NO_COMP_BITS) of INTEGER;
- -- a component, note that the range of a true component is
- -- 0 .. MAX_COMP_VALUE, although intermediate values, obtained
- -- during computations, lie outside the range.
- subtype COMP is INTEGER;
- -- an array of components
- type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
- -- the use of representation specifications could direct the
- -- compiler how to store the array and possibly increase efficiency.
- -- note that the least significant COMP is the first in the
- -- array, and consequently the most significant COMP is the last.
- --
- -- most signif least signif
- -- 'last . . 'first
- -- -------------- -------------- --------------
- -- | 1 2 3 .. n | | 1 2 3 .. n | . . | 1 2 3 .. n |
- -- -------------- -------------- --------------
-
- -- Identification of the caller
- type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
- LONG_FLOAT_CLASS);
-
- -- Declaration for short comp arrays
- SHORT_NUM_COMPS : constant INTEGER := 6;
- SHORT_NUM_BITS : constant INTEGER := SHORT_NUM_COMPS * NO_COMP_BITS;
- subtype SHORT_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. SHORT_NUM_COMPS);
- SHORT_ZERO_ARRAY : constant SHORT_COMPONENT_ARRAY :=
- (1 .. SHORT_NUM_COMPS => 0);
-
- type SHORT_COMP_ARRAY is
- record
- COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
- CLASS_OF_ARRAY : CLASSIFICATION;
- BITS_SHIFTED : INTEGER;
- end record;
-
- INTEGER_COMP_ARRAY : SHORT_COMP_ARRAY :=
- (SHORT_ZERO_ARRAY, INTEGER_CLASS, 0);
- SHORT_FLOAT_COMP_ARRAY : SHORT_COMP_ARRAY :=
- (SHORT_ZERO_ARRAY, SHORT_FLOAT_CLASS, 0);
-
- -- The emulated target dependent constants for 36 bit storage
- TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
- TARGET_SHORT_NUM_BITS : constant INTEGER := 28;
-
- -- Declaration for long comp arrays
- LONG_NUM_COMPS : constant INTEGER := (2 * SHORT_NUM_COMPS);
- LONG_NUM_BITS : constant INTEGER := LONG_NUM_COMPS * NO_COMP_BITS;
- subtype LONG_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS);
- LONG_ZERO_ARRAY : LONG_COMPONENT_ARRAY :=
- (1 .. LONG_NUM_COMPS => 0);
-
- type LONG_COMP_ARRAY is
- record
- COMPONENT_ARRAY : LONG_COMPONENT_ARRAY;
- CLASS_OF_ARRAY : CLASSIFICATION;
- BITS_SHIFTED : INTEGER;
- end record;
-
- LONG_FLOAT_COMP_ARRAY : LONG_COMP_ARRAY :=
- (LONG_ZERO_ARRAY, LONG_FLOAT_CLASS, 0);
- -- The emulated target dependent constants for 72 bit storage
- TARGET_LONG_NUM_BITS : constant INTEGER := 64;
-
- -- Extended array length for LONG multiplication
- subtype EXTRA_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS*2);
- EXTRA_ZERO_ARRAY : EXTRA_COMPONENT_ARRAY :=
- (1 .. LONG_NUM_COMPS*2 => 0);
-
- -- Extended array for spaces filling string arrays
- EMPTY_STRING : STRING (1 .. 40) :=
- " ";
-
- -- the sign of a number
- subtype SIGN_TYPE is BOOLEAN;
- NEG_SIGN : constant BOOLEAN := FALSE;
- POS_SIGN : constant BOOLEAN := TRUE;
-
- -- the exponent of a floating type
- subtype EXPONENT_TYPE is INTEGER;
- MIN_EXPONENT_VALUE : constant INTEGER := -128;
- MAX_EXPONENT_VALUE : constant INTEGER := 127;
-
- -- The follow declarations specify the value of the most
- -- significant component for the digits ONE .. TEN and their
- -- corresponding exponents. The component values can be thought
- -- of as a binary representation(picture) of the most signif
- -- comp. Applying the binary exponent as left shifts, it is
- -- easy to see how the digit is obtained. This allows
- -- for the length of the array to change without affecting
- -- the code in the higher level packages.
- POINT_FIVE : constant INTEGER := 2**(NO_COMP_BITS-1);
- POINT_FIVE_SIX_TWO_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-4);
- POINT_SIX_TWO_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-3);
- POINT_SEVEN_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2);
- POINT_EIGHT_SEVEN_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2) + 2**(NO_COMP_BITS-3);
- DIGIT_PICTURE : constant array (1 .. 10) of INTEGER :=
- (POINT_FIVE,
- POINT_FIVE,
- POINT_SEVEN_FIVE,
- POINT_FIVE,
- POINT_SIX_TWO_FIVE,
- POINT_SEVEN_FIVE,
- POINT_EIGHT_SEVEN_FIVE,
- POINT_FIVE,
- POINT_FIVE_SIX_TWO_FIVE,
- POINT_SIX_TWO_FIVE);
- DIGIT_BINARY_EXPONENT : constant array (1 .. 10) of INTEGER :=
- (1, 2, 2, 3, 3, 3, 3, 4, 4, 4);
-
- -- predefined attributes
- LOG_2 : constant FLOAT := 0.30103;
- SHORT_FLOAT_DIGITS : constant INTEGER :=
- INTEGER(FLOAT(TARGET_SHORT_NUM_BITS-1)*LOG_2);
- LONG_FLOAT_DIGITS : constant INTEGER :=
- INTEGER(FLOAT(TARGET_LONG_NUM_BITS-1)*LOG_2);
-
- SHORT_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
- LONG_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_MANTISSA : INTEGER
- renames TARGET_SHORT_NUM_BITS;
- LONG_FLOAT_MACHINE_MANTISSA : INTEGER
- renames TARGET_LONG_NUM_BITS;
-
- SHORT_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
- LONG_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
-
- SHORT_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
- LONG_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
-
- SHORT_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
- LONG_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
-
- SHORT_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
- -- String IO constants
- -- the only base available is base 10
- subtype NUMBER_BASE is INTEGER range 2 .. 16;
- DEFAULT_BASE : constant NUMBER_BASE := 10;
- subtype FIELD is INTEGER range 0 .. INTEGER'last;
-
- -- a telesoft 1.5 restriction that is detected in the package
- -- above this package does not allow
- -- SHORT_DEFAULT_AFT : constant FIELD := SHORT_FLOAT_DIGITS-1;
- -- LONG_DEFAULT_AFT : constant FIELD := LONG_FLOAT_DIGITS-1;
- SHORT_DEFAULT_AFT : constant FIELD := 7;
- LONG_DEFAULT_AFT : constant FIELD := 17;
-
- SHORT_DEFAULT_EXP : constant FIELD := 3;
- LONG_DEFAULT_EXP : constant FIELD := 3;
-
-
- -------------------------------------------------------------------
- -- The exception to be raised for all arithmetic and boolean
- -- expressions functions defined in this package.
- --
- MAE_NUMERIC_ERROR : EXCEPTION renames STANDARD.NUMERIC_ERROR;
-
- -------------------------------------------------------------------
- -- Function to determine the number of components for
- -- the representation.
- --
- function BITS_TO_COMPS (NO_OF_BITS : INTEGER) return INTEGER;
-
- -------------------------------------------------------------------
- -- Operations on the sign
- --
- -- Since the SIGN_TYPE is an BOOLEAN, most of the operations
- -- are assumed system functions
-
- function CHANGE_SIGN (SIGN : SIGN_TYPE) return SIGN_TYPE;
-
- -------------------------------------------------------------------
- -- Operations on the exponent
- --
- -- Since the EXPONENT_TYPE is an INTEGER, the operations
- -- are assumed system functions
-
- -------------------------------------------------------------------
- -- Operations on the component
- --
- -- If the variable NO_COMP_BITS is chosen properly, a fact
- -- on which the entire package design is based, COMP and any
- -- result of binary operation (except exponentiation which is
- -- never used with COMP) of two COMPs is an INTEGER.
- -- Therefore, the operations are assumed system functions
-
- -------------------------------------------------------------------
- -- Operations on short component arrays
- --
- -- Predefined system functions : function "=" and function "/=".
- -- Comparisions are handled under variable-sized arrays.
- -- The array parameters must have the same length and the same
- -- CLASSIFICATION (both INTEGER_CLASS or both SHORT_FLOAT_CLASS).
- -- The returning result component array will contain the same
- -- number of elements.
- -- For SHORT_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
- -- the array is set for higher level exponent operation.
- -- The SHORT_FLOAT_CLASS array will be normalized by these routines.
- -- Note that the least significant COMP is the first in the
- -- array, and consequently the most significant COMP is the last.
-
- function "+" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "-" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "*" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "/" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "rem" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
-
-
- -------------------------------------------------------------------
- -- Operations on long component arrays
- --
- -- Predefined system functions : function "=" and function "/=".
- -- Comparisions are handled under variable-sized arrays.
- -- The array parameters must have the same length.
- -- The returning result component array will contain the same
- -- number of elements.
- -- For LONG_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
- -- the array is set for higher level exponent operation.
- -- The LONG_FLOAT_CLASS array will be normalized by these routines.
-
- function "+" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "-" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "*" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "/" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
-
-
- -------------------------------------------------------------------
- -- Operations on variable-sized component arrays
- --
- -- The array parameters are only comprized of components,
- -- no CLASSIFICATION or BITS_SHIFTED info is included.
- -- The array will not be normalized by these routines, that
- -- is the responsiblity of a higher level routine.
-
- -- The comparision functions.
- -- Predefined system functions : function "=" and function "/=".
-
- function "<" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
-
- -- This routine performs a divide by two on the array,
- -- with rounding to even.
- procedure DIVIDE_ARRAY_BY_TWO (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
-
- -- This routine sets the range of all individual COMPs within
- -- (0 .. MAX_COMP_VALUE) by looping through the array from the least
- -- significant COMP to the most significant COMP, performing
- -- carries and borrows as necessary. Since the most significant
- -- COMP has nowhere to carry or borrow, it is left unbounded.
- -- This allows the higher level routine to determine if shifting
- -- must occur, an error exists, or whatever.
- procedure RANGE_CHECK (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
-
- -- This routine shifts to the right and truncates a
- -- component array. The BITS variable is the number of bits
- -- to shift the array and must be positive.
- procedure ARRAY_TRUNCATION_SHIFT_RIGHT
- (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : in NATURAL);
-
- -- This routine sets the most significant bit in the array to one
- -- (normalized), by shifting the array to the left.
- -- The BITS variable is the number of bits the array was shifted.
- procedure ARRAY_NORMALIZE
- (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : out INTEGER);
-
- -------------------------------------------------------------------
- end MAE_BASIC_OPERATIONS;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --userman.rpt
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
-
-
-
-
-
-
-
-
-
-
- EEEEEE M M AAAAAA
- EE MM MM AA AA
- EEEEEE MM MM AAAAAA
- EE M MM M AA AA
- EEEEEE M MM M AA AA
-
- EMULATION OF MACHINE ARITHMETIC
-
-
-
-
- U S E R ' S G U I D E
-
-
-
- 30 JUNE 1985
-
-
-
- Prepared for
-
- Naval Ocean Systems Center,
- WIS Joint Program Office
-
-
- Prepared by
-
- Ada* Technology Group
- SYSCON Corportation
- 3990 Sherman Street
- San Diego, California 92110
-
-
-
-
-
-
-
-
- * Ada is a registered trademark of the
- United States Government - Ada Joint Program Office
- <FF>
-
-
-
- Table of Contents
- -----------------
-
-
- 1. INTRODUCTION
-
- 1.1 Purpose
- 1.2 Feature Overview
- 1.3 Basic Usage Overview
- 1.4 Software Architecture
-
-
- 2. USE OF THE MACHINE_ARITHMETIC_EMULATION PACKAGE
-
- 2.1 Installation
- 2.2 Accessing the MACHINE_ARITHMETIC_EMULATION Package
- 2.3 Supported Operations
- 2.4 Interfacing
- 2.5 Exceptions
-
- 3. ADAPTING MACHINE ARITHMETIC EMULATION
-
- 3.1 Target Word Size Specification
- 3.2 Host Word Size Specification and Performance Tuning
-
-
- APPENDIX A. INTERFACE SPECIFICATION
-
- APPENDIX B. SAMPLE CODE
- <FF>
-
- 1. INTRODUCTION
-
- 1.1 Purpose
-
- The Emulation of Machine Arithmetic (EMA) software consists of a set
- of Ada packages which support the emulation of machine arithmetic
- for target processors with arbitrary word length on a host processor
- of sixteen (16) bit or larger word size. The EMA packages utilize
- the general arithmetic capabilities of computer systems to remove
- host specific dependencies. The packages as delivered are
- configured to emulate 36 bit Honeywell processors (e.g., Honeywell
- 6040 and DPS8). This instantiation of the packages will be highly
- useful in rehosting and/or converting existing application software
- with embedded 36 bit accuracy requirements to the more common 16 and
- 32 bit hosts.
-
-
- 1.2 Feature Overview
-
- The EMA packages are written in Ada and use the overloading feature
- to add additional meaning to the arithmetic operations defined in
- the package STANDARD (see the Reference Manual for the Ada
- Programming Language Appendix C). The additional meanings take the
- form of arithmetic operations for integers, reals, and double
- precision reals on the target (emulated) word type. The EMA
- packages provide addition, subtraction, multiplication, division,
- exponentiation, arithmetic comparisions, the Ada attributes
- appropriate for the type (e.g., 'FIRST), string GET and PUT
- procedures, and other operations on the target word type. The entire
- set of operations is listed in the interface specification provided
- in Appendix A.
-
-
- 1.3 Basic Usage Overview
-
- The EMA packages provide a collection of Ada types, procedures and
- functions, that perform a variety of operations. Once the user has
- included the MACHINE_ARITHMETIC_EMULATION package via an Ada context
- clause, the subprograms are available to be called and executed. The
- parameters and returned values for the entire set of operations are
- listed in the interface specification provided in Appendix A.
-
- 1.4 Software Architecture
-
- The software architecture of the EMA packages is illustrated in
- Figure 1-1, which shows the Ada Graphic Notation for the "MAE"
- subsystem.
-
-
- <FF>
-
- MAE
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- | |
- | |
- | |
- | MACHINE_ARITHMETIC_EMULATION |
- | ---------------------------- |
- | | | |
- (target_types)----------->| | |
- | | | |
- |target_operations|------>| | |
- | | | |
- <target_exceptions>------>| | |
- | | |--+ |
- | ---------------------------- | |
- | | |
- | +----------------------------------------+ |
- | | MAE_INTEGER |
- | | --------------- |
- | +->| | |
- | | | | |
- | | | |--+ |
- | | --------------- | |
- | | | MAE_BASIC_OPERATIONS |
- | | MAE_SHORT_FLOAT | ---------------- |
- | | --------------- | | | |
- | +->| | +----->| | |
- | | | | | | |--+ |
- | | | |--+ ---------------- | |
- | | --------------- | | |
- | | | +-----------+ |
- | | MAE_LONG_FLOAT | | |
- | | --------------- | +---->|Ada_predefined_ops|
- | +->| | | |
- | | | | |
- | | |--+ |
- | --------------- |
- | |
- -----------------------------------------------------------
-
- Figure 1-1 Ada Graphic Notation for MAE
-
-
- The MAE subsystem consists of the visible package
- MACHINE_ARITHMETIC_EMULATION which contains the exported target
- types and operations, and four supporting packages. The lowest
- level supporting package is MAE_BASIC_OPERATIONS, which provides the
- basic types and operations for emulating machine arithmetic and
- implements the operations using the predefined arithmetic operations
- of the host system. The other support packages, MAE_INTEGER,
- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
- on one of the exported types, by utilizing MAE_BASIC_OPERATIONS.
- <FF>
-
- 2. USE OF THE MACHINE_ARITHMETIC_EMULATION PACKAGE
-
- 2.1 Installation
-
- Before the MACHINE_ARITHMETIC_EMULATION package can be utilized, it
- and its supporting packages must first be placed in the user's
- program library. This can be done by compiling, in the order
- specified, the following packages into the program library:
-
- 1) MAE_BASIC_OPERATIONS
- 2) MAE_INTEGER
- 3) MAE_SHORT_FLOAT
- 4) MAE_LONG_FLOAT
- 5) MACHINE_ARITHMETIC_EMULATION
-
-
- 2.2 Accessing the MACHINE_ARITHMETIC_EMULATION Package
-
- The required types and subprograms needed to emulate target machine
- arithmetic are exported by the package MACHINE_ARITHMETIC_EMULATION.
- This package can be accessed via the Ada 'with' and 'use' clauses.
- For example:
-
- with MACHINE_ARITHMETIC_EMULATION;
- use MACHINE_ARITHMETIC_EMULATION;
-
- package body USERS_PACKAGE is
- .
- .
- procedure EXAMPLE is
- VAR1, VAR2 : TARGET_INTEGER;
- .
- .
- begin
- VAR1 := VAR1 + VAR2; -- integer add using target
- . -- arithmetic (e.g., 36 bits)
- .
- end EXAMPLE;
-
- end USERS_PACKAGE;
-
-
- The MACHINE_ARITHMETIC_EMULATION target types and subprograms are
- now available within USERS_PACKAGE. A more detailed example showing
- the utilization of the MACHINE_ARITHMETIC_EMULATION package is given
- in Appendix B.
-
-
- 2.3 Supported Operations
-
- The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
- relational operations on target integers (TARGET_INTEGER), floating
- point numbers (TARGET_SHORT_FLOAT), and double precision floating
- point numbers (TARGET_LONG_FLOAT). The accuracy of the numbers is
- given below:
-
- where N is the number of bits in the Target word
-
- TARGET_INTEGER
- range of -2**(N-1) to 2**(N-1)-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (N-9) bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (2*N-9) bit binary fraction
-
- thus for 36 bit words the accuracies are:
-
- TARGET_INTEGER
- range of -2**35 to 2**35-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 27 bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 63 bit binary fraction
-
- The 36 bit word accuracies are consistent with those given in the
- Honeywell Multics FORTRAN Manual (Order Number AT58) which defines
- the operation of the FORTRAN language on 60 series Honeywell
- hardware.
-
- For each of the supported types, the following operations are
- defined:
- addition
- subtraction
- multiplication
- division
- remainder
- modulo
- exponentiation
- arithmetic comparisions
- numerical conversion
- unary plus
- unary minus
- absolute value
- string get
- string put
-
- For target integer types the following attributes are defined:
- 'first
- 'last
- 'image
- 'value
-
- For target floating point types the following attributes are
- defined:
- 'digits
- 'emax
- 'epsilon
- 'first
- 'large
- 'machine_emax
- 'machine_emin
- 'machine_mantissa
- 'machine_overflows
- 'machine_radix
- 'safe_emax
- 'small
-
- The supported attributes are called by using the form:
-
- <type name>_<attribute_name> -- (e.g., TARGET_INTEGER_FIRST)
-
- The standard tic (') symbol can not be used, because the emulated
- types are not directly derived from host types. Instead the tic
- symbol is replaced with an underscore.
-
- The exceptions which can be raised by using these operations are
- described in Section 2.5. The entire set of operations for each of
- the types is listed in the interface specification provided in
- Appendix A. The calling format, parameters, and returned values of
- all of the aforementioned operations conform to operations as
- defined in the package STANDARD (see the Reference Manual for the
- Ada Programming Language Appendix C) for each of the types. The
- functionality of the aforementioned attributes is in accordance with
- the Ada predefined language attributes (see the Reference Manual for
- the Ada Programming Language Appendix A).
-
-
- 2.4 Interfacing
-
- The MACHINE_ARITHMETIC_EMULATION package interfaces with other
- arithmetic types through a pair of conversion procedures for each
- supported type. One of the conversion procedures converts a string
- into the numeric type, and the other conversion procedure converts
- the numeric type into a string. These conversion procedures take
- the form of the standard GET (from a string) and PUT (to a string)
- procedures found in the package TEXT_IO. The GET and PUT procedures
- function exactly as the predefined procedures, and will raise the
- same exceptions when inappropriately used or given invalid data.
- The Reference Manual for the Ada Programming Language sections
- 14.3.7 and 14.3.8 describe the procedures being implemented.
-
- For TARGET_INTEGER the input string must consist of decimal digits
- with an optional leading sign, and without letters, commas, embedded
- spaces, decimal point, exponent and other special characters.
- Leading and trailing spaces are acceptable. The assumed (and only
- available) base value is ten (decimal). The length of the output
- string for integer types is defined by the length of the string
- object used in the PUT call. This is accomplished by inserting
- enough leading spaces to fill the string. Zero is returned as the
- single digit "0".
-
- For the floating point types (TARGET_SHORT_FLOAT and
- TARGET_LONG_FLOAT) the input string can include both a sign and an
- exponent. If the number of digits in the mantissa exceeds the
- digits of precision, the number will be rounded. The characters must
- be decimal digits with an optional leading sign, and without
- letters, commas, embedded spaces, and other special characters. A
- decimal point, exponent, and leading and trailing spaces are
- acceptable. The assumed (and only available) base value is ten
- (decimal). The defined format is:
-
- FORE . AFT
- FORE . AFT E EXP
- where
- FORE : decimal digits plus optional leading spaces and
- minus sign
- . : a decimal point
- AFT : decimal digits with possible trailing zeros
- E : the exponent delimiter
- EXP : the sign and the exponent with possible leading
- zeros
-
- The length of the output string for floating point types is defined
- by the length of the string object used in the PUT call. This is
- accomplished by inserting enough leading spaces to fill the string.
- The number of spaces is determined by the number of digits requested
- in the AFT and EXP calling parameters, and the digits of precision
- of the floating point type. The default values for AFT and EXP are
- set based on the digits of precision and the maximum value of the
- exponent. The defined format is same as shown above.
-
-
- 2.5 Exceptions
-
- Any errors which occur during use of the arithmetic and relational
- subprograms within MACHINE_ARITHMETIC_EMULATION will result in the
- raising of the exception MAE_NUMERIC_ERROR. After the exception is
- raised, the results of the operation which was in progress are
- undefined.
-
- The exception MAE_NUMERIC_ERROR is originally declared in the
- package specification of MAE_BASIC_OPERATIONS, and is defined to
- rename the predefined exception "SYSTEM.NUMERIC_ERROR". Thus
- programs can handle arithmetic errors in a general fashion, by using
- the exception handler "when NUMERIC_ERROR". If it is necessary to
- distinguish between numeric errors occuring in the system and in the
- emulation packages, the original declaration of MAE_NUMERIC_ERROR
- can be changed from a renames to a normal exception declaration
- (i.e., "MAE_NUMERIC_ERROR : exception ;") and the packages
- recompiled.
- <FF>
- 3. ADAPTING MACHINE ARITHMETIC EMULATION
-
- 3.1 Target Word Size Specification
-
- The use of a subset Ada compiler (TeleSoft Version 1.5) prevented
- the use of generics and other generalizing features of the Ada
- language in the EMA implementation. This restriction was overcome by
- defining constants and parameters which control the algorithm (e.g.,
- number of components used to represent the target word). These
- parameters were placed in the MAE_BASIC_OPERATIONS package, and can
- be used to configure the machine arithmetic emulation packages to
- support different target machine word sizes. Configuration is
- considered to be the modification of the packages to emulate word
- sizes (other than the delivered 36 bit emulation) larger than a
- given host machine.
-
- To configure the EMA packages to support arithmetic operations for
- word sizes other than 36 bits, it is necessary to alter the values
- of several parameters controlling the execution of the emulation.
- These parameters are:
-
- TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
- -- This is the number of bits (excluding the sign)
- -- in the standard integer number.
-
- TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
- -- This is the number of bits of mantissa in the short
- -- floating point number.
-
- TARGET_LONG_NUM_BITS : constant INTEGER := 63;
- -- This is the number of bits of mantissa in the double
- -- precision floating point number. It is assumed to
- -- be stored in two target words.
-
- SHORT_NUM_COMPS : constant INTEGER := 6;
- -- This is the number of components used to emulate the
- -- integer and short floating point number. This must
- -- be adjusted to be consistent with the new values of
- -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
- -- The value is given by dividing the number of bits in
- -- the target word by the number of bits in a component,
- -- and rounding up to the next integer.
-
- LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
- -- This is the number of components used to emulate the double
- -- precision floating point number. This value is
- -- automatically adjusted to be consistent with the new
- -- value of TARGET_LONG_NUM_BITS.
-
- The changing of the aforementioned parameters is sufficient to
- 'reprogram' the emulation algorithm to emulate the desired target
- word size.
-
-
- 3.2 Host Word Size Specification and Performance Tuning
-
- The packages comprising the machine arithmetic emulation were coded
- in machine-independent Ada. In achieving this level of portability,
- some of the potential, but machine-dependent, performance improving
- techniques were intentionally ommitted from the design. Several
- methods for improving the performance of the emulation exist which
- rely on utilizing machine and/or compiler dependent features, and
- these methods can be used to tune the performance of the emulation
- when machines and compilers that support the features are available.
- These techniques are discussed in the paragraphs below.
-
- Use the maximum number of bits per target word component possible
- for each host/ compiler combination. The packages support the
- capability to adapt to greater efficiencies available by using the
- host arithmetic capability if it exceeds 16 bits (the restriction of
- the original host compiler). To adapt to a host and compiler
- combination which supports greater than 16 bit integer arithmetic,
- the values of several parameters in the MAE_BASIC_OPERATIONS package
- must be changed. These values are:
-
- NO_COMP_BITS : constant INTEGER := 7;
- -- This value represented the number of bits in each target
- -- word component. It is selected such that arithmetic
- -- operations on components will not overflow the supporting
- -- host arithmetic. The value 7 was selected based on the
- -- present use of 16 bit integers. If 32 bit integer arithmetic
- -- were available, then this value could be as high as 15. The
- -- greater the number of bits in each component, the fewer the
- -- number of components that will be required, and hence the
- -- faster the emulation.
-
- SHORT_NUM_COMPS : constant INTEGER := 6;
- -- This is the number of components used to emulate the
- -- integer and short floating point number. This must
- -- be adjusted to be consistent with the new values of
- -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
- -- The value is given by dividing the number of bits in
- -- the target word by the number of bits in a component,
- -- and rounding up to the next integer.
-
- LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
- -- This is the number of components used to emulate the double
- -- precision floating point number. This value is
- -- automatically adjusted to be consistent with the new
- -- value of TARGET_LONG_NUM_BITS.
-
- Compile the packages using all available compiler optimization
- features. This should result in significantly improved executable
- code, as a result of the compiler performing a variety of useful
- transformations including the removal of many of the unnecessary
- constraint checks inserted by Ada, and the optimal use of registers
- to reduce load and store operations.
-
- Use 'pragma INLINE' to reduce the calling overhead. This should be
- done for the intermediate packages MAE_INTEGER, MAE_SHORT_FLOAT, and
- MAE_LONG_FLOAT to reduce the calling overhead occuring between these
- packages and the bodies of the exported functions of the package
- MACHINE_ARITHMETIC_EMULATION (which are currently implemented as
- single-statement bodies calling the appropriate procedure of the
- intermediate packages). The pragma INLINE could also be applied to
- certain subprograms of the MAE_BASIC_PACKAGE which are short and/or
- only called once per using subprogram (e.g., CHANGE_SIGN and
- ROUND_TO_HOST).
-
- Use 'pragma SUPPRESS' in the arithmetic routines of the package
- MAE_BASIC_OPERATIONS (i.e., '+', '-', '*', '/') to remove
- unnecessary constraint checks. These constraint checks can be
- eliminated because the number of bits utilized in each component has
- been selected to insure that the host arithmetic operations can not
- cause an arithmetic overflow.
- <FF>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- APPENDIX A
-
-
-
- INTERFACE SPECIFICATION
- <FF>
- -------------------------------------------------------------------------------
- -- --
- -- Emulation of Machine Arithmetic - a WIS Ada Tool --
- -- --
- -- Ada Technology Group --
- -- SYSCON Corporation --
- -- 3990 Sherman Street --
- -- San Diego, CA. 92110 --
- -- --
- -- John Long & John Reddan --
- -- --
- -------------------------------------------------------------------------------
-
- with MAE_BASIC_OPERATIONS;
- with MAE_INTEGER;
- with MAE_SHORT_FLOAT;
- with MAE_LONG_FLOAT;
-
- package MACHINE_ARITHMETIC_EMULATION is
- --------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- arithmetic on host machines with 16-bit or larger words.
- -- This package will export support for target integer, real,
- -- and double precision real numbers.
- --
- -- The emulation packages are currently configured to
- -- support Honeywell 36-bit arithmetic.
- --
- -- The ranges for the current configuration are as follows:
- --
- -- TARGET_INTEGER
- -- range of -2**35 to 2**35-1
- -- TARGET_SHORT_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 27 bit binary fraction
- -- exponent => -128 to 127
- -- TARGET_LONG_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 63 bit binary fraction
- -- exponent => -128 to 127
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR". The
- -- exception declared in this package is a rename of
- -- the predefined exception NUMERIC_ERROR. This can be
- -- changed for programs needing to handle arithmetic
- -- exceptions generated by the emulation packages separately.
- --
-
-
- --------------------------------------------------------------------
- -- Parameters within MAE_BASIC_OPERATIONS that need to be available
- -- to the user of the Emulation of Machine Arithmetic package:
- --
- subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
- DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
-
- subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
- TARGET_SHORT_DEFAULT_AFT : FIELD
- renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
- TARGET_LONG_DEFAULT_AFT : FIELD
- renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
- TARGET_SHORT_DEFAULT_EXP : FIELD
- renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
- TARGET_LONG_DEFAULT_EXP : FIELD
- renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
-
- --
- -- predefined attributes for the emulated types
- --
- TARGET_SHORT_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS;
- TARGET_LONG_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS;
-
- TARGET_SHORT_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
- TARGET_LONG_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
-
- TARGET_SHORT_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
- TARGET_LONG_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
-
- TARGET_SHORT_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
- TARGET_LONG_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
-
- TARGET_SHORT_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
- TARGET_LONG_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
-
- TARGET_SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
- TARGET_LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
-
- TARGET_SHORT_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
- TARGET_LONG_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
-
- TARGET_SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
- TARGET_LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
-
- TARGET_SHORT_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
- TARGET_LONG_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_INTEGER
- --
- -- The follow declaration should be private
-
- subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_INTEGER_FIRST return TARGET_INTEGER;
- function TARGET_INTEGER_LAST return TARGET_INTEGER;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "abs" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "+" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "*" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "/" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "rem" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "mod" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "**" (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
- return TARGET_INTEGER;
-
- function TARGET_INTEGER_VALUE (STRING_PIC : STRING)
- return TARGET_INTEGER;
- function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER)
- return STRING;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_INTEGER;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_INTEGER;
- BASE : in NUMBER_BASE := DEFAULT_BASE);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_SHORT_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
-
- function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "abs" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "**" (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER)
- return TARGET_SHORT_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_SHORT_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_SHORT_FLOAT;
- AFT : in FIELD := TARGET_SHORT_DEFAULT_AFT;
- EXP : in FIELD := TARGET_SHORT_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_LONG_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "abs" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "**" (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER)
- return TARGET_LONG_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_LONG_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_LONG_FLOAT;
- AFT : in FIELD := TARGET_LONG_DEFAULT_AFT;
- EXP : in FIELD := TARGET_LONG_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- private
-
- -- Note : Derived types are not supported under
- -- Telesoft version 1.5
-
- -- The types are private to prevent direct manipulation of
- -- the components of the numbers. The exported types
- -- are declarations of the appropriate types from the
- -- respective package.
-
- -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
-
- -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
-
- -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
-
-
- --------------------------------------------------------------------
-
- end MACHINE_ARITHMETIC_EMULATION;
- <FF>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- APPENDIX B
-
-
-
- SAMPLE CODE
- <FF>
-
-
- -- The following code shows a sample procedure which utilizes
- -- the facilities of the MACHINE_ARITHMETIC_EMULATION package
- -- to perform some simple computations.
-
- with MACHINE_ARITHMETIC_EMULATION; use MACHINE_ARITHMETIC_EMULATION;
- with TEXT_IO; use TEXT_IO;
-
- procedure PRINT_SOME_TARGET_SHORT_FLOAT_RESULTS is
- --
- -- This procedure prompts the user for several operands and
- -- then prints the results of selected TARGET_SHORT_FLOAT operations.
- --
- B_RESULT : BOOLEAN;
- LAST : POSITIVE;
- NO_DATA : EXCEPTION;
- POWER : INTEGER;
- RESULTS_STRING : STRING (1..TARGET_SHORT_FLOAT_DIGITS+7);
- SF1, SF2 : TARGET_SHORT_FLOAT;
- SFRESULT, SFRESULT1 : TARGET_SHORT_FLOAT;
-
- procedure GET_TARGET_SHORT_FLOAT_OPERANDS is
- --
- -- Get two TARGET_SHORT_FLOAT operands plus an Integer number for
- -- use as a power in a exponentiation operation
- --
- CNT, CNT1 : NATURAL;
- DONE : BOOLEAN := FALSE;
- EXIT_MENU : exception;
- OP_STRING : STRING (1..80);
- begin
- loop
- begin
- PUT_LINE("MACHINE ARITHMETIC EMULATION");
- PUT_LINE("TARGET_SHORT_FLOAT OPERATIONS");
- PUT_LINE("OPERAND INPUT");
- NEW_LINE;
- TEXT_IO.PUT("OP1 ? ");
- GET_LINE(OP_STRING, CNT);
- if CNT = 0 then
- raise EXIT_MENU;
- end if;
-
- GET (OP_STRING(1..CNT),SF1,LAST);
-
- NEW_LINE;
- TEXT_IO.PUT("POWER ? ");
- GET_LINE(OP_STRING, CNT);
- if CNT = 0 then
- raise EXIT_MENU;
- end if;
-
- INTEGER_IO.GET (OP_STRING(1..CNT),POWER,CNT1);
- -- no INTEGER'value function implemented
-
- NEW_LINE;
- TEXT_IO.PUT("OP2 ? ");
- GET_LINE(OP_STRING, CNT);
- if CNT = 0 then
- raise EXIT_MENU;
- end if;
-
- GET (OP_STRING(1..CNT),SF2,LAST);
-
- DONE := TRUE;
-
- exception
- when EXIT_MENU =>
- raise NO_DATA;
-
- when others =>
- PUT_LINE("*** ILLEGAL DATA ***");
- NEW_LINE;
- TEXT_IO.PUT("return to continue ...");
-
- end;
-
- if DONE then
- exit;
- end if;
- end loop;
-
- end GET_TARGET_SHORT_FLOAT_OPERANDS;
-
-
- begin
-
- -- get the operands
- GET_TARGET_SHORT_FLOAT_OPERANDS;
-
- -- print the results of TARGET_SHORT_FLOAT "+"
- TEXT_IO.PUT("OP1 + OP2 = ");
- SFRESULT := SF1 + SF2;
- PUT(RESULTS_STRING,SFRESULT);
- PUT_LINE(RESULTS_STRING);
-
- -- print the results of TARGET_SHORT_FLOAT "-"
- TEXT_IO.PUT("OP1 - OP2 = ");
- SFRESULT := SF1 - SF2;
- PUT(RESULTS_STRING,SFRESULT);
- PUT_LINE(RESULTS_STRING);
-
- -- print the results of TARGET_SHORT_FLOAT "*"
- TEXT_IO.PUT("OP1 * OP2 = ");
- SFRESULT := SF1 * SF2;
- PUT(RESULTS_STRING,SFRESULT);
- PUT_LINE(RESULTS_STRING);
-
- -- print the results of TARGET_SHORT_FLOAT "/"
- TEXT_IO.PUT("OP1 / OP2 = ");
- SFRESULT := SF1 / SF2;
- PUT(RESULTS_STRING,SFRESULT);
- PUT_LINE(RESULTS_STRING);
-
- -- print the results of TARGET_SHORT_FLOAT ">"
- TEXT_IO.PUT("OP1 > OP2 = ");
- B_RESULT := SF1 > SF2;
- TEXT_IO.PUT(BOOLEAN'image(B_RESULT));
- NEW_LINE;
-
- -- print the results of TARGET_SHORT_FLOAT "**"
- TEXT_IO.PUT("OP1 ** POWER = ");
- SFRESULT1 := SF1 ** POWER;
- PUT(RESULTS_STRING,SFRESULT1);
- PUT_LINE(RESULTS_STRING);
-
- end PRINT_SOME_TARGET_SHORT_FLOAT_RESULTS;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --techinfo.rpt
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
-
-
-
-
-
-
-
-
-
-
- EEEEEE M M AAAAAA
- EE MM MM AA AA
- EEEEEE MM MM AAAAAA
- EE M MM M AA AA
- EEEEEE M MM M AA AA
-
- EMULATION OF MACHINE ARITHMETIC
-
-
-
-
- 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
-
-
-
- 30 JUNE 1985
-
-
-
- Prepared for
-
- Naval Ocean Systems Center,
- WIS Joint Program Office
-
-
- Prepared by
-
- Ada* Technology Group
- SYSCON Corportation
- 3990 Sherman Street
- San Diego, California 92110
-
-
-
-
-
-
-
-
- * Ada is a registered trademark of the
- United States Government - Ada Joint Program Office
- <FF>
-
-
-
- Table of Contents
- -----------------
-
-
- 1. INTRODUCTION
- 1.1 Feature Overview
- 1.2 Basic Usage Overview
-
- 2. SOFTWARE ARCHITECTURE
-
- 3. ALGORITHMS AND DATA STRUCTURES
- 3.1 Requirements
- 3.2 Alternatives and Analysis
- 3.2.1 Alternative Component Architectures
- 3.2.2 Analysis of Component Architectures
- 3.3 Detailed Description of Binary Component Architecture
-
- 4. MACROSCOPIC DESIGN
- 4.1 Package MACHINE_ARITHMETIC_EMULATION
- 4.2 Package MAE_INTEGER
- 4.3 Package MAE_SHORT_FLOAT
- 4.4 Package MAE_LONG_FLOAT
- 4.5 Package MAE_BASIC_OPERATIONS
-
- 5. ADA ISSUES
- 5.1 Compiler Selection
- 5.2 Compiler Impact on Design and Implementation
- 5.3 Configuring the Program
- 5.3.1 Target Word Size Specification
- 5.3.2 Host Word Size Specification and Performance Tuning
-
- 6. TESTING
- 6.1 Unit Testing
- 6.1.1 Approach
- 6.1.2 Results
- 6.2 Integration Testing
- 6.2.1 Approach
- 6.2.2 Results
-
-
- Appendices
-
- A. TEST RESULTS
- A.1 Integer Test Results
- A.2 Short Float Test Results
- A.3 Long Float Test Results
-
- <FF>
-
-
-
- 1. INTRODUCTION
-
- 1.1 Feature Overview
-
- SYSCON Corporation has developed an Emulation of Machine Arithmetic
- (EMA) capability, written in Ada, which supports the emulation of
- machine arithmetic for target processors with arbitrary word length
- on host processors supporting integer arithmetic on 16 bit or larger
- words. This is accomplished by overloading the predefined arithmetic
- operations in package STANDARD (see Appendix C of the Reference
- Manaul for the Ada Programming Language) for target integers, reals,
- and double precision reals. The complete specification of the
- MACHINE_ARITHMETIC_EMULATION package is provided in the Macroscopic
- Design (see Section 4.1). The emulation is accomplished by
- decomposing the target word into components (using Ada record
- structures) easily handled by the host processor's predefined
- arithmetic operations. During the design of the EMA mechanization,
- the computational efficiency and generality (for transportability
- and reusability) of the solution were of primary importance.
-
-
- 1.2 Basic Usage Overview
-
- In the past, conversion of software from one host to another was
- often extensively complicated by the different precisions of the
- host processors and by underlying assumptions in the original
- software about the precision of the hardware. This is particularly
- true for computationally oriented applications requiring extensive
- numerical analysis in the design effort, such as the determination
- of computational ordering to maintain sufficient digits of
- precision.
-
- Ada provides general capabilities, such as overloading and generics,
- which can be used to minimize the direct dependencies of application
- software on the host processor hardware and software. The EMA
- packages are a specific instance of utilizing this general
- capability to remove host dependencies. The packages as delivered
- are configured to emulate 36-bit Honeywell processors and, as such,
- will be highly useful in rehosting and/or converting existing WWMCCS
- applications software with embedded 36-bit accuracy requirements to
- more common 16- and 32-bit hosts. This is accomplished by utilizing
- Ada overloading to permit transparent utilization of target (36-bit)
- accuracy on 16- and 32-bit hardware. Computations of the emulated
- target type are accomplished by incorporating this package via Ada
- 'with' and 'use' clauses, and by changing the operands to the
- appropriate target type defined in the MACHINE_ARITHMETIC_EMULATION
- package.
- <FF>
-
-
- 2. SOFTWARE ARCHITECTURE
-
- The software architecture of the EMA packages is illustrated in
- Figure 2-1, which shows the Ada Graphic Notation for the "MAE"
- subsystem.
-
-
- MAE
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- | |
- | |
- | |
- | MACHINE_ARITHMETIC_EMULATION |
- | ---------------------------- |
- | | | |
- (target_types)----------->| | |
- | | | |
- |target_operations|------>| | |
- | | | |
- <target_exceptions>------>| | |
- | | |--+ |
- | ---------------------------- | |
- | | |
- | +----------------------------------------+ |
- | | MAE_INTEGER |
- | | --------------- |
- | +->| | |
- | | | | |
- | | | |--+ |
- | | --------------- | |
- | | | MAE_BASIC_OPERATIONS |
- | | MAE_SHORT_FLOAT | ---------------- |
- | | --------------- | | | |
- | +->| | +----->| | |
- | | | | | | |--+ |
- | | | |--+ ---------------- | |
- | | --------------- | | |
- | | | +-----------+ |
- | | MAE_LONG_FLOAT | | |
- | | --------------- | +---->|Ada_predefined_ops|
- | +->| | | |
- | | | | |
- | | |--+ |
- | --------------- |
- | |
- -----------------------------------------------------------
-
- Figure 2-1. Ada Graphic Notation for MAE
-
-
- The MAE subsystem consists of the visible package
- MACHINE_ARITHMETIC_EMULATION which contains the exported target
- types and operations, and four supporting packages. The lowest
- level supporting package is MAE_BASIC_OPERATIONS, which provides the
- basic types and operations for emulating machine arithmetic and
- implements the operations using the predefined arithmetic operations
- of the host system. The other support packages, MAE_INTEGER,
- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT, provide support for operations
- on one of the exported types by utilizing MAE_BASIC_OPERATIONS.
-
- The MACHINE_ARITHMETIC_EMULATION package supports arithmetic and
- relational operations on target integers (TARGET_INTEGER), floating
- point numbers (TARGET_SHORT_FLOAT), and double precision floating
- point numbers (TARGET_LONG_FLOAT). The precision of the numbers is
- given below:
-
- where N is the number of bits in the target word
-
- TARGET_INTEGER
- range of -2**(N-1) to 2**(N-1)-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (N-9) bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => (2*N-9) bit binary fraction
-
- thus for 36-bit words the precisons are:
-
- TARGET_INTEGER
- range of -2**35 to 2**35-1
- TARGET_SHORT_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 27-bit binary fraction
- TARGET_LONG_FLOAT
- approximate range of 10**-38 to 10**38 and 0
- exponent => -128 to 127 (8 bits)
- mantissa => 63-bit binary fraction
-
- The precision requirements for the initial configuration of the
- Emulation of Machine Arithmetic are defined by the bit-level storage
- allocation of selected Honeywell processors (mdels 6040, 6060, 6080,
- and DPS8). The 36-bit word precisions are consistent with those given
- in the Honeywell Multics FORTRAN Manual (Order Number AT58) which
- defines the operation of the FORTRAN language on Honeywell 60 series
- hardware.
-
- For each of the supported types, the following operations are
- defined:
- addition arithmetic comparisons
- subtraction numerical conversion
- multiplication unary plus
- division unary minus
- remainder absolute value
- modulo string get
- exponentiation string put
-
- For target integer types, the following attributes are defined:
- 'first
- 'last
- 'image
- 'value
-
- For target floating point types, the following attributes are
- defined:
- 'digits
- 'emax
- 'epsilon
- 'first
- 'large
- 'machine_emax
- 'machine_emin
- 'machine_mantissa
- 'machine_overflows
- 'machine_radix
- 'safe_emax
- 'small
-
- The supported attributes are called by using the form:
-
- <type name>_<attribute_name> -- (e.g., TARGET_INTEGER_FIRST)
-
- The standard tic (') symbol can not be used because the emulated
- types are not directly derived from host types. Instead the tic
- symbol is replaced with an underscore.
-
- The entire set of operations for each of the types is listed in the
- interface specification provided in Section 4. The calling format,
- parameters, and returned values of all of the aforementioned
- operations conform to operations as defined in the package STANDARD
- (see Appendix C of the Reference Manual for the Ada Programming
- Language) for each of the types. The functionality of the
- aforementioned attributes is in accordance with the Ada predefined
- language attributes (see Appendix A of the Reference Manual for the
- Ada Programming Language).
- <FF>
-
- 3. ALGORITHMS AND DATA STRUCTURES
-
- 3.1 Requirements
-
- The purpose of the data structures utilized by the emulation
- packages is to provide a flexible method of storing arithmetic data
- (which exceeds the word size of the host processor) which can be
- efficiently manipulated by an algorithm for emulating machine
- arithmetic. The requirements for the data structure are as follows:
-
- - The data structure must provide the same precision
- as the emulated type of the target processor.
- - The implementation of the data structure must be machine
- independent (e.g., no representation specifications).
- - The data structure must be parameterized to provide a
- flexible approach for emulating arbitrary word sizes.
- - The data structure must segment the emulated word to be
- compatible with 16-bit and larger native operations, and
- be able to take advantage of the greater power of 32-bit
- host arithmetic when available.
- - The data structure must be compatible with computationally
- efficient algorithms.
-
- The purpose of the EMA algorithm is to model the arithmetic
- operations of a target processor with longer word lengths than the
- host processor. This will be done through manipulation of the EMA
- data structures. The requirements for the algorithm are:
-
- - The algorithm must provide the same precision as the
- emulated arithmetic operations of the target processor.
- - The algorithm must be as time efficient as possible.
- - The implementation of the algorithm must be machine
- independent.
-
- The precision requirements for the initial configuration of the
- Emulation of Machine Arithmetic are defined by the bit-level storage
- allocation of selected Honeywell processors (mdels 6040, 6060, 6080,
- and DPS8). The 36-bit word precisions are consistent with those
- given in the Honeywell Multics FORTRAN Manual (Order Number AT58)
- which defines the operation of the FORTRAN language on Honeywell 60
- series hardware. These accuracy requirements are shown in Section 2.
- In implementing the required accuracies, the EMA architecture
- provides parameterized storage allocation in package
- MAE_BASIC_OPERATIONS, which controls the number of bits allocated
- for number constituents (e.g., mantissa and exponent).
-
-
- 3.2 Alternatives and Analysis
-
- The current architecture was selected after an analysis of possible
- alternative methods, that resulted in the determination that fewer
- operations were required with the binary component architecture. The
- predefined arithmetic operations of the supporting host are used to
- manipulate the components (e.g., components are added with the
- standard Integer '+' operation). The size of a component is
- selected to preclude host arithmetic overflow when performing
- component arithmetic. Since the number of component manipulations
- required to complete an emulated operation is proportional to the
- number of components, the size of the component is parameterized so
- that it can be made as large as possible.
-
- 3.2.1 Alternative Component Architectures
-
- The following component architectures were considered during the
- selection of the data representations and algorithms to be used by
- the MAE packages: bit array, binary component, and decimal digit.
- Each of the architectures was considered viable in the sense that it
- could be used to implement an emulation.
-
- The bit array architecture is based on a data structure consisting
- of an array of bits which represents the data. Integers would be a
- simple binary structure with a sign field. Reals would also be a
- binary structure with an implied decimal point preceding the number,
- a sign field, and an appropriately sized exponent field.
-
- The binary component architecture is a modified version of the bit
- array architecture. It is based on a data structure consisting of
- an array of components representing the data. The components can be
- thought of being composed of a group of bits. The size of the
- component is chosen to best match the host system's predefined
- arithmetic operations. Integers would be a simple component array
- structure with a sign field. Reals would be an array structure with
- an implied decimal point preceding the number, a sign field, and an
- appropriately sized exponent field.
-
- The decimal digit architecture is based on a data structure
- consisting of an array of simple decimal digits representing the
- data. Integers would be a simple digit array structure with a sign
- field. Reals would also be an array structure with an implied
- decimal point preceding the number, a sign field, and an
- appropriately sized exponent field.
-
- 3.2.2 Analysis of Component Architectures
-
- Each of the approaches listed in the previous Section was compared
- to determine which method would result in the most time-efficient
- emulation implementation. The comparison was analytical, using
- known facts concerning the relative performance of certain types of
- instructions and the efficiency and availability of operations in
- Ada to evaluate prototypes of each approach. The actual utilization
- of performance measurements from coded prototypes was not possible
- because the necessary instrumentation was not available. In making
- this analysis, no assumptions were made concerning the code
- generation and optimization techniques of the host compiler.
-
- The bit array architecture requires extensive use of low level bit
- operations to be effective and, assuming their availability, this
- technique was considered likely to be the most efficient. Shift
- operations, bit testing, and storage mapping are examples of bit
- operations not available in the Ada language which are required if
- the bit array architecture is to be effective. To obtain the
- necessary bit operations would require the use of machine dependent
- facilities, such as interfacing to assembly language, the use of
- representation clauses, or utilizing assumptions about a compiler's
- method of code generation, which was expressly prohibited by the
- requirements. The lack of these bit mapping facilities led to the
- early rejection of this approach (although it should be noted that
- the bit array architecture is identical to the binary component
- architecture with the group of bits being of size one).
-
- The remaining architectures, binary component and decimal digit were
- compared. A sample integer multiply routine was written in Ada
- using both approaches. The approaches were compared by developing a
- method of counting the operations required to implement the
- algorithms. The method was implemented by inserting statements which
- counted the frequency of selected operations into the code of the
- binary component and decimal digit prototypes. The component size
- used was seven bits, which limits the value of a component to a
- maximum of 127 and makes the positional value of each component a
- power of 128. The decimal digit used the range zero through nine.
- For example, a component number (3, 56, 120), a digit number
- (5,6,4,4,0), and the decimal number 56440 are equivalent since
-
- (3, 56, 120) = 3*(128**2) + 56(128**1) + 120(128**0)
- = 3*16384 + 56*128 + 120
- = 49152 + 7168 + 120
- = 56440
- (5,6,4,4,0) = 5*(10**4) + 6*(10**3) + 4*(10**2) + 4*(10**1) + 0
-
- Not every statement in the algorithms was counted as an operation.
- Some of the statements were considered overhead and, being constant
- across architectures, were ignored. For each of the operations
- selected, a rule was derived for determining its weighting factor.
- The selected operations and their weighting factor rules are:
-
- integer compare to zero = (lowest weight)
- arithmetic compare of integers = 1.5 * integer compare to zero
- integer increment by one = arithmetic compare of integers
- integer add/subtract = 2 * integer increment by one
- modulo/remainder = integer add/subtract
- integer multiply/divide = 2 * integer modulo/remainder
- procedure call = integer multiply/divide
-
- Assigning a weight of two to the integer compare to zero operation,
- yields the following weighting factor values:
-
- integer compare to zero = 2
- arithmetic compare of integers = 3
- integer increment by one = 3
- integer add/subtract = 6
- modulo/remainder = 6
- integer multiply/divide = 12
- procedure call = 12
-
- The choice of the weighting factor rules was based on SYSCON's
- understanding of compiler technology (gained through the development
- of compilers and through our IV&V activities relating to the
- development of the Ada Integrated Environment) and software
- development experience (including the Evaluation of Ada as a
- Communications Language for the Defense Communications Agency).
-
- Some sample results of the tests are shown in Tables 3-1 and 3-2.
- The results show that the binary component architecture code
- required fewer operations than the decimal digit architecure code,
- leading to the conclusion that, in the tested case, the binary
- component approach is more efficient than the bit array and decimal
- digit architectures.
-
- The last factor to be considered in the evaluation was the
- tunability of the architectures. Both of the prototyped
- architectures permit tuning of the algorithms by changing the size
- of the component (number of bits and range of the digits). The
- binary component architecture size is more flexible (increments of 1
- bit instead of 3-4), and is thus better able to efficiently utilize
- the host system's facilities.
-
-
- Table 3-1. Result Summary for Sample Operation
-
- ----------------------------------------------------------------
-
- Operation: 2097151 * 2097151
-
- binary component (127, 127, 127) = 2097151
- decimal digit ('2','0','9','7','1','5','1') = 2097151
-
- This operation would cause maximal intermediate
- overflows with the binary component architecure, and is
- thus a worst case for the binary component architecture.
-
- OPERATION COMPONENT (*WEIGHT) DIGIT (*WEIGHT)
- ----------------------------------------------------------------
- procedure call 24 288 6 72
-
- mult/divide 18 216 56 672
-
- remainder/mod 9 54 - -
-
- add/subtract 33 198 192 1152
-
- increment by one 12 36 64 192
-
- arith compare 33 99 136 408
-
- compare to zero 72 144 84 168
-
- ----------------------------------------------------------------
- TOTAL (*WEIGHT) 1035 2664
- <FF>
-
-
- Table 3-2. Result Summary for Sample Operation
-
- ----------------------------------------------------------------
-
- Operation: 999999 * 999999.
-
- binary component (61, 4, 63)
- decimal digit ('9','9','9','9','9','9')
-
- This operation would cause maximal intermediate
- overflows with the decimal digit architecture, and is
- thus a worst case for the decimal digit architecture.
-
- OPERATION COMPONENT (*WEIGHT) DIGIT (*WEIGHT)
- ----------------------------------------------------------------
- procedure call 21 252 6 72
-
- mult/divide 17 204 57 684
-
- remainder/mod 8 48 - -
-
- add/subtract 30 180 447 2682
-
- increment by one 8 24 318 948
-
- arith compare 30 90 390 1170
-
- compare to zero 72 144 84 168
-
- ----------------------------------------------------------------
- TOTAL (*WEIGHT) 942 5724
-
-
- Thus, in conclusion, the binary component architecture was selected
- for implementation. The details of the architecture are presented
- in the following Section.
-
-
- 3.3 Detailed Description of Binary Component Architecture
-
- The algorithm and data structure selected and refined to meet the
- aforementioned requirements for the Emulation of Machine Arithmetic
- uses a binary component architecture. The binary component
- architecture splits the integer word and floating point mantissa
- into components which can be manipulated using the predefined
- arithmetic operations of Ada. The details of the data structures
- are provided in Section 4, MACROSCOPIC DESIGN. The basic data
- structure is summarized in the Ada PDL shown below:
-
-
- -- number of bits in a component, such that component arithmetic
- -- can not generate an overflow
- -- [currently selected for use with the 16-bit integers]
- NO_COMP_BITS : constant INTEGER := 7;
-
- -- maximum value of a component
- MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
- -- a component
- subtype COMP is INTEGER; -- 16 bit range assumed
- -- an array of components
- type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
-
- -- the sign of a number
- subtype SIGN_TYPE is BOOLEAN;
-
- -- identification of the caller
- type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
- LONG_FLOAT_CLASS);
-
- -- the exponent of a floating type
- subtype EXPONENT_TYPE is INTEGER;
- MIN_EXPONENT_VALUE : constant INTEGER := -128;
- MAX_EXPONENT_VALUE : constant INTEGER := 127;
-
- -- the exponent of a floating type
- subtype EXPONENT_TYPE is INTEGER;
-
- -- this function computes the number of components required
- -- to store the specified number of bits.
- function BITS_TO_COMPS (NO_OF_BITS: NATURAL) return NATURAL;
-
- -- the number of mantissa bits in TARGET_SHORT_FLOAT
- -- which control the digits of precision
- TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
-
- subtype SHORT_COMPONENT_ARRAY is COMPONENT_ARRAY_TYPE
- (1 .. BITS_TO_COMPS(TARGET_SHORT_NUM_BITS));
-
- type SHORT_COMP_ARRAY is
- record
- COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
- CLASS_OF_ARRAY : CLASSIFICATION;
- BITS_SHIFTED : INTEGER;
- end record;
-
- -- the TARGET_SHORT_FLOAT data structure
- type MAE_SHORT_FLOAT_TYPE is
- record
- SIGN : SIGN_TYPE := POSITIVE;
- COMPS : SHORT_COMP_ARRAY;
- EXPONENT : EXPONENT_TYPE;
- end record;
-
-
- The algorithm is implemented by providing common operations, such as
- addition/subtraction/multiplication/division, on component arrays in
- the lowest level package, MAE_BASIC_OPERATIONS. The intermediate
- packages (e.g., MAE_SHORT_FLOAT) then implement the exported
- functions in terms of lower level functions on the components of the
- data structure. The basic algorithm is summarized in the Ada code
- segment shown below:
-
- function "+" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE is
- -- The purpose of this function is to add two
- -- MAE_SHORT_FLOAT_TYPEs.
- RESULT, TEMP : MAE_SHORT_FLOAT_TYPE;
- begin
- -- zero check
- if RIGHT.COMPS.COMPONENT_ARRAY = ZERO.COMPS.COMPONENT_ARRAY then
- RESULT := LEFT;
- NORMALIZE_SHORT_FLOAT(RESULT);
- ROUND_TO_TARGET(RESULT);
- return RESULT;
- elsif LEFT.COMPS.COMPONENT_ARRAY = ZERO.COMPS.COMPONENT_ARRAY then
- RESULT := RIGHT;
- NORMALIZE_SHORT_FLOAT(RESULT);
- ROUND_TO_TARGET(RESULT);
- return RESULT;
- end if;
-
- case (LEFT.SIGN xor RIGHT.SIGN) is
- -- The signs are different (subtraction)
- when TRUE =>
- if LEFT.EXPONENT > RIGHT.EXPONENT then
- TEMP := ALIGN(RIGHT, LEFT.EXPONENT);
- RESULT.COMPS := LEFT.COMPS - TEMP.COMPS;
- RESULT.EXPONENT := LEFT.EXPONENT -
- RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := LEFT.SIGN;
- elsif LEFT.EXPONENT < RIGHT.EXPONENT then
- TEMP := ALIGN(LEFT, RIGHT.EXPONENT);
- RESULT.COMPS := RIGHT.COMPS - TEMP.COMPS;
- RESULT.EXPONENT := RIGHT.EXPONENT -
- RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := RIGHT.SIGN;
- else
- if LEFT.COMPS.COMPONENT_ARRAY > RIGHT.COMPS.COMPONENT_ARRAY
- then
- RESULT.COMPS := LEFT.COMPS - RIGHT.COMPS;
- RESULT.EXPONENT := LEFT.EXPONENT -
- RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := LEFT.SIGN;
- else
- RESULT.COMPS := RIGHT.COMPS - LEFT.COMPS;
- RESULT.EXPONENT := RIGHT.EXPONENT -
- RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := RIGHT.SIGN;
- end if;
- end if;
- -- The signs are the same
- when FALSE =>
- if LEFT.EXPONENT > RIGHT.EXPONENT then
- TEMP := ALIGN(RIGHT, LEFT.EXPONENT);
- RESULT.COMPS := LEFT.COMPS + TEMP.COMPS;
- RESULT.EXPONENT := LEFT.EXPONENT - RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := LEFT.SIGN;
- elsif LEFT.EXPONENT < RIGHT.EXPONENT then
- TEMP := ALIGN(LEFT, RIGHT.EXPONENT);
- RESULT.COMPS := RIGHT.COMPS + TEMP.COMPS;
- RESULT.EXPONENT := RIGHT.EXPONENT -
- RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := RIGHT.SIGN;
- else
- RESULT.COMPS := LEFT.COMPS + RIGHT.COMPS;
- RESULT.EXPONENT := LEFT.EXPONENT - RESULT.COMPS.BITS_SHIFTED;
- RESULT.SIGN := RIGHT.SIGN;
- end if;
-
- end case;
-
- RESULT.COMPS.BITS_SHIFTED := 0;
- if RESULT.COMPS = ZERO.COMPS then
- RESULT.EXPONENT := 0;
- RESULT.SIGN := POS_SIGN;
- end if;
-
- ROUND_TO_TARGET(RESULT);
- return RESULT;
-
- exception
- when others =>
- raise MAE_NUMERIC_ERROR;
-
- end "+";
-
-
- The emulated operations, such as multiplication and division on
- floating point numbers, may need to have intermediate results with
- more precision than the operands. Since extra bits are provided to
- handle the necessary intermediate results and the precision of the
- final result will match the precision of the operands, a rounding
- method was implemented to reduce the intermediate result to the
- precision of the final (exported) result.
-
- The "round to nearest" technique, advocated in the IEEE proposed
- Radix-Independent Standard for Floating-Point Arithmetic, was
- chosen. The representable (within the number of bits in the final
- result) value nearest to the intermediate value is delivered. If
- the two nearest representable values are equally near, then the one
- with its least significant bit equal to zero is delivered. The least
- significant bit refers to the last bit that has importance
- (significance) in the final result. This technique helps to keep
- errors from becoming significant and can be accomplished by checking
- the bits beyond the least significant bit in the intermediate
- result. The first bit beyond the least significant bit in the
- intermediate result is referred to as the guard bit. The logical
- "or" of all the bits after the guard bit, and within the
- intermediate result range, is referred to as the sticky bit.
-
- Table 3-3 illustrates the status of the least significant bit
- before rounding, in the intermediate result, and in the final result
- (after rounding).
-
-
- Table 3-3. Rounding Technique Summary
-
- --------------------------------------------------------------
-
- LSB : the least significant bit
- GUARD : the guard bit, first bit beyond LSB
- STICKY : the logical "or" of all bits beyond GUARD
-
-
- BEFORE ROUNDING AFTER ROUNDING
-
- LSB | GUARD | STICKY || LSB | HOW ROUNDED ?
- --------------------------------------------------------
- 0 | 0 | 0 || 0 | exact
- 0 | 0 | 1 || 0 | down (0<x<.5)
- 0 | 1 | 0 || 0 | down (.5)
- 0 | 1 | 1 || 1 | up (.5<x<1)
- 1 | 0 | 0 || 1 | exact
- 1 | 0 | 1 || 1 | down (0<x<.5)
- 1 | 1 | 0 || 0* | up (.5)
- 1 | 1 | 1 || 0* | up (.5<x<1)
-
- * note that a carry to the bit above the LSB occurs
-
- x is the representative value of the bits beyond
- the LSB proportional to the value of the LSB
-
- The references to 0, .5, and 1, are with respect to the
- least significant bit in the binary representation.
- For example, the representative value of the guard bit
- is one-half the representative value of the least
- significant bit, and the maximum value that can be
- represented by the sticky bit is (.499999 ...) times
- the representative value of the least significant bit.
-
- --------------------------------------------------------------
- <FF>
-
-
- 4. MACROSCOPIC DESIGN
-
- This Section specifies the macroscopic design of the Emulation of
- Machine Arithmetic packages. The design is specified in Ada PDL,
- which was compiled to verify its consistency and syntactical
- correctness. The following subsections specify the Ada PDL of each
- of the constituent packages in the software architecture.
-
-
- 4.1 Package MACHINE_ARITHMETIC_EMULATION
-
-
- with MAE_BASIC_OPERATIONS;
- with MAE_INTEGER;
- with MAE_SHORT_FLOAT;
- with MAE_LONG_FLOAT;
-
- package MACHINE_ARITHMETIC_EMULATION is
- --------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- arithmetic on host machines with 16-bit or larger words.
- -- This package will export support for target integer, real,
- -- and double precision real numbers.
- --
- -- The emulation packages are currently configured to
- -- support Honeywell 36-bit arithmetic.
- --
- -- The ranges for the current configuration are as follows:
- --
- -- TARGET_INTEGER
- -- range of -2**35 to 2**35-1
- -- TARGET_SHORT_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 27 bit binary fraction
- -- exponent => -128 to 127
- -- TARGET_LONG_FLOAT
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => 63 bit binary fraction
- -- exponent => -128 to 127
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR". The
- -- exception declared in this package is a rename of
- -- the predefined exception NUMERIC_ERROR. This can be
- -- changed for programs needing to handle arithmetic
- -- exceptions generated by the emulation packages separately.
- --
-
-
- --------------------------------------------------------------------
- -- Parameters within MAE_BASIC_OPERATIONS that need to be available
- -- to the user of the Emulation of Machine Arithmetic package:
- --
- subtype NUMBER_BASE is MAE_BASIC_OPERATIONS.NUMBER_BASE;
- DEFAULT_BASE : NUMBER_BASE renames MAE_BASIC_OPERATIONS.DEFAULT_BASE;
-
- subtype FIELD is MAE_BASIC_OPERATIONS.FIELD;
- TARGET_SHORT_DEFAULT_AFT : FIELD
- renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_AFT;
- TARGET_LONG_DEFAULT_AFT : FIELD
- renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_AFT;
- TARGET_SHORT_DEFAULT_EXP : FIELD
- renames MAE_BASIC_OPERATIONS.SHORT_DEFAULT_EXP;
- TARGET_LONG_DEFAULT_EXP : FIELD
- renames MAE_BASIC_OPERATIONS.LONG_DEFAULT_EXP;
-
- --
- -- predefined attributes for the emulated types
- --
- TARGET_SHORT_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_DIGITS;
- TARGET_LONG_FLOAT_DIGITS : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_DIGITS;
-
- TARGET_SHORT_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_EMAX;
- TARGET_LONG_FLOAT_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_EMAX;
-
- TARGET_SHORT_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMAX;
- TARGET_LONG_FLOAT_MACHINE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMAX;
-
- TARGET_SHORT_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_EMIN;
- TARGET_LONG_FLOAT_MACHINE_EMIN : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_EMIN;
-
- TARGET_SHORT_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_MANTISSA;
- TARGET_LONG_FLOAT_MACHINE_MANTISSA : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_MANTISSA;
-
- TARGET_SHORT_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_OVERFLOWS;
- TARGET_LONG_FLOAT_MACHINE_OVERFLOWS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_OVERFLOWS;
-
- TARGET_SHORT_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_RADIX;
- TARGET_LONG_FLOAT_MACHINE_RADIX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_RADIX;
-
- TARGET_SHORT_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_MACHINE_ROUNDS;
- TARGET_LONG_FLOAT_MACHINE_ROUNDS : BOOLEAN
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_MACHINE_ROUNDS;
-
- TARGET_SHORT_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.SHORT_FLOAT_SAFE_EMAX;
- TARGET_LONG_FLOAT_SAFE_EMAX : INTEGER
- renames MAE_BASIC_OPERATIONS.LONG_FLOAT_SAFE_EMAX;
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_INTEGER
- --
- -- The follow declaration should be private
-
- subtype TARGET_INTEGER is MAE_INTEGER.MAE_INTEGER_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_INTEGER_FIRST return TARGET_INTEGER;
- function TARGET_INTEGER_LAST return TARGET_INTEGER;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_INTEGER) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "abs" (RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "+" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "-" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "*" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "/" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "rem" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
- function "mod" (LEFT,RIGHT : TARGET_INTEGER) return TARGET_INTEGER;
-
- function "**" (LEFT : TARGET_INTEGER; RIGHT : INTEGER)
- return TARGET_INTEGER;
-
- function TARGET_INTEGER_VALUE (STRING_PIC : STRING)
- return TARGET_INTEGER;
- function TARGET_INTEGER_IMAGE (STORE_PIC : TARGET_INTEGER)
- return STRING;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_INTEGER;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_INTEGER;
- BASE : in NUMBER_BASE := DEFAULT_BASE);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_SHORT_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_SHORT_FLOAT is MAE_SHORT_FLOAT.MAE_SHORT_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
-
- function TARGET_SHORT_FLOAT_EPSILON return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LARGE return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_SMALL return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_LAST return TARGET_SHORT_FLOAT;
- function TARGET_SHORT_FLOAT_FIRST return TARGET_SHORT_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_SHORT_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "abs" (RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_SHORT_FLOAT) return TARGET_SHORT_FLOAT;
-
- function "**" (LEFT : TARGET_SHORT_FLOAT; RIGHT : INTEGER)
- return TARGET_SHORT_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_SHORT_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_SHORT_FLOAT;
- AFT : in FIELD := TARGET_SHORT_DEFAULT_AFT;
- EXP : in FIELD := TARGET_SHORT_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- Visible operations with TARGET_LONG_FLOAT
- --
- -- The following declaration should be private
-
- subtype TARGET_LONG_FLOAT is MAE_LONG_FLOAT.MAE_LONG_FLOAT_TYPE;
-
- -- The defined operators for this type are as follows:
-
- function TARGET_LONG_FLOAT_EPSILON return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LARGE return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_SMALL return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_LAST return TARGET_LONG_FLOAT;
- function TARGET_LONG_FLOAT_FIRST return TARGET_LONG_FLOAT;
-
- -- Predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function "<=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
- function ">=" (LEFT, RIGHT : TARGET_LONG_FLOAT) return BOOLEAN;
-
- function "+" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "abs" (RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "+" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "-" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "*" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
- function "/" (LEFT,RIGHT : TARGET_LONG_FLOAT) return TARGET_LONG_FLOAT;
-
- function "**" (LEFT : TARGET_LONG_FLOAT; RIGHT : INTEGER)
- return TARGET_LONG_FLOAT;
-
- procedure GET (FROM : in STRING;
- ITEM : out TARGET_LONG_FLOAT;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in TARGET_LONG_FLOAT;
- AFT : in FIELD := TARGET_LONG_DEFAULT_AFT;
- EXP : in FIELD := TARGET_LONG_DEFAULT_EXP);
-
- --------------------------------------------------------------------
- -- private
-
- -- Note : Derived types are not supported under
- -- Telesoft version 1.5
-
- -- The types are private to prevent direct manipulation of
- -- the components of the numbers. The exported types
- -- are declarations of the appropriate types from the
- -- respective package.
-
- -- type TARGET_INTEGER is new MAE_INTEGER_TYPE;
-
- -- type TARGET_SHORT_FLOAT is new MAE_SHORT_FLOAT_TYPE;
-
- -- type TARGET_LONG_FLOAT is new MAE_SHORT_LONG_TYPE;
-
-
- --------------------------------------------------------------------
-
- end MACHINE_ARITHMETIC_EMULATION;
-
-
- package body MACHINE_ARITHMETIC_EMULATION is
- --
- -- The package body is implemented by directly calling
- -- the corresponding operations in the MAE_INTEGER,
- -- MAE_SHORT_FLOAT, and MAE_LONG_FLOAT packages.
- --
- end MACHINE_ARITHMETIC_EMULATION;
-
-
- 4.2 Package MAE_INTEGER
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_INTEGER is
- -------------------------------------------------------------------
-
- -- The purpose of this package is to emulate target machine
- -- integer arithmetic on host machines with 16-bit or larger
- -- words.
- --
- -- The range of the supported type is as follows:
- --
- -- TARGET_INTEGER
- -- range of -2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS
- -- to
- -- 2**MAE_BASIC_OPERATIONS.TARGET_INTEGER_NUM_BITS-1
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- --
- -- Visible operations with MAE_INTEGER_TYPE
- --
- type MAE_INTEGER_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_INTEGER_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "-" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "abs" (RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "-" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "*" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "/" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "rem" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
- function "mod" (LEFT,RIGHT : MAE_INTEGER_TYPE) return MAE_INTEGER_TYPE;
-
- function "**" (LEFT : MAE_INTEGER_TYPE; RIGHT : INTEGER)
- return MAE_INTEGER_TYPE;
-
- function MAE_INTEGER_TYPE_VALUE(STRING_PIC : STRING)
- return MAE_INTEGER_TYPE;
-
- function MAE_INTEGER_TYPE_IMAGE(STORE_PIC : MAE_INTEGER_TYPE)
- return STRING;
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_INTEGER_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_INTEGER_TYPE;
- BASE : in NUMBER_BASE := DEFAULT_BASE);
-
- function TARGET_INTEGER_FIRST return MAE_INTEGER_TYPE;
-
- function TARGET_INTEGER_LAST return MAE_INTEGER_TYPE;
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_INTEGER_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : SHORT_COMP_ARRAY := INTEGER_COMP_ARRAY;
- end record;
-
- -------------------------------------------------------------------
- end MAE_INTEGER;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_INTEGER is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_INTEGER type, and in conjunction with
- -- procedures to handle Integer-specific operations such as
- -- carrying and borrowing.
- --
- end MAE_INTEGER;
-
-
- 4.3 Package MAE_SHORT_FLOAT
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_SHORT_FLOAT is
- -------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- floating point arithmetic on host machines with 16-bit or
- -- larger word size.
- --
- -- The range of the supported type is as follows:
- --
- -- TARGET_SHORT_FLOAT (Real)
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => MAE_BASIC_OPERATIONS.TARGET_SHORT_NUM_BITS
- -- bit binary fraction
- -- exponent => -128 to 127
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- --
- -- Visible operations with MAE_SHORT_FLOAT_TYPE
- --
- type MAE_SHORT_FLOAT_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_SHORT_FLOAT_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
- function "-" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
- function "abs" (RIGHT : MAE_SHORT_FLOAT_TYPE) return MAE_SHORT_FLOAT_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "-" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "*" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
- function "/" (LEFT,RIGHT : MAE_SHORT_FLOAT_TYPE)
- return MAE_SHORT_FLOAT_TYPE;
-
- function "**" (LEFT : MAE_SHORT_FLOAT_TYPE; RIGHT : INTEGER)
- return MAE_SHORT_FLOAT_TYPE;
-
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_SHORT_FLOAT_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_SHORT_FLOAT_TYPE;
- AFT : in FIELD := SHORT_DEFAULT_AFT;
- EXP : in FIELD := SHORT_DEFAULT_EXP);
-
- function TARGET_SHORT_FLOAT_EPSILON return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_LARGE return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_SMALL return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_LAST return MAE_SHORT_FLOAT_TYPE;
-
- function TARGET_SHORT_FLOAT_FIRST return MAE_SHORT_FLOAT_TYPE;
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_SHORT_FLOAT_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : SHORT_COMP_ARRAY := SHORT_FLOAT_COMP_ARRAY;
- EXPONENT : EXPONENT_TYPE := 0;
- end record;
-
- -------------------------------------------------------------------
- end MAE_SHORT_FLOAT;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_SHORT_FLOAT is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_SHORT_FLOAT type, and in conjunction with
- -- procedures to handle Integer-specific operations such as
- -- carrying and borrowing.
- --
- end MAE_SHORT_FLOAT;
-
-
- 4.4 Package MAE_LONG_FLOAT
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package MAE_LONG_FLOAT is
- -------------------------------------------------------------------
- -- The purpose of this package is to emulate target machine
- -- double precision floating point arithmetic on host machines
- -- with 16-bit or larger words.
- --
- -- The range of the supported type is as follows:
- --
- -- TARGET_LONG_FLOAT (Double Precision Real)
- -- approximate range of 10**-38 to 10**38 and 0
- -- mantissa => MAE_BASIC_OPERATIONS.TARGET_LONG_NUM_BITS
- -- bit binary fraction
- -- exponent => -128 to 127
- --
- --
- -- Any errors which occur during use of the arithmetic and
- -- boolean functions defined below will result in the
- -- raising of the exception "MAE_NUMERIC_ERROR".
-
- -----------------------------------------------------------------
- -- Visible operations with MAE_LONG_FLOAT_TYPE
- --
- type MAE_LONG_FLOAT_TYPE is private;
-
- -- The defined operators for this type are as follows:
-
- -- predefined system function "=" and function "/="
- function "<" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : MAE_LONG_FLOAT_TYPE) return BOOLEAN;
-
- function "+" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
- function "-" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
- function "abs" (RIGHT : MAE_LONG_FLOAT_TYPE) return MAE_LONG_FLOAT_TYPE;
-
- function "+" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "-" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "*" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
- function "/" (LEFT,RIGHT : MAE_LONG_FLOAT_TYPE)
- return MAE_LONG_FLOAT_TYPE;
-
- function "**" (LEFT : MAE_LONG_FLOAT_TYPE; RIGHT : INTEGER)
- return MAE_LONG_FLOAT_TYPE;
-
-
- procedure GET (FROM : in STRING;
- ITEM : out MAE_LONG_FLOAT_TYPE;
- LAST : out POSITIVE);
-
- procedure PUT (TO : out STRING;
- ITEM : in MAE_LONG_FLOAT_TYPE;
- AFT : in FIELD := LONG_DEFAULT_AFT;
- EXP : in FIELD := LONG_DEFAULT_EXP);
-
- function TARGET_LONG_FLOAT_EPSILON return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_LARGE return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_SMALL return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_LAST return MAE_LONG_FLOAT_TYPE;
-
- function TARGET_LONG_FLOAT_FIRST return MAE_LONG_FLOAT_TYPE;
-
-
- -------------------------------------------------------------------
- private
-
- -- The declaration of the next variable is to allow
- -- the record declaration under the Telesoft version 1.5 compiler.
- -- A better declaration would allow the COMP_ARRAY range to be
- -- (1 .. BITS_TO_COMPS(NO_OF_BITS).
-
- type MAE_LONG_FLOAT_TYPE is
- record
- SIGN : SIGN_TYPE := POS_SIGN;
- COMPS : LONG_COMP_ARRAY := LONG_FLOAT_COMP_ARRAY;
- EXPONENT : EXPONENT_TYPE := 0;
- end record;
-
- -------------------------------------------------------------------
- end MAE_LONG_FLOAT;
-
-
- with MAE_BASIC_OPERATIONS; use MAE_BASIC_OPERATIONS;
-
- package body MAE_LONG_FLOAT is
- --
- -- The package body is implemented by using the subprograms
- -- provided by the MAE_BASIC_OPERATIONS to manipulate the
- -- components of the TARGET_LONG_FLOAT type, and in conjunction with
- -- procedures to handle Integer-specific operations such as
- -- carrying and borrowing.
- --
- end MAE_LONG_FLOAT;
-
-
- 4.5 Package MAE_BASIC_OPERATIONS
-
-
- package MAE_BASIC_OPERATIONS is
- -------------------------------------------------------------------
- -- The emulation packages are currently configured
- -- to support Honeywell 36-bit arithmetic.
- --
- -- The purpose of this package is to provide general machine
- -- arithmetic types and functions to support integer and floating
- -- point variables. The underlying arithmetic operations will
- -- be performed component-wise. It is assumed that the system
- -- provides for integer operations.
-
- -------------------------------------------------------------------
- -- Here are the declarations of the basic constants and variables.
- -- Some of these constants reflect the emulation target and the
- -- implementation host (and compiler) dependencies.
- -- It is possible that changing these constants and variables could
- -- improve software performance. They are the basic elements for
- -- building the MAE_INTEGER_TYPE and MAE_FLOAT_TYPE types.
- --
- -- number of bits in a component
- NO_COMP_BITS : constant INTEGER := 7;
- -- maximum value of a component
- MAX_COMP_VALUE : constant INTEGER := (2**NO_COMP_BITS)-1;
- -- component base value
- BASE_COMP_VALUE : constant INTEGER := MAX_COMP_VALUE+1;
- -- the values associated with a bit position,
- -- initialized in the body of this package
- BIT_VALUE : array (1 .. NO_COMP_BITS) of INTEGER;
- -- a component, note that the range of a true component is
- -- 0 .. MAX_COMP_VALUE, although intermediate values, obtained
- -- during computations, lie outside the range.
- subtype COMP is INTEGER;
- -- an array of components
- type COMPONENT_ARRAY_TYPE is array (NATURAL range <>) of COMP;
- -- the use of representation specifications could direct the
- -- compiler how to store the array and possibly increase efficiency.
- -- note that the least significant COMP is the first in the
- -- array, and consequently the most significant COMP is the last.
- --
- -- most signif least signif
- -- 'last . . 'first
- -- -------------- -------------- --------------
- -- | 1 2 3 .. n | | 1 2 3 .. n | . . | 1 2 3 .. n |
- -- -------------- -------------- --------------
-
- -- Identification of the caller
- type CLASSIFICATION is (INTEGER_CLASS, SHORT_FLOAT_CLASS,
- LONG_FLOAT_CLASS);
-
- -- Declaration for short comp arrays
- SHORT_NUM_COMPS : constant INTEGER := 6;
- SHORT_NUM_BITS : constant INTEGER := SHORT_NUM_COMPS * NO_COMP_BITS;
- subtype SHORT_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. SHORT_NUM_COMPS);
- SHORT_ZERO_ARRAY : constant SHORT_COMPONENT_ARRAY :=
- (1 .. SHORT_NUM_COMPS => 0);
-
- type SHORT_COMP_ARRAY is
- record
- COMPONENT_ARRAY : SHORT_COMPONENT_ARRAY;
- CLASS_OF_ARRAY : CLASSIFICATION;
- BITS_SHIFTED : INTEGER;
- end record;
-
- INTEGER_COMP_ARRAY : SHORT_COMP_ARRAY :=
- (SHORT_ZERO_ARRAY, INTEGER_CLASS, 0);
- SHORT_FLOAT_COMP_ARRAY : SHORT_COMP_ARRAY :=
- (SHORT_ZERO_ARRAY, SHORT_FLOAT_CLASS, 0);
-
- -- The emulated target dependent constants for 36-bit storage
- TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
- TARGET_SHORT_NUM_BITS : constant INTEGER := 28;
-
- -- Declaration for long comp arrays
- LONG_NUM_COMPS : constant INTEGER := (2 * SHORT_NUM_COMPS);
- LONG_NUM_BITS : constant INTEGER := LONG_NUM_COMPS * NO_COMP_BITS;
- subtype LONG_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS);
- LONG_ZERO_ARRAY : LONG_COMPONENT_ARRAY :=
- (1 .. LONG_NUM_COMPS => 0);
-
- type LONG_COMP_ARRAY is
- record
- COMPONENT_ARRAY : LONG_COMPONENT_ARRAY;
- CLASS_OF_ARRAY : CLASSIFICATION;
- BITS_SHIFTED : INTEGER;
- end record;
-
- LONG_FLOAT_COMP_ARRAY : LONG_COMP_ARRAY :=
- (LONG_ZERO_ARRAY, LONG_FLOAT_CLASS, 0);
-
- -- The emulated target dependent constants for 72-bit storage
- TARGET_LONG_NUM_BITS : constant INTEGER := 64;
-
- -- Extended array length for LONG multiplication
- subtype EXTRA_COMPONENT_ARRAY is
- COMPONENT_ARRAY_TYPE (1 .. LONG_NUM_COMPS*2);
- EXTRA_ZERO_ARRAY : EXTRA_COMPONENT_ARRAY :=
- (1 .. LONG_NUM_COMPS*2 => 0);
-
- -- Extended array for spaces filling string arrays
- EMPTY_STRING : STRING (1 .. 40) :=
- " ";
-
- -- the sign of a number
- subtype SIGN_TYPE is BOOLEAN;
- NEG_SIGN : constant BOOLEAN := FALSE;
- POS_SIGN : constant BOOLEAN := TRUE;
- -- the exponent of a floating type
- subtype EXPONENT_TYPE is INTEGER;
- MIN_EXPONENT_VALUE : constant INTEGER := -128;
- MAX_EXPONENT_VALUE : constant INTEGER := 127;
-
- -- The follow declarations specify the value of the most
- -- significant component for the digits ONE .. TEN and their
- -- corresponding exponents. The component values can be thought
- -- of as a binary representation (picture) of the most signif.
- -- comp. Applying the binary exponent as left shifts, it is
- -- easy to see how the digit is obtained. This allows
- -- for the length of the array to change without affecting
- -- the code in the higher level packages.
- POINT_FIVE : constant INTEGER := 2**(NO_COMP_BITS-1);
- POINT_FIVE_SIX_TWO_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-4);
- POINT_SIX_TWO_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-3);
- POINT_SEVEN_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2);
- POINT_EIGHT_SEVEN_FIVE : constant INTEGER :=
- 2**(NO_COMP_BITS-1) + 2**(NO_COMP_BITS-2) + 2**(NO_COMP_BITS-3);
- DIGIT_PICTURE : constant array (1 .. 10) of INTEGER :=
- (POINT_FIVE,
- POINT_FIVE,
- POINT_SEVEN_FIVE,
- POINT_FIVE,
- POINT_SIX_TWO_FIVE,
- POINT_SEVEN_FIVE,
- POINT_EIGHT_SEVEN_FIVE,
- POINT_FIVE,
- POINT_FIVE_SIX_TWO_FIVE,
- POINT_SIX_TWO_FIVE);
- DIGIT_BINARY_EXPONENT : constant array (1 .. 10) of INTEGER :=
- (1, 2, 2, 3, 3, 3, 3, 4, 4, 4);
-
-
- -- String IO constants
- -- the only base available is base 10
- subtype NUMBER_BASE is INTEGER range 2 .. 16;
- DEFAULT_BASE : constant NUMBER_BASE := 10;
- subtype FIELD is INTEGER range 0 .. INTEGER'last;
-
- -- a TeleSoft 1.5 restriction that is detected in the package
- -- above this package does not allow
- -- SHORT_DEFAULT_AFT : constant FIELD := SHORT_FLOAT_DIGITS-1;
- -- LONG_DEFAULT_AFT : constant FIELD := LONG_FLOAT_DIGITS-1;
- SHORT_DEFAULT_AFT : constant FIELD := 7;
- LONG_DEFAULT_AFT : constant FIELD := 17;
-
- SHORT_DEFAULT_EXP : constant FIELD := 3;
- LONG_DEFAULT_EXP : constant FIELD := 3;
-
-
- -- predefined attributes
- LOG_2 : constant FLOAT := 0.30103;
- SHORT_FLOAT_DIGITS : constant INTEGER :=
- INTEGER((FLOAT(TARGET_SHORT_NUM_BITS-1)*LOG_2)-0.5);
- LONG_FLOAT_DIGITS : constant INTEGER :=
- INTEGER((FLOAT(TARGET_LONG_NUM_BITS-1)*LOG_2)-0.5);
- -- the next declaration is not exported from MAE, it
- -- is only used in the integer PUT and IMAGE routines
- INTEGER_DIGITS : constant INTEGER :=
- INTEGER((FLOAT(TARGET_INTEGER_NUM_BITS)*LOG_2)+0.5);
-
- SHORT_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_MACHINE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
- LONG_FLOAT_MACHINE_EMIN : INTEGER renames MIN_EXPONENT_VALUE;
-
- SHORT_FLOAT_MACHINE_MANTISSA : INTEGER
- renames TARGET_SHORT_NUM_BITS;
- LONG_FLOAT_MACHINE_MANTISSA : INTEGER
- renames TARGET_LONG_NUM_BITS;
-
- SHORT_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
- LONG_FLOAT_MACHINE_OVERFLOWS : constant BOOLEAN := TRUE;
-
- SHORT_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
- LONG_FLOAT_MACHINE_RADIX : constant INTEGER := 2;
-
- SHORT_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
- LONG_FLOAT_MACHINE_ROUNDS : constant BOOLEAN := TRUE;
-
- SHORT_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
- LONG_FLOAT_SAFE_EMAX : INTEGER renames MAX_EXPONENT_VALUE;
-
-
- -------------------------------------------------------------------
- -- The exception to be raised for all arithmetic and boolean
- -- functions defined in this package.
- --
- MAE_NUMERIC_ERROR : EXCEPTION renames STANDARD.NUMERIC_ERROR;
-
- -------------------------------------------------------------------
- -- Function to determine the number of components for
- -- the representation.
- --
- function BITS_TO_COMPS (NO_OF_BITS : INTEGER) return INTEGER;
-
- -------------------------------------------------------------------
- -- Operations on the sign
- --
- -- Since the SIGN_TYPE is a BOOLEAN, most of the operations
- -- are assumed system functions
-
- function CHANGE_SIGN (SIGN : SIGN_TYPE) return SIGN_TYPE;
-
- -------------------------------------------------------------------
- -- Operations on the exponent
- --
- -- Since the EXPONENT_TYPE is an INTEGER, the operations
- -- are assumed system functions
-
- -------------------------------------------------------------------
- -- Operations on the component
- --
- -- If the variable NO_COMP_BITS is chosen properly, an assumption
- -- on which the entire package design is based, COMP and any
- -- result of binary operation (except exponentiation which is
- -- never used with COMP) of two COMPs is an INTEGER.
- -- Therefore, the operations are assumed system functions
-
- -------------------------------------------------------------------
- -- Operations on short component arrays
- --
- -- Predefined system functions : function "=" and function "/=".
- -- Comparisons are handled under variable-sized arrays.
- -- The array parameters must have the same length and the same
- -- CLASSIFICATION (both INTEGER_CLASS or both SHORT_FLOAT_CLASS).
- -- The returning result component array will contain the same
- -- number of elements.
- -- For SHORT_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
- -- the array is set for higher level exponent operation.
- -- The SHORT_FLOAT_CLASS array will be normalized by these routines.
- -- Note that the least significant COMP is the first in the
- -- array, and consequently the most significant COMP is the last.
-
- function "+" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "-" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "*" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "/" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
- function "rem" (LEFT,RIGHT : SHORT_COMP_ARRAY) return SHORT_COMP_ARRAY;
-
-
- -------------------------------------------------------------------
- -- Operations on long component arrays
- --
- -- Predefined system functions : function "=" and function "/=".
- -- Comparisions are handled under variable-sized arrays.
- -- The array parameters must have the same length.
- -- The returning result component array will contain the same
- -- number of elements.
- -- For LONG_FLOAT_CLASS parameters, the BITS_SHIFTED variable within
- -- the array is set for higher level exponent operation.
- -- The LONG_FLOAT_CLASS array will be normalized by these routines.
-
- function "+" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "-" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "*" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
- function "/" (LEFT,RIGHT : LONG_COMP_ARRAY) return LONG_COMP_ARRAY;
-
-
- -------------------------------------------------------------------
- -- Operations on variable-sized component arrays
- --
- -- The array parameters are only comprised of components,
- -- no CLASSIFICATION or BITS_SHIFTED info is included.
- -- The array will not be normalized by these routines, that
- -- is the responsibility of a higher level routine.
-
- -- The comparison functions.
- -- Predefined system functions : function "=" and function "/=".
-
- function "<" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function "<=" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function ">" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
- function ">=" (LEFT, RIGHT : COMPONENT_ARRAY_TYPE) return BOOLEAN;
-
- -- This routine performs a divide by two on the array,
- -- with rounding to even.
- procedure DIVIDE_ARRAY_BY_TWO (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
-
- -- This routine sets the range of all individual COMPs within
- -- (0 .. MAX_COMP_VALUE) by looping through the array from the least
- -- significant COMP to the most significant COMP, performing
- -- carries and borrows as necessary. Since the most significant
- -- COMP has nowhere to carry or borrow, it is left unbounded.
- -- This allows the higher level routine to determine if shifting
- -- must occur, an error exists, or whatever.
- procedure RANGE_CHECK (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE);
-
- -- This routine shifts to the right and truncates a
- -- component array. The BITS variable is the number of bits
- -- to shift the array and must be positive.
- procedure ARRAY_TRUNCATION_SHIFT_RIGHT
- (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : in NATURAL);
-
- -- This routine sets the most significant bit in the array to one
- -- (normalized), by shifting the array to the left.
- -- The BITS variable is the number of bits the array was shifted.
- procedure ARRAY_NORMALIZE
- (INTERMEDIATE : in out COMPONENT_ARRAY_TYPE; BITS : out INTEGER);
-
- -------------------------------------------------------------------
- end MAE_BASIC_OPERATIONS;
- <FF>
-
-
- 5. ADA ISSUES
-
- Ada provides a powerful implementation language that is well suited
- to the writing of generalized computational facilities such as the
- Emulation of Machine Arithmetic. Several significant issues relating
- to the use of Ada are relevent to the development and maintenance of
- the EMA software. These issues are 1) compiler selection, 2) the
- impact of utilizing an incomplete non-production quality Ada
- compiler, 3) the methods of adapting the code to emulate target
- machines with different host and target word lengths, and 4) the
- possible methods of tuning the EMA packages to achieve significantly
- improved performance using machine-dependent facilities.
-
- 5.1 Compiler Selection
-
- The design and development activities of the Emulation of Machine
- Arithmetic project were conducted using the Government mandated
- target compiler, which was the most recent release (at the time) of
- the TeleSoft Ada compiler. The TeleSoft compiler release which was
- utilized contained two Ada compiler versions: Version 2.1, which is
- a certified pre-release version of the TeleSoft Ada compiler
- awaiting validation, and Version 1.5, which is an incomplete Ada
- compiler with near-production quality performance in terms of
- compilation speed.
-
- The project was initiated using the Version 2.1 compiler in the
- hopes of utilizing full Ada, with its significant advantages for
- developing generalized code. Unfortunately, the performance and
- support facilities of the Version 2.1 compiler were too poor to
- continue using it beyond the Macroscopic design phase. This
- necessitated a conversion of the project and the design to the
- TeleSoft Version 1.5 compiler. The following shortcomings were the
- principal factors leading to the decision to disgard the Version 2.1
- compiler:
-
- - Extremely slow compilation speed. During Macroscopic
- design and algorithm evaluation, turnaround times normally
- exceeded one hour, and averaged over two hours during normal
- business hours. Extrapolating the turnaround time for
- the full implementation indicated that it was highly probable
- that only two compilations of the emulation system would be
- possible per day.
- - The program library facility was extremely primitive. Each
- time a main program unit was to be recompiled, special
- TeleSoft utilities had to be invoked to reset the tables used
- to track compilation units in the library. The library reset
- facility was slow and subject to errors (i.e., it was easy to
- remove too many or too few units) which would necessitate the
- reinitialization of the library (including recompilation of
- all units).
- - The TeleSoft Ada development system lacked any interactive
- debugging and tracing facilities. Thus, debugging is usually
- reduced to an iterative process consisting of manually
- inserting trace statements in the code under development,
- followed by recompilation, followed by additional testing.
-
-
- The primitive state of the debugging facilities in the TeleSoft
- compiler system made rapid and reliable compilation turnaround a
- necessity. This fact, in combination with the poor compilation
- speed and unreliable program library facilities, made the risk of
- continuing with the Version 2.1 compiler too great.
-
-
- 5.2 Compiler Impact on Design and Implementation
-
- The TeleSoft Version 1.5 compiler used to develop the packages
- comprising the Emulation of Machine Arithmetic lacks numerous Ada
- features, several of which had a significant impact on the design
- and implementation of the system. These features are:
-
- - generics
- - named associations for aggregates and calling parameters
- - dynamic record constructs
- - type attributes (incomplete)
- - universal expressions
- - derived types
- - support for 32-bit Integer arithmetic
-
- In general, the missing facilities prevented the use of dynamic
- calculations to define, initialize, and manipulate data structure
- components, which eventually led to the development of intermediate
- packages supporting the specific target data types required by this
- project. The following paragraphs give some examples of the impact
- on the design and implementation.
-
- The emulation algorithm is designed to use the host machine's native
- arithmetic to efficiently compute results on the components used to
- make up the emulated target types. The number of components needed
- is directly related to the number of bits in a component and the
- number of bits of mantissa to be simulated. In full Ada, the number
- of components, used as a dimension in the emulation data structure,
- can be computed. For example:
-
- subtype SHORT_COMPONENT_ARRAY_TYPE is
- COMPONENT_ARRAY_TYPE (1..BITS_TO_COMPS(TARGET_SHORT_NUM_BITS));
- -- where BITS_TO_COMPS is a function to compute the number
- -- of components required to emulate the specified number
- -- of bits
-
- This approach is not permitted in TeleSoft 1.5 (the function call
- BITS_TO_COMPS is the problem). This problem was largely overcome by
- using parameters (e.g., named numbers) instead. Another related
- problem, the initialization of the arrays whose dimensions are
- controlled by the parameters (and originally the function values),
- was overcome by the use of initialization code in package bodies.
- Ideally the initialization would be performed by:
-
- ZERO_VALUED_SHORT_ARRAY : SHORT_COMPONENT_ARRAY_TYPE :=
- (1..SHORT_COMPONENT_ARRAY_TYPE'last => 0);
-
- However, this too is not permitted in TeleSoft 1.5, due to the
- restriction against named associations. In fact, array aggregates
- can only be of positional types, leading to much more complex
- initialization data and code sequences.
-
- Finally, the lack of generics made it necessary to develop separate
- packages for the target short and long floating point emulations,
- even though the code is virtually identical except for different
- parameters and constant values.
-
-
- 5.3 Configuring the Program
-
- 5.3.1 Target Word Size Specification
-
- The use of a subset Ada compiler (TeleSoft Version 1.5) prevented
- the use of generics and other generalizing features of the Ada
- language in the EMA implementation. This restriction was overcome by
- defining constants and parameters which control the algorithm (e.g.,
- number of components used to represent the target word). These
- parameters were placed in the MAE_BASIC_OPERATIONS package, and can
- be used to configure the machine arithmetic emulation packages to
- support different target machine word sizes. Configuration is
- considered to be the modification of the packages to emulate word
- sizes larger than a given host machine and other than the delivered
- 36-bit emulation.
-
- To configure the EMA packages to support arithmetic operations for
- word sizes other than 36 bits, it is necessary to alter the values
- of several parameters controlling the execution of the emulation.
- These parameters are:
-
- TARGET_INTEGER_NUM_BITS : constant INTEGER := 35;
- -- This is the number of bits (excluding the sign)
- -- in the standard integer number.
-
- TARGET_SHORT_NUM_BITS : constant INTEGER := 27;
- -- This is the number of bits of mantissa in the short
- -- floating point number.
-
- TARGET_LONG_NUM_BITS : constant INTEGER := 63;
- -- This is the number of bits of mantissa in the double
- -- precision floating point number. It is assumed to
- -- be stored in two target words.
-
- SHORT_NUM_COMPS : constant INTEGER := 6;
- -- This is the number of components used to emulate the
- -- integer and short floating point number. This must
- -- be adjusted to be consistent with the new values of
- -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
- -- The value is given by dividing the number of bits in
- -- the target word by the number of bits in a component,
- -- and rounding up to the next integer.
-
- LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
- -- This is the number of components used to emulate the double
- -- precision floating point number. This value is
- -- automatically adjusted to be consistent with the new
- -- value of TARGET_LONG_NUM_BITS.
-
- The changing of the aforementioned parameters is sufficient to
- 'reprogram' the emulation algorithm to emulate the desired target
- word size.
-
-
- 5.3.2 Host Word Size Specification and Performance Tuning
-
- The packages comprising the machine arithmetic emulation were coded
- in machine-independent Ada. To achieve this level of portability,
- some of the potential, but machine-dependent, performance improving
- techniques were intentionally omitted from the design. Several
- methods for improving the performance of the emulation exist which
- rely on utilizing machine and/or compiler-dependent features, and
- these methods can be used to tune the performance of the emulation
- when machines and compilers that support the features are available.
- These techniques are discussed in the paragraphs below.
-
- Use the maximum number of bits per target word component possible
- for each host/compiler combination. The packages support the
- capability to adapt to the greater efficiencies available by using
- the host arithmetic capability if it exceeds 16 bits (the
- restriction of the TeleSoft Version 1.5 compiler). To adapt to a
- host and compiler combination which supports greater than 16-bit
- integer arithmetic, the values of several parameters in the
- MAE_BASIC_OPERATIONS package must be changed. These values are:
-
- NO_COMP_BITS : constant INTEGER := 7;
- -- This value represents the number of bits in each target
- -- word component. It is selected such that arithmetic
- -- operations on components will not overflow the supporting
- -- host arithmetic. The value 7 was selected based on the
- -- present use of 16-bit integers. If 32-bit integer arithmetic
- -- were available, then this value could be as high as 15. The
- -- greater the number of bits in each component, the fewer the
- -- number of components that will be required, and hence the
- -- faster the emulation.
-
- SHORT_NUM_COMPS : constant INTEGER := 6;
- -- This is the number of components used to emulate the
- -- integer and short floating point number. This must
- -- be adjusted to be consistent with the new values of
- -- TARGET_INTEGER_NUM_BITS and TARGET_SHORT_NUM_BITS.
- -- The value is given by dividing the number of bits in
- -- the target word by the number of bits in a component,
- -- and rounding up to the next integer.
-
- LONG_NUM_COMPS : constant INTEGER := 2*SHORT_NUM_COMPS;
- -- This is the number of components used to emulate the double
- -- precision floating point number. This value is
- -- automatically adjusted to be consistent with the new
- -- value of TARGET_LONG_NUM_BITS.
-
- Compile the packages using all available compiler optimization
- features. This should result in significantly improved executable
- code, as a result of the compiler performing a variety of useful
- transformations including the removal of many of the unnecessary
- constraint checks inserted by Ada, and the optimal use of registers
- to reduce load and store operations.
-
- Use 'pragma INLINE' to reduce the calling overhead. This should be
- done for the intermediate packages MAE_INTEGER, MAE_SHORT_FLOAT, and
- MAE_LONG_FLOAT to reduce the calling overhead occuring between these
- packages and the bodies of the exported functions of the package
- MACHINE_ARITHMETIC_EMULATION (which are currently implemented as
- single-statement bodies calling the appropriate procedure of the
- intermediate packages). The 'pragma INLINE' could also be applied to
- certain subprograms of the MAE_BASIC_PACKAGE which are short and/or
- only called once per using subprogram (e.g., CHANGE_SIGN and
- ROUND_TO_HOST).
-
- Use 'pragma SUPPRESS' in the arithmetic routines of the package
- MAE_BASIC_OPERATIONS (i.e., '+', '-', '*', '/') to remove
- unnecessary constraint checks. These constraint checks can be
- eliminated because the number of bits utilized in each component has
- been selected to insure that the host arithmetic operations can not
- cause an arithmetic overflow.
- <FF>
-
- 6. TESTING
-
- The testing of the Emulation of Machine Arithmetic packages was
- quite extensive, as is required for software of this type. The
- testing of the EMA packages was subdivided into two phases: unit
- testing which was performed during the development cycle, and
- integration testing which was performed after the development was
- completed. Each of the two phases of testing made an important
- contribution towards the achievement of a reliable emulation.
-
- 6.1 Unit Testing
-
- 6.1.1 Approach
-
- The EMA design made unit testing during the development cycle
- extremely important. Since the design called for a layered package
- structure, the low level code of the package MAE_BASIC_OPERATIONS,
- which provides facilities to all other EMA packages, needed to be
- tested as it was developed. A thorough check of the operations
- within MAE_BASIC_OPERATION was necessary prior to the testing of any
- of the higher level packages, since the higher level subprograms
- depend on correct results from the lower level routines.
-
- The first step in unit testing was the generation of compilable Ada
- Program Design Language (PDL) specifications for the packages. The
- TeleSoft compiler was then used to identify design deficiencies and
- unsupported Ada language features. As the development of each
- subprogram was completed, each subprogram was hand checked and then
- computer checked by a variety of test programs to insure that it
- produced correct results. The integration of the subprogram, which
- included retesting, verified the completeness and correctness of the
- implementation.
-
- 6.1.2 Results
-
- The testing approach proved to be very valuable in preventing minor
- design flaws and small code errors from expanding into major
- problems. Most design problems were attributed to the utilization of
- non-supported Ada language features. These deficiencies were exposed
- during the generation of the compilable PDL. Coding errors such as
- rounding problems, missing normalization checks, and selection of
- incorrect components were discovered early in the development cycle
- through the use of test drivers at the unit level.
-
-
- 6.2 Integration Testing
-
- 6.2.1 Approach
-
- Integration testing was performed after development of the EMA
- packages was completed. The testing covered both the intermediate
- level packages, which support operations on one of the target types,
- and the top level package MACHINE_ARITHMETIC_EMULATION.
-
- Integration testing began with the development of several individual
- tests which excercised specific code areas. Subsequently, a main
- driver program was developed which combined the individual test
- programs into one, thereby giving the user the flexibility of
- testing different operations without exiting one program and
- starting another. The driver program has menu selected operations,
- which give the user full control over the operations and operands to
- be utilized. The results of the tests are displayed on the user's
- terminal, and are optionally logged in a disk file to allow for
- printed results. The test program also allows the user to output a
- system results trace, that displays the results of the same
- operation using the host system's arithmetic.
-
- Because it is not possible to exhaustively test each operation with
- all possible operand values, the choice of operands for testing is
- critical. The use of randomly selected operands for testing the
- operations would potentially not exercise the EMA packages to the
- necessary extent. The interesting cases for the three types,
- TARGET_INTEGER, TARGET_SHORT_FLOAT, and TARGET_LONG_FLOAT, were
- determined based on the architecture and requirements of the EMA
- package. The interesting cases are primarily constructed with
- boundary values, that are numerically or architecturally at the
- limits of the emulation. The interesting operands are shown in
- Tables 6-1 and 6-2.
-
-
- Table 6-1. Interesting Operands For Target Integers
- -----------------------------------------------------------------
-
- ZERO
- ONE
- (2**35)-1 : the maximum positive value in the range
- integer value = 34359738367
- (2**35) : positive maximum plus one, overflow test
- integer value = 34359738368
- (2**34) : one half positive maximum, overflow test
- integer value = 17179869184
- (2**34)-1 : one half positive maximum minus one,
- overflow test
- integer value = 17179869183
- -(2**35) : the maximum negative value in the range
- integer value = -34359738368
- -(2**34) : one half negative maximum, overflow test
- integer value = -17179869184
-
- <FF>
-
- Table 6-2. Interesting Operands For Target Floating Point
- ---------------------------------------------------------------------
-
- ZERO
- ONE
- (2**127) : the maximum value in the range
- floating value = 1.7014118E+38
- (2**126) : one half the maximum value,
- overflow testing
- floating value = 8.5070592E+37
- 1.0E+31 : a delta value used to cause overflows
- 1.0E+28 : a delta value used to cause overflows
- (2**-129) : the smallest value in the range,
- since (.5*(2**-128)) = (2**-129)
- floating value = 1.469368E-37
- (2**-128) : twice the smallest value,
- underflow to zero testing
- floating value = 2.9387359E-37
-
-
- 6.2.2 Results
-
- The integration testing results included the detection of errors and
- the generation of information on algorithm operation. A large volume
- of printed results was produced, and a sample of them is presented in
- Appendix A.
-
- One code error that the test program exposed was an improper
- handling of a divide by zero exception in the exponentiation
- routine. The error was corrected and then retested with correct
- results. Testing also showed that the slow operation of the test
- program was attributed to the string conversion routines since the
- binary exponent of target floating point types must be changed to a
- decimal exponent within the string. This led to the subsequent
- tuning of the string conversion routines.
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --appdixa.rpt
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- APPENDIX A
-
-
-
- TEST RESULTS
- <FF>
-
-
- A.1 Integer Test Results
-
-
- -- SAMPLE OF OPERATIONS
- INTEGER OPERATIONS RESULTS
-
- OP1 = 4
- OP2 = 2
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = 6
-
- OP1 - OP2 = 2
-
- OP1 * OP2 = 8
-
- OP1 / OP2 = 2
-
- (OP1 / OP2) * OP2 = 4
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 4
- OP2 = -2
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = 2
-
- OP1 - OP2 = 6
-
- OP1 * OP2 = -8
-
- OP1 / OP2 = -2
-
- (OP1 / OP2) * OP2 = 4
- <FF>
-
- -- SAMPLE OF OPERATIONS
- INTEGER OPERATIONS RESULTS
-
- OP1 = -4
- OP2 = 2
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = -2
-
- OP1 - OP2 = -6
-
- OP1 * OP2 = -8
-
- OP1 / OP2 = -2
-
- (OP1 / OP2) * OP2 = -4
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -4
- OP2 = -2
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = -6
-
- OP1 - OP2 = -2
-
- OP1 * OP2 = 8
-
- OP1 / OP2 = 2
-
- (OP1 / OP2) * OP2 = -4
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ZERO
- INTEGER OPERATIONS RESULTS
-
- OP1 = 2
- OP2 = 0
-
- OP1 + OP2 = 2
-
- OP1 - OP2 = 2
-
- OP2 - OP1 = -2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -2
- OP2 = 0
-
- OP1 + OP2 = -2
-
- OP1 - OP2 = -2
-
- OP2 - OP1 = 2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = 2
-
- OP1 + OP2 = 2
-
- OP1 - OP2 = -2
-
- OP2 - OP1 = 2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = -2
-
- OP1 + OP2 = -2
-
- OP1 - OP2 = 2
-
- OP2 - OP1 = -2
- <FF>
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH ZERO
- INTEGER OPERATIONS RESULTS
-
- OP1 = 2
- OP2 = 0
-
- OP1 * OP2 = 0
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -2
- OP2 = 0
-
- OP1 * OP2 = 0
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = 2
-
- OP1 * OP2 = 0
-
- OP1 / OP2 = 0
-
- (OP1 / OP2) * OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = -2
-
- OP1 * OP2 = 0
-
- OP1 / OP2 = 0
-
- (OP1 / OP2) * OP2 = 0
- <FF>
-
- -- COMPARISION OPERATIONS
- -- WITH ZERO
- INTEGER OPERATIONS RESULTS
-
- OP1 = 2
- OP2 = 0
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -2
- OP2 = 0
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = 2
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = -2
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
- <FF>
-
- -- REMAINDER/MODULO OPERATIONS
- -- WITH ZERO
- INTEGER OPERATIONS RESULTS
-
- OP1 = 2
- OP2 = 0
-
- OP1 rem OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -2
- OP2 = 0
-
- OP1 rem OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = 2
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = -2
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
- <FF>
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO
- INTEGER OPERATIONS RESULTS
-
- OP1 = 2
- POWER = 0
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -2
- POWER = 0
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- POWER = 2
-
- OP1 ** POWER = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- POWER = -2
-
- OP1 ** POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO AND ONE
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- POWER = 0
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 1
- POWER = 1
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 1
- POWER = 0
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -1
- POWER = 0
-
- OP1 ** POWER = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- POWER = 1
-
- OP1 ** POWER = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- POWER = -1
-
- OP1 ** POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND (2**35)-1
- INTEGER OPERATIONS RESULTS
-
- OP1 = 34359738367
- OP2 = 0
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = 34359738367
-
- OP1 - OP2 = 34359738367
-
- OP1 * OP2 = 0
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = 34359738367
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 34359738367
-
- OP1 - OP2 = -34359738367
-
- OP1 * OP2 = 0
-
- OP1 / OP2 = 0
-
- (OP1 / OP2) * OP2 = 0
- <FF>
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND -(2**35)
- INTEGER OPERATIONS RESULTS
-
- OP1 = -34359738368
- OP2 = 0
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = -34359738368
-
- OP1 - OP2 = -34359738368
-
- OP1 * OP2 = 0
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 0
- OP2 = -34359738368
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -34359738368
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ONE AND (2**35)-1
- INTEGER OPERATIONS RESULTS
-
- OP1 = 34359738367
- OP2 = 1
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 34359738367
- OP2 = -1
-
- OP1 + OP2 = 34359738366
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ONE AND -(2**35)
- INTEGER OPERATIONS RESULTS
-
- OP1 = -34359738368
- OP2 = 1
-
- OP1 + OP2 = -34359738367
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -34359738368
- OP2 = -1
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH (2**34)
- INTEGER OPERATIONS RESULTS
-
- OP1 = 17179869184
- OP2 = 17179869184
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 17179869184
- OP2 = -17179869184
-
- OP1 + OP2 = 0
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -17179869184
- OP2 = 17179869184
-
- OP1 + OP2 = 0
-
- OP1 - OP2 = -34359738368
-
- OP2 - OP1 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -17179869184
- OP2 = -17179869184
-
- OP1 + OP2 = -34359738368
-
- OP1 - OP2 = 0
-
- OP2 - OP1 = 0
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND (2**34)
- INTEGER OPERATIONS RESULTS
-
- OP1 = 17179869184
- OP2 = 2
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 17179869184
- OP2 = -2
-
- OP1 * OP2 = -34359738368
-
- OP1 / OP2 = -8589934592
-
- (OP1 / OP2) * OP2 = 17179869184
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -17179869184
- OP2 = 2
-
- OP1 * OP2 = -34359738368
-
- OP1 / OP2 = -8589934592
-
- (OP1 / OP2) * OP2 = -17179869184
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -17179869184
- OP2 = -2
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND (2**34)-1
- INTEGER OPERATIONS RESULTS
-
- OP1 = 17179869183
- OP2 = 2
-
- OP1 * OP2 = 34359738366
-
- OP1 / OP2 = 8589934591
-
- (OP1 / OP2) * OP2 = 17179869182
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -17179869183
- OP2 = -2
-
- OP1 * OP2 = 34359738366
-
- OP1 / OP2 = 8589934591
-
- (OP1 / OP2) * OP2 = -17179869182
- <FF>
-
- -- REMAINDER/MODULO OPERATIONS
- -- WITH 10 .. 14 AND 5
- INTEGER OPERATIONS RESULTS
-
- OP1 = 10
- OP2 = 5
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 11
- OP2 = 5
-
- OP1 rem OP2 = 1
-
- OP1 mod OP2 = 1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 12
- OP2 = 5
-
- OP1 rem OP2 = 2
-
- OP1 mod OP2 = 2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 13
- OP2 = 5
-
- OP1 rem OP2 = 3
-
- OP1 mod OP2 = 3
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 14
- OP2 = 5
-
- OP1 rem OP2 = 4
-
- OP1 mod OP2 = 4
- <FF>
-
- -- REMAINDER/MODULO OPERATIONS
- -- WITH -10 .. -14 AND 5
- INTEGER OPERATIONS RESULTS
-
- OP1 = -10
- OP2 = 5
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -11
- OP2 = 5
-
- OP1 rem OP2 = -1
-
- OP1 mod OP2 = 4
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -12
- OP2 = 5
-
- OP1 rem OP2 = -2
-
- OP1 mod OP2 = 3
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -13
- OP2 = 5
-
- OP1 rem OP2 = -3
-
- OP1 mod OP2 = 2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -14
- OP2 = 5
-
- OP1 rem OP2 = -4
-
- OP1 mod OP2 = 1
- <FF>
-
- -- REMAINDER/MODULO OPERATIONS
- -- WITH 10 .. 14 AND -5
- INTEGER OPERATIONS RESULTS
-
- OP1 = 10
- OP2 = -5
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 11
- OP2 = -5
-
- OP1 rem OP2 = 1
-
- OP1 mod OP2 = -4
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 12
- OP2 = -5
-
- OP1 rem OP2 = 2
-
- OP1 mod OP2 = -3
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 13
- OP2 = -5
-
- OP1 rem OP2 = 3
-
- OP1 mod OP2 = -2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = 14
- OP2 = -5
-
- OP1 rem OP2 = 4
-
- OP1 mod OP2 = -1
- <FF>
-
- -- REMAINDER/MODULO OPERATIONS
- -- WITH -10 .. -14 AND -5
- INTEGER OPERATIONS RESULTS
-
- OP1 = -10
- OP2 = -5
-
- OP1 rem OP2 = 0
-
- OP1 mod OP2 = 0
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -11
- OP2 = -5
-
- OP1 rem OP2 = -1
-
- OP1 mod OP2 = -1
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -12
- OP2 = -5
-
- OP1 rem OP2 = -2
-
- OP1 mod OP2 = -2
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -13
- OP2 = -5
-
- OP1 rem OP2 = -3
-
- OP1 mod OP2 = -3
-
- INTEGER OPERATIONS RESULTS
-
- OP1 = -14
- OP2 = -5
-
- OP1 rem OP2 = -4
-
- OP1 mod OP2 = -4
- <FF>
-
-
- A.2 Short Float Test Results
-
-
- -- SAMPLE OF OPERATIONS
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 5.0000000E-01
- OP2 = 1.0000000E+01
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 1.0500000E+01
-
- OP1 - OP2 = -9.5000000E+00
-
- OP1 * OP2 = 5.0000000E+00
-
- OP1 / OP2 = 5.0000000E-02
-
- (OP1 / OP2) * OP2 = 5.0000000E-01
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 5.0000000E-01
- OP2 = -1.0000000E+01
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -9.5000000E+00
-
- OP1 - OP2 = 1.0500000E+01
-
- OP1 * OP2 = -5.0000000E+00
-
- OP1 / OP2 = -5.0000000E-02
-
- (OP1 / OP2) * OP2 = 5.0000000E-01
- <FF>
-
-
- -- SAMPLE OF OPERATIONS
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -5.0000000E-01
- OP2 = 1.0000000E+01
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 9.5000000E+00
-
- OP1 - OP2 = -1.0500000E+01
-
- OP1 * OP2 = -5.0000000E+00
-
- OP1 / OP2 = -5.0000000E-02
-
- (OP1 / OP2) * OP2 = -5.0000000E-01
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -5.0000000E-01
- OP2 = -1.0000000E+01
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -1.0500000E+01
-
- OP1 - OP2 = 9.5000000E+00
-
- OP1 * OP2 = 5.0000000E+00
-
- OP1 / OP2 = 5.0000000E-02
-
- (OP1 / OP2) * OP2 = -5.0000000E-01
- <FF>
-
- -- SAMPLE OF OPERATIONS
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.0000000E+00
- OP2 = 3.0000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 4.0000000E+00
-
- OP1 - OP2 = -2.0000000E+00
-
- OP1 * OP2 = 3.0000000E+00
-
- OP1 / OP2 = 3.3333333E-01
-
- (OP1 / OP2) * OP2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.0000000E+00
- OP2 = 3.0000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 5.0000000E+00
-
- OP1 - OP2 = -1.0000000E+00
-
- OP1 * OP2 = 6.0000000E+00
-
- OP1 / OP2 = 6.6666667E-01
-
- (OP1 / OP2) * OP2 = 2.0000000E+00
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ZERO
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 + OP2 = 4.0000000E-01
-
- OP1 - OP2 = 4.0000000E-01
-
- OP2 - OP1 = -4.0000000E-01
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 + OP2 = -4.0000000E-01
-
- OP1 - OP2 = -4.0000000E-01
-
- OP2 - OP1 = 4.0000000E-01
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = 4.0000000E-01
-
- OP1 + OP2 = 4.0000000E-01
-
- OP1 - OP2 = -4.0000000E-01
-
- OP2 - OP1 = 4.0000000E-01
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = -4.0000000E-01
-
- OP1 + OP2 = -4.0000000E-01
-
- OP1 - OP2 = 4.0000000E-01
-
- OP2 - OP1 = -4.0000000E-01
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH ZERO
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = 4.0000000E-01
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = -4.0000000E-01
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
- <FF>
-
-
- -- COMPARISION OPERATIONS
- -- WITH ZERO
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.0000000E-01
- OP2 = 0.0000000E+00
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = 4.0000000E-01
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = -4.0000000E-01
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
- <FF>
-
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.0000000E-01
- POWER = 0
-
- OP1 ** POWER = 1.0000000E+00
-
- OP1 ** -POWER = 1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.0000000E-01
- POWER = 0
-
- OP1 ** POWER = 1.0000000E+00
-
- OP1 ** -POWER = 1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- POWER = 4
-
- OP1 ** POWER = 0.0000000E+00
-
- OP1 ** -POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO AND ONE
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.0000000E+00
-
- OP1 ** -POWER = 1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.0000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.0000000E+00
-
- OP1 ** -POWER = 1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.0000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.0000000E+00
-
- OP1 ** -POWER = 1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.0000000E+00
- POWER = -1
-
- OP1 ** POWER = -1.0000000E+00
-
- OP1 ** -POWER = -1.0000000E+00
-
- RESULT1 * RESULT2 = 1.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- POWER = 1
-
- OP1 ** POWER = 0.0000000E+00
-
- OP1 ** -POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND NEAR (2**127)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.7014118E+38
- OP2 = 0.0000000E+00
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = 1.7014118E+38
-
- OP1 - OP2 = 1.7014118E+38
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = 1.7014118E+38
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 1.7014118E+38
-
- OP1 - OP2 = -1.7014118E+38
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
- <FF>
-
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND NEAR -(2**127)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.7014118E+38
- OP2 = 0.0000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = -1.7014118E+38
-
- OP1 - OP2 = -1.7014118E+38
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.0000000E+00
- OP2 = -1.7014118E+38
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -1.7014118E+38
-
- OP1 - OP2 = 1.7014118E+38
-
- OP1 * OP2 = 0.0000000E+00
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH NEAR (2**127)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.7014118E+38
- OP2 = 1.0000000E+31
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.7014118E+38
- OP2 = -1.0000000E+31
-
- OP1 + OP2 = 1.7014117E+38
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.7014118E+38
- OP2 = 1.0000000E+31
-
- OP1 + OP2 = -1.7014117E+38
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.7014118E+38
- OP2 = -1.0000000E+31
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR (2**126)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 8.5070592E+37
- OP2 = 2.0000000E+00
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 8.5070591E+37
- OP2 = 2.0000000E+00
-
- OP1 * OP2 = 1.7014118E+38
-
- OP1 / OP2 = 4.2535296E+37
-
- (OP1 / OP2) * OP2 = 8.5070591E+37
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR -(2**126)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -8.5070592E+37
- OP2 = 2.0000000E+00
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -8.5070591E+37
- OP2 = 2.0000000E+00
-
- OP1 * OP2 = -1.7014118E+38
-
- OP1 / OP2 = -4.2535296E+37
-
- (OP1 / OP2) * OP2 = -8.5070591E+37
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ZERO AND NEAR (2**-129)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.4693680E-39
- OP2 = 0.0000000E+00
-
- OP1 + OP2 = 1.4693680E-39
-
- OP1 - OP2 = 1.4693680E-39
-
- OP2 - OP1 = -1.4693680E-39
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.4693680E-39
- OP2 = 0.0000000E+00
-
- OP1 + OP2 = -1.4693680E-39
-
- OP1 - OP2 = -1.4693680E-39
-
- OP2 - OP1 = 1.4693680E-39
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH (2**-128) AND NEAR (2**-129)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.9387359E-39
- OP2 = 1.4693680E-39
-
- OP1 + OP2 = 4.4081039E-39
-
- OP1 - OP2 = 0.0000000E+00
-
- OP2 - OP1 = 0.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.9387359E-39
- OP2 = -1.4693680E-39
-
- OP1 + OP2 = 0.0000000E+00
-
- OP1 - OP2 = 4.4081039E-39
-
- OP2 - OP1 = -4.4081039E-39
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.9387359E-39
- OP2 = 1.4693680E-39
-
- OP1 + OP2 = 0.0000000E+00
-
- OP1 - OP2 = -4.4081039E-39
-
- OP2 - OP1 = 4.4081039E-39
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.9387359E-39
- OP2 = -1.4693680E-39
-
- OP1 + OP2 = -4.4081039E-39
-
- OP1 - OP2 = 0.0000000E+00
-
- OP2 - OP1 = 0.0000000E+00
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR (2**-128)
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.9387358E-39
- OP2 = 2.0000000E+00
-
- OP1 * OP2 = 5.8774716E-39
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.9387358E-39
- OP2 = 2.0000000E+00
-
- OP1 * OP2 = -5.8774716E-39
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.9387358E-39
- OP2 = -2.0000000E+00
-
- OP1 * OP2 = -5.8774716E-39
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
-
- SHORT_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.9387358E-39
- OP2 = -2.0000000E+00
-
- OP1 * OP2 = 5.8774716E-39
-
- OP1 / OP2 = 0.0000000E+00
-
- (OP1 / OP2) * OP2 = 0.0000000E+00
- <FF>
-
-
- A.3 Long Float Test Results
-
-
- -- SAMPLE OF OPERATIONS
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 5.00000000000000000E-01
- OP2 = 1.00000000000000000E+01
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 1.05000000000000284E+01
-
- OP1 - OP2 = -9.50000000000000000E+00
-
- OP1 * OP2 = 5.00000000000000000E+00
-
- OP1 / OP2 = 5.00000000000000000E-02
-
- (OP1 / OP2) * OP2 = 5.00000000000000000E-01
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 5.00000000000000000E-01
- OP2 = -1.00000000000000000E+01
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -9.50000000000000000E+00
-
- OP1 - OP2 = 1.05000000000000284E+01
-
- OP1 * OP2 = -5.00000000000000000E+00
-
- OP1 / OP2 = -5.00000000000000000E-02
-
- (OP1 / OP2) * OP2 = 5.00000000000000000E-01
- <FF>
-
-
- -- SAMPLE OF OPERATIONS
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -5.00000000000000000E-01
- OP2 = 1.00000000000000000E+01
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 9.50000000000000000E+00
-
- OP1 - OP2 = -1.05000000000000284E+01
-
- OP1 * OP2 = -5.00000000000000000E+00
-
- OP1 / OP2 = -5.00000000000000000E-02
-
- (OP1 / OP2) * OP2 = -5.00000000000000000E-01
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -5.00000000000000000E-01
- OP2 = -1.00000000000000000E+01
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -1.05000000000000284E+01
-
- OP1 - OP2 = 9.50000000000000000E+00
-
- OP1 * OP2 = 5.00000000000000000E+00
-
- OP1 / OP2 = 5.00000000000000000E-02
-
- (OP1 / OP2) * OP2 = -5.00000000000000000E-01
- <FF>
-
-
- -- SAMPLE OF OPERATIONS
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.00000000000000000E+00
- OP2 = 3.00000000000000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 4.00000000000000000E+00
-
- OP1 - OP2 = -2.00000000000000000E+00
-
- OP1 * OP2 = 3.00000000000000000E+00
-
- OP1 / OP2 = 3.33333333333333333E-01
-
- (OP1 / OP2) * OP2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.00000000000000000E+00
- OP2 = 3.00000000000000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 5.00000000000000000E+00
-
- OP1 - OP2 = -1.00000000000000000E+00
-
- OP1 * OP2 = 6.00000000000000000E+00
-
- OP1 / OP2 = 6.66666666666666667E-01
-
- (OP1 / OP2) * OP2 = 2.00000000000000000E+00
- <FF>
-
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ZERO
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 + OP2 = 4.00000000000000000E-01
-
- OP1 - OP2 = 4.00000000000000000E-01
-
- OP2 - OP1 = -4.00000000000000000E-01
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 + OP2 = -4.00000000000000000E-01
-
- OP1 - OP2 = -4.00000000000000000E-01
-
- OP2 - OP1 = 4.00000000000000000E-01
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = 4.00000000000000000E-01
-
- OP1 + OP2 = 4.00000000000000000E-01
-
- OP1 - OP2 = -4.00000000000000000E-01
-
- OP2 - OP1 = 4.00000000000000000E-01
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = -4.00000000000000000E-01
-
- OP1 + OP2 = -4.00000000000000000E-01
-
- OP1 - OP2 = 4.00000000000000000E-01
-
- OP2 - OP1 = -4.00000000000000000E-01
- <FF>
-
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH ZERO
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = 4.00000000000000000E-01
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = -4.00000000000000000E-01
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
- <FF>
-
-
- -- COMPARISION OPERATIONS
- -- WITH ZERO
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.00000000000000000E-01
- OP2 = 0.00000000000000000E+00
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = 4.00000000000000000E-01
-
- OP1 > OP2 = FALSE
-
- OP1 >= OP2 = FALSE
-
- OP1 < OP2 = TRUE
-
- OP1 <= OP2 = TRUE
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = -4.00000000000000000E-01
-
- OP1 > OP2 = TRUE
-
- OP1 >= OP2 = TRUE
-
- OP1 < OP2 = FALSE
-
- OP1 <= OP2 = FALSE
- <FF>
-
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 4.00000000000000000E-01
- POWER = 0
-
- OP1 ** POWER = 1.00000000000000000E+00
-
- OP1 ** -POWER = 1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -4.00000000000000000E-01
- POWER = 0
-
- OP1 ** POWER = 1.00000000000000000E+00
-
- OP1 ** -POWER = 1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- POWER = 4
-
- OP1 ** POWER = 0.00000000000000000E+00
-
- OP1 ** -POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- EXPONENTIATION OPERATIONS
- -- WITH ZERO AND ONE
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.00000000000000000E+00
-
- OP1 ** -POWER = 1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.00000000000000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.00000000000000000E+00
-
- OP1 ** -POWER = 1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.00000000000000000E+00
- POWER = 0
-
- OP1 ** POWER = 1.00000000000000000E+00
-
- OP1 ** -POWER = 1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.00000000000000000E+00
- POWER = -1
-
- OP1 ** POWER = -1.00000000000000000E+00
-
- OP1 ** -POWER = -1.00000000000000000E+00
-
- RESULT1 * RESULT2 = 1.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- POWER = 1
-
- OP1 ** POWER = 0.00000000000000000E+00
-
- OP1 ** -POWER =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND NEAR (2**127)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.70141183460000000E+38
- OP2 = 0.00000000000000000E+00
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = 1.70141183460000000E+38
-
- OP1 - OP2 = 1.70141183460000000E+38
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = 1.70141183460000000E+38
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = 1.70141183460000000E+38
-
- OP1 - OP2 = -1.70141183460000000E+38
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
- <FF>
-
- -- SAMPLE OPERATIONS
- -- WITH ZERO AND NEAR -(2**127)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.70141183460000000E+38
- OP2 = 0.00000000000000000E+00
-
- OP1 >= OP2 = FALSE
-
- OP1 + OP2 = -1.70141183460000000E+38
-
- OP1 - OP2 = -1.70141183460000000E+38
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 0.00000000000000000E+00
- OP2 = -1.70141183460000000E+38
-
- OP1 >= OP2 = TRUE
-
- OP1 + OP2 = -1.70141183460000000E+38
-
- OP1 - OP2 = 1.70141183460000000E+38
-
- OP1 * OP2 = 0.00000000000000000E+00
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH NEAR (2**127)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.70141183460000000E+38
- OP2 = 1.00000000000000000E+28
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.70141183460000000E+38
- OP2 = -1.00000000000000000E+28
-
- OP1 + OP2 = 1.70141183450000000E+38
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.70141183460000000E+38
- OP2 = 1.00000000000000000E+28
-
- OP1 + OP2 = -1.70141183450000000E+38
-
- OP1 - OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.70141183460000000E+38
- OP2 = -1.00000000000000000E+28
-
- OP1 + OP2 =
- *** EXCEPTION CONDITION RAISED ***
- <FF>
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR (2**126)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 8.50705917400000000E+37
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 8.50705917300000000E+37
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 = 1.70141183460000000E+38
-
- OP1 / OP2 = 4.25352958650000000E+37
-
- (OP1 / OP2) * OP2 = 8.50705917300000000E+37
- <FF>
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR -(2**126)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -8.50705917400000000E+37
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 =
- *** EXCEPTION CONDITION RAISED ***
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -8.50705917300000000E+37
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 = -1.70141183460000000E+38
-
- OP1 / OP2 = -4.25352958650000000E+37
-
- (OP1 / OP2) * OP2 = -8.50705917300000000E+37
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH ZERO AND NEAR (2**-129)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 1.46936794000000000E-39
- OP2 = 0.00000000000000000E+00
-
- OP1 + OP2 = 1.46936794000000000E-39
-
- OP1 - OP2 = 1.46936794000000000E-39
-
- OP2 - OP1 = -1.46936794000000000E-39
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -1.46936794000000000E-39
- OP2 = 0.00000000000000000E+00
-
- OP1 + OP2 = -1.46936794000000000E-39
-
- OP1 - OP2 = -1.46936794000000000E-39
-
- OP2 - OP1 = 1.46936794000000000E-39
- <FF>
-
- -- ADD/SUBTRACT OPERATIONS
- -- WITH NEAR (2**-128) AND NEAR (2**-129)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.93873587000000000E-39
- OP2 = 1.46936794000000000E-39
-
- OP1 + OP2 = 4.40810381000000000E-39
-
- OP1 - OP2 = 0.00000000000000000E+00
-
- OP2 - OP1 = 0.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.93873587000000000E-39
- OP2 = -1.46936794000000000E-39
-
- OP1 + OP2 = 0.00000000000000000E+00
-
- OP1 - OP2 = 4.40810381000000000E-39
-
- OP2 - OP1 = -4.40810381000000000E-39
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.93873587000000000E-39
- OP2 = 1.46936794000000000E-39
-
- OP1 + OP2 = 0.00000000000000000E+00
-
- OP1 - OP2 = -4.40810381000000000E-39
-
- OP2 - OP1 = 4.40810381000000000E-39
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.93873587000000000E-39
- OP2 = -1.46936794000000000E-39
-
- OP1 + OP2 = -4.40810381000000000E-39
-
- OP1 - OP2 = 0.00000000000000000E+00
-
- OP2 - OP1 = 0.00000000000000000E+00
- <FF>
-
- -- MULTIPLY/DIVIDE OPERATIONS
- -- WITH TWO AND NEAR (2**-128)
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = 2.93873587000000000E-39
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 = 5.87747174000000000E-39
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.93873587000000000E-39
- OP2 = 2.00000000000000000E+00
-
- OP1 * OP2 = -5.87747174000000000E-39
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
-
- LONG_FLOAT OPERATIONS RESULTS
-
- OP1 = -2.93873587000000000E-39
- OP2 = -2.00000000000000000E+00
-
- OP1 * OP2 = 5.87747174000000000E-39
-
- OP1 / OP2 = 0.00000000000000000E+00
-
- (OP1 / OP2) * OP2 = 0.00000000000000000E+00
-
-
-