t-edson / P65Pas

CPU 6502 Pascal Compiler/IDE/Debugger
GNU General Public License v3.0
119 stars 27 forks source link

Generating wrong code 2 - absolute variables #58

Open Squall-FF8 opened 1 year ago

Squall-FF8 commented 1 year ago

The snipet is this:

var
  r0:  word absolute $02;
  r1:  word absolute $04;
  r2:  word absolute $06;
...
procedure Copy;
  var Src: word absolute $02;  // this declarations are only for convenience
      Dst: word absolute r1;
begin
    asm 
          LDA (Src), Y
          STA (Dst), Y

It generates the following code:

      $082B B1 02    LDA ($02),Y 
      $082D 91 00    STA ($00),Y   ; this is wrong should be STA ($04), Y

so when constant is used - it works fine, but if a declaration is used, it always generate $00