pTAL Conversion Guide

TAL Standard Routines
pTAL Conversion Guide527302-002
17-3
$CARRY
count
is an INT value that specifies the number of 16-bit words in param.
$CARRY
$CARRY is a TAL routine for which pTAL has a built-in routine with the same name but
slightly different behavior.
$CARRY routine returns a value that indicates whether an arithmetic carry occurred
during certain arithmetic operations or during execution of a SCAN or RSCAN
statement.
TAL
The value returned by $CARRY is based on the carry bit (K) in the TNS environment
register. $CARRY returns -1 if the carry bit is set, 0 if the carry bit is reset. TAL
procedures can test $CARRY at any time. For example, in TAL, a procedure can pass
$CARRY as an actual parameter, or an expression can use $CARRY as an operand.
You must have a detailed knowledge of which TNS operators alter the carry bit to use
$CARRY correctly in TNS processes.
pTAL
The value returned by $CARRY is based on instructions emitted by the native compiler
that determine whether a carry occurred. $CARRY returns -1 if a carry occurred, 0
otherwise.
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.
Procedures cannot return $CARRY. Example 17-1 on page 17-4 is valid in TAL, but not
in pTAL.
VST076.vsd
$CARRY