Skip to main content

AND

Compute the bitwise AND of the two operands, storing the result in the left operand.

OpcodeBytesCyclesFormExample
$7633AND B:_, {U_BYTE}AND B:1, 123
$CE43AND P:_, {U_PAIR}AND P:2, 12345
$7733AND I:_, {U_BYTE}AND I:4, 123
$CF43AND I:_, {U_PAIR}AND I:4, 12345
$7833AND I:_, XHEX {XINT}AND I:4, XHEX $D000_0000
$7933AND B:_, B:_AND B:1, B:2
$7A33AND P:_, P:_AND P:2, P:4
$7B33AND I:_, I:_AND I:4, I:8
Condition flagOutput
zero (ZF)If the result is zero, this flag is 1; otherwise it is 0.
negative (NF)This flag is updated with the highest bit of the result.
For example, if AND B:0, $F0 stores $80 in B:0, then NF will be 1.
overflow (OF)This flag is always 0.
carry (CF)This flag is always 0.

Notes

  • AND is commonly used for bitmask operations.

  • Large literal values such as $D000_0000 must be compatible with XHEX encoding.