From 6c0210b7047b3c5b8c34c7da24b2c4e5c0b1d38d Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 10 Jun 2020 07:12:10 +0200 Subject: [PATCH] Added static init test. #257 --- .../dk/camelot64/kickc/test/TestPrograms.java | 5 +++++ src/test/kc/static-init-code.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/test/kc/static-init-code.c diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 71a545bf1..c8b212212 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -42,6 +42,11 @@ public class TestPrograms { public TestPrograms() { } + //@Test + //public void testStaticInitCode() throws IOException, URISyntaxException { + // compileAndCompare("static-init-code.c", log()); + //} + @Test public void testConstParenthesis() throws IOException, URISyntaxException { compileAndCompare("const-parenthesis.c"); diff --git a/src/test/kc/static-init-code.c b/src/test/kc/static-init-code.c new file mode 100644 index 000000000..7a194abb2 --- /dev/null +++ b/src/test/kc/static-init-code.c @@ -0,0 +1,16 @@ +// Tests static initialization code +// Currently placed outside any function scope and pushed into @begin block. +// To be put into an initializer function. + +// Initialize a volatile ZP-variable (will be done in the initializer) +volatile char c1 = 'x'; + +char * const SCREEN = 0x0400; + +void main() { + SCREEN[0] = c1; + SCREEN[0] = c2; +} + +// Initialize another volatile ZP-variable (will be done in the initializer) +volatile char c2 = 'y';