I don't remember where I found it, but I'm looking at a .asm file that's essentially a hello world program, and it raises a number of questions for a noob like me, despite consisting mostly of comments and very little code.
1. The beginning of the file has hardly any comments.
.segment "HEADER"
.byte "NES", 26, 2, 1
; CHR ROM data
.segment "CHARS"
.segment "VECTORS"
.word 0, 0, 0, nmi, reset, irq
.segment "STARTUP"
.segment "CODE"
I've been trying to read up on this, and I think CA65 uses these segments keywords to determine where in the resulting .NES file it will put your data upon assembly/compilation (are they the same, by the way?), since e.g. CHR data has to be in a certain address range within the .NES, though if I'm wrong about this, please do correct me. Anyway, is this the full list of possible segments? If not, where can I find such a list, if one exists?
2. [ANSWERED] This particular .asm file has the following labels:
reset
@vblankwait1
@clrmem
@vblankwait2
forever
irq
nmi
What is the purpose of having an @ at the beginning of a label?
3. What is the significance or purpose of the leading 3 zeroes, here?
.segment "VECTORS"
.word 0, 0, 0, nmi, reset, irq
If I got this right, the NMI vector is at $FFFA, so whenever an NMI occurs, the program goes to the NMI label (which is located at the address stored at $FFFA) and starts running the code there. The address to this label is 2 bytes long ($FFFA). Do each of the leading zeroes also represent 2 bytes, i.e. does the vectors segment start at $FFF4? Which interrupts do the first 3 zeroes correspond to? Are they only used by mappers, and is that why they have been set to 0 in this particular program (which doesn't use mappers)?
1. The beginning of the file has hardly any comments.
.segment "HEADER"
.byte "NES", 26, 2, 1
; CHR ROM data
.segment "CHARS"
.segment "VECTORS"
.word 0, 0, 0, nmi, reset, irq
.segment "STARTUP"
.segment "CODE"
I've been trying to read up on this, and I think CA65 uses these segments keywords to determine where in the resulting .NES file it will put your data upon assembly/compilation (are they the same, by the way?), since e.g. CHR data has to be in a certain address range within the .NES, though if I'm wrong about this, please do correct me. Anyway, is this the full list of possible segments? If not, where can I find such a list, if one exists?
2. [ANSWERED] This particular .asm file has the following labels:
reset
@vblankwait1
@clrmem
@vblankwait2
forever
irq
nmi
What is the purpose of having an @ at the beginning of a label?
3. What is the significance or purpose of the leading 3 zeroes, here?
.segment "VECTORS"
.word 0, 0, 0, nmi, reset, irq
If I got this right, the NMI vector is at $FFFA, so whenever an NMI occurs, the program goes to the NMI label (which is located at the address stored at $FFFA) and starts running the code there. The address to this label is 2 bytes long ($FFFA). Do each of the leading zeroes also represent 2 bytes, i.e. does the vectors segment start at $FFF4? Which interrupts do the first 3 zeroes correspond to? Are they only used by mappers, and is that why they have been set to 0 in this particular program (which doesn't use mappers)?