Skip to content

Commit

Permalink
optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tebe6502 committed Oct 6, 2024
1 parent a25ef3a commit 4984082
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
Binary file modified bin/windows/mp.exe
Binary file not shown.
18 changes: 9 additions & 9 deletions src/include/opt6502/opt_ADD.inc
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ begin


if add_sub(i) and // add|sub ; 0
sta_a(i+1) and (sta_stack(i+1) = false) and // sta S ; 1
sta_val(i+1) and // sta S ; 1 ~sta :STACKORIGN
lda_a(i+2) and // lda ; 2
adc_sbc(i+3) and // adc|sbc ; 3
sta_a(i+4) and (sta_stack(i+4) = false) and // sta S+1 ; 4
sta_val(i+4) and // sta S+1 ; 4 ~sta :STACKORIGN
lda_a(i+5) and // lda ; 5
adc_sbc(i+6) and // adc|sbc ; 6
sta_stack(i+7) and // sta :STACKORIGIN+STACKWIDTH*2 ; 7
Expand All @@ -481,7 +481,7 @@ begin


if add_sub(i) and // add|sub ; 0
sta_a(i+1) and (sta_stack(i+1) = false) and // sta S ; 1
sta_val(i+1) and // sta S ; 1 ~sta :STACKORIGN
lda_a(i+2) and // lda ; 2
adc_sbc(i+3) and // adc|sbc ; 3
sta_stack(i+4) and // sta :STACKORIGIN+STACKWIDTH ; 4
Expand Down Expand Up @@ -611,13 +611,13 @@ begin
adc_sbc(i+4) and // adc|sbc ; 4
sta_stack(i+5) and // sta :STACKORIGIN+STACKWIDTH+10 ; 5
lda_a(i+6) and (lda_stack(i+6) = false) and // lda ; 6
sta_a(i+7) and (sta_stack(i+7) = false) and // sta ; 7
sta_val(i+7) and // sta ; 7 ~sta :STACKORIGN
lda_a(i+8) and (lda_stack(i+8) = false) and // lda ; 8
sta_a(i+9) and (sta_stack(i+9) = false) and // sta ; 9
sta_val(i+9) and // sta ; 9 ~sta :STACKORIGN
lda_stack(i+10) and // lda :STACKORIGIN+10 ; 10
sta_a(i+11) and (sta_stack(i+11) = false) and // sta ; 11
sta_val(i+11) and // sta ; 11 ~sta :STACKORIGN
lda_stack(i+12) and // lda :STACKORIGIN+STACKWIDTH+10 ; 12
sta_a(i+13) and (sta_stack(i+13) = false) then // sta ; 13
sta_val(i+13) then // sta ; 13 ~sta :STACKORIGN
if (copy(listing[i+2], 6, 256) = copy(listing[i+10], 6, 256)) and
(copy(listing[i+5], 6, 256) = copy(listing[i+12], 6, 256)) then
begin
Expand Down Expand Up @@ -832,10 +832,10 @@ begin


