TAL Programmer's Guide
TAL and C Guidelines
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–35
In Example 17-1, a large-memory-model C routine calls a TAL routine that
manipulates data in an explicit extended segment and then restores the automatic
extended segment. When control returns to the C routine, it manipulates data in the
restored automatic extended segment:
Example 17-1. D-Series TAL and C Extended Segment Management (Page 1 of 2)
TAL Code
INT .EXT array[0:10]; !Allocated in the automatic
 ! extended data segment ID 1024D
INT .EXT arr_ptr;
?PUSHLIST, NOLIST, SOURCE $SYSTEM.SYSTEM.EXTDECS0 (
? PROCESS_DEBUG_, DEFINEPOOL, GETPOOL,
? SEGMENT_ALLOCATE_, SEGMENT_USE_, SEGMENT_DEALLOCATE_)
?POPLIST
PROC might_lose_seg;
 BEGIN
 INT status := 0;
 INT old_seg := 0;
 INT new_seg := 100;
 INT(32) seg_len := %2000D; !1024D
 array[0] := 10; !Do work in automatic segment
 status := SEGMENT_ALLOCATE_ (
 new_seg, seg_len, , , , , arr_ptr);
 !Allocate an explicit extended data segment;
 !store segment base address in ARR_PTR
 IF status <> 0 THEN CALL PROCESS_DEBUG_;
 Status := SEGMENT_USE_ (new_seg, old_seg, arr_ptr);
 !Make the explicit extended data segment current
 IF status <> 0 THEN CALL PROCESS_DEBUG_;
 !Use DEFINEPOOL, GETPOOL to retrieve a block in the
 ! explicit extended data segment.
 arr_ptr[2] := 10; !Do some work in the segment.
 !When you no longer need the explicit extended data
 ! segment, call SEGMENT_DEALLOCATE_.
 status := SEGMENT_USE_ (old_seg);
 !Restore the automatic extended data segment
 IF status <> 0 THEN CALL PROCESS_DEBUG_;
 END;










