SRB, SRBL        Set/reset bits from a TML data

Syntax                        

SRB VAR16, ANDmask, ORmask

Set/Reset Bits of VAR16 (short addressing)

SRBL VAR16, ANDmask, ORmask

Set/Reset Bits of VAR16 (full addressing)

OperandsVAR16: integer variable

ANDmask: 16-bit mask for AND operation

ORmask: 16-bit mask for OR operation

PlaceTMLOnline

Binary code

SRB

DescriptionPerforms a logic AND between VAR16 and the AND mask, followed by a logic OR between the result and the OR mask. The result is saved in VAR16. These instructions may be used to set/reset individual bits from a register or a TML variable without affecting the other ones. SRB performs these operations in a safe way avoiding the interference with the other concurrent processes wanting to change the same TML data. This is particularly useful for the TML registers, which have bits that can be manipulated by both drive/motor and user at TML level.

SRB uses a 9-bit short address for the operand. Bit 9 value X specifies the destination address range:

AddressRange

All predefined or user-defined TML data are inside these address ranges, hence this instruction can be used without checking the variables addresses. However, considering future developments, the TML also includes SRBL instruction using a 16-bit full address for the operand.

 

Example        

int var1;

....

SRB var1, 0xFF0F, 0x0003;        //Reset bits 4 to 7, set bits 0

//and 1 of var1