if add_sub_val(i) and // add|sub ; 0 2023-01-26
sta_a(i+1) and (sta_stack(i+1) = false) and // sta A ; 1
sta_val(i+1) and // sta A ; 1 ~sta :STACKORIGN
lda_a(i+2) and // lda ; 2
adc_sbc_val(i+3) and // adc|sbc ; 3
sta_a(i+4) and (sta_stack(i+4) = false) and // sta A+1 ; 4
sta_val(i+4) and // sta A+1 ; 4 ~sta :STACKORIGN
lda_a(i+5) and // lda A ; 5
sta_stack(i+6) and // sta :STACKORIGIN ; 6
lda_a(i+7) and // lda A+1 ; 7
Expand Down
28 changes: 14 additions & 14 deletions src/include/opt6502/opt_ASL.inc
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ begin
lda_a(i+2) and // lda ; 2
asl_stack(i+3) and // asl :STACKORIGIN ; 3
rol_a(i+4) and // rol @ ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and // sta ; 5
sta_val(i+5) and // sta ; 5 ~sta :STACKORIGN
lda_stack(i+6) and // lda :STACKORIGIN ; 6
sta_a(i+7) and (sta_stack(i+7) = false) and (iy(i+7) = false) then // sta ; 7
sta_val(i+7) and (iy(i+7) = false) then // sta ; 7 ~sta :STACKORIGN
if (copy(listing[i+1], 6, 256) = copy(listing[i+3], 6, 256)) and
(copy(listing[i+3], 6, 256) = copy(listing[i+6], 6, 256)) then
begin
Expand Down Expand Up @@ -568,9 +568,9 @@ begin
rol_stack(i+2) and // rol :STACKORIGIN+STACKWIDTH*2 ; 2
rol_stack(i+3) and // rol :STACKORIGIN+STACKWIDTH*3 ; 3
lda_stack(i+4) and // lda :STACKORIGIN ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and (EAX(i+5) = false) and // sta ; 5
sta_val(i+5) and (EAX(i+5) = false) and // sta ; 5 ~sta :STACKORIGN
lda_stack(i+6) and // lda :STACKORIGIN+STACKWIDTH ; 6
sta_a(i+7) and (sta_stack(i+7) = false) and (EAX(i+7) = false) and // sta ; 7
sta_val(i+7) and (EAX(i+7) = false) and // sta ; 7 ~sta :STACKORIGN
(lda_stack(i+8) = false) then //~lda :STACKORIGIN+STACKWIDTH*2 ; 8
if (copy(listing[i], 6, 256) = copy(listing[i+4], 6, 256)) and
(copy(listing[i+1], 6, 256) = copy(listing[i+6], 6, 256)) then begin
Expand All @@ -595,9 +595,9 @@ begin
rol_stack(i+1) and // rol :STACKORIGIN+STACKWIDTH ; 1
rol_stack(i+2) and // rol :STACKORIGIN+STACKWIDTH*2 ; 2
lda_stack(i+3) and // lda :STACKORIGIN+STACKWIDTH ; 3
sta_a(i+4) and (sta_stack(i+4) = false) and (EAX(i+4) = false) and // sta ; 4
sta_val(i+4) and (EAX(i+4) = false) and // sta ; 4 ~sta :STACKORIGN
lda_stack(i+5) and // lda :STACKORIGIN+STACKWIDTH*2 ; 5
sta_a(i+6) and (sta_stack(i+6) = false) and (EAX(i+6) = false) and // sta ; 6
sta_val(i+6) and (EAX(i+6) = false) and // sta ; 6 ~sta :STACKORIGN
(lda_stack(i+7) = false) then //~lda :STACKORIGIN ; 7
if (copy(listing[i+1], 6, 256) = copy(listing[i+3], 6, 256)) and
(copy(listing[i+2], 6, 256) = copy(listing[i+5], 6, 256)) then begin
Expand Down Expand Up @@ -639,9 +639,9 @@ begin
if asl_stack(i) and // asl :STACKORIGIN ; 0
rol_stack(i+1) and // rol :STACKORIGIN+STACKWIDTH ; 1
lda_stack(i+2) and // lda :STACKORIGIN ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and (EAX(i+3) = false) and // sta ; 3
sta_val(i+3) and (EAX(i+3) = false) and // sta ; 3 ~sta :STACKORIGN
lda_stack(i+4) and // lda :STACKORIGIN+STACKWIDTH ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and (EAX(i+5) = false) and // sta ; 5
sta_val(i+5) and (EAX(i+5) = false) and // sta ; 5 ~sta :STACKORIGN
(lda_stack(i+6) = false) then //~lda :STACK ; 6
if (copy(listing[i], 6, 256) = copy(listing[i+2], 6, 256)) and
(copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256)) then begin
Expand Down Expand Up @@ -705,7 +705,7 @@ begin
rol_stack(i+2) and // rol :STACKORIGIN+STACKWIDTH*2 ; 2
rol_stack(i+3) and // rol :STACKORIGIN+STACKWIDTH*3 ; 3
lda_stack(i+4) and // lda :STACKORIGIN ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and (EAX(i+5) = false) and // sta ; 5
sta_val(i+5) and (EAX(i+5) = false) and // sta ; 5 ~sta :STACKORIGN
(lda_stack(i+6) = false) then //~lda :STACKORIGIN+STACKWIDTH*2 ; 8
if (copy(listing[i], 6, 256) = copy(listing[i+4], 6, 256)) then begin

