Given the following CA65 code:

foo = $82

.scope
        LDA #$ff
        STA foo*$40
.endscope

I get this error message:

foo.s(5): Error: Range error (8320 not in [0..255])

Interestingly, the following version works as expected:

foo = $82

        LDA #$ff
        STA foo*$40

So how do I get this working inside a .scope?

有帮助吗?

解决方案

If you're referring to a global symbol from inside a .scope or .proc, sometimes you have to explicitly state that the symbol is in the global scope and not the inner scope. You do this by adding the "paamayim nekudotayim" (pair of colons) operator before the symbol: ::spam. I've noticed this mostly with things like .if.

The following compiles in ca65:

foo = $82

.scope
        LDA #$ff
        STA ::foo*$40
.endscope

其他提示

I'm not sure why the scope is causing an issue, but it looks like you need to tell the assembler that the STA is an absolute, rather than the Zero Page reference it is inferring:

foo = $82

.scope
        LDA #$ff
        STA a:foo*$40
.endscope
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top