From a064e766bc15b52b7d26bfe52b9dddd47dd64326 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 28 Aug 2019 09:56:00 +0200 Subject: [PATCH] Added missing fragments for Clay Cowgill --- .../fragment/pwsc1_derefidx_vbuxx_gt_vwsc2_then_la1.asm | 8 ++++++++ .../fragment/pwsc1_derefidx_vbuyy_gt_vwsc2_then_la1.asm | 8 ++++++++ .../fragment/vwsc1_lt_pwsc2_derefidx_vbuxx_then_la1.asm | 8 ++++++++ .../fragment/vwsc1_lt_pwsc2_derefidx_vbuyy_then_la1.asm | 8 ++++++++ .../kickc/fragment/AsmFragmentTemplateSynthesisRule.java | 7 +++++++ 5 files changed, 39 insertions(+) create mode 100644 src/main/fragment/pwsc1_derefidx_vbuxx_gt_vwsc2_then_la1.asm create mode 100644 src/main/fragment/pwsc1_derefidx_vbuyy_gt_vwsc2_then_la1.asm create mode 100644 src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuxx_then_la1.asm create mode 100644 src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuyy_then_la1.asm diff --git a/src/main/fragment/pwsc1_derefidx_vbuxx_gt_vwsc2_then_la1.asm b/src/main/fragment/pwsc1_derefidx_vbuxx_gt_vwsc2_then_la1.asm new file mode 100644 index 000000000..c85699a99 --- /dev/null +++ b/src/main/fragment/pwsc1_derefidx_vbuxx_gt_vwsc2_then_la1.asm @@ -0,0 +1,8 @@ +lda #<{c2} +cmp {c1},x +lda #>{c2} +sbc {c1}+1,x +bvc !+ +eor #$80 +!: +bmi {la1} \ No newline at end of file diff --git a/src/main/fragment/pwsc1_derefidx_vbuyy_gt_vwsc2_then_la1.asm b/src/main/fragment/pwsc1_derefidx_vbuyy_gt_vwsc2_then_la1.asm new file mode 100644 index 000000000..14233f9e9 --- /dev/null +++ b/src/main/fragment/pwsc1_derefidx_vbuyy_gt_vwsc2_then_la1.asm @@ -0,0 +1,8 @@ +lda #<{c2} +cmp {c1},y +lda #>{c2} +sbc {c1}+1,y +bvc !+ +eor #$80 +!: +bmi {la1} \ No newline at end of file diff --git a/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuxx_then_la1.asm b/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuxx_then_la1.asm new file mode 100644 index 000000000..5aa544ba1 --- /dev/null +++ b/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuxx_then_la1.asm @@ -0,0 +1,8 @@ +lda #<{c1} +cmp {c2},x +lda #>{c1} +sbc {c2}+1,x +bvc !+ +eor #$80 +!: +bmi {la1} \ No newline at end of file diff --git a/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuyy_then_la1.asm b/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuyy_then_la1.asm new file mode 100644 index 000000000..bca750895 --- /dev/null +++ b/src/main/fragment/vwsc1_lt_pwsc2_derefidx_vbuyy_then_la1.asm @@ -0,0 +1,8 @@ +lda #<{c1} +cmp {c2},y +lda #>{c1} +sbc {c2}+1,y +bvc !+ +eor #$80 +!: +bmi {la1} \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java index 22b5d0719..8c905e2be 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java @@ -285,6 +285,11 @@ class AsmFragmentTemplateSynthesisRule { mapZ2Swap.put("z2", "zn"); mapZ2Swap.put("z1", "z2"); mapZ2Swap.put("zn", "z1"); + // Swap c1 and c2 + Map mapC2Swap = new LinkedHashMap<>(); + mapC2Swap.put("c2", "cn"); + mapC2Swap.put("c1", "c2"); + mapC2Swap.put("cn", "c1"); // Swap z2 and z3 Map mapZ3Swap = new LinkedHashMap<>(); mapZ3Swap.put("z3", "zn"); @@ -449,6 +454,8 @@ class AsmFragmentTemplateSynthesisRule { synths.add(new AsmFragmentTemplateSynthesisRule("(.*)z2(.*)z1(.*)", twoZ1+"|"+twoZ2, null, "$1z1$2z2$3", null, mapZ2Swap, false)); // Correct wrong ordered Z3/Z2 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)z3(.*)z2(.*)", twoZ2+"|"+twoZ3, null, "$1z2$2z3$3", null, mapZ3Swap, false)); + // Correct wrong ordered C2/C1 + synths.add(new AsmFragmentTemplateSynthesisRule("(.*)c2(.*)c1(.*)", twoC1+"|"+twoC2, null, "$1c1$2c2$3", null, mapC2Swap, false)); // Rewrite comparisons < to > synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_gt_(.*)_then_(.*)", null, null, "$2_lt_$1_then_$3", null, null));