Hi Guys, I'm trying to get the address of some of my variables.
Code:
.zeropage
ZPLoc: .res 20
.bss
BSSLoc: .res 10
.data
DataLoc: .res 15
lda #ZPLoc
lda #BSSLoc
lda #DataLoc
ld65 config file
ZP starts at $0000
RAM starts at $0200
where BSS is the first segment under RAM, and DATA is the second segment under RAM.
The ca65 assembler throws the following error for
BSSLoc and
DataLoc:
Error: Range error (Address size 2 does not match fragment size 1)But works fine for ZPLoc.
I've tried a number of things, moving the variables around, but still getting the same error. Always works in zero page memory but not the others.
Background: I wanted the address of the variables so I could clear their memory locations with an stz in a loop.
Then I learn't that ca65 can declare and initialise a variable in one statement, e.g. ZPLoc: .res 20, $00
Regardless, I would still like to understand why this fragmentation error is occurring, as no doubt I will eventually need to get the address of a variable sooner or later.
According to the error, Address size 2 and Fragment size 1 are the clues here, but I don't understand what is going on. Isn't LDA working with bytes (8 bits) here?
Thanks for your help.