문제

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