A store instruction copies the value currently held in a processor register into memory. On the 6502, store commands begin with ST and name the source register: STA stores A, STX stores X, and STY stores Y. The operand identifies the destination memory location. section 3.3.2 section 3.4
Figure 3.15 Storing a register value in a memory location
Read a store as a one-way transfer: the named register supplies the value, and the address selects where that value is written in memory. section 3.3.2
Start with a direct address. Zero-page addresses use the first 256 bytes of memory and are written as an 8-bit offset; absolute addresses name a full 16-bit address anywhere in memory. Load a value into a register first, then store it at the chosen address. section 3.3.2
Store three register values in zero page
Load A with $10 and use STA $06 to place $10 at memory location $06. Likewise, load X with $11 and store it at $07 with STX, then load Y with $12 and store it at $08 with STY. After running the code, inspect memory to verify the values at those locations. section 3.3.2
Indexed addressing calculates the destination from a base address plus X or Y. For example, with X set to $01, STA $01,X stores A at $02; an absolute base can be indexed in the same way. Indirect indexed forms use bytes in zero page as an address before applying an index, allowing a store to reach an address specified through memory. section 3.3.2
Table 3.9 The available addressing modes (view table figure)
Compare addressing modes to choose whether a destination is a direct zero-page address, a full address, an indexed address, or an address obtained indirectly through zero page. section 3.3.2
Choosing a store form means choosing how the destination is specified. Assemble and run small tests, then inspect the displayed memory range: the changed bytes show exactly where each register value was stored. section 3.3.2 section 3.4
