ORRV
From Creatures Wiki
ORRV is a CAOS command for a bitwise operation.
[edit] Usage
Syntax: ORRV var (int variable) mask (int)
Performs a bitwise OR operation on var. Wherever either var or mask contains a 1 bit, so will the corresponding bit in var after the operation. In C, this is var = var | mask.
Both arguments should be integer, but mask will be cast if not. They are treated as 32-bit integers signed using two's complement.
[edit] Examples
Here is a numeric example:
SETV va00 41 * 41 = %00101001
ORRV va00 186 * 186 = %10111010
OUTV va00
187 * 187 = %10111011
This constructs ORRV va00 va01 using ANDV and NOTV, with C-style commentary:
* va00 = A; va01 = B
NOTV va00 * va00 = ~A
NOTV va01 * va01 = ~B
ANDV va00 va01 * va00 = ~A & ~B
NOTV va00 * va00 = ~(~A & ~B)
ANDV has an example for constructing XOR.
[edit] See also
[edit] References
- Mathworld on OR for algorithm in example


