tebe6502 / Mad-Pascal

Mad Pascal Compiler for 6502 (Atari XE/XL, C64, C4Plus, Neo6502)
122 stars 20 forks source link

Neo6502: Illegal addressing mode (CPU 65816) #134

Closed zbyti closed 9 months ago

zbyti commented 9 months ago
uses crt, neo6502;

const
    HEIGHT       = 8;
    WIDTH        = 8;
    BOARD_SIZE   = HEIGHT * WIDTH;
    CENTER_X     = 96;
    CENTER_Y     = 64;
    TILE_SIZE    = 16;
    TILE_ADDRESS = $9000;

var
    tmpB1, tmpB2     : byte;
    posX, posY, tmpW : word;

begin
      for tmpB1 := 0 to BOARD_SIZE - 1 do begin
          if peek(TILE_ADDRESS + 3 + tmpB1) > 4 then begin
              posX := (CENTER_X + 3 * TILE_SIZE + 8) + (tmpB1 mod HEIGHT) * TILE_SIZE;
              posY := (CENTER_Y + 3 * TILE_SIZE + 8) + (tmpB1 div WIDTH) * TILE_SIZE;            
          end
      end;
end.

gives:

mp-build-neo test.pas 200 r
Mad Pascal Compiler version 1.7.1 [2024/02/11] for 6502
Compiling test.pas
test.pas (13) Note: Local variable 'TMPB2' not used
test.pas (14) Note: Local variable 'TMPW' not used
23 lines compiled, 0.79 sec, 9924 tokens, 736 idents, 178 blocks, 8 types
2 note(s) issued
ZPAGE: $0000..$0053
RTBUF: $0200..$02FF
RTLIB: $0203..$0223
        jsr #$00
test.a65 (299) ERROR: Illegal addressing mode (CPU 65816)

workaround:

uses crt, neo6502;

const
    HEIGHT       = 8;
    WIDTH        = 8;
    BOARD_SIZE   = HEIGHT * WIDTH;
    CENTER_X     = 96;
    CENTER_Y     = 64;
    TILE_SIZE    = 16;
    TILE_ADDRESS = $9000;

var
    tmpB1, tmpB2     : byte;
    posX, posY, tmpW : word;

begin
      for tmpB1 := 0 to BOARD_SIZE - 1 do begin
          if peek(TILE_ADDRESS + 3 + tmpB1) > 4 then begin
              tmpB2 := (tmpB1 mod HEIGHT) * TILE_SIZE;
              posX := (CENTER_X + 3 * TILE_SIZE + 8) + tmpB2;
              tmpB2 := (tmpB1 div WIDTH) * TILE_SIZE;
              posY := (CENTER_Y + 3 * TILE_SIZE + 8) + tmpB2;            
          end
      end;
end.
zbyti commented 9 months ago

@tebe6502 thx :)