FORTRAN Reference Manual

Mixed-Language Programming
FORTRAN Reference Manual528615-001
13-11
The FORTRAN Calling Sequence
of types other than CHARACTER. For an EXTENSIBLE procedure, the length words
are stored in the reverse order, so that you can add formal parameters of type
CHARACTER to existing procedures.
FORTRAN passes the length words so that the called procedure knows the lengths of
the actual arguments that correspond to the formal arguments, as well as the function
return value pseudo-parameter, as type CHARACTER*(*). For example, given the
FORTRAN statement:
conan = sherlock (holmes, moriarity, doyle)
the FORTRAN compiler generates object code equivalent to the following TAL source
code:
STACK 8; ! The length of SHERLOCK
STACK 9; ! The length of MORIARITY
STACK @temp; ! The function return address
CODE (PUSH %722); ! Push the lengths and address into mem
CALL sherlock (holmes, moriarity, doyle);
CODE (ADDS -3); ! Delete the non-parameter words
and follows this with object code for the FORTRAN statement:
conan = temp
where TEMP is a type CHARACTER*8 temporary variable created by the compiler for
the function value returned by SHERLOCK. If you write the called function in TAL, you
can reference the length words by declaring them equivalent to 'L' minus the
appropriate number of words. For example, assuming you use EXTENDEDREF, you
can code the function SHERLOCK in TAL as:
PROC sherlock (holmes, moriarity, doyle);
INT .EXT holmes;
STRING .EXT moriarity;
REAL .EXT doyle;
BEGIN
INT len_result = 'L' - 12;
INT len_moriarity = 'L' - 11;
STRING .EXT result = 'L' - 10;
...
result ':=' ... FOR len_result;
END;