TAL Programmer's Guide

TAL and C Guidelines
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–33
When you pass a large-memory-model C routine as a parameter, 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. When you pass a small-memory-model C routine as a
parameter, the compiler passes a 16-bit address that contains PEP and map
information.
Extended Data Segments In addition to the user data segment, you can store data in:
The automatic extended data segment
One or more explicit extended data segments
You should use only the automatic extended data segment if possible. You should not
mix the two approaches. If you must use explicit segments and the automatic
segment, however, follow guidelines 4 and 11 in “Explicit Extended Data Segments”
later in this section.
Automatic Extended Data Segment
The TAL compiler allocates the automatic extended data segment when a TAL
program declares arrays or structures that have extended indirection.
The C compiler allocates the automatic extended data segment for all large-memory-
model modules.
Explicit Extended Data Segments
TAL modules and large-memory-model C modules can allocate and deallocate
extended data segments explicitly. Since the advent of the automatic extended data
segment, however, programs usually need not use explicit extended data segments.
The information in this subsection is provided to support existing programs.
To create and use an explicit extended segment, you call system procedures. You can
allocate and manage as many extended segments as you need, but you can use only
one extended segment at a time. You can access data in an explicit extended segment
only by using extended pointers. The compiler allocates memory space for the
extended pointers you declare. You must manage allocation of the data yourself.
Here are guidelines for using explicit extended segments:
1. Declare an extended pointer for the base address of the explicit extended segment.
2. To allocate an explicit extended segment and obtain the segment base address, call
SEGMENT_ALLOCATE_.
3. To make the explicit extended segment the current segment, call
SEGMENT_USE_.
4. If the automatic extended segment is already in place, SEGMENT_USE_ returns
the automatic extended segment's number. Save this number so you can later
access the automatic segment again.
5. C requires special treatment for SEGMENT_USE_, which returns a value and sets
the condition code. (See the C Reference Manual.)