ANDV is a CAOS command for a bitwise operation.
Syntax: ANDV var (int variable) mask (int)
This performs a bitwise AND on var. Bitwise AND matches up the bits of var and mask which both contain 1, and produces a new sequence of bits which contains 1s in these positions. In C, ANDV would be written
var = var & mask.
Here is a simple AND operation:
SETV va00 24 * 24 = %11000 ANDV va00 14 * 14 = %01110 OUTV va00 8 * 8 = %01000
* va00 = A; va01 = B SETV va02 va00 NOTV va02 * va02 = ~A SETV va03 va01 NOTV va03 * va03 = ~B ANDV va00 va03 * va00 = A & ~B ANDV va02 va01 * va03 = ~A & B ORRV va00 va02 * va00 = (A & ~B) | (~A & B)
As an example, performing the above with va00 = 5 (%0101) and va01 = 3 (%0011) yields va00 = 6 (%0110).
- Mathworld on XOR for the XOR algorithm above