diff --git a/.gitignore b/.gitignore
index 1d5928af7..196cdc3d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,5 +8,6 @@
 /mou/
 /ser/
 /targetutil/
+/testwrk/
 /tgi/
 /wrk/
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 000000000..5761abcfd
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+*.o
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 000000000..b942cbcdf
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,52 @@
+
+# toplevel makefile for the regression tests
+
+MAKE := make --no-print-dir
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  RM := del /f
+  EXE := .exe
+  MKDIR = mkdir
+  RMDIR = rmdir
+else
+  RM := rm -f
+  EXE :=
+  MKDIR = mkdir -p
+  RMDIR = rmdir
+endif
+
+WORKDIR := ../testwrk
+
+.PHONY: dotests clean
+
+all: dotests
+
+$(WORKDIR):
+	@$(MKDIR) $(WORKDIR)
+
+$(WORKDIR)/bdiff$(EXE): $(WORKDIR)
+	@$(CC) -o $(WORKDIR)/bdiff$(EXE) bdiff.c
+
+dotests: $(WORKDIR)/bdiff$(EXE)
+	@$(MAKE) -C val clean all
+	@$(MAKE) -C ref clean all
+	@$(MAKE) -C err clean all
+	@$(MAKE) -C misc clean all
+
+continue: $(WORKDIR)/bdiff$(EXE)
+	@$(MAKE) -C val all
+	@$(MAKE) -C ref all
+	@$(MAKE) -C err all
+	@$(MAKE) -C misc all
+
+clean:
+	@$(MAKE) -C val clean
+	@$(MAKE) -C ref clean
+	@$(MAKE) -C err clean
+	@$(MAKE) -C misc clean
+	@$(RM) $(WORKDIR)/bdiff$(EXE)
+	@$(RMDIR) $(WORKDIR)
diff --git a/test/bdiff.c b/test/bdiff.c
new file mode 100644
index 000000000..797ba4302
--- /dev/null
+++ b/test/bdiff.c
@@ -0,0 +1,28 @@
+
+// minimal tool to compare two binaries
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    FILE *f1, *f2;
+    if (argc < 3) {
+        return EXIT_FAILURE;
+    }
+    f1 = fopen(argv[1], "rb");
+    f2 = fopen(argv[2], "rb");
+    if ((f1 == NULL) || (f2 == NULL)) {
+        return EXIT_FAILURE;
+    }
+    for(;;) {
+        if (feof(f1) && feof(f2)) {
+            return EXIT_SUCCESS;
+        } else if (feof(f1) || feof(f2)) {
+            return EXIT_FAILURE;
+        }
+        if (fgetc(f1) != fgetc(f2)) {
+            return EXIT_FAILURE;
+        }
+    }
+}
diff --git a/test/err/Makefile b/test/err/Makefile
new file mode 100644
index 000000000..40ccfcb59
--- /dev/null
+++ b/test/err/Makefile
@@ -0,0 +1,52 @@
+
+# makefile for the tests that MUST NOT compile
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(TESTS)
+
+$(WORKDIR)/%.prg: %.c
+	! $(CL65) $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.o.prg: %.c
+	! $(CL65) -O $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.os.prg: %.c
+	! $(CL65) -Os $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.osi.prg: %.c
+	! $(CL65) -Osi $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.osir.prg: %.c
+	! $(CL65) -Osir $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.oi.prg: %.c
+	! $(CL65) -Oi $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.oir.prg: %.c
+	! $(CL65) -Oir $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.or.prg: %.c
+	! $(CL65) -Or $(CC65FLAGS) $< -o $@
+clean:
+	@$(RM) $(TESTS)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
diff --git a/test/misc/Makefile b/test/misc/Makefile
new file mode 100644
index 000000000..b18d9165e
--- /dev/null
+++ b/test/misc/Makefile
@@ -0,0 +1,67 @@
+
+# makefile for the remaining tests that need special care in one way or another
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+DIFF := $(WORKDIR)/bdiff
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+# FIXME: actually use/build differently optimized programs here
+
+all: $(TESTS)
+
+# should compile, but then hangs in an endless loop
+$(WORKDIR)/endless%prg: endless.c
+	$(CL65) $(CC65FLAGS) $< -o $@
+	! $(SIM65) $(SIM65FLAGS) $@
+
+# these need reference data that cant be generated by a host compiled program
+# in a useful way
+$(WORKDIR)/limits%prg: limits.c
+	$(CL65) $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out
+	$(DIFF) $(WORKDIR)/limits.out limits.ref
+
+# the rest are tests that fail currently for one reason or another
+$(WORKDIR)/fields%prg: fields.c
+	@echo "FIXME: " $@ "will currently fail"
+	$(CL65) $(CC65FLAGS) $< -o $@
+	-$(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/sitest%prg: sitest.c
+	@echo "FIXME: " $@ "will currently fail"
+	-$(CL65) $(CC65FLAGS) $< -o $@
+	-$(SIM65) $(SIM65FLAGS) $@
+
+clean:
+	@$(RM) $(TESTS)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
+
+
diff --git a/test/misc/common.h b/test/misc/common.h
new file mode 100644
index 000000000..dada61a14
--- /dev/null
+++ b/test/misc/common.h
@@ -0,0 +1,22 @@
+
+#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
diff --git a/test/misc/endless.c b/test/misc/endless.c
new file mode 100644
index 000000000..fe0782941
--- /dev/null
+++ b/test/misc/endless.c
@@ -0,0 +1,13 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+    printf("entering endless loop\n");
+    for(;;) {
+        ;
+    }
+    printf("error: should not come here\n");
+    return EXIT_FAILURE;
+}
diff --git a/test/ref/fields.c b/test/misc/fields.c
similarity index 98%
rename from test/ref/fields.c
rename to test/misc/fields.c
index 794a81924..83bee82b7 100644
--- a/test/ref/fields.c
+++ b/test/misc/fields.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifdef NO_BITFIELDS
 
 main()
