TAL Programmer's Guide

TAL and C Guidelines
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–15
Sharing Data You can share global data in the user data segment between the following kinds of
TAL and C modules:
TAL modules that declare global variables having standard indirection (.)
C small-memory-model modules
You can share global data in the automatic extended data segment between the
following kinds of TAL and C modules:
TAL modules that declare global variables having extended indirection (.EXT)
C large-memory-model modules
In a large-memory-model C module, you can use the lowmem declaration to allocate a
C array or structure that can be represented by a 16-bit address if needed in a call to a
TAL routine or a system procedure.
Using pointers to share data is easier and safer than trying to match declarations in
both languages. Using pointers also eliminates problems associated with where the
data is placed.
To share data by using pointers, first decide whether the TAL module or the C module
declares the data:
If the TAL module is to declare the data, follow the guidelines in “Sharing TAL
Data With C Using Pointers.”
If the C module is to declare the data, follow the guidelines in“Sharing C Data
With TAL Using Pointers.”
Sharing TAL Data With C Using Pointers
To share TAL global data with C modules, follow these steps:
1. In the TAL module, declare the data using C-compatible identifiers, data types,
and alignments. (Alignments depend on byte or word addressing and variable
layouts as described in “Parameters and Variables” later in this section.)
When you declare TAL arrays and structures, use indirect addressing.
2. In the C module, declare pointers to the data, using TAL-compatible data types.
3. In the C module, declare a routine to which TAL can pass the addresses of the
shared data.
4. In the C routine, initialize the pointers with the addresses sent by the TAL module.
5. Use the pointers in the C module to access the TAL data.
The following example shows how to share TAL data with a large-memory-model C
module. The TAL module passes to a C routine the addresses of two TAL arrays. The
C routine assigns the array addresses to C pointers.