Expand Down Expand Up @@ -756,7 +756,7 @@ begin
asl_stack(i+1) and // asl :STACKORIGN ; 1
rol_stack(i+2) and // rol :STACKORIGIN+STACKWIDTH ; 2
lda_stack(i+3) and // lda :STACKORIGIN+STACKWIDTH ; 3
sta_a(i+4) and (sta_stack(i+4) = false) and // sta ; 4
sta_val(i+4) and // sta ; 4 ~sta :STACKORIGN
(lda_stack(i+5) = false) then //~lda :STACKORIGIN+ ; 5
if (copy(listing[i], 6, 256) = copy(listing[i+2], 6, 256)) and
(copy(listing[i+2], 6, 256) = copy(listing[i+3], 6, 256)) then
Expand All @@ -773,7 +773,7 @@ begin
if asl_stack(i) and // asl :STACKORIGN ; 0
rol_stack(i+1) and // rol :STACKORIGIN+STACKWIDTH ; 1
lda_stack(i+2) and // lda :STACKORIGIN ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and (EAX(i+3) = false) and // sta ; 3
sta_val(i+3) and (EAX(i+3) = false) and // sta ; 3 ~sta :STACKORIGN
(lda_stack(i+4) = false) then //~lda :STACKORIGIN+STACKWIDTH ; 4
if (copy(listing[i], 6, 256) = copy(listing[i+2], 6, 256)) then
begin
Expand Down Expand Up @@ -1108,7 +1108,7 @@ begin
rol_stack(i+2) and // rol :STACKORIGIN+STACKWIDTH ; 2
lda_a(i+3) and (lda_stack(i+3) = false) and // lda ; 3
add_stack(i+4) and // add :STACKORIGIN+STACKWIDTH ; 4
sta_a(i+5) and (sta_stack(i+5) = false) then // sta ; 5
sta_val(i+5) then // sta ; 5 ~sta :STACKORIGN
if (copy(listing[i], 6, 256) = copy(listing[i+2], 6, 256)) and
(copy(listing[i+2], 6, 256) = copy(listing[i+4], 6, 256)) then
begin
Expand Down Expand Up @@ -1301,10 +1301,10 @@ begin

