• Aucun résultat trouvé

The Library Conversion Package

Dans le document OS PL/I (Page 194-198)

The library conversion package consists of some 26 modules and is capable of handling all the conversions that are allowed in the OS PL/I Optimizing Compiler implementation of the PL/I language. All but seven of the modules convert data from one data type to another. As there are approximately 170 possible conversions and only 19 conversion modules, many conversions are done by using a series of modules. For instance, to convert from fixed-decimal to bit-string involves an intermediate conversion to floating-point. The conversion package also contains five

Chapter 10: Data Conversion

r---,

Data attributes I stored internally as

the library conversion package is given in the publication Q§-E~/I_B~2i9~n~_~ibr~~y~

E~Qg~2!!L~Qg!£ • this are data-directed and list-directed input, and edit-directed input or output

conversion utilities, and the

string/arithmetic directors. It i s ' s ' for the edit-directed format directors. The modules in the arifhmetic conversion package have six letter names, the sixth letter being an arbitrary module

identifier. The string conversion modules and conversion utilities have seven lett~r

names in which the sixth and seventh

Q pictured character A arithmetic

o

output in S module G ftcheck ft or utility T table

SPECIFYING A CONVERSION PATH

When a number of conversion modules need to that particular conversion. For instance, the module IBMBCE handles fixed-decimal to fixed-binary conversions. If the module is entered to carry out this conversion, entry point IBMBCEDX is called. However, if i t is only an intermediate stage in a

conversion from fixed-decimal to bit-string, the entry point IBMBCEDB will be called. When the conversion to floating-point is completed, the conversion to bit will be carried out by the module IBMBCR.

In addition to the use of various entry pOints to specify the conversion path to be taken, there are two control modules to handle the conversion paths between character-string and arithmetic data.

HOUSEKEEPING WHEN MORE THAN ONE MODULE IS USED

When more than one arithmetic conversion module is used in a conversion, a ~ethod cf minimizing the housekeeping has been

evolved. This avoids saving registers and acquiring workspace for each module

entered. The same library workspace is used for all modules in a single conversion operation. The first module in the chain saves the registers and acquires workspace;

the last module frees the workspace and restores the registers.

A simple method is used to allow each

ARGUMENTS PASSED TO THE CONVERSION ROUTINES

Each conversion routine expects a standard set of arguments. These consist of the address of the source and target, and the addresses of the DEDs (data element

r---,

Conversion 1 I Optimization Comments and Conditions

t---Source Target 1 SIZE 1 SIZE

Idisabledlenabled IFixed binary

I Fixed decimal

Fixed binary Floating-point

Bit string

Character string or picture

Fixed binary

Fixed decimal Fixed decimal Floating-point

Bit string

If either scale factor = 0 and the other factor S 0, the optimization can be 'none'.

If source scale factor = 0, the optimization can be 'none' (whether SIZE is enabled or not).

String must be fixed-length, aligned, and with length S2048.

Source scale factor must be S

o.

String must be fixed-length with length S256. Picture type 1, 2, or 3.

If source and target scales have the same sign and are non-zero, the optimization (SIZE disabled) must be

'time' •

Source precision must be ~10.

Source scale factor must be zero.

String must be fixed-length, aligned, and with length S2048.

ICharacter string Source scale factor must be ~

o.

1 String must be fixed-length and

1 length S256.

1

1 I time time

time

time

time

time

time

not done in-line not done in line time

time not done in-line time

1 Picture picture type 1,. 2, or 3. For 1- time not done in-line 1 picture types 1 and 2 with no sign, 1

1 optimization can be 'none'. 1

---1- ---1

--- Floating-point

IFixed binary 1 time

I 1

1 I

Fixed decimal Target precision must be S9. 1 time Floating-point

Bit string

Source and target may be single or double length.

1 1 1 1

String must be fixed-length, aligned, 1 I time

and with length S2048. 1

not done in-line not done in-line

not done in-line

--- - ---1

---I

Fixed binary Source string must be fixed-length,

I

I aligned, and with length S2048. I

I 1

not done in-line IBit string Fixed decimal and Source must be fixed-length, aligned, I time not done

I floating-point and with length <32. 1 in-line

L---·---___________________________________

J

Figure 10.2. (Part 1 of 2). Data conversions performed in-line

r---,

Conversion 1 I Optimization

---1

Comments and Conditions

1---Source 1 Target 1 I SIZE 1 SIZE

1 1 Idisabledlenabled

1 1

ICharacter string IString must be fixed-length with

1 Ilength ~256.

Picture 1 1

1 1

1 Picture pictures must be identical.

Fixed binary Source precision must be <10. time not done in-line Fixed decimal If picture has a sign, the

optimization must be 'time'.

not done in-line Picture

type 1 (See note below)

Floating-point Source precision must be <10. time not done in-line Picture Picture type 1, 2 or 3. time not done

lin-line

Locator 1 Locator 1

---_._---Label ILabel I

The word "time" in the columns headed "Optimization" indicates that the conversion is done in-line only if optimization has been specified; "not done in-line" indicates that the conversion is done by library call.

L---__________________________________

J

Figure 10.2. (Part 2 of 2). Data conversions performed in-line descriptors) for the source and the target.

Arguments are passed in a list addressed by register 1. (The source is the variable or constant that requires conversion; the target is the area where the converted result is to be placed.)

The DEDs are used to describe the data type of the element. Those passed to the library conversion package are set up by compiled code in the constants pool. They are described in chapter 4 and fully mapped in appendix A.

COMMUNICATION BETWEEN MODULES

When the conversion path goes through a series of modules, the address of the final target must be retained until the last module is reached.

Temporary targets and DEDs are created for the intermediate results, and these are passed on as the source for the next

184

module. When information is passed between two conv.ersion modules using the same workspace, registers are normally used rather than a parameter list.

In some arithmetic conversions to string, precision data is passed through certain modules that do not themselves need such data.

FREE DECIMAL FORMAT

Because all floating~point data is in binary form, there is no direct

representation of the PL/I floating-point decimal format. In order to simplify certain conversions~ a simulated floating-point decimal format is employed by the optimizing compiler. This format is termed

fr~~ decimal (sometimes known as eacked intermediate decimal). The format of free decimal is-a I7=digIt packed decimal

mantissa and a fullword binary exponent.

Conversions to and from free decimal form

r---,

IConversion I Conversion

Fixed-binary to bit-string Floating-point to bit-string Bit-string to fixed-binary Fixed-decimal to picture type 1

Fixed-decimal to picture type 2

Figure 10.3. Fundamental in-line conversions

an integral part of the arithmetic conversion package.

Dans le document OS PL/I (Page 194-198)