6502 processor basics

Depending on how you look at it, the 6502 can be considered as having 1, 3, or 6 registers. In one point of view, the A register is the only real general purpose register, and all the others are unique and special. The point of view that I think is most accurate, is to say that it has three registers: A, X, and Y. The PC, P, and S registers are so special purpose they don't really deserve to be called registers at all.

Registers:

bits in the status register:

Addressing modes

Pay attention! If you get all this straight, you know most of what you need to know to understand this chip. There is some weird stuff here.

Byte 1 is the opcode for the instruction being executed. Some instructions have additional information in one or two bytes that follow.

The Stack

The stack always and only uses memory from 0100 to 01ff (i.e. the stack lives in page 1). Notice that this has implications for hardware design - you better put a block of RAM starting at address zero and big enough to provide for both pages 0 and 1. Notice the implication here that page zero will be ram and that startup code must initialize all zero page contents that matter. The usual thing to do is to initialize the stack pointer to 0xff. Once this is done, the first value pushed will go to 0x1ff and SP will become 0x1fe. The stack pointer points to the empty location above the top of the stack where the next push will go.

Vector locations

After reset, the processor loads the PC from FFFC (low byte) and FFFD (high byte) and away she goes. There are two other vectors (lsb first), the full set of 3 is:


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org