BINARY OPERATIONS

AND

This operation takes the contents of the A-register, and another 8-bit field, and examines these, bit by bit. Only if corresponding bits are both "1" does it put a "1" back in this position in the A-register. Otherwise it inserts a "0".

For instance, AND A, 07 has the following effect:

A-register before the operation00110101
0700000111
A-register after the AND00000101

OR

This works in a similar way to AND, but this time, the resulting bit is a "1" if either of the initial bits is a "1". So OR A, 05 gives:

A-register before the operation01001011
0500000101
A-register after the OR01001111

XOR

Here the initial bit values must be different for the result to be a "1". XOR A, B3 gives:

A-register before the operation01011010
B310110011
A-register after the XOR11101001


It's particularly useful for flipping a register from 0 to 1 and back again. If the A-register contains 0 to start with, every time the instruction XOR A, 01 is executed, the value in the A-register will flip. (0 to 1, back to 0, back to 1 and so on.)

SET

Sets one bit of a byte, for example:

SET 3, A

sets the third bit of A, adding 8 to it.

BIT

Tests one bit of a byte, for example:

BIT 3, A

checks the third bit of A, and sets the Zero flag if set.

Back to Main Page