lda_stack(i+6) and // lda :STACKORIGIN ; 6
add_sub_val(i+7) and // add|sub ; 7
sta_a(i+8) and (sta_stack(i+8) = false) and // sta ; 8
sta_val(i+8) and // sta ; 8 ~sta :STACKORIGN
lda_stack(i+9) and // lda :STACKORIGIN+STACKWIDTH ; 9
adc_sbc_val(i+10) and // adc|sbc ; 10
sta_a(i+11) and (sta_stack(i+11) = false) then // sta ; 11
sta_val(i+11) then // sta ; 11 ~sta :STACKORIGN
if ((copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256))) and
((copy(listing[i+3], 6, 256) = copy(listing[i+5], 6, 256))) and
((copy(listing[i+4], 6, 256) = copy(listing[i+6], 6, 256))) and
Expand Down
2 changes: 1 addition & 1 deletion src/include/opt6502/opt_BP.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ begin
sta_stack(i+2) and // sta :STACKORIGIN+STACKWIDTH ; 2
ldy_im(i+3) and // ldy # ; 3
LDA_BP2_Y(i+4) and // lda (:bp2),y ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and // sta ; 5
sta_val(i+5) and // sta ; 5 ~sta :STACKORIGN
lda_stack(i+6) then // lda :STACKORIGIN+STACKWIDTH ; 6
if (copy(listing[i+2], 6, 256) = copy(listing[i+6], 6, 256)) then
begin
Expand Down
4 changes: 2 additions & 2 deletions src/include/opt6502/opt_EOR.inc
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ begin
and_ora_eor(i+1) and // and|ora|eor ; 1
sta_stack(i+2) and // sta :STACKORIGIN ; 2
lda_a(i+3) and // lda ; 3
sta_a(i+4) and (sta_stack(i+4) = false) and // sta ; 4
sta_val(i+4) and // sta ; 4 ~sta :STACKORIGN
lda_stack(i+5) and // lda :STACKORIGIN ; 5
and_ora_eor(i+6) and // and|ora|eor ; 6
sta_a(i+7) and (sta_stack(i+7) = false) then // sta ; 7
sta_val(i+7) then // sta ; 7 ~sta :STACKORIGN
if copy(listing[i+2], 6, 256) = copy(listing[i+5], 6, 256) then
begin
listing[i+2] := listing[i+6];
Expand Down
32 changes: 16 additions & 16 deletions src/include/opt6502/opt_LDA.inc
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ begin
sta_stack(i+3) and // sta :STACKORIGIN+STACKWIDTH+10 ; 3
lda_stack(i+4) and // lda :STACKORIGIN+9 ; 4
AND_ORA_EOR_STACK(i+5) and // and|ora|eor :STACKORIGIN+10 ; 5
sta_a(i+6) and (sta_stack(i+6) = false) and // sta ; 6
sta_val(i+6) and // sta ; 6 ~sta :STACKORIGN
lda_stack(i+7) and // lda :STACKORIGIN+STACKWIDTH+9 ; 7
AND_ORA_EOR_STACK(i+8) and // and|ora|eor :STACKORIGIN+STACKWIDTH+10 ; 8
sta_a(i+9) and (sta_stack(i+9) = false) then // sta ; 9
sta_val(i+9) then // sta ; 9 ~sta :STACKORIGN
if (copy(listing[i+1], 6, 256) = copy(listing[i+5], 6, 256)) and
(copy(listing[i+3], 6, 256) = copy(listing[i+8], 6, 256)) and
(copy(listing[i], 6, 256) <> copy(listing[i+4], 6, 256)) and
Expand All @@ -308,10 +308,10 @@ begin
sta_stack(i+3) and // sta :STACKORIGIN+STACKWIDTH ; 3
lda_a(i+4) and (lda_stack(i+4) = false) and // lda ; 4
AND_ORA_EOR_STACK(i+5) and // and|ora|eor :STACKORIGIN ; 5
sta_a(i+6) and (sta_stack(i+6) = false) and // sta ; 6
sta_val(i+6) and // sta ; 6 ~sta :STACKORIGN
lda_a(i+7) and (lda_stack(i+7) = false) and // lda ; 7
AND_ORA_EOR_STACK(i+8) and // and|ora|eor :STACKORIGIN+STACKWIDTH ; 8
sta_a(i+9) and (sta_stack(i+9) = false) then // sta ; 9
sta_val(i+9) then // sta ; 9 ~sta :STACKORIGN
if (copy(listing[i+1], 6, 256) = copy(listing[i+5], 6, 256)) and
(copy(listing[i+3], 6, 256) = copy(listing[i+8], 6, 256)) then
begin
Expand Down Expand Up @@ -768,9 +768,9 @@ begin
if lda_stack(i) and // lda :STACKORIGIN ; 0
sta_stack(i+1) and // sta :STACKORIGIN+STACKWIDTH ; 1
lda_a(i+2) and (lda_stack(i+2) = false) and // lda ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and // sta A ; 3
sta_val(i+3) and // sta A ; 3 ~sta :STACKORIGN
lda_stack(i+4) and // lda :STACKORIGIN+STACKWIDTH ; 4
sta_a(i+5) and (sta_stack(i+5) = false) then // sta A+1 ; 5
sta_val(i+5) then // sta A+1 ; 5 ~sta :STACKORIGN
if (copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256)) then
begin
listing[i+4] := listing[i];
Expand Down Expand Up @@ -1042,13 +1042,13 @@ begin


