From 709039de8753d04932114db6fe3c433206cbb1c5 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Fri, 5 Jun 2020 17:02:38 +0200 Subject: [PATCH] Added missing c-file. --- src/test/kc/global-label-problem.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/kc/global-label-problem.c diff --git a/src/test/kc/global-label-problem.c b/src/test/kc/global-label-problem.c new file mode 100644 index 000000000..2ebf4f3d6 --- /dev/null +++ b/src/test/kc/global-label-problem.c @@ -0,0 +1,24 @@ +// Demonstrates problems with local labels overwriting global labels +// This should produce "abca" - but produces "abcc" because the local variable containing "c" overrides the global variable containing "a" + +void main () { + print("a"); + print("b"); + print1(); +} + +void print1() { + print("c"); + print("a"); +} + +// Screen pointer and index +char* const SCREEN = 0x0400; +char idx = 0; + +void print(char* msg) { + while(*msg) + SCREEN[idx++] = *msg++; +} + +