Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 29
Referencing Data in an Extended Data Segment
You can also specify the optional base-address output parameter to return the
address of the start of the allocated segment, along with the optional error-detail
parameter to return a value giving more information about any nonzero error value.
The following example allocates four selectable segments and specifies that the first of
these (segment ID 0) is to be the current selectable segment:
FOR I := 0 TO 3 DO
BEGIN
SEGID[I] := I;
SIZE := 100000D;
ERROR := SEGMENT_ALLOCATE_(SEGID[I],
SIZE,
!swap^file:length!,
ERROR^DETAIL,
!pin!,
!segment^type!,
BASE^ADDRESS[I]);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
END;
NEW^SEGMENT^ID := 0;
ERROR := SEGMENT_USE_(NEW^SEGMENT^ID,
OLD^SEGMENT^ID,
@SEG^PTR,
ERROR^DETAIL);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
After your program calls the SEGMENT_USE_ procedure, all references to selectable
segments access the selectable segment that was specified in the SEGMENT_USE_
call. Although the other selectable segments cannot be accessed by your process
(unless SEGMENT_USE_ is called), they remain allocated; data in the other segments
is therefore retained. The MOVEX procedure can be used to copy data into or out of a
selectable segment that is not currently in use.
Referencing Data in an Extended Data Segment
Once you have allocated an extended data segment and, if it is a selectable segment,
made it current, you can refer directly to locations in that extended data segment. You
do this by using extended pointers in TAL or pTAL.
An extended pointer is a 32-bit address of an extended data segment. (An extended
po
inter can also contain the address of a TNS user data segment storage location; see
Using the Data Stack earlier in this section.)
You declare an extended pointer using the .EXT keyword. The following examples
show extended pointers used to access selectable and flat segments.