pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 238 $BITOFFSET Routine
STRUCT a;
BEGIN
INT array[0:40];
STRUCT ab[0:9];
BEGIN
UNSIGNED(1) flag;
UNSIGNED(15) offset;
END;
END;
INT c;
c := $BITOFFSET (a.ab[2]); ! Return offset of 3rd occurrence
! of ab
$CARRY
$CARRY returns a value that indicates whether an arithmetic carry occurred during certain arithmetic
operations or during execution of a SCAN or RSCAN statement.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
The value returned by $CARRY is based on instructions emitted by the compiler that determine
whether a carry occurred. $CARRY returns -1 if a carry occurred, 0 otherwise.
Procedures cannot return $CARRY.
You can test $CARRY only after one of the following statements:
• An assignment statement in which the final operator executed in the expression on the right
side of the assignment is one of the following:
◦ Signed integer add, subtract, or negate
◦ Unsigned integer add, subtract, or negate
• A SCAN or RSCAN statement.
$CARRY cannot be an actual parameter. If it is important to pass the value of $CARRY to a
procedure, use code similar to that in Example 239.
Example 239 $CARRY Routine
INT a, carry_flag;
carry_flag := 0;
a := a + 1;
IF $CARRY THEN carry_flag := 1;
CALL p1(carry_flag, .... );
$CHECKSUM
$CHECKSUM returns the checksum of data.
Nonatomic Operations 297