User's Manual

PMAC User Manual
160 Computational Features
Syntax
There are four forms of synchronous M-variable assignment statements:
M{constant}=={expression} ; Straight equals assignment
M{constant}&={expression} ; AND-equals assignment
M{constant}|={expression} ; OR-equals assignment
M{constant}^={expression} ; XOR-equals assignment
In all of these forms, the expression on the right side of the statement is evaluated when the line is
encountered in the program, ahead of the execution of the move. The value of the expression, the
variable number, and the operator are placed on a stack for execution at the proper time.
Execution
When actual execution of the appropriate move starts, these items are pulled off the stack, and the actual
action is performed. In the case of the == syntax, the value is simply assigned to the variable at this time.
In the case of the other forms (&=, |=, and ^=), the variable is read at this time, the bit-by-bit Boolean
operation (AND, OR, XOR, respectively) is performed between the variable value and the expression
value, and the result is written back to the variable.
Special Boolean Feature
These Boolean assignment operators are subtly different from what would seem to be equivalent ==
statements. Consider the two statements acting on an 8-bit M-variable, which attempt to make all of the
odd bits 1, while leaving the even bits where they are:
M50==M50 & $AA
M50&=$AA
The difference between the two statements is in when M50 is read for the operation. In the first case, it is
read when the statement is first evaluated in the program. In the second case, it is read when the
operation is pulled off the stack, immediately before the variable is written to. In this second technique,
there is no chance that the value of the M-variable can be changed by some other task in the mean time.
Limitations
There are a few limitations to these functions to be aware of:
Valid Forms
These statements may not be used with any of the thumbwheel-multiplexer-port M-variable forms (TWB,
TWD, TWR, or TWS). The Boolean assignments (&=, |=, ^=) cannot be used with any double-width M-
variable forms (D, L, or F).
Stack Limits
Second, the stack space that holds these actions is limited to 32 words of memory (per coordinate
system). Each assignment occupies two or three words of memory while it is pending, and there is one
extra word per move to mark the end of actions for that move. When PMAC is working n moves ahead,
it is always safe to allot 32/(n+1) words per move. This rule of thumb will give PMAC adequate stack
space for its stack manipulations and will give enough synchronous M-variables. When PMAC is
working one move ahead, this rule of thumb gives 16 words per move of stack space (which is at least
five assignments plus one end word); when PMAC is working two moves ahead, this rule of thumb gives
10 words per move of stack space (which is at least three assignments plus one end word).
More assignments than this can be made with a single move if, for instance, it is known that the next
move will have no synchronous assignments, or that some of the assignments will occupy less than three
words on the stack. In no case may the assignments for a single move occupy more than 32 words of
memory.
The following table shows the number of words of stack space required for each type of assignment: