TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-36
Example of SCAN Statements
character did not occur. If $CARRY is true after SCAN WHILE, a character other than
the test character did not occur. Here are examples for using $CARRY:
IF $CARRY THEN ... ; !If test character not found
IF NOT $CARRY THEN ... ; !If test character found
To determine the number of multibyte elements processed, divide (next-addr '–' byte
address of
identifier) by the number of bytes per element, using unsigned arithmetic.
Example of SCAN Statements
The following example converts the word address of an INT array to a byte address.
The assignment statement stores the resulting byte address in a STRING pointer. The
SCAN statement then scans the bytes in the array until it finds a comma:
INT .words[-1:3] := [0,"Doe, J",0];
!Declare INT array WORDS
STRING .byte_ptr := @words[0] '<<' 1;
!Declare BYTE_PTR; initialize
! with byte address of WORDS[0]
SCAN byte_ptr[0] UNTIL ","; !Scan bytes in WORDS
For more examples, see Section 7, Using Arrays, in the TAL Programmer’s Guide.
STACK Statement
The STACK statement loads values onto the register stack.
expression
is a value to load onto the register stack. If you list multiple values, the compiler
loads them starting with the leftmost value.
Usage Considerations
You can use the register stack for temporary storage and for optimizing critical code.
The compiler loads values on the register stack starting at the current setting of RP + 1
and increments RP by the number of words needed by each value. For example, an
INT(32) value needs two words; a FIXED value needs four words.
The number of registers needed by a value depends on its data type. If enough
registers are not free, the compiler transfers the content of registers R[0] through RP to
the data stack and then loads STACK values starting at RP[0]. The compiler keeps
expression
STACK
,
VST1220.vsd