Step Three: Convert the Source to HP C/XL [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
Step Three: Convert the Source to HP C/XL
If the preceding two steps have been performed carefully, conversion of
the SPL source to something acceptable to the HP C/XL compiler may take
less time and effort than expected. The major structural changes will be
to remove the initial BEGIN, the outer block (call to procedure main),
and the final END. HP C/XL will generate code to initiate the running of
the program by calling function main. As the order of declaration of HP
C/XL functions is not as critical as in SPL, it is common practice to
declare function main as the first function, immediately after any global
data declarations, followed by the rest of the function declarations.
Thus, all FORWARD declarations should be removed, but the type of any
function used prior to its declaration should be specified in the
function where it is called.
There are certain obvious changes to be made at this point. They include
deleting the word PROCEDURE, changing BEGIN to "{", END to "}" (make sure
the preceding statement ends in ";"), and replacing any "'" (apostrophe)
characters within variable names with "_" (underscore).
Conversion of the data types should be undertaken with some caution;
refer to the SPL data types in this document for suggestions.
As you make the syntax changes in statements such as IF and DO, remember
to downshift the keywords. This will serve as a reminder of what has
been converted. It's also necessary so the HP C/XL compiler can
recognize them.
After converting $CONTROL lines to their equivalent HP C/XL constructs,
the first attempts to compile the program may be made.
With the exception of rewriting any code designed to use features such as
extra data segments and split stack operations, the most difficult and
time consuming work will be assuring that equated declarations and
pointer operations behave as they did in SPL. If the equating is
necessary, it may be emulated via the union declaration. Pointer
operations, especially pointer arithmetic and storing numeric values into
pointers, will require the most care in converting. SPL allowed many
extremely dangerous operations to be performed, and pointer adjustments
were done assuming very specific hardware-dependent rules. HP C/XL,
while allowing a great deal of freedom to manipulate pointers, has much
more consistent rules regarding the effects of operations on pointers.
The differences, however, must be accommodated. The resulting HP C/XL
code should be clearer and easier to maintain than the original SPL.
MPE/iX 5.0 Documentation