Category:6502 Assembly: Difference between revisions

m
Line 318:
* A numeral without a <code>#</code> in front is interpreted as a memory address, regardless of whether it is decimal, binary, or hexadecimal. <code>LDA 0</code> will load <i>the value at zero page memory address $00</i> into the accumulator. If you want to load the number 0 into the accumulator you need to type <code>LDA #0</code>.
===ORG===
In the modern era, the advent of linkers, dynamically linked libraries, and the use of <code>INT</code> and <code>SVC</code> to perform I/O operations have rendered this concept mostly obsolete. The <code>org</code> directive (sometimes preceded with a period) tells the assembler where the beginning of a section of code is. Some sections of code will only function in a specific location, so this is often necessary to ensure the code or data table goes where it should. You wouldn't want your executable code in the zero page, for example.
 
Example:
<lang 6502asm> ;typical skeleton for an NES ROM
.org $8000
RESET:
 
maingameloop:
jmp maingameloop
NMI:
RTI
IRQ:
RTI
 
.org $FFFA
dw NMI
dw RESET
dw IRQ ;you can use whatever names you want as long as they match. This is just for clarity.</lang>
 
===Value Labels===
Whether a given number is written in binary, hexadecimal, or decimal does not affect the assembled code. The resulting bytecode is the same regardless. For example,
1,489

edits