t-edson / P65Pas

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

Generating wrong code for procedures #57

Open Squall-FF8 opened 1 year ago

Squall-FF8 commented 1 year ago

I have a function that is called like that:

procedure FillChar(Dest: word; Count: byte registerY; Value: byte registerA);
begin
 ... 
end;
...
FillChar($2000, 20, 10);

The code generated is:

      $08B9 A9 0A    LDA #$0A 
      $08BB A0 14    LDY #$14 
      $08BD A9 00    LDA #$00 
      $08BF 8D 0E 08 STA Src@0 
      $08C2 A9 20    LDA #$20 
      $08C4 8D 0F 08 STA Src@1 
      $08C7 20 60 08 JSR __FillChar

This code destroys Value argument, because A is overridden .