Compare Instruction

From C64-Wiki
Jump to navigationJump to search

One of several instructions that compares the value in a processor register with a byte value in memory.

The Comparison instructions in the [[MOS 6510]MOS 65xx] family of processors are: CMP, CPX, and CPY. The purpose of these instructions is to set certain processor flags, speficially the Negative flag, the Zero flag, and the Carry flag.

The processor carries out these instructions in the same way the SBC instruction is carried out, with three significant differences. First, and most important, the result value is not stored. Second, these instructions operate on the X index register, the Y index register or the Accumulator, whereas SBC only operates on the Accumulator. And finally, the Compare instructions do not alter the Overflow flag.

CMP Compare Memory and Accumulator

CPX Compare Memory and X Index

CPY Compare Memory and Y Index