DMC-40x0 Command Reference & | • 7
& |
FUNCTION: Bitwise Logical Operators AND and OR
DESCRIPTION:
The operators & and | are typically used with IF, JP, and JS to perform conditional jumps;
however, they can also be used to perform bitwise logical operations.
ARGUMENTS: n & m or n | m where
n and m are signed numbers in the range -2147483648 to 2147483647.
For IF, JP, and JS, n and m are typically the results of logical expressions such as (x > 2)
“&” is also used to pass a variable by reference in a JS call. See
JS.
USAGE: DEFAULTS:
While Moving Yes Default Value -
In a Program Yes Default Format -
Command Line Yes
Controller Usage
ALL
RELATED COMMANDS:
@COM[n] Bitwise complement
IF If statement
JP Jump statement
JS Jump subroutine
EXAMPLES:
IF (x > 2) & (y = 4)
MG "true"
ENDIF
;'x must be greater than 2 and y equal to 4
;'for the message to print
:MG 1 | 2
3.0000
:
;'Bitwise operation: 01 OR 10 is 11 = 3
Pass By Reference Example:
value=5 ;'a value to be passed by reference
global=8 ;'a global variable
JS#SUM(&value,1,2,3,4,5,6,7) ;'note first arg passed by reference
MG value ;'message out value after subroutine.
MG _JS ;'message out returned value
EN
'
#SUM ;NO(* ^a,^b,^c,^d,^e,^f,^g)
^a=^b+^c+^d+^e+^f+^g+^h+global
EN,,^a
'notes:
'do not use spaces when working with ^
'If using global variables, they MUST be created before the subroutine is run
Executed program from program2.dmc
36.0000
36.0000