TAL Programmer's Guide

Using Extended Data Segments
Managing Addressing
096254 Tandem Computers Incorporated B–13
Managing Data Allocation in Extended Segments
When you declare a pointer, the compiler allocates storage for the pointer itself but
does not allocate storage for data at the address that is contained in the pointer. You
must manage such allocation yourself. You must remember which addresses you
have used and the length of the data item pointed to by each pointer. When you
initialize subsequent pointers, you must allow space for the preceding data items.
All data items in an extended data segment are byte addressed. You can manage data
allocation in an extended segment as follows:
?SOURCE $SYSTEM.SYSTEM.EXTDECS0 (
? SEGMENT_ALLOCATE_, SEGMENT_USE_)
PROC xsegment MAIN;
BEGIN
DEFINE error = ! ...! #; !Error handling routine
!Extended pointer declarations:
INT .EXT x; !For a 435-word array
INT .EXT y; !For a 1000-word array
INT .EXT z; !For a 94-word array
INT s;
!Lots of code
s := SEGMENT_ALLOCATE_ (0, 4096D, , , , , x);
!Allocate extended segment 0;
! assign status value to S;
! request 2 pages of extended
! memory; obtain base address
IF s <> 0 THEN error; !Continue if segment 0 is
!allocated; else return error
s := SEGMENT_USE_ (0, , x); !Make segment 0 the current
! extended segment
IF s <> 0 THEN error; !Continue if segment 0 is
!current; else return error
@y := @x + 870D; !Assign pointer Y to
! first free space after
! area pointed to by X
@z := @y + 2000D; !Assign pointer Z to the
. ! first free space after
! area pointed to by Y
!Lots of code
END;