Empty program: Difference between revisions
Content deleted Content added
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 21: | Line 21: | ||
===Nintendo Entertainment System=== |
===Nintendo Entertainment System=== |
||
Without an infinite loop the program counter will eventually attempt to execute the interrupt vectors as executable code |
Without an infinite loop the program counter will execute undefined behavior, depending on how "empty" bytes are padded. If we're generous and assume that empty bytes are padded with <code>NOP</code>, eventually the program counter will attempt to execute the interrupt vectors as executable code. If we assume that an "empty program" needs to not crash (even though you really can't tell the difference with nothing on screen), we need a way to "trap" the program counter. |
||
<lang 6502asm>.org $8000 ; |
<lang 6502asm>.org $8000 ;usually $8000 but it depends on the mapper. |
||
RESET: ;execution starts here |
RESET: ;execution starts here |
||
JMP RESET |
JMP RESET |
||
NMI: ;NMI can't happen if the screen is off. |
NMI: ;NMI can't happen if the screen is off. No need for RTI |
||
IRQ: ;this will never occur without a CLI command |
IRQ: ;this will never occur without a CLI command. |
||
.org $FFFA ;all 6502 based hardware uses this section of memory to hold the addresses of interrupt routines |
.org $FFFA ;all 6502 based hardware uses this section of memory to hold the addresses of interrupt routines |