diff --git a/test/ref/limits.c b/test/misc/limits.c
similarity index 100%
rename from test/ref/limits.c
rename to test/misc/limits.c
diff --git a/test/misc/limits.ref b/test/misc/limits.ref
new file mode 100644
index 000000000..9be906beb
--- /dev/null
+++ b/test/misc/limits.ref
@@ -0,0 +1,24 @@
+CHAR_MAX:  0x000000ff=255
+UCHAR_MAX: 0x000000ff=255
+SCHAR_MAX: 0x0000007f=127
+SHRT_MAX:  0x00007fff=32767
+USHRT_MAX: 0x0000ffff=-1
+SSHRT_MAX: 0x00007fff=32767
+INT_MAX:   0x00007fff=32767
+UINT_MAX:  0x0000ffff=-1
+SINT_MAX:  0x00007fff=32767
+LONG_MAX:  0x7fffffff=2147483647
+ULONG_MAX: 0xffffffff=-1
+SLONG_MAX: 0x7fffffff=2147483647
+CHAR_MIN:  0x00000000=0
+UCHAR_MIN: 0x00000000=0
+SCHAR_MIN: 0x0000ff80=-128
+SHRT_MIN:  0x00008000=-32768
+USHRT_MIN: 0x00000000=0
+SSHRT_MIN: 0x00008000=-32768
+INT_MIN:   0x00008000=-32768
+UINT_MIN:  0x00000000=0
+SINT_MIN:  0x00008000=-32768
+LONG_MIN:  0x80000000=-2147483648
+ULONG_MIN: 0x00000000=0
+SLONG_MIN: 0x80000000=-2147483648
diff --git a/test/val/sitest.c b/test/misc/sitest.c
similarity index 100%
rename from test/val/sitest.c
rename to test/misc/sitest.c
diff --git a/test/readme.txt b/test/readme.txt
new file mode 100644
index 000000000..cd3b7501a
--- /dev/null
+++ b/test/readme.txt
@@ -0,0 +1,25 @@
+This directory contains test code for automatic regression testing of the CC65
+compiler.
+
+
+/val  - the bulk of tests are contained here, individual tests should exit with
+        an exit code of EXIT_SUCCESS when they pass, or EXIT_FAILURE on error
+
+/ref  - these tests produce output that must be compared with reference output
+
+/err  - contains tests that MUST NOT compile
+
+/misc - a few tests that need special care of some sort
+
+
+to run the tests use "make" in this (top) directory, the makefile should exit
+with no error.
+
+when a test failed you can use "make continue" to run further tests
+
+--------------------------------------------------------------------------------
+
+TODO:
+
+- reduce usage of "common.h" to a minimum
+- convert more tests from using reference output to returning an exit code
diff --git a/test/ref/8q.c b/test/ref/8q.c
index afbe41c64..e8bd1ca2e 100644
--- a/test/ref/8q.c
+++ b/test/ref/8q.c
@@ -4,6 +4,8 @@
   !!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);
