pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

An INT(32) expression can include INT(32) and UNSIGNED(17-31) operands.
The system treats UNSIGNED(17-31) operands as if they were 32-bit values. Before evaluating
the expression, the system places an UNSIGNED(17-31) operand in the right bits of a
doubleword and sets the unused left bits to 0.
The built-in routine, not the expression or its data type, determines whether the value of the
parameter is signed or unsigned:
Built-in routines that expect signed arguments treat unsigned expressions as if they were
signed.
Built-in routines that expect unsigned arguments treat signed expressions as if they were
unsigned.
Hardware Indicators
The description of each built-in routine specifies which hardware indicators (condition code,
$CARRY, and $OVERFLOW) the built-in routine sets. If the description does not specify the conditions
for which the built-in routine sets the value of a hardware indicator, see the system description
manual for your system.
If a built-in routine does not set a particular hardware indicator, then the value of that hardware
indicator is undefined after the built-in routine completes. If you reference a hardware indicator
when its value is undefined, the compiler reports a syntax error.
If the value of $OVERFLOW would be nonzero after executing a built-in routine, an overflow trap
occurs if overflow traps are enabled. If overflow traps are disabled, you must test $OVERFLOW
explicitly in your program.
For general information about hardware indicators, see Chapter 13 (page 234).
Atomic Operations
The built-in routines in Table 58 (page 276) perform atomic operations. No other process can access
the memory referenced by an atomic operation until the atomic operation completes; for example,
$ATOMIC_ADD is equivalent to the following algorithm:
var := var + value;
After the atomic operation reads var, no other process can access the memory location associated
with var until the read completes. The read, add, and store operations are performed without
interruption, as if the three operations were one.
Table 58 Built-In Routines for Atomic Operations
Can Set ...Atomic OperationRoutine
Adds two INT values$ATOMIC_ADD Condition code
$CARRY
$OVERFLOW
Condition codePerforms a LAND on two INT values$ATOMIC_AND
Condition codeDeposits bits into an INT variable[EN|DIS]ABLE_OVERFLOW_TRAPS
Block Attribute
Condition codeGets (returns) the value of a variable$ATOMIC_GET
Condition codePerforms a LOR on two INT valuesSubstructure Alignment
Puts a value into a variable$ATOMIC_PUT
$ATOMIC_ADD
$ATOMIC_ADD atomically adds two INT values.
276 Built-In Routines