Data is stored in RAM, but the only reason you'd ever want to also store it in ROM is if you plan to copy it to RAM at the start of the program, such as a small piece of code related to bank switching. Here are the traditional definitions of the segments:FinalZero wrote:Why is it useless though? Isn't data stored there? I don't see why it should be any different from the CODE segment.In SEGMENTS, use type=bss instead of type=rw for any RAM segment. For segments of type bss, the linker won't try to (uselessly) put initial values for the segment into the ROM file.
- CODE: stored in ROM, used in ROM
- RODATA: stored in ROM, used in ROM. Primary difference from CODE is that some architectures such as 65816 and 8086 allow for a separate program bank and data bank.
- DATA: stored in ROM, copied to RAM in init code (which isn't written automatically for you), used in RAM
- BSS: stored nowhere, cleared to zero* in init code, used in RAM
- ZEROPAGE: like BSS but in $0000-$00FF
What values end up in $FFFA through $FFFF? There should be three addresses (in the typical reverse byte order of the 6502); do they point anywhere familiar?However, running the debugger, it seems to be alternating between $0002 and $FFFF. I don't know why.
Where do $FFFA-$FFFB and $FFFE-$FFFF point? Are you pushing or pulling anything in your NMI and IRQ handlers?Edit: I forgot to change the number of PRG banks in the header back to 1. Doing that, it runs code that I wrote. I think I made an error in the code though, because it isn't doing the addition that I wanted it to do.
Edit Edit: It seems to be interrupting every so often, and then returning to the wrong address. Ideas as to why?
* Yes, tokumaru, ca65 was originally intended to support a C compiler, and the C language does specify clearing uninitialized variables in the init code. In pure assembly language programs, one can use an alternate convention that each is responsible for clearing its own memory.