My goal here is to write a nes rom in assembly using ca65 which sets the accumulator to $FF and loops forever.
I have been looking over the following list of articles:
http://shiru.untergrund.net/articles/programming_nes_games_in_c.htm
http://oliverschmidt.github.io/cc65/doc/ld65-5.html
http://forums.nesdev.com/viewtopic.php?f=2&t=9896&p=109046&hilit=nes.cfg#p109046
http://forums.nesdev.com/viewtopic.php?t=3816
And based on my understanding (or lack thereof) I have distilled everything to the following two files.
My "nes.cfg" file:
My assembly code:
Using an emulator I am able to see the my "LDA #$FF" instruction is indeed being loaded into memory at the correct location by the accumulator isn't being set - which, given what I know, means the program counter isn't making it to $8000 - where my code is.
Any ideas on what I'm missing here?
I have been looking over the following list of articles:
http://shiru.untergrund.net/articles/programming_nes_games_in_c.htm
http://oliverschmidt.github.io/cc65/doc/ld65-5.html
http://forums.nesdev.com/viewtopic.php?f=2&t=9896&p=109046&hilit=nes.cfg#p109046
http://forums.nesdev.com/viewtopic.php?t=3816
And based on my understanding (or lack thereof) I have distilled everything to the following two files.
My "nes.cfg" file:
Code:
MEMORY {
RAM: start = $0000, size = $1FFF;
IOREG: start = $2000, size = $201F;
EXROM: start = $4020, size = $1FDF;
SRAM: start = $6000, size = $1FFF;
PRGROM: start = $8000, size = $7FFF;
}
SEGMENTS {
HEADER: load = RAM, type = ro;
STARTUP: load = PRGROM, type = ro;
VECTORS: load = PRGROM, type = ro;
CHARS: load = PRGROM, type = ro;
}
RAM: start = $0000, size = $1FFF;
IOREG: start = $2000, size = $201F;
EXROM: start = $4020, size = $1FDF;
SRAM: start = $6000, size = $1FFF;
PRGROM: start = $8000, size = $7FFF;
}
SEGMENTS {
HEADER: load = RAM, type = ro;
STARTUP: load = PRGROM, type = ro;
VECTORS: load = PRGROM, type = ro;
CHARS: load = PRGROM, type = ro;
}
My assembly code:
Code:
; TESTING
; cl65 -t nes test.s
.segment "HEADER"
.byte "NES" ; signature
.byte $1A ; signature
.byte $01 ; # of 16kb PRG-ROM banks
.byte $01 ; # of 8kb VROM banks
.byte $00 ; ROM control byte one
.byte $00 ; ROM control byte two
.byte $01 ; # of 8kb RAM banks
.byte $00 ; reserved
.segment "STARTUP"
INIT:
LDA #$FF
LOOP:
JMP LOOP
.segment "VECTORS"
.segment "CHARS"
; cl65 -t nes test.s
.segment "HEADER"
.byte "NES" ; signature
.byte $1A ; signature
.byte $01 ; # of 16kb PRG-ROM banks
.byte $01 ; # of 8kb VROM banks
.byte $00 ; ROM control byte one
.byte $00 ; ROM control byte two
.byte $01 ; # of 8kb RAM banks
.byte $00 ; reserved
.segment "STARTUP"
INIT:
LDA #$FF
LOOP:
JMP LOOP
.segment "VECTORS"
.segment "CHARS"
Using an emulator I am able to see the my "LDA #$FF" instruction is indeed being loaded into memory at the correct location by the accumulator isn't being set - which, given what I know, means the program counter isn't making it to $8000 - where my code is.
Any ideas on what I'm missing here?