From http://www.6502.org/tutorials/65c816opcodes.html#6.1.1.2
For the CPX instruction:
E0 3-x 3-x imm x.....xx . CPX #$54
E4 2 4-x+w dir x.....xx . CPX $10
EC 3 5-x abs x.....xx . CPX $9876
What is the difference between these in terms of the addressing modes specified? At first glance I thought this was obvious to me, but then I realized I actually don't know.
imm means immediate. If x (native mode) is set, then the length of the total instruction (including operand) is 2, otherwise it is 3?
dir means direct? It always takes a one byte operand.
abs means absolute? It always takes a two byte operand.
'#' means the operand is immediate data.
'$' specifies hexadecimal.
But what is the difference between them? My confusion is e.g. what the difference between E0 CPX with the native mode set and E4 CPX? Don't they both simply take a single byte operand? Same with E0 CPX and EC CPX, if the native mode flag is not set, then what is the difference?
Do any of these work with relative addressing, e.g. comparing the value at an offset from the program counter? Are any of them indirect, as in holding a "pointer" value which is dereferenced? Is the seemingly duplicated behavior due to backwards compatibility with the 6502?
I assume this will become very clear to me as long as I can get a clear explanation of what "imm", "dir", and "abs" actually mean and how they are different.
This section of the document talks about addressing modes:
http://www.6502.org/tutorials/65c816opcodes.html#5
However, it doesn't make it any more clear to me, the section mostly deals with how addressing modes translate into page and bank boundary wrapping, not so much as explaining the basic differences between the various modes.