| And Memory With Accumulator |
|
|
AND (And Memory With Accumulator) performs a logical AND on the operand and the accumulator and stores the result in the accumulator. This opcode is similar in function to ORA and EOR.
Operation
This pseudo C code shows how the AND opcode functions when it is executed.
Operand &= ACCUMULATOR // AND the two values together.
SET_NEGATIVE(Operand); // Clears the Negative Flag if the Operand is $#00-7F, otherwise sets it.
SET_ZERO(Operand); // Sets the Zero Flag if the Operand is $#00, otherwise clears it.
ACCUMULATOR = Operand; // Stores the Operand in the Accumulator Register.
Addressing Modes
| Addressing Mode
|
Assembly Language Form
|
Opcode
|
# Bytes
|
# Cycles
|
| Immediate
|
AND #Operand
|
29
|
2
|
2
|
| Zero Page
|
AND Operand
|
25
|
2
|
3
|
| Zero Page, X
|
AND Operand, X
|
35
|
2
|
4
|
| Absolute
|
AND Operand
|
2D
|
3
|
4
|
| Absolute, X
|
AND Operand, X
|
3D
|
3
|
4*
|
| Absolute, Y
|
AND Operand, Y
|
39
|
3
|
4*
|
| (Indirect, X)
|
AND (Operand, X)
|
21
|
2
|
6
|
| (Indirect), Y
|
AND (Operand), Y
|
31
|
2
|
5*
|
| * Add 1 if page boundary is crossed.
|
Examples