Page 1 of 1

New features for the Matrix42 Package Robot Part II

Posted: 04. Aug 2018, 08:05
by Theo_Gottwald
If you go deeper into Scripting, you sometimes have to deal with "set or clear bits".
For this you had to get into mathematics until now, but now here is the new BIT\ command.

Code: Select all

BIT\[and|or|xor|not|set|clr|toggle|get]|p1|p2[>$$var]
This command can be used to perform bit operations of all sorts.

The commands "and", "or", "xor" and "not" do exactly what their names say, with the given parameters "p1" and "p2".
p1 and p2 are considered as 32-bit values.

"set" - sets bit p2 in p1
"clr" - clear bit p2 in p1
"toggle" - changes bit p2 to p1 (from 0 to 1 or vice versa)
"get" - returns the value of bit p2 in p1.

The result is assigned to a program-internal variable, which you can access with the string "$v1$". If you specify the character ">" at the end of the data part and then a variable name ("$$ xyz"), the result is written directly into this variable.

Sample Code:

Code: Select all

BIT\and|4|1                           ' $v1$ = 0
BIT\or|4|1                            ' $v1$ = 5
BIT\set|4|1>$$xyz                     ' $$xyz = 5
BIT\get|4|1                           ' $v1$ = 0
BIT\not|65535                         ' $v1$ = -65536 (not(0000ffff) -> ffff0000)