User's Manual

PMAC User Manual
152 Computational Features
Array Capabilities
Array Reading
It is possible to use a set of Q-variables as an array. To do this when reading from the variables, simply
replace the constant specifying the variable number with an expression in parentheses — use the
({expression}) syntax instead of the Q{constant} syntax. PMAC simply treats this syntax as a
type of function call, like SIN({expression}).
Example:
To move in sequence to the positions specified by Q51 to Q100, use a program segment like the
following.
F10
P1=51 ; Array index variable
WHILE (P1<101) ; Start loop
X(Q(P1)) ; As P1 changes, the destination position changes
DWELL100
P1=P1+1 ; Increment the index
ENDWHILE
Array Writing
Writing to a set of Q-variables as an array must be done with indirect addressing techniques. To set this
up, first define an M-variable to point to Q0 of C.S.1 (e.g. M60->L:$1400). Next, define a second M-
variable to point to the lowest twelve bits of the first M-variable's definition word which is in Y-register
$BC3C (e.g. M70->Y:$BC3C,0, 12 defines M70 to the low 12 bits of the definition word for M60).
To point to the definition word for M0, use Y-register $BC00; for M1, Y:$BC01; for M50, Y:$BC32 (32
hex is 50 decimal); and for M1023, Y:$BFFF.
Now, by giving a value to the second M-variable, it changes which Q-variable the first M-variable points
to. In the example, the command M70=1024+17 makes M60 point to variable Q17 of C.S.1.
Q-Pointer Offsets
Note the offset of 1024 for C.S.1; each coordinate system has its own required offset to make the value in
the M-variable definition match the Q-variable number for that coordinate system. The offsets are:
C.S.1: 1024 C.S.5: 1152
C.S.2: 1536 C.S.6: 1664
C.S.3 1280 C.S.7: 1408
C.S.4 1792 C.S.8: 1920
Once the first M-variable has been pointed to a particular Q-variable, giving a value to this M-variable
writes that value into the addressed P-variable. Continuing our example, the command M60=3.14
writes a value of 3.14 to Q17 of C.S.1.
Example:
To create a table of square roots of values from 0.0 to 9.9 in Q-variables Q0 to Q99 of C.S.2, use the
following program segment, which assumes the use of M60 and M70 as set up above:
Q100=0 ; Starting value for array index
WHILE (Q100<100) ; Loop until done
M70=1536+Q100 ; Point M60 to the proper Q-variable
M60=SQRT (Q100/10) ; Assign square root value to this
; Q-variable
Q100=Q100+1 ; Increment array index
ENDWHILE