14
Figure 2-5. NMI (Non-Maskable Interrupt) handling.
2.5 Addressing Modes
The 6502 has several different addressing modes, providing different ways to access
memory locations. There are also addressing modes which operate on the contents of
registers, rather than memory. In total there are 13 different addressing modes on the 6502.
Some instructions can use more than one different addressing mode. Details on the available
addressing modes can be found in Appendix E.
2.6 Instructions
The 6502 has 56 different instructions although some come in multiple variations using
different addressing modes, making a total of 151 valid opcodes (operation codes) out of a
possible 256. A detailed explanation of the complete instruction set can be found in [2], [29]
and [32]. Instructions are either one, two or three bytes long, depending on the addressing
mode. The first byte is the opcode and the remaining bytes are the operands. Instructions fit
into several functional groups [3]:
• Load / Store Operations - Load a register from memory or stores the contents of a
register to memory.
• Register Transfer Operations - Copy contents of X or Y register to the accumulator or
copy contents of accumulator to X or Y register.
• Stack Operations - Push or pull the stack or manipulate stack pointer using X register.
• Logical Operations - Perform logical operations on the accumulator and a value stored in
memory.
• Arithmetic Operations - Perform arithmetic operations on registers and memory.
• Increments / Decrements - Increment or decrement the X or Y registers or a value stored
in memory.
• Shifts - Shift the bits of either the accumulator or a memory location one bit to the left or
right.