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.

The arguments must be integers (though the second will be cast if a float). They will be treated as signed 32-bit using two's complement.


Here is a simple AND operation:

SETV va00 24  * 24 = %11000
ANDV va00 14  * 14 = %01110
OUTV va00
    8         * 8  = %01000

This implements va00 = va00 XOR va01 using ANDV and ORRV:

                         * 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).

See also


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.