TAL Programmer's Guide

TAL and C Guidelines
Mixed-Language Programming
17–32 096254 Tandem Computers Incorporated
C Routines as Parameters to TAL
You can call TAL routines and pass C routines as parameters. You can call a TAL
entry-point identifier as if it were the routine identifier. C routines cannot be nested.
When a called TAL routine in turn calls a C routine received as a parameter, the TAL
routine assumes that all required parameters of the C routine are value parameters.
The TAL compiler has no way of checking the number, type, or passing method
expected by the C routine. If the C routine requires a reference parameter, the TAL
routine must explicitly pass the address by using:
The @ operator for a small-memory-model parameter
The $XADR standard function for a large-memory-model parameter
In the following example, a C large-memory-model module contains C routine
C_PARAM_FUNC, which is to be passed as a parameter. The TAL module contains:
An EXTERNAL procedure declaration for C_PARAM_FUNC
TAL_PROC, which expects C_PARAM_FUNC as a parameter
TAL_CALLER, which calls TAL_PROC and passes C_PARAM_FUNC as a
parameter
TAL Module
INT i;
STRING .EXT s[0:9];
PROC c_param_func (i, s) !EXTERNAL procedure declaration
LANGUAGE C; ! for C routine expected as
INT i; ! a parameter
STRING .EXT s; !Extended indirection for large-
EXTERNAL; ! memory-model
PROC tal_proc (x); !TAL routine that expects
PROC(32) x; ! a large-memory-model C routine
BEGIN ! as a parameter
CALL x (i, $XADR (s));
END;
PROC tal_caller;
BEGIN
CALL tal_proc (c_param_func);
END;
PROC m main;
BEGIN
CALL tal_caller;
END;
C Module
void C_PARAM_FUNC (short i, char * s)
{ /* C routine to be passed as */
/* a parameter to TAL_PROC */
}