<< Click to Display Table of Contents >> Navigation: Reference > Commands > Logical definitions |
A logical definition command takes one of the forms:
DM mvar = logical definition,
D col = logical definition,
A logical definition is an expression in which two or more variables are combined bit by bit using the operators:
.OR. Either or Both. True if the previous result bit is true or the next variable bit is true or both are true. False if both bits are false.
.AND. Both. True if both the previous result bit is true and the next variable bit is true. False if either or both of the bits are false.
.EOR. One but not the other (exclusive or). True if either the previous result bit is true or the next variable bit is true but not both. False if both bits are true or both bits are false. To put it another way, true if the two bits are different, false if they are the same.
.NOT. Reverse bits in following variable only before using.
The definition takes the form
variable.op.variable.op.variable ...
The operator works on corresponding bits in each variable. For instance, the fifth bit in the result is determined by the fifth bit in each of the variables and is unaffected by the other bits in each variable; each bit in the result is determined independently from all the other bits.
All variables used must have the same length, except that a single bit variable may be used in .AND. operations as a filter on the other variables.
Variables in logical definitions must be svars, mvars or cols.
NOTE: CL always evaluates logical expressions from left to right.
To explain how each operator works, let us suppose we have two 5-bit variables, $A with values 1, 3 and 5 and $B with values 1 and 2:
$a.and.$b would give 1 only
$a.or.$b would give values 1,2,3 and 5
$a.eor.$b would give values 2,3 and 5
.not $b would give values 3,4 and 5
$a.and..not.$b would give values 3 and 5
Examples of logical definition commands:
d $128=$123.or.$124.or.$125,
d $mnew=$301.and.$mrem,
dm $mar=.not.$ma,
dm $what = $sa1.or..not.$mb1.eor.$mtot,