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

NOTE: There are two types of extended data segments: flat segments and selectable segments.
This section uses the term “extended data segment” to refer to a selectable segment. It does not
describe flat segments, although much of the information is the same for flat segments. Flat segments
provide many benefits over selectable segments. Flat segments are easier to program, provide
better performance, and allow access to more virtual memory than selectable segments. For
information on using flat segments, see the Guardian Programmer’s Guide.
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 TNS C compiler allocates the automatic extended data segment for all large-memory-model
modules.
Explicit Extended Data Segments
TAL modules and large-memory-model TNS 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 explicit extended segments as you need, but you can use only one explicit
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 data segments:
1. Declare an extended pointer for the base address of the explicit extended segment.
2. To allocate an explicit extended data 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 data segment is already in place, SEGMENT_USE_ returns the
automatic extended data segment’s number. Save this number so you can later access the
automatic extended data segment again.
5. C requires special treatment for SEGMENT_USE_, which returns a value and sets the condition
code.
6. You must keep track of addresses stored in extended pointers. When storing addresses into
subsequent pointers, you must allow space for preceding data items.
7. To refer to data in the current segment, call READX or WRITEX.
8. To move data between explicit extended data segments, call MOVEX.
9. To manage large blocks of memory, call DEFINEPOOL, GETPOOL, and PUTPOOL.
10. To determine the size of a segment, call SEGMENT_GETINFO_.
11. To access data in the automatic extended data segment, call SEGMENT_USE_ and restore
the segment number that you saved at step 4.
12. To delete an explicit extended data segment that you no longer need, call
SEGMENT_DEALLOCATE_.
For information on using these system procedures, see the Guardian Programmer's Guide and the
Guardian Procedure Calls Reference Manual.
Interfacing to TAL 117