--- /dev/null
+
+# toplevel makefile for the regression tests
+
+MAKE := make --no-print-dir
+
+.PHONY: all clean
+
+all:
+       @$(MAKE) -C val all
+       @$(MAKE) -C ref all
+       @$(MAKE) -C err all
+
+clean:
+       @$(MAKE) -C val clean
+       @$(MAKE) -C ref clean
+       @$(MAKE) -C err clean
 
--- /dev/null
+
+# makefile for the tests that MUST NOT compile
+
+CC65FLAGS = -t sim6502
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+RM := rm -f
+
+.PHONY: all
+
+TESTS := $(patsubst %.c,%.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.o.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.os.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.osi.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.osir.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.oi.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.oir.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.or.prg,$(wildcard *.c))
+
+all: $(TESTS)
+
+%.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.o.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.os.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.osi.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.osir.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.oi.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.oir.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+%.or.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+clean:
+       @$(RM) *.o
+       @$(RM) *.prg
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include <stdio.h>
+
 int up[15], down[15], rows[8], x[8];
 void queens(int c);
 void print(void);
 
--- /dev/null
+
+# makefile for the regression tests that generate output which has to be
+# compared with reference output
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+RM := rm -f
+
+.PHONY: all
+
+TESTS := $(patsubst %.c,%.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.o.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.os.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.osi.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.osir.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.oi.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.oir.prg,$(wildcard *.c))
+TESTS += $(patsubst %.c,%.or.prg,$(wildcard *.c))
+
+all: $(TESTS)
+
+%.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.o.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.os.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.osi.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.osir.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.oi.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.oir.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+%.or.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $*.out
+
+clean:
+       @$(RM) *.o
+       @$(RM) *.prg
+       @$(RM) *.out
+       @$(RM) *.ref
 
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 long a;  /* must be static life */
 long b;  /* must be static life */
 
 
 Best, Oliver
 */
 
+#include <stdio.h>
+
 void f(void){struct{int i;}d;}
 struct{void(*p)(void);}s={f};
 
 
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 cc65 doesn't compile this, if i use the "-O"-option.
 but it works with "while(!0)"; instead of  "for(;;);"
 
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 there is a bug in the preprocessor (i think) ... the following works 
 (compiles) correctly:
 
   !!AUTHOR!!
 */
 
+#include "common.h"
+
 struct Record {
   struct Record *PtrComp;
   int x;
 
   !!AUTHOR!!      Oliver Schmidt
 */
 
+#include <stdio.h>
+
 /*
 After spending a "little" time I finally succeeded in isolating an
 (maybe THE) optimizer bug causing Contiki to fail.
 
 
 */
 
+#include <stdio.h>
+
 int foo=0,bar=2;
 
 int main(void)
 
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
+
 /*
 This produces the compiler error "test.c(9): Error: Assignment to const"
 Shouldn't be an error, should it? baz is const, bar isn't.
 
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
+
 /*
 ...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl.
 Is it really unknown?
 
     test2 and test3 will result in an endless loop (SVN version: 4974M)
 */
 
+#include <stdio.h>
+
 #define OPENTEST()
 #define CLOSETEST()
 
 
         cf - print character frequencies
 */
 
+#include "common.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
 
+FILE *in;
+
 #define INFILE   "cf.in"
+#define GETCHAR() fgetc(in)
 
 #ifndef NO_FLOATS
 float f[0x100];
         signed cutoff;
 #endif
 
+        in = fopen(INFILE, "rb");
+        if (in == NULL) {
+            return EXIT_FAILURE;
+        }
+
        if (argc <= 1)
 #ifndef NO_FLOATS
                cutoff = 0.0;
 #endif
                }
     }
-
+    fclose(in);
     return 0;
 }
 
--- /dev/null
+start cf.input >
+The sky above the port was the color of television, tuned
+to a dead channel.
+"It's not like I'm using," Case heard someone say, as he
+shouldered his way through the crowd around the door of the
+Chat. "It's like my body's developed this massive drug deficiency."
+It was a Sprawl voice and a Sprawl joke. The Chatsubo
+was a bar for professional expatriates; you could drink there
+for a week and never hear two words in Japanese.
+Ratz was tending bar, his prosthetic arm jerking monotonously
+as he filled a tray of glasses with draft Kirin. He saw
+Case and smiled, his teeth a web work of East European steel
+and brown decay. Case found a place at the bar, between the
+unlikely tan on one of Lonny Zone's whores and the crisp naval
+uniform of a tall African whose cheekbones were ridged with
+Joe boys," Ratz said, shoving a draft across the bar with his
+good hand. "Maybe some business with you, Case?"
+Case shrugged. The girl to his right giggled and nudged
+< end cf.input
\ No newline at end of file
 
   !!LICENCE!!     Public Domain
 */
 
+#include "common.h"
 #include <limits.h>
 #include <ctype.h>
 
 
