Category:6502 Assembly: Difference between revisions

m
Line 10:
==Registers==
The 6502 has three main data registers: A (the accumulator), X, and Y. Most mathematical operations can only be done with the accumulator. X and Y are often limited to loop counters and offsets for indirect addressing. It also has the system flags, the stack pointer, and the program counter.
 
Like with other assembly languages, 6502's A, X, and Y registers have a few key properties, which are fairly straightforward:
* A data register maintains its contents unless a command explicitly alters the contents (or the hardware is powered off).
* If a new value is loaded into a data register, the old value is destroyed. The computer "forgets" what used to be in that register. If you want to preserve a value, you will need to "push" it onto the stack, or store its value in RAM and retrieve it later.
* Commands that "move" or "transfer" the value from one register to another actually <i>copy</i> that value. The value in the source register is unchanged; only the value in the destination is updated. For example, if the X register contains 4 and the accumulator contains 7, the <code>TXA</code> command (transfer X to accumulator) will set the accumulator to 4, and X still contains 4.
* A register's contents at startup are undefined. Emulators of 6502-based hardware will typically initialize them to zero, but on real hardware this is not guaranteed.
 
==RAM==
1,489

edits