CALL 1 SUB
OBEY 0(1) [ get address of arg#0 to X3 ... OBEY 1(1) [ get address of arg#1 to X3
EXIT 1 2 [ skip over 2 arguments
For example, a PLAN program could call a FORTRAN integer function with two arguments like this:
CALL 1 ISUM LDN 3 LOWVAL1 [ get addr of lower variable to X3 LDX 3 'UPVAL2' [ get addr if upper variable to X3 STO 6 SOMEWHERE [ store result of functionIf ISUM were coded in PLAN it could look like this:
#PROGRAM /ISUM #LOWER LINK ARG1 ARG2 #PROGRAM STO 1 LINK [ save link address OBEY 0(1) [ get addr of 1st arg LDX 0 0(3) [ get value of 1st arg STO 0 ARG1 OBEY 1(1) [ get addr of 2nd arg LDX 0 0(3) [ get value of 2nd arg STO 0 ARG2 ... LDX 6 RESULT [ get result to X6 LDX 1 LINK [ restore link EXIT 1 2 [ return
DIMENSION X(22) ... CALL PLANSUB (X)This passes the address of an array descriptor block to the PLAN function.
The FORTRAN library provides a funcion GETAH to transform the array
descriptor into an array header that can be manipulated by PLAN to find
the actual elements of the array. The same format of array descriptor is
used by ALGOL.
CALL PLANSUB (X (5))This passes the address of the element with one or both of the top two bits of the address set.
Note that if the address is used directly for character instructions (LDCH, DCH, BCHX) then the two high bits should be masked out.
COBOL has no way of generating FORTRAN/ALGOL compatible array headers, but a trick can be used to pass a character pointer to the array which Fortran will interpret as a pointer to an element of the array.
From tp4449 Fortran - George 3 and 4 compilers:
SUBROUTINE FORT(M,N) DIMENSION M(N) END ... 02 TABLE 03 ELEMENTS PIC 9(6) COMP SYNC RIGHT OCCURS 25 DEPENDING ON N. 02 ARRAY REDEFINES TABLE. 03 FILLER PIC X. 03 CHARADD PIC X. 03 FILLER PIC X OCCURS 98. ENTER FORTRAN FORT USING CHARADD,N.The address of CHARADD is passed across in character modifier form. As it is the second character of a word, the address is passed across with one of the top two bits set, so FORTRAN interprets this as the address of an array element, and this will point to the first word of TABLE.