--- /dev/null
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NO_OLD_FUNC_DECL
+#define NO_TYPELESS_INT
+#define NO_TYPELESS_INT_PTR
+#define MAIN_RETURNS_INT
+#define NO_IMPLICIT_FUNC_PROTOTYPES
+#define NO_FLOATS
+#define NO_WCHAR
+#define NO_EMPTY_FUNC_ARGS
+#define NO_SLOPPY_STRUCT_INIT
+#define NO_FUNCS_TAKE_STRUCTS
+#define NO_FUNCS_RETURN_STRUCTS
+#define CAST_STRUCT_PTR
+#define NO_TYPELESS_STRUCT_PTR
+#define NO_IMPLICIT_FUNCPTR_CONV
+#define SIZEOF_INT_16BIT
+#define SIZEOF_LONG_32BIT
+#define UNSIGNED_CHARS
+#define UNSIGNED_BITFIELDS
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+#include <stdio.h>
+
 signed char c;
 signed short s;
 signed int i;
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifdef NO_BITFIELDS
 
 main()
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC\r
 */\r
 \r
+#include "common.h"\r
 /* todo: add back conditional stuff here ! */\r
 \r
 typedef struct { int codes[3]; char name[6]; } Word;\r
 \r
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
-
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES\r
+\r
 #ifdef NO_OLD_FUNC_DECL\r
 f();\r
 void g(Word *p);\r
 \r
 /*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/\r
 int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };\r
-int *y[] = { x[0], x[1], x[2], 0 };
-
+int *y[] = { x[0], x[1], x[2], 0 };\r
+\r
 main()\r
 {\r
        int i, j;\r
 
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 int main(void)
 {
 #if 1
 
   !!LICENCE!!     GPL (?), read COPYING.GPL
 */
 
+#include "common.h"
+
 /*
  * Sample OTCC C example. You can uncomment the first line and install
  * otcc in /usr/local/bin to make otcc scripts !  
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifdef NO_FLOATS
 
 main()
 {
         printf("NO_FLOATS\n\r");
+        return 0;
 }
 
 #else
 
   !!LICENCE!!     public domain\r
 */\r
 \r
+#include "common.h"\r
 #include <stdio.h>\r
 \r
 /*\r
   cc65 seems to have problems here aswell ;/\r
 */\r
 \r
-int main(void) {
+int main(void) {\r
        test1();\r
        test2();\r
        test30();\r
        test31();\r
 /*     test32(); */\r
-       return 0;
+       return 0;\r
 }\r
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdio.h>
 
 int main(void)
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdarg.h>
 
 #ifndef NO_FUNCS_TAKE_STRUCTS
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 typedef struct point { int x,y; } point;
 typedef struct rect { point pt1, pt2; } rect;
 
 
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <limits.h>
 
 #ifdef NO_IMPLICIT_FUNC_PROTOTYPES
 
 
 #define MAXWORDS 250
 
+FILE *in;
+#define getchar() fgetc(in)
+
 struct node
 {
        int count;              /* frequency count */
        struct node *root;
        char word[20];
 
+        in = fopen("wf1.in","rb");
+        if (in == NULL) {
+            return EXIT_FAILURE;
+        }
+
        root = 0;
        next = 0;
        while (getword(word))
                lookup(word, &root)->count++;
        tprint(root);
 
+        fclose(in);
         return 0;
 }
 
--- /dev/null
+The sky above the port was the color of television, tuned
+to a dead channel.
+"It's not like I'm using," Case heard someone say, as he
+shouldered his way through the crowd around the door of the
+Chat. "It's like my body's developed this massive drug deficiency."
+It was a Sprawl voice and a Sprawl joke. The Chatsubo
+was a bar for professional expatriates; you could drink there
+for a week and never hear two words in Japanese.
+Ratz was tending bar, his prosthetic arm jerking monotonously
+as he filled a tray of glasses with draft Kirin. He saw
+Case and smiled, his teeth a web work of East European steel
+and brown decay. Case found a place at the bar, between the
+unlikely tan on one of Lonny Zone's whores and the crisp naval
+uniform of a tall African whose cheekbones were ridged with
+Joe boys," Ratz said, shoving a draft across the bar with his
+good hand. "Maybe some business with you, Case?"
+Case shrugged. The girl to his right giggled and nudged
 
 
 /*#define STANDALONE*/
 
+#include "common.h"
+
 #ifndef YACCDBG
 
 #include <stdio.h>
 
 #endif
 
+FILE *infile, *outfile;
+#define getchar() fgetc(infile)
+
 /* hack the original tables to work with both petscii and ascii */
 #define CHARSETHACK
 
 extern char *yysptr, yysbuf[];
 int yytchar;
 
-/*FILE *yyin ={stdin}, *yyout ={stdout};*/
 #define yyin  infile
 #define yyout outfile
 
 main() 
 {
         printf("main start\n");
+        infile = fopen("yacc.in","rb");
+        if (infile == NULL) {
+            return EXIT_FAILURE;
+        }
+        outfile = stdout;
         yyparse();
+        fclose(infile);
         printf("main end\n");
         return 0;
 }
 
--- /dev/null
+x=(e+1)*3/(3+7)
 
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 # define YYTYPE char
 struct yywork 
 { 
 
 
+# makefile for the regression tests that return an error code on failure
+
 CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
 
 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
 SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
 
 %.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.o.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.os.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.osi.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.osir.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.oi.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.oir.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 %.or.prg: %.c
        $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $@
+       $(SIM65) $(SIM65FLAGS) $@
 
 clean:
        @$(RM) *.o