A hardware register is a small storage location inside the processor. The 6502 uses registers to perform calculations and move information, making them faster to access than external memory. Because the 6502 has very few registers, programs regularly move values between registers and RAM. section 3.2 section 3.2.2
Registers are not general-purpose variables with unlimited capacity. They hold the temporary values needed for operations such as adjusting an object’s coordinates or adding a player’s score, while longer-lived game data remains in memory. section 3.2 section 3.3
The principal 6502 registers have distinct jobs:
- A, the 8-bit accumulator, performs primary arithmetic operations and accesses memory. section 3.2.2
- X and Y, each 8 bits, act as indexes in some addressing modes. section 3.2.2
- PC, the 16-bit program counter, points to the next instruction to execute. section 3.2.2
- S, the 8-bit stack index, indicates where the next stack element will be written. section 3.2.2
- P, the 8-bit status flag, records CPU state and information about the previous instruction’s result. section 3.2.2
Table 3.5 The registers available in a 6502 processor (view table figure)
| Register |
Size (bits) |
Description |
|---|---|---|
| A |
8 |
Also called the accumulator. It is the primary register for arithmetic operations and accessing memory. |
| X |
8 |
Used as an index in some addressing modes. |
| Y |
8 |
Used as an index in some addressing modes. |
| PC |
16 |
Also called the program counter. It points to the address of the next instruction to be executed. |
| S |
8 |
Also called the stack index. It indicates where the next element will be written to the stack. |
| P |
8 |
Also called the status flag. It contains the current state of the CPU or information about the result of the previous instruction. |
Use the register table to compare each register’s size and role before choosing where a value belongs. section 3.2.2



