There are no register/register operations on the 6502 (except for transfer). The 6502 follows a strict accumulator/memory scheme (with a few extensions for index-register/memory).
Your example is a bit useless, as comparing two constants doesn't make sense - one needs to be a variable at least, right? Let's assume the first (#$03) is a memory location called VALUE
instead. So a useful check for VALUE
holding 00
would work like this:
LDX #$05 * Prepare X
LDA VALUE * Value to compare
CMP #$00 * Compare with this
BEQ Equal * Do not store X when equal
STX $0200 * Store X
Equal:
BRK
In a real life 6502 program the CMP instruction can be left out completely, as loading a value already performs a test for zero.
(Further, CLD
is not needed, as decimal mode has no influence beside addition/subtractions and there is no need to use X, as storing a constant value (or moving one) can be done by using A
after the BEQ
- same program length but fewer cycles when not needed. And so on :)))
$0200
?