Technical data
Interlanguage Communication [9]
The output from the execution of the calling sequence illustrated in the preceding
example is as follows:
Start C++ main
Call C C_add_func
Start C function C_add_func.
p1 = 10
p2 = 20
global_int = 123
Result of C_add_func = 30
End C++ main
9.2 Calling Assembly Language Functions from a C or C++ Function
You can sometimes avoid bottlenecks in programs by rewriting parts of
the program in assembly language, maximizing performance by selecting
instructions to reduce machine cycles. When writing assembly language
functions that will be called by C or C++ functions, use the standard UNICOS
program linkage macros. When using these macros, you do not need to know the
specific registers used by the C or C++ program or by the calling sequence of
the assembly coded routine. UNICOS program linkage macros are described
in the
UNICOS Macros and Opdefs Reference Manual.
In Cray Standard C++, use extern "C" to declare the assembly language
function.
9.2.1 Cray Assembly Language (CAL) Functions on UNICOS Systems
The use of Cray Assembly Language (CAL) on UNICOS systems is described in
the Cray Assembly Language (CAL) for Cray PVP Systems Reference Manual.
On UNICOS systems, the ALLOC, DEFARG, DEFB, DEFT, ENTER, EXIT,
MXCALLEN, and PROGRAM macros can be used to define the calling list; B and T
register use; temporary storage; and entry and exit points.
9.2.2 Cray Assembler for MPP (CAM) Functions on UNICOS/mk Systems
The use of the Cray Assembler for MPP (CAM) on UNICOS/mk systems is
described in the Cray Assembler for MPP (CAM) Reference Manual.
On UNICOS/mk systems, the ALLOC, LOAD, STORE and DEFARG, ENTER, EXIT,
ADDRESS, VALUE macros can be used to define local (temporary) storage; entry or
exit points; argument processing; and calls to other functions.
S–2179–36 125