diff --git a/test/ref/Makefile b/test/ref/Makefile
new file mode 100644
index 000000000..b752adc1d
--- /dev/null
+++ b/test/ref/Makefile
@@ -0,0 +1,92 @@
+
+# makefile for the regression tests that generate output which has to be
+# compared with reference output
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+DIFF := $(WORKDIR)/bdiff
+
+CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
+
+.PHONY: all clean
+
+REFS := $(patsubst %.c,$(WORKDIR)/%.ref,$(wildcard *.c))
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(REFS) $(TESTS)
+
+$(WORKDIR)/%.ref: %.c
+	$(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
+	$(WORKDIR)/$*.host > $@
+
+$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -O $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Os $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Osi $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Osir $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Oi $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Oir $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
+	$(CL65) -Or $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+	$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+clean:
+	@$(RM) $(TESTS)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.ref)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.host)
diff --git a/test/ref/cc65080227.c b/test/ref/cc65080227.c
index 4dd454b98..78afbb2c2 100644
--- a/test/ref/cc65080227.c
+++ b/test/ref/cc65080227.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 long a;  /* must be static life */
 long b;  /* must be static life */
 
diff --git a/test/ref/cc65080328.c b/test/ref/cc65080328.c
index 11ef73514..630638f3d 100644
--- a/test/ref/cc65080328.c
+++ b/test/ref/cc65080328.c
@@ -13,6 +13,8 @@ optimizations. If I remove the struct inside f() it compiles fine ?!?
 Best, Oliver
 */
 
+#include <stdio.h>
+
 void f(void){struct{int i;}d;}
 struct{void(*p)(void);}s={f};
 
diff --git a/test/ref/cc65090111.c b/test/ref/cc65090111.c
index f515716f7..be889a608 100644
--- a/test/ref/cc65090111.c
+++ b/test/ref/cc65090111.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 cc65 doesn't compile this, if i use the "-O"-option.
 but it works with "while(!0)"; instead of  "for(;;);"
diff --git a/test/ref/cc65090124.c b/test/ref/cc65090124.c
index fef22268f..3f8279b27 100644
--- a/test/ref/cc65090124.c
+++ b/test/ref/cc65090124.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 there is a bug in the preprocessor (i think) ... the following works 
 (compiles) correctly:
diff --git a/test/ref/cc65090726.c b/test/ref/cc65090726.c
index fb4773afb..b260f0afd 100644
--- a/test/ref/cc65090726.c
+++ b/test/ref/cc65090726.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include "common.h"
+
 struct Record {
   struct Record *PtrComp;
   int x;
diff --git a/test/ref/cc65090910.c b/test/ref/cc65090910.c
index c8e5ce934..6ac5d9dcb 100644
--- a/test/ref/cc65090910.c
+++ b/test/ref/cc65090910.c
@@ -5,6 +5,8 @@
   !!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.
diff --git a/test/ref/cc65090913.c b/test/ref/cc65090913.c
index a319fec50..da6e37ef3 100644
--- a/test/ref/cc65090913.c
+++ b/test/ref/cc65090913.c
@@ -18,6 +18,8 @@
 
 */
 
+#include <stdio.h>
+
 int foo=0,bar=2;
 
 int main(void)
diff --git a/test/ref/cc65091007.c b/test/ref/cc65091007.c
index 1c69e02f9..31f725f8b 100644
--- a/test/ref/cc65091007.c
+++ b/test/ref/cc65091007.c
@@ -5,6 +5,8 @@
   !!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.
diff --git a/test/ref/cc65091022.c b/test/ref/cc65091022.c
index 222253992..25d197c11 100644
--- a/test/ref/cc65091022.c
+++ b/test/ref/cc65091022.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
+
 /*
 ...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl.
 Is it really unknown?
diff --git a/test/ref/cc65110211.c b/test/ref/cc65110211.c
index 76b3f4a70..83be84b67 100644
--- a/test/ref/cc65110211.c
+++ b/test/ref/cc65110211.c
@@ -8,6 +8,8 @@
     test2 and test3 will result in an endless loop (SVN version: 4974M)
 */
 
+#include <stdio.h>
+
 #define OPENTEST()
 #define CLOSETEST()
 
diff --git a/test/ref/cf.c b/test/ref/cf.c
index 951f31295..66fb42b10 100644
--- a/test/ref/cf.c
+++ b/test/ref/cf.c
@@ -8,11 +8,16 @@
         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];
