Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 1 OVERVIEWConverting Data Files from MPE V/E to MPE/iX |
|
When converting files from MPE V/E to MPE/iX, you must consider several differences in data storage, including:
MPE/iX has many data type differences from MPE V/E, in terms of concepts of data storage, differences in data storage techniques, and implications for the programmer in handling them. For an overview of data conversion, refer to Introduction to MPE/iX for MPE V Programmers (30367-90005). For detailed information on MPE/iX data types, refer to Data Types Conversion Programmer's Guide (32650-90015). It describes the utilities for converting MPE V/E binary data files to MPE/iX native mode format. Differences integral to the conversion of MPE V/E data files to MPE/iX are:
MPE/iX is the same as MPE V/E for most data conversions, except for floating-point decimal numbers. An intrinsic called HPFPCONVERT, included in MPE/iX, converts floating-point decimal number formats. Data alignment and real number storage formats differ in MPE/iX from their MPE V/E implementations. MPE V/E and MPE/iX each have a different word size; MPE/iX has a 32-bit word size, and MPE V/E has a 16-bit word size. Therefore, applications to be compiled on MPE/iX to run in Native Mode using MPE V/E-compatible data files, may have to select the HP3000_16 compiler directive that is provided with Native Mode compilers. This option causes the compiler to:
Many data structures that are aligned on 16-bit boundaries on MPE V/E are aligned on 32-bit boundaries on MPE/iX. On MPE/iX, 32-bit data types are aligned on 32-bit boundaries, by default, to improve performance. Figure 1-11 “HP FORTRAN 77/iX COMMON Block Data Alignment Example” shows the differences in data alignment between MPE V/E and MPE/iX with an HP FORTRAN 77/iX example. Native alignment for some HP Pascal/iX, COBOL II/XL, and HP FORTRAN 77/iX data types is different than that used by languages running on MPE V/E. For tables comparing alignment by data type, refer to Introduction to MPE/iX for MPE V Programmers (30367-90005). If an application uses both native aligned data files and MPE V/E aligned data files, an alignment directive should be specified in the program record definitions to force MPE/iX or MPE V/E-aligned records on a structure-by-structure basis. MPE/iX compilers offer two directives to specify MPE/iX or MPE V/E alignment, HP3000_32 and HP3000_16. For more information on these directives, refer to the programmer's guide for the appropriate language in the Language Series.
Native Mode (NM) words and integers are different from Compatibility Mode (CM) words. Table 1-1 “Word and Integer Conversions” shows the proper conversions. In this manual, NM words are implied, unless a CM prefix is added to a term. Table 1-1 Word and Integer Conversions
Integers in MPE/iX can be 16 or 32 bits long, signed, or unsigned. Signed integers are in twos complement form. Halfword integers (16-bit) are stored in memory at even byte addresses, and word integers (32-bit) at addresses divisible by four. Real numbers in MPE/iX are stored in one of two floating-point formats. The two methods of storing floating-point numbers in the MPE/iX environment are: HP 3000 format, and according to IEEE Task P854. The default MPE/iX Native Mode (NM) real number representation conforms to IEEE Task P854. This standard specifies a storage format different than that used in MPE V/E-based HP 3000 systems. The real number format for a particular application can be forced to the HP 3000 representation by specifying the HP3000_16 compiler directive. Since this compiler directive selects both MPE V/E alignment and real number format, native aligned data must then be aligned on a per record basis. A single source module can use only one real number format, but the HPFPCONVERT intrinsic converts real numbers between the various formats. Separate (external) procedures may use different formats. The formats have different precisions and ranges for both single-precision and double-precision real numbers. Because of accuracy differences between IEEE and HP 3000 double real numbers, the least significant digit may be lost in 16-digit real numbers. Since the HP 3000 double precision range is smaller than the IEEE double real range, conversion from a very large or small one in IEEE to one in HP 3000 may cause an overflow or underflow. For a comparison of the real number representation on MPE V/E and MPE/iX, refer to Introduction to MPE/iX for MPE V Programmers (30367-90005). Figure 1-12 “IEEE Single-precision Real Number Format” and Figure 1-13 “IEEE Double-precision Real Number Format” show the internal representation for floating-point numbers on MPE/iX. Conversion from HP 3000 format to IEEE format for a single-precision real number can present a range problem, because the IEEE range is smaller. Thus, overflow can occur in performing either of the following conversions:
You may have to develop new error handling code to prevent overflow. The mantissa of an HP 3000 double-precision real number provides enough bits for 16 digits of accuracy. The mantissa of an IEEE double-precision real number provides for 15.9 digits of accuracy. Thus, converting double-precision real numbers from HP 3000 to IEEE format can incur an extremely small loss of numeric precision. However, if the requirements of an application depend on the ASCII representation of floating-point results, the effect of this accuracy difference can be important. For example, if a program assumes 16-digit accuracy and requests 16 digits for formatting output, with trailing zero suppression, the number 64.4 appears as 64.4 when the system is running in Compatibility Mode (CM) and 64.40000000000001 when the system is running in Native Mode (NM). Rounding is frequently necessary when formatting output. In HP 3000 format, a number equidistant from two adjacent integers rounds to the integer of greater magnitude. For example, 1.5 rounds to 2, and 2.5 rounds to 3. In IEEE format, a number equidistant from two adjacent integers rounds to the integer that has a least significant bit of zero (in other words, the even integer). For example, 1.5 rounds to 2, and 2.5 also rounds to 2. General procedures for converting data files from MPE V/E to MPE/iX are described below. For detailed information on conversion, refer to Introduction to MPE/iX for MPE V Programmers (30367-90005) or the appropriate language manual in the Migration Series. The procedure for converting HP FORTRAN 77 binary files from MPE V/E to MPE/iX format is as follows:
Pascal on MPE V/E and MPE/iX has the following incompatibilities due to data alignment:
COBOL II on MPE V/E and MPE/iX has incompatible indexed and synchronized data items. |