py6502 icon indicating copy to clipboard operation
py6502 copied to clipboard

absolute vs zero page bug

Open TobyLobster opened this issue 2 years ago • 2 comments

The assembler chooses 'zero page,X' when it should choose 'absolute,X'. e.g. the "ORA absolute,X" instruction is assembled as "ORA zp,X" even though it isn't, when using a label thats defined later.

i.e. I think this will not produce the correct bytes:

""" ORG $200 ORA label,X

label: DB $ff """

TobyLobster avatar Jan 27 '22 00:01 TobyLobster

Confirmed.. root@deadhat:/home/dj/src/py6502/src# python2 small_example.py LISTING 1 0000 : 2 0100 : org $100 3 0100 : start: 4 0100 : A9 10 lda #$10 5 0102 : A2 00 ldx #$00 6 0104 : 15 0F ora alab,x 7 0106 : loop: 8 0106 : 9D 00 10 sta $1000,x 9 0109 : E8 inx 10 010A : E9 01 sbc #$01 11 010C : 10 F8 bpl loop 12 010E : 60 rts 13 010F : alab: 14 010F : db $55

I'll look into it. Thanks

dj-on-github avatar Jan 27 '22 17:01 dj-on-github

It's not just ORA

LISTING 1 0000 : 2 0300 : org $300 3 0300 : start: 4 0300 : A9 10 lda #$10 5 0302 : A2 00 ldx #$00 6 0304 : 35 0F and alab,x 7 0306 : loop: 8 0306 : 9D 00 10 sta $1000,x 9 0309 : E8 inx 10 030A : E9 01 sbc #$01 11 030C : 10 F8 bpl loop 12 030E : 60 rts 13 030F : alab: 14 030F : db $55

dj-on-github avatar Jan 27 '22 18:01 dj-on-github