if (lda_a(i) = false) and //~lda ; 0
sta_a(i+1) and (sta_stack(i+1) = false) and // sta A ; 1
sta_val(i+1) and // sta A ; 1 ~sta :STACKORIGN
lda_stack(i+2) and // lda :STACKORIGIN ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and // sta A+1 ; 3
sta_val(i+3) and // sta A+1 ; 3 ~sta :STACKORIGN
lda_a(i+4) and // lda A ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and // sta ; 5
sta_val(i+5) and // sta ; 5 ~sta :STACKORIGN
lda_a(i+6) and // lda A+1 ; 6
sta_a(i+7) and (sta_stack(i+7) = false) then // sta ; 7
sta_val(i+7) then // sta ; 7 ~sta :STACKORIGN
if (copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256)) and
(copy(listing[i+3], 6, 256) = copy(listing[i+6], 6, 256)) then
begin
Expand All @@ -1066,9 +1066,9 @@ begin
lda_a(i+2) and (lda_stack(i+2) = false) and // lda ; 2
sta_stack(i+3) and // sta :STACKORIGIN+STACKWIDTH ; 3
lda_stack(i+4) and // lda :STACKORIGIN ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and // sta ; 5 5 <> 2 !!!
sta_val(i+5) and // sta ; 5 5 <> 2 !!! ~sta :STACKORIGN
lda_stack(i+6) and // lda :STACKORIGIN+STACKWIDTH ; 6
sta_a(i+7) and (sta_stack(i+7) = false) then // sta ; 7
sta_val(i+7) then // sta ; 7 ~sta :STACKORIGN
if (copy(listing[i], 6, 256) <> copy(listing[i+2], 6, 256)) and
(copy(listing[i+1], 6, 256) <> copy(listing[i+3], 6, 256)) and
(copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256)) and
Expand All @@ -1087,9 +1087,9 @@ begin
if lda_a(i) and (lda_stack(i) = false) and // lda ; 0
sta_stack(i+1) and // sta :STACKORIGIN ; 1
lda_a(i+2) and (lda_stack(i+2) = false) and // lda ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and // sta ; 3
sta_val(i+3) and // sta ; 3 ~sta :STACKORIGN
lda_stack(i+4) and // lda :STACKORIGIN ; 4
sta_a(i+5) and (sta_stack(i+5) = false) then // sta ; 5
sta_val(i+5) then // sta ; 5 ~sta :STACKORIGN
if (copy(listing[i], 6, 256) <> copy(listing[i+3], 6, 256)) and
(copy(listing[i+1], 6, 256) = copy(listing[i+4], 6, 256)) then
begin
Expand Down Expand Up @@ -1120,9 +1120,9 @@ begin


if //(lda_a(i) = false) and //~lda ; 0
sta_a(i+1) and (sta_stack(i+1) = false) and // sta A ; 1
sta_val(i+1) and // sta A ; 1 ~sta :STACKORIGN
lda_stack(i+2) and // lda :STACKORIGIN+STACKWIDTH ; 2
sta_a(i+3) and (sta_stack(i+3) = false) and // sta A+1 ; 3
sta_val(i+3) and // sta A+1 ; 3 ~sta :STACKORIGN
lda_a(i+4) and (lda_stack(i+4) = false) and // lda A ; 4
sta_stack(i+5) and // sta :STACKORIGIN ; 5
lda_a(i+6) and (lda_stack(i+6) = false) and // lda A+1 ; 6
Expand Down
4 changes: 2 additions & 2 deletions src/include/opt6502/opt_LDY.inc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ begin

if lda_a(i) and (lda_stack(i) = false) and (lda_im(i) = false) and // lda I ; 0
add_sub(i+1) and // add|sub ; 1
sta_a(i+2) and (sta_stack(i+2) = false) and // sta ; 2
sta_val(i+2) and // sta ; 2 ~sta :STACKORIGN
ldy(i+3) then // ldy I ; 3
if copy(listing[i], 6, 256) = copy(listing[i+3], 6, 256) then
begin
Expand Down Expand Up @@ -191,7 +191,7 @@ begin
lda_a(i+2) and (lda_stack(i+2) = false) and // lda ; 2
add_sub_val(i+3) and // add|sub ; 3
ldy_stack(i+4) and // ldy :STACKORIGIN ; 4
sta_a(i+5) and (sta_stack(i+5) = false) then // sta ; 5
sta_val(i+5) then // sta ; 5 ~sta :STACKORIGN
if (copy(listing[i], 6, 256) = copy(listing[i+4], 6, 256)) then
begin
listing[i] := '';
Expand Down
4 changes: 2 additions & 2 deletions src/include/opt6502/opt_SPL.inc
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,9 @@ begin


if sty_stack(i+4) and // sty :STACKORIGIN+STACKWIDTH ; 4
sta_a(i+5) and (sta_stack(i+5) = false) and // sta ; 5
sta_val(i+5) and // sta ; 5 ~sta :STACKORIGN
lda_stack(i+6) and // lda :STACKORIGIN+STACKWIDTH ; 6
sta_a(i+7) and (sta_stack(i+7) = false) and // sta ; 7
sta_val(i+7) and // sta ; 7 ~sta :STACKORIGN
(sta_a(i+8) = false) then //~sta ; 8
if (copy(listing[i+4], 6, 256) = copy(listing[i+6], 6, 256)) then
begin
Expand Down

0 comments on commit 4984082

Please sign in to comment.