User manual

TMCM-1140 TMCL Firmware V1.19 Manual (Rev. 1.01 / 2012-JUL-27) 52
www.trinamic.com
3.6.28 CALCX (calculate using the X register)
This instruction is very similar to CALC, but the second operand comes from the X register. The X register
can be loaded with the LOAD or the SWAP type of this instruction. The result is written back to the
accumulator for further processing like comparisons or data transfer.
Related commands: CALC, COMP, JC, AAP, AGP
Mnemonic: CALCX <operation>
with <operation>=ADD|SUB|MUL|DIV|MOD|AND|OR|XOR|NOT|LOAD|SWAP
Binary representation:
INSTRUCTION NO.
TYPE
MOT/BANK
VALUE
33
0 ADD add X register to accu
1 SUB subtract X register from accu
2 MUL multiply accu by X register
3 DIV divide accu by X-register
4 MOD modulo divide accu by x-register
5 AND logical and accu with X-register
6 OR logical or accu with X-register
7 XOR logical exor accu with X-register
8 NOT logical invert X-register
9 LOAD load accu to X-register
10 SWAP swap accu with X-register
(don't care)
(don't care)
Example:
Multiply accu by X-register
Mnemonic: CALCX MUL
Binary:
Byte Index
0
1
2
3
4
5
6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$21
$02
$00
$00
$00
$00
$00