ZomCoder wrote:
I wasn't yet aware of the distinction between RAM and ROM segments.
There's your problem.
Also, though I'm not familiar with P65, I imagine that .space defines an address or value that the program uses but where the places in code where the .space label is used are simply repplaced with the value specified in .space. Such as:
Code:
.segment zp
.org $0000
.space label $45
.text
.org $c000
lda #$00
sta label
rti
This would produce the same ROM output as if you just wrote:
Code:
.text
.org $c000
lda #$00
sta $45
rti
The .space statement gets written nowhere in the ROM output, but is simply a label that has a specific valued defined to it, and that when the program is assembled, all instances of the label appearing in code are replaced with the value, nothing more or less.
.byte on the other hand causes the values after it to actually be written to the ROM output where it appears in the code, just in the same location as if it were code. Where as the "label:" statement causes it to be a label just like defined in .space, but the value that goes into the label at that point is the address in the ROM the label is defined. So:
Code:
.text
.org $c000
my_label: ;value of $c000 is stored in "my_label" because that is the location of its definition.
.byte 1 ;the value of 1 is written to the ROM
lda my_label ;this statement will be at address $c001 in the ROM, because the value of 1 was already written.
sta $00
rti
would be the same as if you just wrote:
Code:
.text
.org $c000
.byte 1
lda $c000
sta $00
rti
Do you see the difference between the .space statements and the normal "label:" and .byte statements?