@@ -35,6 +40,11 @@ char *argv[];
         signed cutoff;
 #endif
 
+        in = fopen(INFILE, "rb");
+        if (in == NULL) {
+            return EXIT_FAILURE;
+        }
+
 	if (argc <= 1)
 #ifndef NO_FLOATS
 		cutoff = 0.0;
@@ -176,6 +186,6 @@ char *argv[];
 #endif
 		}
     }
-
+    fclose(in);
     return 0;
 }
diff --git a/test/ref/cf.in b/test/ref/cf.in
new file mode 100755
index 000000000..8190039e6
--- /dev/null
+++ b/test/ref/cf.in
@@ -0,0 +1,19 @@
+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
diff --git a/test/ref/charconst.c b/test/ref/charconst.c
index 1aa9f8e3f..65ebc70be 100644
--- a/test/ref/charconst.c
+++ b/test/ref/charconst.c
@@ -4,6 +4,7 @@
   !!LICENCE!!     Public Domain
 */
 
+#include "common.h"
 #include <limits.h>
 #include <ctype.h>
 
diff --git a/test/ref/common.h b/test/ref/common.h
new file mode 100644
index 000000000..dada61a14
--- /dev/null
+++ b/test/ref/common.h
@@ -0,0 +1,22 @@
+
+#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
diff --git a/test/ref/cvt.c b/test/ref/cvt.c
index ed7b6084e..841c1b3b2 100644
--- a/test/ref/cvt.c
+++ b/test/ref/cvt.c
@@ -4,6 +4,9 @@
   !!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;
diff --git a/test/ref/init.c b/test/ref/init.c
index dc3f28a81..5a5816753 100644
--- a/test/ref/init.c
+++ b/test/ref/init.c
@@ -4,12 +4,13 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 /* todo: add back conditional stuff here ! */
 
 typedef struct { int codes[3]; char name[6]; } Word;
 
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
-
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
+
 #ifdef NO_OLD_FUNC_DECL
 f();
 void g(Word *p);
