Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tebe6502 committed Oct 1, 2024
1 parent e9722f8 commit 02f6fac
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
Binary file modified bin/windows/mp.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions src/Optimize.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,17 @@ procedure OptimizeASM;

listing[k] := listing[i];


if (k > 0) and
inx(k) and // dex ; k-1
dex(k-1) then // inx ; k
begin
listing[k-1] := '';
listing[k] := '';
dec(k, 2);
end;


if (k > 0) and
sta_stack(k) and // lda :STACKORIGIN ; k-1
lda_stack(k-1) and // sta :STACKORIGIN ; k
Expand Down
2 changes: 1 addition & 1 deletion src/include/opt6502/opt_CMP.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ begin
cmp_stack(i+7) and // cmp :STACKORIGIN+9 ; 7
seq(i+8) and // seq ; 8
((listing[i+9] = #9'bpl @+') or (listing[i+9] = #9'bcs @+')) and // bpl|bcs @+ ; 9
(pos('jmp l_', listing[i+10]) > 0) then // jmp l_ ; 10
jmp(i+10) then // jmp l_ ; 10
if (copy(listing[i+2], 6, 256) = copy(listing[i+7], 6, 256)) then
begin
listing[i+3] := '';
Expand Down
20 changes: 10 additions & 10 deletions src/include/opt6502/opt_FOR.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
cmp(1) and (cmp_im(1) = false) and
(listing[2] = #9'bcc *+7') and
(listing[3] = #9'beq *+5') and
(pos('jmp l_', listing[4]) > 0 ) then
jmp(4) then
begin
listing[2] := #9'lda ' + copy(listing[1], 6, 256);
listing[3] := #9'cmp ' + copy(listing[0], 6, 256);
Expand All @@ -79,7 +79,7 @@
cmp_im(1) and
(listing[2] = #9'bcc *+7') and
(listing[3] = #9'beq *+5') and
(pos('jmp l_', listing[4]) > 0 ) then
jmp(4) then
begin
k := GetBYTE(1) + 1;

Expand Down Expand Up @@ -134,7 +134,7 @@
(listing[3] = #9'eor #$80') and
(listing[4] = #9'bmi *+7') and
(listing[5] = #9'beq *+5') and
(pos('jmp l_', listing[6]) > 0 ) then
jmp(6) then
begin
k := GetBYTE(1) + 1;

Expand All @@ -155,7 +155,7 @@
(listing[2] = #9'svc') and
(listing[3] = #9'eor #$80') and
(listing[4] = #9'bpl *+5') and
(pos('jmp l_', listing[5]) > 0 ) then
jmp(5) then
begin
listing[4] := #9'jmi ' + copy(listing[5], 6, 256);
listing[5] := '';
Expand All @@ -171,7 +171,7 @@
lab_a(5) and
(listing[6] = #9'bcc *+7') and
(listing[7] = #9'beq *+5') and
(pos('jmp l_', listing[8]) > 0 ) then
jmp(8) then
begin

k := GetBYTE(1) shl 8 + GetBYTE(4);
Expand Down Expand Up @@ -209,7 +209,7 @@
lab_a(5) and
(listing[6] = #9'bcc *+7') and
(listing[7] = #9'beq *+5') and
(pos('jmp l_', listing[8]) > 0 ) then
jmp(8) then
begin
listing[7] := '@';
listing[8] := #9'jcc ' + copy(listing[8], 6, 256);
Expand Down Expand Up @@ -242,7 +242,7 @@
lab_a(11) and
(listing[12] = #9'bcc *+7') and
(listing[13] = #9'beq *+5') and
(pos('jmp l_', listing[14]) > 0 ) then
jmp(14) then
begin
listing[13] := '@';
listing[14] := #9'jcc ' + copy(listing[14], 6, 256);
Expand Down Expand Up @@ -313,7 +313,7 @@
lab_a(11) and
(listing[12] = #9'bcc *+7') and
(listing[13] = #9'beq *+5') and
(pos('jmp l_', listing[14]) > 0 ) then
jmp(14) then
begin
listing[0] := '';
listing[1] := '';
Expand Down Expand Up @@ -353,7 +353,7 @@
(listing[16] = #9'.ENDL') and
(listing[17] = #9'bmi *+7') and
(listing[18] = #9'beq *+5') and
(pos('jmp l_', listing[19]) > 0 ) then
jmp(19) then
begin
k := GetBYTE(2) shl 8 + GetBYTE(5) + 1;

Expand Down Expand Up @@ -402,7 +402,7 @@
(listing[15] = 'L5') and
(listing[16] = #9'.ENDL') and
(listing[17] = #9'bpl *+5') and
(pos('jmp l_', listing[18]) > 0 ) then
jmp(18) then
begin
k := GetBYTE(2) shl 8 + GetBYTE(5);

Expand Down

0 comments on commit 02f6fac

Please sign in to comment.