From ae7a0b6fe53c117b28fb2d760ef1ba046ea033fb Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 9 Oct 2019 09:30:11 +0200 Subject: [PATCH 1/3] Added long fragment. --- .../mos6502-common/vduz1=_deref_pduc1_plus_2.asm | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/fragment/mos6502-common/vduz1=_deref_pduc1_plus_2.asm diff --git a/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_plus_2.asm b/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_plus_2.asm new file mode 100644 index 000000000..e2a5db311 --- /dev/null +++ b/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_plus_2.asm @@ -0,0 +1,13 @@ +clc +lda {c1} +adc #2 +sta {z1} +lda {c1}+1 +adc #0 +sta {z1}+1 +lda {c1}+2 +adc #0 +sta {z1}+2 +lda {c1}+3 +adc #0 +sta {z1}+3 From 22139da54e3b0629d573eea4c0a1df5de1b5e72f Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 9 Oct 2019 13:41:12 +0200 Subject: [PATCH 2/3] Added long fragment. --- .../vduz1=_deref_pduc1_minus_vduz2.asm | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/fragment/mos6502-common/vduz1=_deref_pduc1_minus_vduz2.asm diff --git a/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_minus_vduz2.asm b/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_minus_vduz2.asm new file mode 100644 index 000000000..385b49485 --- /dev/null +++ b/src/main/fragment/mos6502-common/vduz1=_deref_pduc1_minus_vduz2.asm @@ -0,0 +1,13 @@ +sec +lda {c1} +sbc {z2} +sta {z1} +lda {c1}+1 +sbc {z2}+1 +sta {z1}+1 +lda {c1}+2 +sbc {z2}+2 +sta {z1}+2 +lda {c1}+3 +sbc {z2}+3 +sta {z1}+3 From 08da28e9760bbfc75b655b8ec873b9adc1a5586d Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 9 Oct 2019 16:43:02 +0200 Subject: [PATCH 3/3] Added another test for literal number type detection in ternaries. #199 --- .../dk/camelot64/kickc/test/TestPrograms.java | 3 ++ src/test/kc/number-ternary-fail-2.kc | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/kc/number-ternary-fail-2.kc diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index eef8703e2..6294a3291 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -715,6 +715,9 @@ public class TestPrograms { /** * TODO: Fix error with number resolving * + * @Test public void testNumberTernaryFail2() throws IOException, URISyntaxException { + * compileAndCompare("number-ternary-fail-2"); + * } * @Test public void testNumberTernaryFail() throws IOException, URISyntaxException { * compileAndCompare("number-ternary-fail"); * } diff --git a/src/test/kc/number-ternary-fail-2.kc b/src/test/kc/number-ternary-fail-2.kc new file mode 100644 index 000000000..ae88f2b71 --- /dev/null +++ b/src/test/kc/number-ternary-fail-2.kc @@ -0,0 +1,36 @@ +// Failing number type resolving in ternary operator +// Currently fails in the ternary operator with number-issues if integer literal is not specified! + +import "stdlib" + +void SolveMaze(char *maze, word width, word height) { + + word count=0; + word x=3, y=2; + word forward=0; + + while(x != (width - 2) || y != (height - 2)) { + + maze[y * width + x] = forward ? 2 : 3; + if ( 1 == 1 ) { + forward = 1; // <- HERE + } else { + forward = 0; + count = 0; + } + } +} + +void main() { + + word width=18 * 2 + 3; + word height=6 * 2 + 3; + char *maze; + maze = malloc(width * height); + + SolveMaze(maze, width, height); + + free(maze); + asm {loop: jmp loop } +} +