TAL Programmer's Guide

Using Simple Pointers
Using Pointers
9–10 096254 Tandem Computers Incorporated
The following example shows pointers used in assignment, move, IF, and SCAN
statements:
INT var_a; !Declare variables VAR_A and
INT var_b; ! VAR_B
INT .ptr; !Declare standard simple
! pointer PTR
INT .EXT ptr_a; !Declare extended simple
INT .EXT ptr_b; ! pointers PTR_A and PTR_B
!Some code to initialize PTR_A and PTR_B
!Assignment statements:
var_a := ptr_a; !Assign to VAR_A the value of
! item pointed to by PTR_A
ptr_a := var_a; !Assign value of VAR_A to PTR_A
ptr_a := ptr_b; !Assign to PTR_A the value of
! item pointed to by PTR_B
!Move statements:
var_a ':=' ptr_a FOR 2 WORDS; !Copy 2 words starting at
! address in PTR_A (modify
! both VAR_A and VAR_B)
ptr_a ':=' var_a FOR 2 WORDS; !Copy 2 words starting at
! address of VAR_A (copy
! content of VAR_A and VAR_B
! into location pointed to
! by PTR_A)
ptr_a ':=' ptr_b FOR 10 WORDS; !Copy 10 words starting at
! address contained in PTR_B
!IF and SCAN statements:
IF var_a = ptr_a FOR 2 WORDS THEN
SCAN ptr WHILE " "; !If contents of VAR_A and VAR_B
! match data pointed to by
! PTR_A, scan area starting at
! address contained in PTR
! while spaces occur
Indexing Simple Pointers You can access data by appending an index (enclosed in brackets) to the identifier of a
simple pointer as follows:
ptr[2]
For a standard simple pointer, the index must be a signed INT arithmetic expression.
For an extended simple pointer, the index can be either:
A signed INT arithmetic expression (–32,768 through 32,767)
A signed INT(32) arithmetic expression (–2,147,483,648 through 2,147,483,647)