nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

indirect addressing #66

Closed leyyinad closed 4 years ago

leyyinad commented 4 years ago

Is there a problem with indirect addressing?

The following source yields a

main.asm:6:5: error: Couldn't encode instruction 'sta'

* = $c000

main:
    lda #$28
    ldy #$08
    sta (screen),y
    rts

screen:
    !word $0400

https://nurpax.github.io/c64jasm-browser/?gist_id=3bd93f19af02db5b434bb0e658b55092

Am I missing something here?

Thank you!

nurpax commented 4 years ago

I think the indirect ptr screen needs to reside in the zero page? Eg.

!let screen = $40 ; 40 is arbitrary

sta (screen), y

should work

IIRC an absolute, larger than 255 address for screen is not supported in 6502 for the indirect addressing mode.

Please correct me if I’m wrong, maybe I missed an encoding.

At the very least the error message is poor and should provide better guidance.

leyyinad commented 4 years ago

Of course. Should’ve read the manual a bit more thoroughly. Sorry & thank you a lot, this answers a couple of questions I had in my mind. :-)