Delta Tau GEO BRICK LV User Manual
Turbo PMAC User Manual
Turbo PMAC Computational Features
247
the M-variables are instantaneous servo variables, there is no guarantee that M16 or M17 will have the
same value in both places in the expression or that the values for M16 and M17 will come from the same
servo cycle. The first problem can be overcome by setting P1=M16 and P2=M17 right above this, but
there is no general solution to the second problem.
same value in both places in the expression or that the values for M16 and M17 will come from the same
servo cycle. The first problem can be overcome by setting P1=M16 and P2=M17 right above this, but
there is no general solution to the second problem.
Use for Indirect Addressing
As pointers, M-variables can be used for a technique known as indirect addressing to access a range of
registers without having to define a separate variable for each register. This technique uses two M-
variables. The first is assigned to a register in the address area of interest, with a format of the desired
type; the second is assigned to the register that contains the address of the first definition.
registers without having to define a separate variable for each register. This technique uses two M-
variables. The first is assigned to a register in the address area of interest, with a format of the desired
type; the second is assigned to the register that contains the address of the first definition.
M-variable address definitions are in fixed locations in Turbo PMAC memory, starting at $004000 (for
M0) and ending at $005FFF (for M8191). The X-register at each of these addresses holds the code that
determines the format of the M-variable; the Y-register holds the address of the register being pointed to.
By changing the contents of this Y-register, you can change the address of the register that this M-
variable points to.
M0) and ending at $005FFF (for M8191). The X-register at each of these addresses holds the code that
determines the format of the M-variable; the Y-register holds the address of the register being pointed to.
By changing the contents of this Y-register, you can change the address of the register that this M-
variable points to.
This technique is best illustrated by an example. Suppose that a 2048-word UBUFFER had been created
in a Turbo PMAC with standard memory. This UBUFFER would occupy addresses $010000 to
$0107FF. In this buffer, we wanted to create a 2048-entry floating-point sine table. We would start off
with two M-variable definitions:
in a Turbo PMAC with standard memory. This UBUFFER would occupy addresses $010000 to
$0107FF. In this buffer, we wanted to create a 2048-entry floating-point sine table. We would start off
with two M-variable definitions:
M64->L:$010000
; Floating-point M-var def to start of UBUFFER
M65->Y:$004040,0,12
; M64 definition address, low 12 bits
Now, by changing the value of M65, we change the address to which M64 points. Note that by assigning
M65 to only the low 12 bits (last 3 hex digits) of the M64 definition address, we can in this case just
assign values to M65 representing offsets from the beginning of the register set. To create the sine table,
use the following code:
M65 to only the low 12 bits (last 3 hex digits) of the M64 definition address, we can in this case just
assign values to M65 representing offsets from the beginning of the register set. To create the sine table,
use the following code:
M65=0
; Point M64 to L:$010000
WHILE (M65<2048)
M64=SIN(360*M65/2048)
; Write sine value
M65=M65+1
; Index M64 to next register
ENDHWILE
Operators
Turbo PMAC operators work like those in any computer language: they combine values to produce new
values. Detailed descriptions of the operators are given in the Software Reference manual; overviews are
given here.
values. Detailed descriptions of the operators are given in the Software Reference manual; overviews are
given here.
Arithmetic Operators
Turbo PMAC uses the four standard arithmetic operators: +, -, *, and /. The standard algebraic
precedence rules are used: multiply and divide are executed before add and subtract, operations of equal
precedence are executed left to right, and operations inside parentheses are executed first.
precedence rules are used: multiply and divide are executed before add and subtract, operations of equal
precedence are executed left to right, and operations inside parentheses are executed first.
Modulo Operator
Turbo PMAC also has the ‘%’ modulo operator, which produces the resulting remainder when the value
in front of the operator is divided by the value after the operator. Values may be integer or floating point.
This operator is particularly useful for dealing with counters and timers that roll over.
in front of the operator is divided by the value after the operator. Values may be integer or floating point.
This operator is particularly useful for dealing with counters and timers that roll over.
When the modulo operation is done by a positive value x, the results can range from 0 to x (not including
x itself). When the modulo operation is done by a negative value x, the results can range from -x to x (not
including x itself). This negative modulo operation is useful when a register can roll over in either
direction.
x itself). When the modulo operation is done by a negative value x, the results can range from -x to x (not
including x itself). This negative modulo operation is useful when a register can roll over in either
direction.