The accumulator, also called the A register, is the 6502’s main working register for many calculations. An instruction takes the value already in A, combines it with a direct value or a value read from memory, and leaves the result in A. This makes A the place to load a starting value before arithmetic or bit operations, then save or reuse the finished value. section 4.1.1 section 4.5.2
Use the A register as a short, explicit sequence:
- Load or otherwise establish the starting value in A. section 4.1.1 section 4.1.2
- Set the carry state correctly: CLC before ADC addition, or SEC before SBC subtraction. section 4.1.1 section 4.1.2
- Run the operation; ADC or SBC replaces A with the arithmetic result. section 4.1.1 section 4.1.2
- Use AND, EOR, or ORA when the task is to change selected bits; each stores its result back in A. section 4.5.2
Add a value and verify A
To turn $01 into $06, clear carry, load $01 into A, then add $05: `clc`, `lda #$01`, `adc #$05`. After running the code in the assembler simulator, the debug display shows `A=$06`. The same pattern works when the second value comes from an absolute address, zero-page address, or indexed address. section 4.1.1
Subtraction follows the same accumulator pattern but uses a different carry preparation. With `sec`, `lda #$06`, and `sbc #$05`, A becomes $01. Setting carry matters because SBC also subtracts an extra 1 when carry is clear. section 4.1.2
For bit work, A is both an input and destination. AND keeps bits that are 1 in both values; EOR flips positions selected by 1 bits in the other value; ORA ensures positions are set when either value has a 1. Each operation compares corresponding bits of A with a direct value or memory value and writes the byte result to A. section 4.5.2
Table 4.14 Commands for using the stack (view table figure)
| Command |
Name |
|---|---|
| pha |
|
| php |
Push P—Pushes the contents of the P register onto the stack |
| pla |
Pull/Pop A—Pops the top item off the stack and stores it in the A register |
| plp |
Pull/Pop P—Pops the top item off the stack and stores it in the P register |
When A must be preserved while another calculation uses it, PHA pushes its current contents onto the stack and PLA later restores the top stack value into A. section 4.6
