ANC

From C64-Wiki
Jump to navigationJump to search

ANC (short for "Logic ANd altering Carry") is an illegal opcode that works the same as AND, except that the Carry Flag is set to the same state that the Negative Flag is set to.

Addressing modes[edit | edit source]

Opcode Addressing
mode
Assembler
format
Length
in bytes
Number of
cycles
Dec Hex
11 0B Immediate ANC #nn 2 2
43 2B Immediate ANC #nn 2 2

ANC only supports immediate mode, and may have an opcode of either $0B or $2B.

CPU flags[edit | edit source]

ANC affects 3 of the CPU's status flags:

  • The negative flag is set if the result is negative, i.e. has its most significant bit set.
  • The zero flag is set if the result is zero, or cleared if it is non-zero.
  • The carry flag to the same state that the Negative Flag is set to.

Examples[edit | edit source]

ANC Opcode

ANC #$00 acts like LDA #$00 followed by CLC

Links[edit | edit source]