fachat / xa65

6502/65816 cross assembler
http://www.floodgap.com/retrotech/xa/
55 stars 8 forks source link

arithmetic problem? #21

Open fachat opened 1 month ago

fachat commented 1 month ago

When I write

       ldx $d900,y           
       lda VIDPAGE<<8+$900,y 
       sta $d900,y           
       txa                   
       sta VIDPAGE<<8+$900,y 

I get

.C:9344  99 00 E0    STA $E000,Y
.C:9347  BE 00 D9    LDX $D900,Y
.C:934a  B9 00 E0    LDA $E000,Y
.C:934d  99 00 D9    STA $D900,Y

So the shift left of VIDPAGE is done, but the addition of the offset is missing

fachat commented 1 month ago

Exchanging the values gives this..:

 lda $800+VIDPAGE<<8,y
devices/con_c64.a65:line 151: 9342:Overflow error
 sta $800+VIDPAGE<<8,y
devices/con_c64.a65:line 154: 9349:Overflow error 
 lda $900+VIDPAGE<<8,y
devices/con_c64.a65:line 157: 934f:Overflow error
 sta $900+VIDPAGE<<8,y                            
devices/con_c64.a65:line 160: 9356:Overflow error 
 lda $a00+VIDPAGE<<8,y                            
devices/con_c64.a65:line 163: 935c:Overflow error 
 sta $a00+VIDPAGE<<8,y                            
devices/con_c64.a65:line 166: 9363:Overflow error 
 lda $b00+VIDPAGE<<8,y                            
devices/con_c64.a65:line 169: 9369:Overflow error 
 sta $b00+VIDPAGE<<8,y                            
devices/con_c64.a65:line 172: 9370:Overflow error
fachat commented 1 month ago

doing this

       ldx $d900,y            
       lda $900+(VIDPAGE<<8),y
       sta $d900,y            
       txa                    
       sta $900+(VIDPAGE<<8),y

This seems to indicate a priority problem with between the '+' and '<<' shift operators.