Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Logical Boolean

Operands are treated as booleans: \(0\) is false, any non-zero value is true. Results are \(1_{i64}\) or \(0_{i64}\).

CodeMnemonicStack EffectDescription
0x36NOT\([\ldots, a] \to [\ldots, [a = 0]]\)Logical NOT.
0x37AND\([\ldots, a, b] \to [\ldots, [a \neq 0 ;\wedge; b \neq 0]]\)Logical AND. Both operands are already popped; no short-circuit.
0x38OR\([\ldots, a, b] \to [\ldots, [a \neq 0 ;\vee; b \neq 0]]\)Logical OR.
0x39XOR\([\ldots, a, b] \to [\ldots, [a \neq 0 ;\oplus; b \neq 0]]\)Logical XOR. True iff exactly one operand is non-zero.

None of these instructions have register effects.

Logical vs. Bitwise

These instructions perform logical (boolean) operations. For bitwise operations on the raw i64 bit pattern, see the Bitwise instructions (BAND, BOR, BXOR, BNOT).

The key difference: \(\text{NOT}; 5 = 0\) (logically false), while \(\text{BNOT}; 5 = \mathord{\sim}5\) (bitwise complement, a large negative number).