diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 2dcb6727e..7413945bf 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -41,6 +41,20 @@ public class TestPrograms { compileAndCompare("kickasm-uses-prevent-deletion"); } + // TODO: Fix inline kickasm uses handling of used variables. https://gitlab.com/camelot/kickc/issues/296 + /* + @Test + public void testKickasmUses1() throws IOException, URISyntaxException { + compileAndCompare("kickasm-uses-1"); + } + + @Test + public void testKickasmUses0() throws IOException, URISyntaxException { + compileAndCompare("kickasm-uses-0"); + } + */ + + @Test public void testBitmapCircle() throws IOException, URISyntaxException { compileAndCompare("bitmap-circle"); diff --git a/src/test/kc/kickasm-uses-0.kc b/src/test/kc/kickasm-uses-0.kc new file mode 100644 index 000000000..0c4bbe2be --- /dev/null +++ b/src/test/kc/kickasm-uses-0.kc @@ -0,0 +1,13 @@ +// Tests that inline kickasm uses clause makes the compiler treat the variable in a special way +// Always allocate memory for the variable (do not allow it to be turned into a constant) + +char color = 7; + +void main() { + + kickasm(uses color) {{ + lda color + sta $d020 + }} + +} \ No newline at end of file diff --git a/src/test/kc/kickasm-uses-1.kc b/src/test/kc/kickasm-uses-1.kc new file mode 100644 index 000000000..2a996d668 --- /dev/null +++ b/src/test/kc/kickasm-uses-1.kc @@ -0,0 +1,14 @@ +// Tests that inline kickasm uses clause makes the compiler treat the variable in a special way +// Make sure the version of the variable transfered into the inline asm is not turned into a constant + +void main() { + char color; + for( char i:0..2) + color = i; + color = 7; + kickasm(uses color) {{ // Here 7 is turned into a constant! + lda color + sta $d020 + }} + +} \ No newline at end of file