C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

UNSIGNED(3) x; !TAL code
UNSIGNED(3) y;
IF x + y ... ; !Signed operation
IF x '+' y ... ; !Unsigned operation
UNSIGNED arrays that contain 8-bit or 16-bit elements are compatible with C arrays that contain
elements of like size. UNSIGNED arrays that contain 1-bit, 2-bit, or 4-bit elements are incompatible
with C arrays.
TAL Routines as Parameters to TNS C
You can call TNS C routines and pass TAL routines as parameters. You can pass any TAL routine
except EXTENSIBLE or VARIABLE routines as parameters.
A passed TAL routine can access the routine’s local variables and global TAL variables. The passed
routine can contain subprocedures, but they cannot be passed as parameters.
If you call a large-memory-module TNS C routine, the EXTERNAL procedure declaration for the
TNS C routine must specify the PROC(32) parameter type in the parameter declaration. When
you pass the PROC(32) parameter to the TNS C routine, the compiler passes a 32-bit address that
contains PEP and map information in the high-order word and a zero in the low-order word.
If you call a small-memory-module TNS C routine, the EXTERNAL procedure declaration for the
TNS C routine must specify the PROC parameter type in the parameter declaration. When you
pass the PROC parameter to the TNS C routine, the compiler passes a 16-bit address that contains
PEP and map information.
In this example, a large-memory-model TNS C module contains C_FUNC, which expects a TAL
procedure as a parameter. The TAL module contains:
An EXTERNAL procedure declaration for C_FUNC
TAL_PARAM_PROC, a routine to be passed as a parameter to C_FUNC
TAL_CALLER, a routine that calls C_FUNC and passes TAL_PARAM_PROC as a parameter
C Module
/* C function that accepts TAL routine as a parameter */
void C_FUNC (short (*F) (short n))
{
short j;
j = (*F)(2);
/* lots of code */
}
TAL Module
PROC c_func (x) LANGUAGE C; !EXTERNAL procedure declaration
! for C routine to be called
INT PROC(32) x; !Parameter declaration
EXTERNAL;
INT PROC tal_param_proc (f); !Procedure to be passed as a
INT f; ! parameter to C_FUNC
BEGIN
RETURN f;
END;
PROC tal_caller; !Procedure that calls C_FUNC
BEGIN ! and passes TAL_PARAM_PROC
!Lots of code
CALL c_func (tal_param_proc);
!Lots of code
END;
PROC m MAIN;
BEGIN
CALL tal_caller;
END;
Interfacing to TAL 115