@@ -42,8 +43,8 @@ Word words[] = {
 
 /*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
 int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
-int *y[] = { x[0], x[1], x[2], 0 };
-
+int *y[] = { x[0], x[1], x[2], 0 };
+
 main()
 {
 	int i, j;
diff --git a/test/ref/minimal.c b/test/ref/minimal.c
index 5aa3c5f4f..b2e2d9d8f 100644
--- a/test/ref/minimal.c
+++ b/test/ref/minimal.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 int main(void)
 {
 #if 1
diff --git a/test/ref/otccex.c b/test/ref/otccex.c
index a967e4805..f3d6c71ec 100644
--- a/test/ref/otccex.c
+++ b/test/ref/otccex.c
@@ -4,6 +4,8 @@
   !!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 !  
diff --git a/test/ref/paranoia.c b/test/ref/paranoia.c
index 3616c9391..e9a47dd71 100644
--- a/test/ref/paranoia.c
+++ b/test/ref/paranoia.c
@@ -4,11 +4,14 @@
   !!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
diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c
index 69d04a989..d8c064ef3 100644
--- a/test/ref/pointer2.c
+++ b/test/ref/pointer2.c
@@ -4,6 +4,7 @@
   !!LICENCE!!     public domain
 */
 
+#include "common.h"
 #include <stdio.h>
 
 /*
@@ -101,11 +102,11 @@ static void test30(void)
   cc65 seems to have problems here aswell ;/
 */
 
-int main(void) {
+int main(void) {
   	test1();
 	test2();
 	test30();
 	test31();
 /*	test32(); */
-	return 0;
+	return 0;
 }
diff --git a/test/ref/spill.c b/test/ref/spill.c
index 2aedf0c8c..56b03d6a7 100644
--- a/test/ref/spill.c
+++ b/test/ref/spill.c
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdio.h>
 
 int main(void)
diff --git a/test/ref/stdarg.c b/test/ref/stdarg.c
index b476cf338..295a2ccad 100644
--- a/test/ref/stdarg.c
+++ b/test/ref/stdarg.c
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdarg.h>
 
 #ifndef NO_FUNCS_TAKE_STRUCTS
diff --git a/test/ref/struct.c b/test/ref/struct.c
index ccd74953f..a0f181e96 100644
--- a/test/ref/struct.c
+++ b/test/ref/struct.c
@@ -4,6 +4,8 @@
   !!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;
 
diff --git a/test/ref/switch.c b/test/ref/switch.c
index 1fc315d90..0821d29ee 100644
--- a/test/ref/switch.c
+++ b/test/ref/switch.c
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <limits.h>
 
 #ifdef NO_IMPLICIT_FUNC_PROTOTYPES
diff --git a/test/ref/wf1.c b/test/ref/wf1.c
index 3e9c80fb2..0539d8398 100644
--- a/test/ref/wf1.c
+++ b/test/ref/wf1.c
@@ -11,6 +11,9 @@
 
 #define MAXWORDS 250
 
+FILE *in;
+#define getchar() fgetc(in)
+
 struct node
 {
 	int count;		/* frequency count */
@@ -122,11 +125,17 @@ int main(void)
 	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;
 }
diff --git a/test/ref/wf1.in b/test/ref/wf1.in
new file mode 100644
index 000000000..3e50fbac8
--- /dev/null
+++ b/test/ref/wf1.in
@@ -0,0 +1,17 @@
+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
diff --git a/test/ref/yacc.c b/test/ref/yacc.c
index 3baefd348..5768f80d0 100644
--- a/test/ref/yacc.c
+++ b/test/ref/yacc.c
@@ -6,6 +6,8 @@
 
 /*#define STANDALONE*/
 
+#include "common.h"
+
 #ifndef YACCDBG
 
 #include <stdio.h>
@@ -19,6 +21,9 @@
 
 #endif
 
+FILE *infile, *outfile;
+#define getchar() fgetc(infile)
+
 /* hack the original tables to work with both petscii and ascii */
 #define CHARSETHACK
 
@@ -61,7 +66,6 @@ int yymorfg;
 extern char *yysptr, yysbuf[];
 int yytchar;
 
-/*FILE *yyin ={stdin}, *yyout ={stdout};*/
 #define yyin  infile
 #define yyout outfile
 
@@ -665,7 +669,13 @@ yyunput(c)
 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;
 }
diff --git a/test/ref/yacc.in b/test/ref/yacc.in
new file mode 100755
index 000000000..697b244d0
--- /dev/null
+++ b/test/ref/yacc.in
@@ -0,0 +1,3 @@
+x=(e+1)*3/(3+7)
+
+
diff --git a/test/ref/yacc2.c b/test/ref/yacc2.c
index c62fca34a..78d654ded 100644
--- a/test/ref/yacc2.c
+++ b/test/ref/yacc2.c
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 # define YYTYPE char
 struct yywork 
 { 
diff --git a/test/val/Makefile b/test/val/Makefile
new file mode 100644
index 000000000..2e0aca278
--- /dev/null
+++ b/test/val/Makefile
@@ -0,0 +1,70 @@
+
+# makefile for the regression tests that return an error code on failure
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(TESTS)
+
+$(WORKDIR)/%.prg: %.c
+	$(CL65) $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.o.prg: %.c
+	$(CL65) -O $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.os.prg: %.c
+	$(CL65) -Os $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.osi.prg: %.c
+	$(CL65) -Osi $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.osir.prg: %.c
+	$(CL65) -Osir $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.oi.prg: %.c
+	$(CL65) -Oi $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.oir.prg: %.c
+	$(CL65) -Oir $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.or.prg: %.c
+	$(CL65) -Or $(CC65FLAGS) $< -o $@
+	$(SIM65) $(SIM65FLAGS) $@
+
+clean:
+	@$(RM) $(TESTS)
+	@$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
diff --git a/test/val/add1.o b/test/val/add1.o
deleted file mode 100644
index bc6b2f505..000000000
Binary files a/test/val/add1.o and /dev/null differ
diff --git a/test/val/add1.prg b/test/val/add1.prg
deleted file mode 100644
index c0bdb01a2..000000000
Binary files a/test/val/add1.prg and /dev/null differ
diff --git a/test/val/add3.c b/test/val/add3.c
index abbc93b47..c031f1d0f 100644
--- a/test/val/add3.c
+++ b/test/val/add3.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     GPL, read COPYING.GPL
 */
 
+#include "common.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
diff --git a/test/val/add3.o b/test/val/add3.o
deleted file mode 100644
index 53a40880f..000000000
Binary files a/test/val/add3.o and /dev/null differ
diff --git a/test/val/add3.prg b/test/val/add3.prg
deleted file mode 100644
index 9ababe609..000000000
Binary files a/test/val/add3.prg and /dev/null differ
diff --git a/test/val/add4.o b/test/val/add4.o
deleted file mode 100644
index cc6c6aa52..000000000
Binary files a/test/val/add4.o and /dev/null differ
diff --git a/test/val/add4.prg b/test/val/add4.prg
deleted file mode 100644
index b00f31329..000000000
Binary files a/test/val/add4.prg and /dev/null differ
diff --git a/test/val/cc65091020.c b/test/val/cc65091020.c
index 8ec11ef8d..d23b70a06 100644
--- a/test/val/cc65091020.c
+++ b/test/val/cc65091020.c
@@ -5,6 +5,7 @@
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
 #include <assert.h>
 
 struct {
diff --git a/test/val/common.h b/test/val/common.h
new file mode 100644
index 000000000..dada61a14
--- /dev/null
+++ b/test/val/common.h
@@ -0,0 +1,22 @@
+
+#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
diff --git a/test/val/compare5.c b/test/val/compare5.c
index b5dd93f01..9e0c97a63 100644
--- a/test/val/compare5.c
+++ b/test/val/compare5.c
@@ -17,9 +17,6 @@ unsigned char success = 0;
 unsigned char failures = 0;
 unsigned char dummy = 0;
 
-#ifdef SUPPORT_BIT_TYPES
-bit bit0 = 0;
-#endif
 int int0 = 0;
 int int1 = 0;
 char char0 = 0;
@@ -291,19 +288,16 @@ void c_minus1(void)
   printf("(long0 != -1)\n");
   if(long0 != -1)
   {
-	LOG_ERROR(1);
 	failures++;
   }
   printf("(long0 > 0)\n");
   if(long0 > 0)
   {
-	LOG_ERROR(1);
 	failures++;
   }
   printf("(long1 < 0)\n");
   if(long1 < 0)
   {
-	LOG_ERROR(1);
 	failures++;
   }
 /*
diff --git a/test/val/cq22.c b/test/val/cq22.c
index 4ce40ecc0..bcd1570c8 100644
--- a/test/val/cq22.c
+++ b/test/val/cq22.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq241.c b/test/val/cq241.c
index d7d8ed952..76f437e0c 100644
--- a/test/val/cq241.c
+++ b/test/val/cq241.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq243.c b/test/val/cq243.c
index 03b08b4d2..676c73182 100644
--- a/test/val/cq243.c
+++ b/test/val/cq243.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq244.c b/test/val/cq244.c
index 52695bfb6..bedf51e95 100644
--- a/test/val/cq244.c
+++ b/test/val/cq244.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq25.c b/test/val/cq25.c
index d4a0c4a90..9cb2f61c8 100644
--- a/test/val/cq25.c
+++ b/test/val/cq25.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq26.c b/test/val/cq26.c
index 42527e80f..399f0a45e 100644
--- a/test/val/cq26.c
+++ b/test/val/cq26.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifndef CQ26_INCLUDED
 struct defs {
      int cbits;          /* No. of bits per char           */
diff --git a/test/val/cq4.c b/test/val/cq4.c
index 94f4d5fb7..8a8125c52 100644
--- a/test/val/cq4.c
+++ b/test/val/cq4.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
@@ -41,7 +43,124 @@ struct defs {
      int crc;            /* Cumulative return code         */
      char rfs[8];        /* Return from section            */
 
-/*#include "cq26.c"*/ /* hardware check */
+#define CQ26_INCLUDED
+/*
+  section s26, which pokes around at the hardware
+  trying to figure out the characteristics of the machine that
+  it is running on, saves information that is subsequently
+  used by sections s626, s72, and s757. If this program is
+  to be broken up into smallish pieces, say for running on
+  a microcomputer, take care to see that s26 is called before
+  calling any of the latter three sections.
+*/
+
+/*
+        2.6  Hardware Characteristics
+*/
+
+#ifndef NO_OLD_FUNC_DECL
+s26(pd0)
+struct defs *pd0;
+{
+#else
+s26(struct defs *pd0) {
+#endif
+   static char qs26[8] = "s26    ";
+   char *ps, *pt;
+   char c0, c1;
+   #ifndef NO_FLOATS
+        float temp, one, delta;
+        double tempd, oned;
+   #endif
+   static char s[] = "%3d bits in %ss.\n";
+   static char s2[] = "%e is the least number that can be added to 1. (%s).\n";
+
+   ps = qs26;
+   pt = pd0->rfs;
+
+   while(*pt++ = *ps++);
+
+          /* Here, we shake the machinery a little to see what falls
+             out.  First, we find out how many bits are in a char.  */
+
+   pd0->cbits = 0;
+   c0 = 0;
+   c1 = 1;
+
+   while(c0 != c1) {
+     c1 = c1<<1;
+     pd0->cbits = pd0->cbits+1;
+   }
+          /* That information lets us determine the size of everything else. */
+
+   pd0->ibits = pd0->cbits * sizeof(int);
+   pd0->sbits = pd0->cbits * sizeof(short);
+   pd0->lbits = pd0->cbits * sizeof(long);
+   pd0->ubits = pd0->cbits * sizeof(unsigned);
+   #ifndef NO_FLOATS
+        pd0->fbits = pd0->cbits * sizeof(float);
+        pd0->dbits = pd0->cbits * sizeof(double);
+   #endif
+
+          /* We have now almost reconstructed the table in section 2.6, the
+             exception being the range of the floating point hardware.
+             Now there are just so many ways to conjure up a floating point
+             representation system that it's damned near impossible to guess
+             what's going on by writing a program to interpret bit patterns.
+             Further, the information isn't all that useful, if we consider
+             the fact that machines that won't handle numbers between 10**30
+             and 10**-30 are very hard to find, and that people playing with
+             numbers outside that range have a lot more to worry about than
+             just the capacity of the characteristic.
+
+             A much more useful measure is the precision, which can be ex-
+             pressed in terms of the smallest number that can be added to
+             1. without loss of significance. We calculate that here, for
+             float and double.                       */
+
+#ifndef NO_FLOATS
+   one = 1.;
+   delta = 1.;
+   temp = 0.;
+   while(temp != one) {
+     temp = one+delta;
+     delta = delta/2.;
+   }
+   pd0->fprec = delta * 4.;
+   oned = 1.;
+   delta = 1.;
+   tempd = 0.;
+   while(tempd != oned) {
+     tempd = oned+delta;
+     delta = delta/2.;
+   }
+   pd0->dprec = delta * 4.;
+#endif
+
+          /* Now, if anyone's interested, we publish the results.       */
+
+#ifndef CQ26_INCLUDED
+   if(pd0->flgm != 0) {
+     printf(s,pd0->cbits,"char");
+     printf(s,pd0->ibits,"int");
+     printf(s,pd0->sbits,"short");
+     printf(s,pd0->lbits,"long");
+     printf(s,pd0->ubits,"unsigned");
+     printf(s,pd0->fbits,"float");
+     printf(s,pd0->dbits,"double");
+     #ifndef NO_FLOATS
+        printf(s2,pd0->fprec,"float");
+        printf(s2,pd0->dprec,"double");
+     #else
+        printf("NO_FLOATS\n");
+     #endif
+   }
+#endif
+          /* Since we are only exploring and perhaps reporting, but not
+             testing any features, we cannot return an error code.  */
+
+   return 0;
+}
 
 int extvar;
 
@@ -125,10 +244,13 @@ implementation                                                  */
 
    target = ~0U;
    mask = 1;
+   printf("sizeof target: %08x pd0->cbits: %08x\n", sizeof target, pd0->cbits);
+   printf("mask: %08x target: %08x\n", mask, target);
 
    for(j=0; j<(sizeof target)*pd0->cbits; j++){
      mask = mask&target;
      target = target>>1;
+     printf("mask: %08x target: %08x\n", mask, target);
    }
 
    if(mask != 1 || target != 0){
@@ -200,11 +322,12 @@ setev(){
 	int section(int j,void* pd0){
 #endif
         switch(j){
-                case 0: return s4(pd0);
+                case 0: return s26(pd0);
+                case 1: return s4(pd0);
         }
 }
 
-#define cq_sections 1
+#define cq_sections 2
 
 /*
         C REFERENCE MANUAL (main)
diff --git a/test/val/cq61.c b/test/val/cq61.c
index f40b21d61..3dcca6454 100644
--- a/test/val/cq61.c
+++ b/test/val/cq61.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq626.c b/test/val/cq626.c
index 7fab43f53..166d3a95b 100644
--- a/test/val/cq626.c
+++ b/test/val/cq626.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq71.c b/test/val/cq71.c
index 342b9809a..7bf0d9e1e 100644
--- a/test/val/cq71.c
+++ b/test/val/cq71.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 /*include "cq26.c"*/ /* hardware check */
 
 struct defs {
diff --git a/test/val/cq714.c b/test/val/cq714.c
index 1d36b18ab..f4c58801f 100644
--- a/test/val/cq714.c
+++ b/test/val/cq714.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq714b.c b/test/val/cq714b.c
index 9a09a88f0..b4908f4cb 100644
--- a/test/val/cq714b.c
+++ b/test/val/cq714b.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq715.c b/test/val/cq715.c
index dd829156c..fec9c6170 100644
--- a/test/val/cq715.c
+++ b/test/val/cq715.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq72.c b/test/val/cq72.c
index 5f60fdcad..2f956e59d 100644
--- a/test/val/cq72.c
+++ b/test/val/cq72.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq757.c b/test/val/cq757.c
index 7c898ca5b..60b588555 100644
--- a/test/val/cq757.c
+++ b/test/val/cq757.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq7813.c b/test/val/cq7813.c
index 77d34a2a6..0e743abcd 100644
--- a/test/val/cq7813.c
+++ b/test/val/cq7813.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq81.c b/test/val/cq81.c
index 198cbc4f6..0271cae5d 100644
--- a/test/val/cq81.c
+++ b/test/val/cq81.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq84.c b/test/val/cq84.c
index fcadd9af6..d37c82f29 100644
--- a/test/val/cq84.c
+++ b/test/val/cq84.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq85.c b/test/val/cq85.c
index 3e5ef938d..15b055b20 100644
--- a/test/val/cq85.c
+++ b/test/val/cq85.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq86.c b/test/val/cq86.c
index 2800307f7..9f2409e7a 100644
--- a/test/val/cq86.c
+++ b/test/val/cq86.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq88.c b/test/val/cq88.c
index 77bb9e88c..a15f75110 100644
--- a/test/val/cq88.c
+++ b/test/val/cq88.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/cq9.c b/test/val/cq9.c
index 698443ce6..228ac9e77 100644
--- a/test/val/cq9.c
+++ b/test/val/cq9.c
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */