pTAL Reference Manual (H06.08+)

Built-In Routines
HP pTAL Reference Manual523746-006
15-4
Hardware Indicators
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 Section 13, Hardware
Indicators.
Atomic Operations
The built-in routines in Table 15-1 on page 15-4 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 15-1. Built-In Routines for Atomic Operations
Routine Atomic Operation Can Set ...
$ATOMIC_ADD
Adds two INT values Condition code
$CARRY
$OVERFLOW
$ATOMIC_AND
Performs a LAND on two INT values Condition code
$ATOMIC_DEP
Deposits bits into an INT variable Condition code
$ATOMIC_GET
Gets (returns) the value of a variable Condition code
$ATOMIC_OR
Performs a LOR on two INT values Condition code
$ATOMIC_PUT
Puts a value into a variable