Assignment & Data Transfer - Arithmetic Operations Dialogue

The “Arithmetic Operations” dialogue allows you to program the following arithmetic operations: addition, subtraction, multiplication and division, plus the left and right shifting. All these operations are signed i.e. the operands are treated as signed numbers. Except the multiplication, the result is saved in the left operand. For multiplication, the result is saved in the dedicated product register.

arithmetic

Select Add to variable and introduce the name of the left operand to perform an addition. Indicate the right operand in the value/variable field. The left operand may be a 16-bit or 32-bit TML data. The right operand may be an immediate value or another TML data, of the same type as the left operand.

Remark: When the left operand is a 32-bit long or fixed TML data and the right operand is a 16-bit integer value, it is treated as follows:

Sign extended to a 32-bit long value, if the left operand is a 32-bit long
Set as the integer part of a fixed value, if the left operand is a 32-bit fixed

Select Subtract from variable and introduce the name of the left operand to perform a subtraction. Indicate the right operand in the value/variable field. The left operand may be a 16-bit or 32-bit TML data. The right operand may be an immediate value or another TML data, of the same type as the left operand.

Remark: When the left operand is a 32-bit long or fixed TML data and the right operand is a 16-bit integer value, it is treated as follows:

Sign extended to a 32-bit long value, if the left operand is a 32-bit long
Set as the integer part of a fixed value, if the left operand is a 32-bit fixed

Select Set PROD register with the product of variable and introduce the name of the first operand to perform a multiplication. Indicate the second operand in with value / 16 bit variable field. The first operand may be a 16-bit or 32-bit TML data. The second operand may be a 16-bit value or a 16-bit TML data. The multiplication result is saved left or right shifted in a dedicated 48-bit product register. Choose the shift type Left or Right and number of shift bits: 0 to 15. Use 0 to perform no shift.

Remark: The result is placed in the product register function of the left operand. When shift is 0:

In the 32 least significant bits, when the left operand is a 16-bit integer. The result is a 32-bit long integer
In all the 48 bits, when the left operand is a 32-bit fixed. The result has the integer part in the 32 most significant bits and the fractional part in the 16 least significant bits
In all the 48 bits, when the left operand is a 32-bit long. The result is a 48-bit integer

The TML variable PRODH contains the 32 most significant bits of the product register. The TML variable PROD contains the 32 least significant bits of the product register.

Select Divide variable and introduce the name of the left operand: the dividend, to perform a division. Indicate the right operand: the divisor, in the by the value of variable field. The dividend is a 32-bit TML data. The divisor is 16-bit TML data.

Remark: The result, saved in first operand, is a fixed value with the integer part in the 16 most significant bits and the fractional part in the 16 least significant bits.

Choose Shift Left / Right and introduce the name of the TML data to be shifted left or right in the variable field, followed by the number of shift bits: 0 to 15. The TML data can be any 16-bit or 32-bit TML data.

Choose Shift Left / Right product register by and introduce the number of shift bits: 0 to 15, to perform a left or right shift of the 48-bit product register.

Remark: At right shifts, high order bits are sign-extended and the low order bits are lost. At left shifts, high order bits are lost and the low order bits are zeroed.

OK: Close this dialogue and save the arithmetic or logic operation in your motion sequence list.

Cancel: Close this dialogue without anything in your motion sequence list.

Help: Open this help page.

 

See also:

Arithmetic and logic operations. TML Programming Details

Motion Programming