summaryrefslogtreecommitdiff
path: root/bcc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'bcc/misc')
-rw-r--r--bcc/misc/sformat56
-rw-r--r--bcc/misc/test/8queens.pas33
-rw-r--r--bcc/misc/test/8queens.t74
-rw-r--r--bcc/misc/test/atol.t29
-rw-r--r--bcc/misc/test/bigsievec.t29
-rw-r--r--bcc/misc/test/bt.t373
-rw-r--r--bcc/misc/test/cast.t144
-rw-r--r--bcc/misc/test/cast1.t144
-rw-r--r--bcc/misc/test/castest.t74
-rw-r--r--bcc/misc/test/ctype.t38
-rw-r--r--bcc/misc/test/error.t78
-rw-r--r--bcc/misc/test/extern.t236
-rw-r--r--bcc/misc/test/hilbert.t169
-rw-r--r--bcc/misc/test/longtest.c24
-rw-r--r--bcc/misc/test/longtest.dat15
-rwxr-xr-xbcc/misc/test/longtest.mak3
-rwxr-xr-xbcc/misc/test/longtest.sh4
-rw-r--r--bcc/misc/test/miniltest.t72
-rw-r--r--bcc/misc/test/op1.t120
-rw-r--r--bcc/misc/test/opcmp.t106
-rw-r--r--bcc/misc/test/oplong.t264
-rw-r--r--bcc/misc/test/opplus.t122
-rw-r--r--bcc/misc/test/opsoft.t259
-rw-r--r--bcc/misc/test/puzzle.t178
-rw-r--r--bcc/misc/test/sierpin.t123
-rw-r--r--bcc/misc/test/sievec.t28
-rw-r--r--bcc/misc/test/sievecp.t45
-rw-r--r--bcc/misc/test/sievei.t28
-rw-r--r--bcc/misc/test/sort.t104
-rw-r--r--bcc/misc/test/stdio.t87
30 files changed, 3059 insertions, 0 deletions
diff --git a/bcc/misc/sformat b/bcc/misc/sformat
new file mode 100644
index 0000000..3dcb0c4
--- /dev/null
+++ b/bcc/misc/sformat
@@ -0,0 +1,56 @@
+int x;
+.comm _x,2
+
+int x = 1;
+.global _x
+.data
+_x:
+1
+
+static int x;
+.bss
+_x:
+.=.+2
+
+static int x = 1;
+.bss | implicit
+.data
+_x:
+1
+
+char x[10];
+.comm _x,12
+
+char x[10] = "1";
+.globl _x
+.data
+_x:
+.byte 61,0
+.=.+10
+
+static char x[10];
+.bss;
+_cc:
+.=.+12
+
+static char x[10] = "1";
+.data
+_x:
+.byte 61,0
+.=.+10
+
+test()
+.globl _test
+.text
+_test:
+
+{
+static int x;
+.bss
+L3:
+.=.+2
+
+static int x = 1;
+.bss
+.data
+L5:1
diff --git a/bcc/misc/test/8queens.pas b/bcc/misc/test/8queens.pas
new file mode 100644
index 0000000..f4f1b47
--- /dev/null
+++ b/bcc/misc/test/8queens.pas
@@ -0,0 +1,33 @@
+program eightqueens;
+
+var i: integer;
+ a: array[ 1..8 ] of boolean;
+ b: array[ 2..16] of boolean;
+ c: array[-7..7 ] of boolean;
+ x: array[ 1..8 ] of integer;
+
+procedure print;
+var k: integer;
+begin
+ for k:= 1 to 8 do write(x[k]:4);
+ writeln;
+end;
+
+procedure try(i: integer);
+var j: integer;
+begin
+ for j:= 1 to 8 do if a[j] and b[i+j] and c[i-j] then
+ begin
+ x[i]:= j;
+ a[j]:= false; b[i+j]:= false; c[i-j]:= false;
+ if i < 8 then try(i+1) else print;
+ a[j]:= true; b[i+j]:= true; c[i-j]:= true;
+ end;
+end;
+
+begin
+ for i:= 1 to 8 do a[i]:= true;
+ for i:= 2 to 16 do b[i]:= true;
+ for i:= -7 to 7 do c[i]:= true;
+ try(1);
+end.
diff --git a/bcc/misc/test/8queens.t b/bcc/misc/test/8queens.t
new file mode 100644
index 0000000..8d20a4d
--- /dev/null
+++ b/bcc/misc/test/8queens.t
@@ -0,0 +1,74 @@
+/* 8queens - straightforward translation of pascal version */
+
+#define TRUE 1
+#define FALSE 0
+
+int i;
+char a[8],b[15],c[15],x[8];
+
+main()
+{
+ for (i=0;i<8;i++)
+ a[i]=TRUE;
+ for (i=0;i<15;i++)
+ b[i]=TRUE;
+ for (i=0;i<15;i++)
+ c[i]=TRUE;
+ try(0);
+}
+
+print()
+{
+ int k;
+
+ for (k=0;k<8;k++)
+ write(x[k]);
+ writeln();
+}
+
+write(i)
+int i;
+{
+ {
+#asm
+ LDA #$20
+ JSR $E820
+ LDD .i,S
+ JSR $C682
+#endasm
+ }
+}
+
+writeln()
+{
+ {
+#asm
+ LDA #13
+ JSR $E820
+ LDA #10
+ JSR $E820
+#endasm
+ }
+}
+
+try(i)
+int i;
+{
+ int j;
+
+ for(j=0;j<8;j++)
+ if (a[j] && b[i+j] && c[7+i-j])
+ {
+ x[i]=j;
+ a[j]=FALSE;
+ b[i+j]=FALSE;
+ c[7+i-j]=FALSE;
+ if (i<7)
+ try(i+1);
+ else
+ print();
+ a[j]=TRUE;
+ b[i+j]=TRUE;
+ c[7+i-j]=TRUE;
+ }
+}
diff --git a/bcc/misc/test/atol.t b/bcc/misc/test/atol.t
new file mode 100644
index 0000000..79c78b7
--- /dev/null
+++ b/bcc/misc/test/atol.t
@@ -0,0 +1,29 @@
+/* atol.c - long atol( char *s ) */
+
+/* atol converts s to a long */
+/* leading spaces and tabs are ignored, an optional sign is recognised, */
+/* and the digits (0 to 9) following determine the long */
+
+long atol( s )
+register char *s;
+{
+ char signflag;
+ long number;
+
+ while ( *s == ' ' || *s == '\t')
+ s++;
+ signflag = 0;
+ if ( *s == '+' )
+ s++;
+ else if ( *s == '-' )
+ {
+ signflag = 1;
+ s++;
+ }
+ number = 0;
+ while ( *s >= '0' && *s <= '9' )
+ number = 10 * number + *s++ - '0';
+ if ( signflag )
+ return -number;
+ return number;
+}
diff --git a/bcc/misc/test/bigsievec.t b/bcc/misc/test/bigsievec.t
new file mode 100644
index 0000000..f3f76b2
--- /dev/null
+++ b/bcc/misc/test/bigsievec.t
@@ -0,0 +1,29 @@
+#define TRUE 1
+#define FALSE 0
+#define NITER 10
+#define SIZE 100000
+
+char flags[SIZE+1];
+
+main()
+{
+ int i,prime,k,count,iter;
+
+ for (iter=0;iter<NITER;iter++)
+ {
+ count=0;
+ for (i=0;i<=SIZE;i++)
+ flags[i]=TRUE;
+ for (i=0;i<=SIZE;i++)
+ {
+ if (flags[i])
+ {
+ prime=i+i+3;
+ for (k=i+prime;k<=SIZE;k=k+prime)
+ flags[k]=FALSE;
+ count++;
+ }
+ }
+ }
+ printf( "%d primes\n", count );
+}
diff --git a/bcc/misc/test/bt.t b/bcc/misc/test/bt.t
new file mode 100644
index 0000000..b88836c
--- /dev/null
+++ b/bcc/misc/test/bt.t
@@ -0,0 +1,373 @@
+/* bt.t - bug tests */
+
+test1()
+{
+ char *p, *q;
+
+ q += *p++;
+}
+
+test2()
+{
+ int i,j,k,a[2],b[2],c[2];
+
+ i = a[i] + b[j] + c[k];
+}
+
+test3()
+{
+ int *p, *q;
+ int i;
+
+ i = p - q;
+}
+
+test4()
+{
+ int a[2];
+ int *p;
+
+ p = a;
+ test4(a);
+}
+
+test5()
+{
+ char c;
+
+ test4(c);
+}
+
+test6(a,b)
+int b,a;
+{
+ int i;
+
+ i = b;
+ i = a;
+}
+
+test7()
+{
+ int a[2];
+ int *p;
+
+ p = a + 1;
+}
+
+int *test8();
+
+int *test8()
+{
+ int i;
+
+ if ( test8() == i )
+ ;
+ i = *test8();
+}
+
+test9()
+{
+ int i,j,k,n;
+
+ if ((i < 0 || j > 100) && (k < 0 || n > 50))
+ i = 1;
+}
+
+struct complex
+{
+ int re;
+ int im;
+}
+ znum, *zptr, zarr[10], *zptrarr[10];
+
+test10()
+{
+ int i;
+
+ znum.re = i;
+ znum.im = 1;
+ zptr -> re = 1;
+ zptr -> im = i;
+ zarr[3].im = i;
+ zptrarr[4] -> im = 1;
+}
+
+test11()
+{
+ char symtab[100];
+
+ char *p;
+
+ if (p > symtab)
+ ;
+}
+
+test12()
+{
+char symtab[100];
+
+ char *p;
+
+ p = symtab - 21;
+}
+
+test13()
+{
+ char a[10];
+ int i;
+
+ i = a - 1;
+}
+
+test14()
+{
+ int i, **pi;
+
+ **pi = i;
+}
+
+test15()
+{
+ int i, j;
+
+ if ( (i = j ) == 2 )
+ test();
+}
+
+test16()
+{
+ struct cx3
+ {
+ int re3;
+ char im3;
+ }
+ z[10], *pz, *pz1;
+ int i;
+
+ i = z[i].re3;
+ i = pz1 - pz;
+}
+
+test17()
+{
+ int i;
+ char c;
+
+ c &= ~i;
+}
+
+test18()
+{
+ typedef int (*PFI)();
+ PFI h();
+
+ (*h())( 0 );
+}
+
+test19()
+{
+ register int *p, *q;
+ int ***z,i,a[10];
+
+ test(***z + a[i]);
+}
+
+char a[2][3][5];
+
+char *p = a;
+char *q = a[1];
+char *r = a[1][2];
+
+char test20();
+char (*test21)();
+
+test22()
+{
+ char i,k;
+ char *p;
+
+ p = a;
+ p = a[1];
+ p = a[1][2];
+ p = a[k];
+ p = a[k][k];
+ i = sizeof a;
+ i = sizeof a[k];
+ i = sizeof a[k][k];
+ i = sizeof test20;
+ i = sizeof test21;
+ i = sizeof test20();
+ i = sizeof (*test21)();
+}
+
+test23()
+{
+ long *pl;
+ int i;
+ char *s;
+
+ *pl += i;
+ *s += *pl;
+}
+
+test24()
+{
+ float f;
+ double *dp1(), *dp2();
+
+ f = *dp1()++; /* illegal */
+ f = *++dp1(); /* illegal */
+ f = *dp1() + *dp2(); /* bad code (pushes ptr to doubly indirect) */
+}
+
+test25()
+{
+ test25( "2"[1] ); /* added 1 to label number, not label address */
+}
+
+struct stat
+{
+ int st_dev;
+};
+
+test26( buf )
+struct stat buf; /* wrong declare, s.b. struct stat *buf */
+{
+ buf->st_dev = 1; /* error caused null pointer to be dereferenced */
+}
+
+union
+{
+ long l;
+}
+ test27;
+
+test28()
+{
+ test27.l = test27.l + 1; /* produced poor code */
+}
+
+int test29 = (char) 1; /* cast was clobbering the global symptr */
+
+struct { int i; } test30;
+
+test31()
+{
+ return test30; /* a structure cannot be returned (yet) */
+}
+
+int *test32, test33() {} /* this is illegal */
+
+test35()
+{
+ char a[1];
+ char b[1];
+ int i;
+
+ i = i == 1 ? a : b; /* arrays were not converted to ptrs */
+}
+
+test36()
+{
+ struct fp
+ {
+ struct filp *fp_filp[1];
+ };
+ struct filp
+ {
+ int filp_int;
+ long filp_long;
+ };
+ int i;
+ register char *junk;
+ register struct fp *cp;
+
+ cp->fp_filp[i]->filp_int++; /* used to push lvalue */
+ cp->fp_filp[i]->filp_long++; /* used to push lvalue */
+ cp->fp_filp[i]->filp_int += 1; /* was OK */
+ cp->fp_filp[i]->filp_long += 1; /* used to load long into DREG:DREG */
+}
+
+test37()
+{
+ unsigned u;
+
+ u = -u; /* used to give botched nodetype */
+}
+
+test38()
+{
+ char c;
+ int i;
+
+ i = -c; /* did i = (char) -c for a time */
+}
+
+test39()
+{
+ int i;
+
+ i = (char) 1000; /* the constant wasn't being truncated */
+}
+
+#define test40(x) (x)
+
+test41()
+{
+ int i;
+ int j;
+ int k;
+
+ i = test40( j + /* was confused by EOL in macro argument */
+ k );
+}
+
+test42()
+{
+ register char *junk1;
+ register char *junk2;
+ long *longptr;
+ long longfn();
+
+ *longptr = longfn(); /* used to run out of index regs */
+}
+
+test43()
+{
+ register char *jnk1, *junk2;
+ unsigned char *bp;
+ struct FILE_BUF
+ {
+ char *bufp;
+ } *op;
+
+ *op->bufp++ = *bp; /* used to push lvalue */
+}
+
+test44()
+{
+ register char *x, *y;
+ int i;
+ char a[2];
+ char **p;
+
+ a[**p] = **p; /* used to push lvalue */
+}
+
+struct test45
+{
+ int i;
+ int j;
+} test45[10];
+
+test46()
+{
+ register char *p, *q;
+ int i;
+ int j;
+
+ test45[i] = test45[j]; /* used to push lvalue */
+}
+
+int (*test100( x )() {} /* this is legal, keep last avoid swallowing */
diff --git a/bcc/misc/test/cast.t b/bcc/misc/test/cast.t
new file mode 100644
index 0000000..554cb93
--- /dev/null
+++ b/bcc/misc/test/cast.t
@@ -0,0 +1,144 @@
+/* cast.t */
+
+char c;
+unsigned char uc;
+short s;
+unsigned short us;
+int i;
+unsigned int ui;
+long l;
+unsigned long ul;
+float f;
+double d;
+int *p;
+
+cast()
+{
+ c = (char) c;
+ uc = (unsigned char) c;
+ s = (short) c;
+ us = (unsigned short) c;
+ i = (int) c;
+ ui = (unsigned int) c;
+ l = (long) c;
+ ul = (unsigned long) c;
+ f = (float) c;
+ d = (double) c;
+ p = (int *) c;
+
+ c = (char) uc;
+ uc = (unsigned char) uc;
+ s = (short) uc;
+ us = (unsigned short) uc;
+ i = (int) uc;
+ ui = (unsigned int) uc;
+ l = (long) uc;
+ ul = (unsigned long) uc;
+ f = (float) uc;
+ d = (double) uc;
+ p = (int *) uc;
+
+ c = (char) s;
+ uc = (unsigned char) s;
+ s = (short) s;
+ us = (unsigned short) s;
+ i = (int) s;
+ ui = (unsigned int) s;
+ l = (long) s;
+ ul = (unsigned long) s;
+ f = (float) s;
+ d = (double) s;
+ p = (int *) s;
+
+ c = (char) us;
+ uc = (unsigned char) us;
+ s = (short) us;
+ us = (unsigned short) us;
+ i = (int) us;
+ ui = (unsigned int) us;
+ l = (long) us;
+ ul = (unsigned long) us;
+ f = (float) us;
+ d = (double) us;
+ p = (int *) us;
+
+ c = (char) i;
+ uc = (unsigned char) i;
+ s = (short) i;
+ us = (unsigned short) i;
+ i = (int) i;
+ ui = (unsigned int) i;
+ l = (long) i;
+ ul = (unsigned long) i;
+ f = (float) i;
+ d = (double) i;
+ p = (int *) i;
+
+ c = (char) ui;
+ uc = (unsigned char) ui;
+ s = (short) ui;
+ us = (unsigned short) ui;
+ i = (int) ui;
+ ui = (unsigned int) ui;
+ l = (long) ui;
+ ul = (unsigned long) ui;
+ f = (float) ui;
+ d = (double) ui;
+ p = (int *) ui;
+
+ c = (char) l;
+ uc = (unsigned char) l;
+ s = (short) l;
+ us = (unsigned short) l;
+ i = (int) l;
+ ui = (unsigned int) l;
+ l = (long) l;
+ ul = (unsigned long) l;
+ f = (float) l;
+ d = (double) l;
+ p = (int *) l;
+
+ c = (char) ul;
+ uc = (unsigned char) ul;
+ s = (short) ul;
+ us = (unsigned short) ul;
+ i = (int) ul;
+ ui = (unsigned int) ul;
+ l = (long) ul;
+ ul = (unsigned long) ul;
+ f = (float) ul;
+ d = (double) ul;
+ p = (int *) ul;
+
+ c = (char) f;
+ uc = (unsigned char) f;
+ s = (short) f;
+ us = (unsigned short) f;
+ i = (int) f;
+ ui = (unsigned int) f;
+ l = (long) f;
+ ul = (unsigned long) f;
+ f = (float) f;
+ d = (double) f;
+
+ c = (char) d;
+ uc = (unsigned char) d;
+ s = (short) d;
+ us = (unsigned short) d;
+ i = (int) d;
+ ui = (unsigned int) d;
+ l = (long) d;
+ ul = (unsigned long) d;
+ f = (float) d;
+ d = (double) d;
+
+ c = (char) p;
+ uc = (unsigned char) p;
+ s = (short) p;
+ us = (unsigned short) p;
+ i = (int) p;
+ ui = (unsigned int) p;
+ l = (long) p;
+ ul = (unsigned long) p;
+ p = (int *) p;
+}
diff --git a/bcc/misc/test/cast1.t b/bcc/misc/test/cast1.t
new file mode 100644
index 0000000..a4c15d5
--- /dev/null
+++ b/bcc/misc/test/cast1.t
@@ -0,0 +1,144 @@
+/* cast1.t */
+
+char c;
+unsigned char uc;
+short s;
+unsigned short us;
+int i;
+unsigned int ui;
+long l;
+unsigned long ul;
+float f;
+double d;
+int *p;
+
+cast()
+{
+ c = c;
+ uc = c;
+ s = c;
+ us = c;
+ i = c;
+ ui = c;
+ l = c;
+ ul = c;
+ f = c;
+ d = c;
+ p = c;
+
+ c = uc;
+ uc = uc;
+ s = uc;
+ us = uc;
+ i = uc;
+ ui = uc;
+ l = uc;
+ ul = uc;
+ f = uc;
+ d = uc;
+ p = uc;
+
+ c = s;
+ uc = s;
+ s = s;
+ us = s;
+ i = s;
+ ui = s;
+ l = s;
+ ul = s;
+ f = s;
+ d = s;
+ p = s;
+
+ c = us;
+ uc = us;
+ s = us;
+ us = us;
+ i = us;
+ ui = us;
+ l = us;
+ ul = us;
+ f = us;
+ d = us;
+ p = us;
+
+ c = i;
+ uc = i;
+ s = i;
+ us = i;
+ i = i;
+ ui = i;
+ l = i;
+ ul = i;
+ f = i;
+ d = i;
+ p = i;
+
+ c = ui;
+ uc = ui;
+ s = ui;
+ us = ui;
+ i = ui;
+ ui = ui;
+ l = ui;
+ ul = ui;
+ f = ui;
+ d = ui;
+ p = ui;
+
+ c = l;
+ uc = l;
+ s = l;
+ us = l;
+ i = l;
+ ui = l;
+ l = l;
+ ul = l;
+ f = l;
+ d = l;
+ p = l;
+
+ c = ul;
+ uc = ul;
+ s = ul;
+ us = ul;
+ i = ul;
+ ui = ul;
+ l = ul;
+ ul = ul;
+ f = ul;
+ d = ul;
+ p = ul;
+
+ c = f;
+ uc = f;
+ s = f;
+ us = f;
+ i = f;
+ ui = f;
+ l = f;
+ ul = f;
+ f = f;
+ d = f;
+
+ c = d;
+ uc = d;
+ s = d;
+ us = d;
+ i = d;
+ ui = d;
+ l = d;
+ ul = d;
+ f = d;
+ d = d;
+
+ c = p;
+ uc = p;
+ s = p;
+ us = p;
+ i = p;
+ ui = p;
+ l = p;
+ ul = p;
+ p = p;
+}
diff --git a/bcc/misc/test/castest.t b/bcc/misc/test/castest.t
new file mode 100644
index 0000000..ae27f7b
--- /dev/null
+++ b/bcc/misc/test/castest.t
@@ -0,0 +1,74 @@
+/* castest.c */
+
+/*
+#define signedchar
+#define bigints
+*/
+#define unsigchar
+#define unsigshort
+#define unsiglong
+
+#define TEST(u,c) if ( (u) != (c) )\
+ { printf( "u != c\n" ); ++bad; } ++possible
+
+main()
+{
+ int bad;
+ int possible;
+ char c;
+#ifdef signedchar
+ signed char sc;
+#endif
+#ifdef unsigchar
+ unsigned char uc;
+#endif
+ short s;
+#ifdef unsigshort
+ unsigned short us;
+#endif
+ int i;
+ unsigned u;
+ long l;
+#ifdef unsiglong
+ unsigned long ul;
+#endif
+
+ bad = possible = 0;
+ u = 0x1ff;
+ c = (char) u;
+ if ( c < 0 )
+ printf( "characters are signed\n" );
+ TEST((char)u,c);
+ i = (int)(char) u;
+ TEST(i,(int)c);
+ TEST((int)(char)u,i);
+
+#ifdef signedchar
+ sc = (signed char) u;
+ if ( sc >= 0 )
+ printf( "??? signed char not signed\n" );
+ TEST((signed char)u,sc);
+ TEST((int)(signed char)u,(int)sc);
+ i = (int) sc;
+ TEST((int)(signed char)u,i);
+#endif
+
+#ifdef bigints
+ u = 0x1ffff;
+ s = (short) u;
+ TEST((short)u,s);
+ TEST((int)(short)u,(int)s);
+ i = (int) s;
+ TEST((int)(short)u,i);
+
+#ifdef unsigshort
+ us = (unsigned short) u;
+ TEST((unsigned short)u,us);
+ TEST((int)(unsigned short)u,(int)us);
+ i = (int) us;
+ TEST((int)(unsigned short)u,i);
+#endif
+#endif
+
+ printf( "%d bad out of a possible %d\n", bad, possible );
+}
diff --git a/bcc/misc/test/ctype.t b/bcc/misc/test/ctype.t
new file mode 100644
index 0000000..93b3e4f
--- /dev/null
+++ b/bcc/misc/test/ctype.t
@@ -0,0 +1,38 @@
+/* ctype.h */
+
+#define _C 1 /* control */
+#define _D 2 /* digit */
+#define _L 4 /* lower */
+#define _P 8 /* punctuation */
+#define _S 16 /* space */
+#define _U 32 /* upper */
+#define _UN 64 /* underline */
+#define _X '\200' /* hex digit, not digit */
+
+extern char _ctype_[];
+
+#define _ct1_ (_ctype_+1)
+
+#define isalnum(c) (_ct1_[c]&(_U|_L|_D))
+#define isalpha(c) (_ct1_[c]&(_U|_L))
+#define isascii(i) ((unsigned)(i)<=0x7f)
+#define isalpha(c) (_ct1_[c]&(_U|_L))
+#define iscntrl(c) (_ct1_[c]&_C)
+#define iscsym(c) (_ct1_[c]&(_U|_L|_D|_UN))
+#define iscsymf(c) (_ct1_[c]&(_U|_L|_UN))
+#define isdigit(c) (_ct1_[c]&_D)
+#define isgraph(c) (_ct1_[c]&(_U|_L|_D|_P))
+#define islower(c) (_ct1_[c]&_L)
+/* isodigit(i) is a function */
+/* isprint(i) is a function */
+#define ispunct(c) (_ct1_[c]&_P)
+#define isspace(c) (_ct1_[c]&_S)
+#define isupper(c) (_ct1_[c]&_U)
+#define isxdigit(c) (_ct1_[c]&(_D|_X))
+
+#define toascii(i) ((i)&0x7f)
+/* toint(i) is a function */
+/* tolower(i) is a function */
+#define _tolower(c) ((c)+('a'-'A'))
+/* toupper(i) is a function */
+#define _toupper(c) ((c)+('A'-'a'))
diff --git a/bcc/misc/test/error.t b/bcc/misc/test/error.t
new file mode 100644
index 0000000..24e302a
--- /dev/null
+++ b/bcc/misc/test/error.t
@@ -0,0 +1,78 @@
+static char *errorstring[] =
+{
+ "# in a macro: not preprocessed",
+ "already declared",
+ "array of functions is illegal",
+ "bad address",
+ "bad case label",
+ "bad character constant",
+ "bad character",
+ "bad control",
+ "bad default label",
+ "bad expression",
+ "bad file name",
+ "bad indirection count",
+ "bad initializer address",
+ "bad register store",
+ "call of non-function",
+ "can't continue in switch",
+ "can't index",
+ "can't load char to index reg",
+ "can't open",
+ "can't open input",
+ "can't open output",
+ "case can't be reached with char switch",
+ "constant expression expected",
+ "else without if",
+ "end of file in #asm",
+ "end of file in #define",
+ "end of file in comment",
+ "end of file in failed #if",
+ "end of file in macro parameter expansion",
+ "end of file in string constant",
+ "end of line in string constant",
+ "endif without if",
+ "function returning array is illegal",
+ "function returning function is illegal",
+ "function returning structure is illegal",
+ "if stack overflow",
+ "illegal indirection",
+ "illegal macro name",
+ "illegal non-external function",
+ "illegal symbol name",
+ "illegal type conversion",
+ "illegal type name",
+ "initializer too complicated",
+ "input error",
+ "load of long constants not implemented",
+ "loading direct long with offset not implemented",
+ "local symbol table overflow",
+ "macro stack overflow",
+ "missing '('",
+ "missing while at end of do-while",
+ "need '",
+ "need int or char",
+ "need lvalue",
+ "need scalar or ptr type",
+ "need structure",
+ "no active fors, switches or whiles",
+ "not in a compound statement",
+ "null dimension",
+ "out of index registers",
+ "redefined macro",
+ "repeated argument",
+ "repeated default label",
+ "repeated parameter",
+ "table full",
+ "too few macro parameters",
+ "too many active whiles",
+ "too many cases",
+ "too many macro parameters",
+ "too many open compound statements",
+ "too many parameters",
+ "undeclared variable",
+ "undefined structure element",
+ "undefined structure",
+ "unsigned ints only",
+ "variable not in argument list"
+};
diff --git a/bcc/misc/test/extern.t b/bcc/misc/test/extern.t
new file mode 100644
index 0000000..dac5f5c
--- /dev/null
+++ b/bcc/misc/test/extern.t
@@ -0,0 +1,236 @@
+/* extern.c - external declarations (K & R p218-9) */
+
+#include "def.h"
+#include "globvar.h"
+#include "symbol.h"
+
+struct typestruct *declarator();
+struct typestruct *extypespec();
+int paramlist();
+struct typestruct *typespec();
+
+/*=============================================================================
+ -- notation is 1st attempt at EBNF (see Modula-2 book)
+ program = { type-definition | function-or-data-definition }.
+ type-definition = "typedef" type-definition-list.
+=============================================================================*/
+
+program()
+{
+ nextsym();
+ while ( sym != EOFSYM )
+ {
+ if ( sym = TYPEDEFDECL )
+ deftypes();
+ else
+ functordata();
+ }
+}
+
+/*=============================================================================
+ type-definition-list. -- not implemented
+=============================================================================*/
+
+deftypes()
+{}
+
+/*=============================================================================
+ function-or-data-definition = external-type-specification
+ ( function-definition | init-declarators ).
+ function-definition = "(" parameter-list ")" arg-list compound-statement.
+ -- this is different from K & R who omit typedefs and static functions
+=============================================================================*/
+
+functordata()
+{
+ struct typestruct *type;
+ int nargs;
+
+ type = extypespec();
+ if ( sym == LPAREN )
+ {
+ nextsym();
+ nargs = paramlist();
+ need( RPAREN );
+ arglist( nargs );
+ need( LBRACE );
+ compound( 1 + locptr-pstartloc );/* 1 = function flag, rest = nargs */
+ oldlevel();
+ }
+ else
+ initdecl( type );
+}
+
+/*=============================================================================
+ external-type-specification = extern-sc type-specifier declarator.
+ extern-sc = [ extern | static ].
+=============================================================================*/
+
+struct typestruct *extypespec()
+{
+ int sc;
+
+ switch( sym )
+ {
+ case EXTERNDECL:
+ case STATICDECL:
+ sc = sym; nextsym(); break;
+ default:
+ sc = EXTERNDECL; break;
+ }
+ return declarator( typespec() );
+}
+
+/*=============================================================================
+ parameter-list = [identifier { "," identifier }].
+=============================================================================*/
+
+int paramlist()
+{
+ int nargs;
+
+ locptr = pstartloc;
+ newlevel();
+ nargs = 0;
+ while ( sym == IDENT )
+ {
+ addloc( gsname, itype, 0 ); /* fix up types and offsets later */
+ nextsym();
+ ++nargs;
+ if ( sym != COMMA )
+ break;
+ nextsym();
+ }
+ return nargs;
+}
+
+/*=============================================================================
+ arg-list =
+=============================================================================*/
+
+arglist( nargs )
+int nargs;
+{
+ struct symstruct *symptr;
+ int argsize, argsp;
+ int lastsym;
+ struct typestruct *basetype;
+ char declflag;
+
+ declflag = TRUE;
+ do
+ {
+ switch( sym )
+ {
+ case TYPEDECL:
+ basetype = gsymptr->type;
+ nextsym();
+ getarg1( basetype );
+ break;
+ case STRUCTDECL:
+ case UNIONDECL:
+ lastsym = sym;
+ nextsym();
+ getarg( declsu( lastsym ) );
+ break;
+ case AUTODECL:
+ case EXTERNDECL:
+ case REGDECL:
+ case STATICDECL:
+ case SEMICOLON:
+ nextsym();
+ break;
+ default:
+ declflag = FALSE;
+ break;
+ }
+ }
+ while ( declflag );
+ argsp = -2;
+ symptr = pstartloc;
+ while ( nargs && symptr < locptr ) /* convert arg sizes to offsets */
+ {
+ argsize = symptr->offset;
+ if ( symptr->type == ctype )
+ {
+ ++argsp;
+ --argsize;
+ }
+ symptr->offset = argsp;
+ argsp += argsize;
+ if ( symptr == pstartloc )
+ argsp += 2;
+ --nargs;
+ ++symptr;
+ }
+ if ( nargs )
+ error( "arguments not all declared" );
+}
+
+/* getarg( basetype ) - fill in argument types and sizes */
+
+getarg1( basetype )
+struct typestruct *basetype;
+{
+ char sname[NAMESIZE];
+ struct typestruct *type;
+ int size;
+ struct symstruct *symptr;
+
+ if ( sym != SEMICOLON )
+ while ( TRUE )
+ {
+ type = basetype;
+ size = getvar( sname, &type );
+ if ( (symptr = findlorg( sname )) == NULL || symptr->level != ARGLEVEL )
+ error( "variable not in argument list" );
+ else if ( symptr->offset != 0 ) /* already in arg list */
+ multidecl( sname, type, symptr );
+ else
+ {
+ if ( size < 2 || type->typeop == ATYPEOP )
+ size = 2;
+ symptr->offset = size;
+ symptr->type = type;
+ }
+ if ( sym == COMMA )
+ nextsym();
+ else
+ break;
+ }
+ ns();
+}
+
+struct typestruct *declarator( basetype )
+struct typestruct *basetype;
+{
+ char sname[NAMESIZE];
+ int size;
+ struct symstruct *multi;
+
+ size = getvar( sname, &type );
+ if ( multi = findlorg( sname ) )
+ multidecl( sname, type, multi );
+ else
+ addglb( sname, type, size );
+ nextsym();
+}
+
+struct typestruct *typespec()
+{
+ int lastsym;
+
+ switch( sym )
+ {
+ case TYPEDECL:
+ nextsym();
+ return gsymptr->type;
+ case STRUCTDECL:
+ case UNIONDECL:
+ lastsym = sym;
+ nextsym();
+ return declsu( lastsym );
+ default:
+ return itype;
+ }
+}
diff --git a/bcc/misc/test/hilbert.t b/bcc/misc/test/hilbert.t
new file mode 100644
index 0000000..e18dc63
--- /dev/null
+++ b/bcc/misc/test/hilbert.t
@@ -0,0 +1,169 @@
+/* hilbert.c */
+
+/* S1 stuff
+
+#define PIFBUF ( *(struct IFBUF **) 0xf010 )
+#define PSET 2
+
+struct IFBUF
+{
+ char ERR;
+ char COMMAND;
+ char COLOR;
+ char PLOTOPTION;
+ int LINESTYLE;
+ int X1;
+ int Y1;
+ int X2;
+ int Y2;
+ char BFFLAG;
+};
+end of S1 stuff */
+
+/* L3 stuff */
+
+#define PIFBUF ( (struct IFBUF *) 0xa1 )
+#define PSET 1
+
+struct IFBUF
+{
+ char PLOTOPTION;
+ char junk1[0xa8-0xa2];
+ int X1;
+ int Y1;
+ int X2;
+ int Y2;
+ char junk2[0xf0-0xb0];
+ char ERR; /* this to BFFLAG are dummies to keep S1 code */
+ char COMMAND;
+ int LINESTYLE;
+ char BFFLAG;
+ char junk3[0x3ea-0xf5];
+ char COLOR;
+};
+
+#define H0 512 /* square size */
+#define XOFFS 80 /* offset to centre square */
+#define XNUM 15 /* scale 512 * 15/16 = 480 */
+#define XDENOM 16
+#define YNUM 25 /* scale 512 * 25/64 = 200 */
+#define YDENOM 64 /* to give max height, dot ratio 480/200 = 2.4 */
+
+int h, x, y;
+
+main()
+{
+ int i, x0, y0;
+ char color;
+
+ PIFBUF->PLOTOPTION = PSET;
+ PIFBUF->LINESTYLE = /* normal */
+ PIFBUF->COMMAND = /* ?? */
+ PIFBUF->BFFLAG = 0; /* not a box */
+ color = i = 0;
+ x0 = y0 = (h = H0)/2;
+ while ( h > 1 )
+ {
+ ++i;
+ h = h/2;
+ if ( ++color > 7 )
+ color = 1;
+ gcolor( color );
+ x = x0 += h/2;
+ y = y0 += h/2;
+ glocate();
+ a( i );
+ }
+}
+
+a( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ d( i ); x -= h; plot();
+ a( i ); y -= h; plot();
+ a( i ); x += h; plot();
+ b( i );
+ }
+}
+
+b( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ c( i ); y += h; plot();
+ b( i ); x += h; plot();
+ b( i ); y -= h; plot();
+ a( i );
+ }
+}
+
+c( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ b( i ); x += h; plot();
+ c( i ); y += h; plot();
+ c( i ); x -= h; plot();
+ d( i );
+ }
+}
+
+d( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ a( i ); y -= h; plot();
+ d( i ); x -= h; plot();
+ d( i ); y += h; plot();
+ c( i );
+ }
+}
+
+glocate()
+{
+ PIFBUF->X2 = x - x * (XDENOM - XNUM) / XDENOM + XOFFS;
+ PIFBUF->Y2 = (y * YNUM) / YDENOM;
+}
+
+/* S1 gcolor and plot
+
+gcolor( color )
+int color;
+{
+ PIFBUF->COLOR = color;
+}
+
+plot()
+{
+ PIFBUF->X1 = PIFBUF->X2;
+ PIFBUF->Y1 = PIFBUF->Y2;
+ glocate();
+#asm
+ SWI2
+ FDB $4201 call LINEMA
+#endasm
+}
+
+end S1 plot */
+
+gcolor( color )
+int color;
+{
+ PIFBUF->COLOR = color | 0x10;
+}
+
+plot()
+{
+ PIFBUF->X1 = PIFBUF->X2;
+ PIFBUF->Y1 = PIFBUF->Y2;
+ glocate();
+#asm
+ JSR $D709
+ JSR $D79A
+#endasm
+}
diff --git a/bcc/misc/test/longtest.c b/bcc/misc/test/longtest.c
new file mode 100644
index 0000000..0c0bfe0
--- /dev/null
+++ b/bcc/misc/test/longtest.c
@@ -0,0 +1,24 @@
+int i,j;
+long m,n;
+
+main()
+{
+ while ( 1 )
+ {
+ if ( scanf( "%ld %ld", &m, &n ) <= 0 )
+ exit( 0 );
+ printf( "m = %ld n = %ld m + n = %ld m - n = %ld m * n = %ld\n",
+ m, n, m + n, m - n, m * n );
+ printf( "m = %ld n = %ld m / n = %ld m %% n = %ld\n",
+ m, n, m / n, m % n );
+ printf( "m = %ld n = %ld m&n = %ld m | n = %ld m^n = %ld\n",
+ m, n, m & n, m | n, m ^ n );
+ printf( "m = %ld n = %ld m << n = %ld m >> n = %ld\n",
+ m, n, m << (int) n, m >> (int) n );
+ printf(
+ "m = %ld n = %ld m < n is %d m == n is %d m > n is %d m == 0 is %d\n",
+ m, n, m < n, m == n, m > n, m == 0 );
+ printf( "m = %ld n = %ld -m = %ld ~m = %ld ++m = %ld --n = %ld\n",
+ m, n, -m, ~m, ++m, --n );
+ }
+}
diff --git a/bcc/misc/test/longtest.dat b/bcc/misc/test/longtest.dat
new file mode 100644
index 0000000..a1c7998
--- /dev/null
+++ b/bcc/misc/test/longtest.dat
@@ -0,0 +1,15 @@
+1 1
+-1 1
+1 -1
+-1 -1
+2 3
+4 5
+234234 34554
+4534534 34535
+345324523 3245325
+345435345 319755
+34534 345
+-352351235 23535
+533512351 -3535345
+-351351313 -12235
+123456789 987654321
diff --git a/bcc/misc/test/longtest.mak b/bcc/misc/test/longtest.mak
new file mode 100755
index 0000000..454a4e8
--- /dev/null
+++ b/bcc/misc/test/longtest.mak
@@ -0,0 +1,3 @@
+cc -o cclongtest longtest.c
+sc longtest.c sclongtest.s
+cc -o sclongtest sclongtest.s $HOME/lib/libcb.a $HOME/lib/liblb.a
diff --git a/bcc/misc/test/longtest.sh b/bcc/misc/test/longtest.sh
new file mode 100755
index 0000000..e76f98a
--- /dev/null
+++ b/bcc/misc/test/longtest.sh
@@ -0,0 +1,4 @@
+./sclongtest < longtest.dat >scl.out
+./cclongtest < longtest.dat >ccl.out
+diff scl.out ccl.out >longtest.diff
+cat longtest.diff
diff --git a/bcc/misc/test/miniltest.t b/bcc/misc/test/miniltest.t
new file mode 100644
index 0000000..78097d4
--- /dev/null
+++ b/bcc/misc/test/miniltest.t
@@ -0,0 +1,72 @@
+long x;
+int i;
+unsigned u;
+
+long test1(x)
+long x;
+{
+ return x;
+}
+
+long test2(x)
+int x;
+{
+ return x;
+}
+
+main()
+{
+ printlong( "x=1 is ", x = 1 );
+ printlong( "test1(x) is ", test1(x) );
+ printlong( "test1(1L) is ", test1(1L) );
+ printlong( "x = test1(1L) is ", x = test1(1L) );
+ printlong( "x = test1(x=1) is ", x = test1(x=1) );
+ printlong( "i=1 is ", (long) (i = 1) );
+ printlong( "test2(i) is ", test2(i) );
+ printlong( "test2(1) is ", test2(1) );
+ printlong( "i = test2(1) is ", (long) (i = test2(1)) );
+ printlong( "i = test2(i=1) is ", (long) (i = test2(i=1)) );
+ printlong( "(long) (i = -1) is ", (long) (i=-1) );
+ printlong( "(long) (u = -1) is ", (long) (u=-1) );
+ printlong( "x = -1 is ", x = -1 );
+}
+
+printlong( s, x )
+char *s;
+long x;
+{
+ printf( "%s", s );
+ if ( x & 0x80000000 )
+ {
+ putchar( '-' );
+ x = -x;
+ }
+ printf( "%08lx", (x >> 16) + (x << 16) );
+ putchar( '\n' );
+}
+
+outulhex( pnum )
+char *pnum;
+{
+ int i;
+
+ for ( i = 3; i >=0; --i )
+ p2( pnum[i] );
+}
+
+p2(i)
+int i;
+{
+ p1(i>>4);
+ p1(i);
+}
+
+p1(num)
+int num;
+{
+ int digit;
+
+ if ( (digit = num & 0xf) >= 10 )
+ digit += 'A' - ('9' + 1);
+ putchar( digit + '0' );
+}
diff --git a/bcc/misc/test/op1.t b/bcc/misc/test/op1.t
new file mode 100644
index 0000000..614e093
--- /dev/null
+++ b/bcc/misc/test/op1.t
@@ -0,0 +1,120 @@
+/* op1.t - test and, or (eor same as or ) */
+
+char cfn();
+int ifn();
+
+char *op1()
+{
+ char c, *pc, **ppc;
+ int i, *pi, **ppi;
+
+ i = c & 1;
+ i = 1 & c;
+ i = i & 1;
+ i = 1 & i;
+
+ i = c & 500;
+ i = 500 & c;
+ i = i & 500;
+ i = 500 & i;
+
+ i = c | 1;
+ i = 1 | c;
+ i = i | 1;
+ i = 1 | i;
+
+ i = c | 500;
+ i = 500 | c;
+ i = i | 500;
+ i = 500 | i;
+
+ i = c & c;
+ i = c & i;
+ i = i & c;
+ i = i & i;
+
+ i = c | c;
+ i = c | i;
+ i = i | c;
+ i = i | i;
+
+ i = c & c++;
+ i = c & i++;
+ i = i & c++;
+ i = i & i++;
+
+ i = c++ & c;
+ i = i++ & c;
+ i = c++ & i;
+ i = i++ & i;
+
+ i = c | c++;
+ i = c | i++;
+ i = i | c++;
+ i = i | i++;
+
+ i = c++ | c;
+ i = i++ | c;
+ i = c++ | i;
+ i = i++ | i;
+
+ i = c & cfn();
+ i = c & ifn();
+ i = i & cfn();
+ i = i & ifn();
+
+ i = cfn() & c;
+ i = ifn() & c;
+ i = cfn() & i;
+ i = ifn() & i;
+
+ i = c | cfn();
+ i = c | ifn();
+ i = i | cfn();
+ i = i | ifn();
+
+ i = cfn() | c;
+ i = ifn() | c;
+ i = cfn() | i;
+ i = ifn() | i;
+
+ i = *pc & c++;
+ i = *pc & i++;
+ i = *pi & c++;
+ i = *pi & i++;
+
+ i = c++ & *pc;
+ i = i++ & *pc;
+ i = c++ & *pi;
+ i = i++ & *pi;
+
+ i = *pc | c++;
+ i = *pc | i++;
+ i = *pi | c++;
+ i = *pi | i++;
+
+ i = c++ | *pc;
+ i = i++ | *pc;
+ i = c++ | *pi;
+ i = i++ | *pi;
+
+ i = **ppc & c++;
+ i = **ppc & i++;
+ i = **ppi & c++;
+ i = **ppi & i++;
+
+ i = c++ & **ppc;
+ i = i++ & **ppc;
+ i = c++ & **ppi;
+ i = i++ & **ppi;
+
+ i = **ppc | c++;
+ i = **ppc | i++;
+ i = **ppi | c++;
+ i = **ppi | i++;
+
+ i = c++ | **ppc;
+ i = i++ | **ppc;
+ i = c++ | **ppi;
+ i = i++ | **ppi;
+}
diff --git a/bcc/misc/test/opcmp.t b/bcc/misc/test/opcmp.t
new file mode 100644
index 0000000..28bd1a2
--- /dev/null
+++ b/bcc/misc/test/opcmp.t
@@ -0,0 +1,106 @@
+/* opcmp.t - test logical compare operations */
+
+/* only doing chars, shorts, ints and unsigneds */
+/* not doing longs, floats or doubles */
+
+/* short = int, so only a few examples */
+/* unsigned like int, so only a few examples */
+/* all examples < */
+
+op1()
+{
+ char c, *pc, **ppc, cfn();
+ short s, *ps, **pps, sfn();
+ int i, *pi, **ppi, ifn();
+ unsigned u, *pu, **ppu, ufn();
+
+ c < 0;
+ 0 < c;
+ i < 0;
+ 0 < i;
+
+ s < 0;
+ 0 < s;
+
+ 0 < u;
+ u < 0;
+ 1 < u;
+ u < 1;
+
+ c < 1;
+ 1 < c;
+ c < 500;
+ 500 < c;
+
+ c < c;
+ c < i;
+ i < c;
+ i < i;
+
+ s < c;
+ i < u;
+
+ c < c++;
+ c < i++;
+ i < c++;
+ i < i++;
+
+ s < i++;
+ c < u++;
+
+ c++ < c;
+ i++ < c;
+ c++ < i;
+ i++ < i;
+
+ s++ < c;
+ i++ < u;
+
+ c < cfn();
+ c < ifn();
+ i < cfn();
+ i < ifn();
+
+ s < cfn();
+ c < ufn();
+
+ cfn() < c;
+ ifn() < c;
+ cfn() < i;
+ ifn() < i;
+
+ sfn() < c;
+ ifn() < u;
+
+ *pc < c++;
+ *pc < i++;
+ *pi < c++;
+ *pi < i++;
+
+ *ps < c++;
+ *pi < u++;
+
+ c++ < *pc;
+ i++ < *pc;
+ c++ < *pi;
+ i++ < *pi;
+
+ s++ < *pc;
+ i++ < *pu;
+
+ **ppc < c++;
+ **ppc < i++;
+ **ppi < c++;
+ **ppi < i++;
+
+ **pps < c++;
+ **ppi < u++;
+
+ c++ < **ppc;
+ i++ < **ppc;
+ c++ < **ppi;
+ i++ < **ppi;
+
+ s++ < **ppc;
+ i++ < **ppu;
+}
diff --git a/bcc/misc/test/oplong.t b/bcc/misc/test/oplong.t
new file mode 100644
index 0000000..b452243
--- /dev/null
+++ b/bcc/misc/test/oplong.t
@@ -0,0 +1,264 @@
+/* oplong.t - test long operations */
+
+/* this is just opsoft.t with int defined as long */
+
+#define int long
+#define UNSIGNED unsigned long
+
+/* only doing chars, shorts, ints and unsigneds */
+/* not doing longs, floats or doubles */
+
+/* short = int, so only a few examples */
+/* unsigned like int, so only a few examples */
+/* most examples for DIVOP */
+/* only (all) special cases of MULOP, MODOP, SLOP and SROP are tried */
+
+op1()
+{
+ char c, *pc, **ppc, cfn();
+ short s, *ps, **pps, sfn();
+ int i, *pi, **ppi, ifn();
+ UNSIGNED u, *pu, **ppu, ufn();
+
+ i = c / 0;
+ i = 0 / c;
+ i = i / 0;
+ i = 0 / i;
+
+ i = s / 0;
+ i = 0 / u;
+
+ i = c / 1;
+ i = 1 / c;
+ i = i / 1;
+ i = 1 / i;
+
+ i = s / 1;
+ i = 1 / u;
+
+ i = c / 2;
+ i = 2 / c;
+ i = i / 2;
+ i = 2 / i;
+
+ i = s / 2;
+ i = 2 / u;
+
+ i = c / 500;
+ i = 500 / c;
+ i = i / 500;
+ i = 500 / i;
+
+ i = s / 500;
+ i = 500 / u;
+
+ i = c / c;
+ i = c / i;
+ i = i / c;
+ i = i / i;
+
+ i = s / c;
+ i = i / u;
+
+ i = c / c++;
+ i = c / i++;
+ i = i / c++;
+ i = i / i++;
+
+ i = s / i++;
+ i = c / u++;
+
+ i = c++ / c;
+ i = i++ / c;
+ i = c++ / i;
+ i = i++ / i;
+
+ i = s++ / c;
+ i = i++ / u;
+
+ i = c / cfn();
+ i = c / ifn();
+ i = i / cfn();
+ i = i / ifn();
+
+ i = s / cfn();
+ i = c / ufn();
+
+ i = cfn() / c;
+ i = ifn() / c;
+ i = cfn() / i;
+ i = ifn() / i;
+
+ i = sfn() / c;
+ i = ifn() / u;
+
+ i = *pc / c++;
+ i = *pc / i++;
+ i = *pi / c++;
+ i = *pi / i++;
+
+ i = *ps / c++;
+ i = *pi / u++;
+
+ i = c++ / *pc;
+ i = i++ / *pc;
+ i = c++ / *pi;
+ i = i++ / *pi;
+
+ i = s++ / *pc;
+ i = i++ / *pu;
+
+ i = **ppc / c++;
+ i = **ppc / i++;
+ i = **ppi / c++;
+ i = **ppi / i++;
+
+ i = **pps / c++;
+ i = **ppi / u++;
+
+ i = c++ / **ppc;
+ i = i++ / **ppc;
+ i = c++ / **ppi;
+ i = i++ / **ppi;
+
+ i = s++ / **ppc;
+ i = i++ / **ppu;
+
+ i = c * 0;
+ i = 0 * c;
+ i = i * 0;
+ i = 0 * i;
+
+ i = s * 0;
+ i = 0 * u;
+
+ i = c * 1;
+ i = 1 * c;
+ i = i * 1;
+ i = 1 * i;
+
+ i = s * 1;
+ i = 1 * u;
+
+ i = c * 2;
+ i = 2 * c;
+ i = i * 2;
+ i = 2 * i;
+
+ i = s * 2;
+ i = 2 * u;
+
+ i = c * 500;
+ i = 500 * c;
+ i = i * 500;
+ i = 500 * i;
+
+ i = s * 500;
+ i = 500 * u;
+
+ i = c * c;
+ i = c * c++;
+ i = c++ * c;
+ i = c * cfn();
+ i = cfn() * c;
+ i = *pc * c++;
+ i = c++ * *pc;
+ i = **ppc * c++;
+ i = c++ * **ppc;
+
+ i = c % 0;
+ i = 0 % c;
+ i = i % 0;
+ i = 0 % i;
+
+ i = s % 0;
+ i = 0 % u;
+
+ i = c % 1;
+ i = 1 % c;
+ i = i % 1;
+ i = 1 % i;
+
+ i = s % 1;
+ i = 1 % u;
+
+ i = c % 2;
+ i = 2 % c;
+ i = i % 2;
+ i = 2 % i;
+
+ i = s % 2;
+ i = 2 % u;
+
+ i = c % 500;
+ i = 500 % c;
+ i = i % 500;
+ i = 500 % i;
+
+ i = s % 500;
+ i = 500 % u;
+
+ i = c << 0;
+ i = 0 << c;
+ i = i << 0;
+ i = 0 << i;
+
+ i = s << 0;
+ i = 0 << u;
+
+ i = c << 1;
+ i = 1 << c;
+ i = i << 1;
+ i = 1 << i;
+
+ i = s << 1;
+ i = 1 << u;
+
+ i = c << 8;
+ i = 8 << c;
+ i = i << 8;
+ i = 8 << i;
+
+ i = s << 8;
+ i = 8 << u;
+
+ i = c << 9;
+ i = 9 << c;
+ i = i << 9;
+ i = 9 << i;
+
+ i = s << 9;
+ i = 9 << u;
+
+ i = c >> 0;
+ i = 0 >> c;
+ i = i >> 0;
+ i = 0 >> i;
+
+ i = s >> 0;
+ i = 0 >> u;
+
+ i = c >> 1;
+ i = 1 >> c;
+ i = i >> 1;
+ i = 1 >> i;
+
+ i = s >> 1;
+ i = 1 >> u;
+
+ i = c >> 8;
+ i = 8 >> c;
+ i = i >> 8;
+ i = 8 >> i;
+
+ i = s >> 8;
+ i = 8 >> u;
+
+ i = c >> 9;
+ i = 9 >> c;
+ i = i >> 9;
+ i = 9 >> i;
+
+ i = s >> 9;
+ i = 9 >> u;
+}
diff --git a/bcc/misc/test/opplus.t b/bcc/misc/test/opplus.t
new file mode 100644
index 0000000..88e31e9
--- /dev/null
+++ b/bcc/misc/test/opplus.t
@@ -0,0 +1,122 @@
+/* op+-.t - test plus, minus operators */
+
+/* only doing chars and ints, not shorts, longs, floats, doubles */
+/* not doing pointer arithmetic */
+
+op1()
+{
+ char cfn();
+ int ifn();
+ char c, *pc, **ppc;
+ int i, *pi, **ppi;
+
+ i = c + 1;
+ i = 1 + c;
+ i = i + 1;
+ i = 1 + i;
+
+ i = c + 500;
+ i = 500 + c;
+ i = i + 500;
+ i = 500 + i;
+
+ i = c - 1;
+ i = 1 - c;
+ i = i - 1;
+ i = 1 - i;
+
+ i = c - 500;
+ i = 500 - c;
+ i = i - 500;
+ i = 500 - i;
+
+ i = c + c;
+ i = c + i;
+ i = i + c; /* -2 cycles, +1 byte different from c + i, lhs loaded 1st */
+ i = i + i;
+
+ i = c - c;
+ i = c - i;
+ i = i - c;
+ i = i - i;
+
+ i = c + c++;
+ i = c + i++;
+ i = i + c++;
+ i = i + i++;
+
+ i = c++ + c;
+ i = i++ + c;
+ i = c++ + i;
+ i = i++ + i;
+
+ i = c - c++;
+ i = c - i++;
+ i = i - c++;
+ i = i - i++;
+
+ i = c++ - c;
+ i = i++ - c;
+ i = c++ - i;
+ i = i++ - i;
+
+ i = c + cfn();
+ i = c + ifn();
+ i = i + cfn();
+ i = i + ifn();
+
+ i = cfn() + c;
+ i = ifn() + c;
+ i = cfn() + i;
+ i = ifn() + i;
+
+ i = c - cfn();
+ i = c - ifn();
+ i = i - cfn();
+ i = i - ifn();
+
+ i = cfn() - c;
+ i = ifn() - c;
+ i = cfn() - i;
+ i = ifn() - i;
+
+ i = *pc + c++;
+ i = *pc + i++;
+ i = *pi + c++;
+ i = *pi + i++;
+
+ i = c++ + *pc;
+ i = i++ + *pc;
+ i = c++ + *pi;
+ i = i++ + *pi;
+
+ i = *pc - c++;
+ i = *pc - i++;
+ i = *pi - c++;
+ i = *pi - i++;
+
+ i = c++ - *pc;
+ i = i++ - *pc;
+ i = c++ - *pi;
+ i = i++ - *pi;
+
+ i = **ppc + c++;
+ i = **ppc + i++;
+ i = **ppi + c++;
+ i = **ppi + i++;
+
+ i = c++ + **ppc;
+ i = i++ + **ppc;
+ i = c++ + **ppi;
+ i = i++ + **ppi;
+
+ i = **ppc - c++;
+ i = **ppc - i++;
+ i = **ppi - c++;
+ i = **ppi - i++;
+
+ i = c++ - **ppc;
+ i = i++ - **ppc;
+ i = c++ - **ppi;
+ i = i++ - **ppi;
+}
diff --git a/bcc/misc/test/opsoft.t b/bcc/misc/test/opsoft.t
new file mode 100644
index 0000000..346df4d
--- /dev/null
+++ b/bcc/misc/test/opsoft.t
@@ -0,0 +1,259 @@
+/* opsoft.t - test software operations */
+
+/* only doing chars, shorts, ints and unsigneds */
+/* not doing longs, floats or doubles */
+
+/* short = int, so only a few examples */
+/* unsigned like int, so only a few examples */
+/* most examples for DIVOP */
+/* only (all) special cases of MULOP, MODOP, SLOP and SROP are tried */
+
+op1()
+{
+ char c, *pc, **ppc, cfn();
+ short s, *ps, **pps, sfn();
+ int i, *pi, **ppi, ifn();
+ unsigned u, *pu, **ppu, ufn();
+
+ i = c / 0;
+ i = 0 / c;
+ i = i / 0;
+ i = 0 / i;
+
+ i = s / 0;
+ i = 0 / u;
+
+ i = c / 1;
+ i = 1 / c;
+ i = i / 1;
+ i = 1 / i;
+
+ i = s / 1;
+ i = 1 / u;
+
+ i = c / 2;
+ i = 2 / c;
+ i = i / 2;
+ i = 2 / i;
+
+ i = s / 2;
+ i = 2 / u;
+
+ i = c / 500;
+ i = 500 / c;
+ i = i / 500;
+ i = 500 / i;
+
+ i = s / 500;
+ i = 500 / u;
+
+ i = c / c;
+ i = c / i;
+ i = i / c;
+ i = i / i;
+
+ i = s / c;
+ i = i / u;
+
+ i = c / c++;
+ i = c / i++;
+ i = i / c++;
+ i = i / i++;
+
+ i = s / i++;
+ i = c / u++;
+
+ i = c++ / c;
+ i = i++ / c;
+ i = c++ / i;
+ i = i++ / i;
+
+ i = s++ / c;
+ i = i++ / u;
+
+ i = c / cfn();
+ i = c / ifn();
+ i = i / cfn();
+ i = i / ifn();
+
+ i = s / cfn();
+ i = c / ufn();
+
+ i = cfn() / c;
+ i = ifn() / c;
+ i = cfn() / i;
+ i = ifn() / i;
+
+ i = sfn() / c;
+ i = ifn() / u;
+
+ i = *pc / c++;
+ i = *pc / i++;
+ i = *pi / c++;
+ i = *pi / i++;
+
+ i = *ps / c++;
+ i = *pi / u++;
+
+ i = c++ / *pc;
+ i = i++ / *pc;
+ i = c++ / *pi;
+ i = i++ / *pi;
+
+ i = s++ / *pc;
+ i = i++ / *pu;
+
+ i = **ppc / c++;
+ i = **ppc / i++;
+ i = **ppi / c++;
+ i = **ppi / i++;
+
+ i = **pps / c++;
+ i = **ppi / u++;
+
+ i = c++ / **ppc;
+ i = i++ / **ppc;
+ i = c++ / **ppi;
+ i = i++ / **ppi;
+
+ i = s++ / **ppc;
+ i = i++ / **ppu;
+
+ i = c * 0;
+ i = 0 * c;
+ i = i * 0;
+ i = 0 * i;
+
+ i = s * 0;
+ i = 0 * u;
+
+ i = c * 1;
+ i = 1 * c;
+ i = i * 1;
+ i = 1 * i;
+
+ i = s * 1;
+ i = 1 * u;
+
+ i = c * 2;
+ i = 2 * c;
+ i = i * 2;
+ i = 2 * i;
+
+ i = s * 2;
+ i = 2 * u;
+
+ i = c * 500;
+ i = 500 * c;
+ i = i * 500;
+ i = 500 * i;
+
+ i = s * 500;
+ i = 500 * u;
+
+ i = c * c;
+ i = c * c++;
+ i = c++ * c;
+ i = c * cfn();
+ i = cfn() * c;
+ i = *pc * c++;
+ i = c++ * *pc;
+ i = **ppc * c++;
+ i = c++ * **ppc;
+
+ i = c % 0;
+ i = 0 % c;
+ i = i % 0;
+ i = 0 % i;
+
+ i = s % 0;
+ i = 0 % u;
+
+ i = c % 1;
+ i = 1 % c;
+ i = i % 1;
+ i = 1 % i;
+
+ i = s % 1;
+ i = 1 % u;
+
+ i = c % 2;
+ i = 2 % c;
+ i = i % 2;
+ i = 2 % i;
+
+ i = s % 2;
+ i = 2 % u;
+
+ i = c % 500;
+ i = 500 % c;
+ i = i % 500;
+ i = 500 % i;
+
+ i = s % 500;
+ i = 500 % u;
+
+ i = c << 0;
+ i = 0 << c;
+ i = i << 0;
+ i = 0 << i;
+
+ i = s << 0;
+ i = 0 << u;
+
+ i = c << 1;
+ i = 1 << c;
+ i = i << 1;
+ i = 1 << i;
+
+ i = s << 1;
+ i = 1 << u;
+
+ i = c << 8;
+ i = 8 << c;
+ i = i << 8;
+ i = 8 << i;
+
+ i = s << 8;
+ i = 8 << u;
+
+ i = c << 9;
+ i = 9 << c;
+ i = i << 9;
+ i = 9 << i;
+
+ i = s << 9;
+ i = 9 << u;
+
+ i = c >> 0;
+ i = 0 >> c;
+ i = i >> 0;
+ i = 0 >> i;
+
+ i = s >> 0;
+ i = 0 >> u;
+
+ i = c >> 1;
+ i = 1 >> c;
+ i = i >> 1;
+ i = 1 >> i;
+
+ i = s >> 1;
+ i = 1 >> u;
+
+ i = c >> 8;
+ i = 8 >> c;
+ i = i >> 8;
+ i = 8 >> i;
+
+ i = s >> 8;
+ i = 8 >> u;
+
+ i = c >> 9;
+ i = 9 >> c;
+ i = i >> 9;
+ i = 9 >> i;
+
+ i = s >> 9;
+ i = 9 >> u;
+}
diff --git a/bcc/misc/test/puzzle.t b/bcc/misc/test/puzzle.t
new file mode 100644
index 0000000..9d2c4ab
--- /dev/null
+++ b/bcc/misc/test/puzzle.t
@@ -0,0 +1,178 @@
+/* puzzle.t - from C puzzle book */
+
+#define puzzle(which) ( puts( "-----which-----\n" ), which() )
+
+main()
+{
+ puzzle( op1 );
+ puzzle( op2 );
+ puzzle( op3 );
+ puzzle( op4 );
+ puzzle( op5 );
+ puzzle( op6 );
+ puzzle( prep1 );
+ puzzle( prep2 );
+}
+
+op1()
+{
+ int x;
+
+ x = - 3 + 4 * 5 - 6; printf("%d\n",x);
+ x = 3 + 4 % 5 - 6; printf("%d\n",x);
+ x = - 3 * 4 % - 6 / 5; printf("%d\n",x);
+ x = ( 7 + 6 ) % 5 /2; printf("%d\n",x);
+}
+
+#define PRINTX printf( "%d\n", x )
+
+op2()
+{
+ int x, y, z;
+
+ x = 2;
+ x *= 3 + 2; PRINTX;
+ x *= y = z = 4; PRINTX;
+ x = y == z; PRINTX;
+ x == (y == z); PRINTX;
+}
+
+#define PRINT(int) printf( "int = %d\n", int )
+
+op3()
+{
+ int x, y, z;
+
+ x = 2; y = 1; z = 0;
+ x = x && y || z; PRINT(x);
+ PRINT( x || ! y && z );
+
+ x = y = 1;
+ z = x ++ - 1; PRINT(x); PRINT(z);
+ z += - x ++ + ++ y;PRINT(x);PRINT(z);
+ z = x / ++ x; PRINT(z);
+}
+
+op4()
+{
+ int x, y, z;
+
+ x = 03; y = 02; z = 01;
+ PRINT( x | y & z );
+ PRINT( x | y & ~ z );
+ PRINT( x ^ y & ~ z );
+ PRINT( x & y && z );
+
+ x = 1; y = -1;
+ PRINT( ! x | x );
+ PRINT( ~ x | x );
+ PRINT( x ^ x );
+ x <<= 3; PRINT(x);
+ y <<= 3; PRINT(y);
+ y >>= 3; PRINT(y);
+}
+
+op5()
+{
+ int x, y, z;
+
+ x = 1; y = 1; z = 1;
+
+ x += y += z;
+ PRINT( x < y ? y : x );
+
+ PRINT( x < y ? x ++ : y ++ );
+ PRINT(x); PRINT(y);
+
+ PRINT( z += x < y ? x ++ : y ++ );
+ PRINT(y); PRINT(z);
+
+ x = 3; y=z=4;
+ PRINT( (z >= y >= x) ? 1 : 0 );
+ PRINT( z >= y && y >= x );
+}
+
+#define PRINT3(x,y,z) printf("x=%d\ty=%d\tz=%d\n",x,y,z)
+
+op6()
+{
+ int x, y, z;
+
+ x = y = z = 1;
+ ++x || ++y && ++z; PRINT3(x,y,z);
+
+ x = y = z = 1;
+ ++x && ++y || ++z; PRINT3(x,y,z);
+
+ x = y = z = 1;
+ ++x && ++y && ++z; PRINT3(x,y,z);
+
+ x = y = z = -1;
+ ++x && ++y || ++z; PRINT3(x,y,z);
+
+ x = y = z = -1;
+ ++x || ++y && ++z; PRINT3(x,y,z);
+
+ x = y = z = -1;
+ ++x && ++y && ++z; PRINT3(x,y,z);
+}
+
+#define FUDGE(k) k+3
+#define PR(a) printf("a= %d\t",(int)(a))
+#define PRINTNEW(a) PR(a); putchar( '\n' );
+#define PRINT2(a,b) PR(a); PRINT(b)
+#define PRINT3NEW(a,b,c) PR(a); PRINT2(b,c)
+#define MAX(a,b) (a<b ? b : a )
+
+prep1()
+{
+ {
+ int x;
+ x = 2;
+ PRINTNEW( x*FUDGE(2) );
+ }
+ {
+ int cel;
+ for( cel=0; cel<=100; cel+=50 )
+ PRINT2( cel, 9/5*cel+32 );
+ }
+ {
+ int x, y;
+ x=1; y=2;
+ PRINT3NEW( MAX(x++,y),x,y );
+ PRINT3NEW( MAX(x++,y),x,y );
+ }
+}
+
+#define NEG(a)-a
+#define weeks(mins) (days(mins)/7)
+#define days(mins) (hours(mins)/24)
+#define hours(mins) (mins/60)
+#define mins(secs) (secs/60)
+#define TAB(c,i,oi,tx) if(c=='\t')\
+ for(tx=8-(i-oi-1)%8,oi=i; tx; tx--)\
+ putchar(' ')
+
+static char *input = "\twhich\tif?";
+
+prep2()
+{
+ {
+ int x;
+ x=1;
+ PRINT( -NEG(x) );
+ }
+ {
+ PRINT( weeks(10080) );
+ PRINT( days(mins(86400)) );
+ }
+ {
+ char c;
+ int i, oldi, temp;
+
+ for( oldi= -1,i=0; (c=input[i])!='\0'; i++ )
+ if( c<' ' ) TAB(c,i,oldi,temp);
+ else putchar(c);
+ putchar('\n');
+ }
+}
diff --git a/bcc/misc/test/sierpin.t b/bcc/misc/test/sierpin.t
new file mode 100644
index 0000000..79016f7
--- /dev/null
+++ b/bcc/misc/test/sierpin.t
@@ -0,0 +1,123 @@
+/* sierpin.t */
+
+#define PPIFBUF 0xf010 /* address of ptr to IFBUF */
+#define PSET 2 /* use this plot option */
+
+struct IFBUF
+{
+ char ERR;
+ char COMMAND;
+ char COLOR;
+ char PLOTOPTION;
+ int LINESTYLE;
+ int X1;
+ int Y1;
+ int X2;
+ int Y2;
+ char BFFLAG;
+};
+
+#define H0 512 /* square size */
+#define XOFFS 80 /* offset to centre square */
+#define XNUM 15 /* scale 512 * 15/16 = 480 */
+#define XDENOM 16
+#define YNUM 25 /* scale 512 * 25/64 = 200 */
+#define YDENOM 64 /* to give max height, dot ratio 480/200 = 2.4 */
+
+struct IFBUF *pifbuf;
+int h, x, y;
+
+main()
+{
+ struct IFBUF **ppifbuf; /* required since no casts */
+ int i, x0, y0;
+ char color;
+
+ pifbuf = *(ppifbuf = PPIFBUF); /* pifbuf = *(struct IFBUF **)PPIFBUF; */
+ pifbuf->PLOTOPTION = PSET;
+ pifbuf->LINESTYLE = /* normal */
+ pifbuf->COMMAND = /* ?? */
+ pifbuf->BFFLAG = 0; /* not a box */
+ color = i = 0;
+ x0 = 2 * (h = H0/4);
+ y0 = 3 * (H0/4);
+ while ( h > 1 )
+ {
+ ++i;
+ if ( ++color > 7 )
+ color = 1;
+ pifbuf->COLOR = color;
+ x = x0 -= h;
+ y = y0 += h /= 2;
+ glocate();
+ a( i ); x += h; y -= h; plot();
+ b( i ); x -= h; y -= h; plot();
+ c( i ); x -= h; y += h; plot();
+ d( i ); x += h; y += h; plot();
+ }
+}
+
+a( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ a( i ); x += h; y -=h; plot();
+ b( i ); x += 2*h; plot();
+ d( i ); x += h; y += h; plot();
+ a( i );
+ }
+}
+
+b( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ b( i ); x -= h; y -=h; plot();
+ c( i ); y -= 2*h; plot();
+ a( i ); x += h; y -= h; plot();
+ b( i );
+ }
+}
+
+c( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ c( i ); x -= h; y +=h; plot();
+ d( i ); x -= 2*h; plot();
+ b( i ); x -= h; y -= h; plot();
+ c( i );
+ }
+}
+
+d( i )
+int i;
+{
+ if ( --i >= 0 )
+ {
+ d( i ); x += h; y +=h; plot();
+ a( i ); y += 2*h; plot();
+ c( i ); x -= h; y += h; plot();
+ d( i );
+ }
+}
+
+glocate()
+{
+ pifbuf->X2 = x - x * (XDENOM - XNUM) / XDENOM + XOFFS;
+ pifbuf->Y2 = (y * YNUM) / YDENOM;
+}
+
+plot()
+{
+ pifbuf->X1 = pifbuf->X2;
+ pifbuf->Y1 = pifbuf->Y2;
+ glocate();
+#asm
+ SWI2
+ FDB $4201 call LINEMA
+#endasm
+}
diff --git a/bcc/misc/test/sievec.t b/bcc/misc/test/sievec.t
new file mode 100644
index 0000000..1b51fdb
--- /dev/null
+++ b/bcc/misc/test/sievec.t
@@ -0,0 +1,28 @@
+#define TRUE 1
+#define FALSE 0
+#define SIZE 8190
+
+char flags[SIZE+1];
+
+main()
+{
+ int i,prime,k,count,iter;
+
+ for (iter=0;iter<10;iter++)
+ {
+ count=0;
+ for (i=0;i<=SIZE;i++)
+ flags[i]=TRUE;
+ for (i=0;i<=SIZE;i++)
+ {
+ if (flags[i])
+ {
+ prime=i+i+3;
+ for (k=i+prime;k<=SIZE;k=k+prime)
+ flags[k]=FALSE;
+ count++;
+ }
+ }
+ }
+ printf( "%d primes\n", count );
+}
diff --git a/bcc/misc/test/sievecp.t b/bcc/misc/test/sievecp.t
new file mode 100644
index 0000000..185b031
--- /dev/null
+++ b/bcc/misc/test/sievecp.t
@@ -0,0 +1,45 @@
+/* sieve using pointers */
+
+#define TRUE 1
+#define FALSE 0
+#define NITER 100
+#define SIZE 8191 /* last prime <= 2*this+3 */
+#define SQRSIZE 63 /* last divisor tested = 2*this+3 */
+
+char flags[SIZE+2*SQRSIZE+3]; /* avoid ptr+=prime overflowing */
+
+main()
+{
+ int i,count,iter;
+ register char *ptr;
+ char *endptr;
+ int prime;
+
+ for (iter=0;iter<NITER;iter++)
+ {
+ count=0;
+ ptr=flags;
+ endptr=flags+SIZE;
+ while (ptr<endptr)
+ *ptr++=TRUE;
+ for (i=0;i<SQRSIZE;i++)
+ {
+ if (flags[i])
+ {
+ prime=i+i+3;
+ ptr=flags+i+prime; /* ptr<endptr since i<SQRSIZE */
+ while (ptr<endptr)
+ {
+ *ptr=FALSE;
+ ptr+=prime; /* does not overflow since in flags */
+ }
+ count++;
+ }
+ }
+ ptr=flags+SQRSIZE;
+ while (ptr<endptr)
+ if (*ptr++)
+ count++;
+ }
+ printf( "%d primes\n", count );
+}
diff --git a/bcc/misc/test/sievei.t b/bcc/misc/test/sievei.t
new file mode 100644
index 0000000..d4910dc
--- /dev/null
+++ b/bcc/misc/test/sievei.t
@@ -0,0 +1,28 @@
+#define TRUE 1
+#define FALSE 0
+#define SIZE 8190
+
+int flags[SIZE+1];
+
+main()
+{
+ int i,prime,k,count,iter;
+
+ for (iter=0;iter<10;iter++)
+ {
+ count=0;
+ for (i=0;i<=SIZE;i++)
+ flags[i]=TRUE;
+ for (i=0;i<=SIZE;i++)
+ {
+ if (flags[i])
+ {
+ prime=i+i+3;
+ for (k=i+prime;k<=SIZE;k=k+prime)
+ flags[k]=FALSE;
+ count++;
+ }
+ }
+ }
+ printf( "%d primes\n", count );
+}
diff --git a/bcc/misc/test/sort.t b/bcc/misc/test/sort.t
new file mode 100644
index 0000000..34bcb9e
--- /dev/null
+++ b/bcc/misc/test/sort.t
@@ -0,0 +1,104 @@
+unsigned t[10000];
+unsigned s[10000];
+unsigned size,repet;
+unsigned comp=0,swap=0; /* s.b. long */
+
+main(argc)
+{
+ int i,zz;
+
+/*
+ printf("size?");
+ scanf("%d",&size);
+ printf("repet?");
+ scanf("%d",&repet);
+*/
+ if ( argc > 20 )
+ {
+ printf( "usage: sort [args], where 500*argc is the array size\n" );
+ exit( 1 );
+ }
+ size = 500 * argc;
+ repet = 1;
+ for (i = 0; i < size; i++)
+ s[i] = size-i;
+ printf("\npress key to begin shell sorting\n");
+ getchar();
+ for (zz=0;zz<repet;zz++)
+ {
+ comp=swap=0;
+ for (i=0;i<size;i++)
+ t[i]=s[i];
+ sort();
+ }
+ printf("\nsorted\n");
+ printf("\ncompares = %d, swaps = %d\n",comp,swap);
+ printf("\npress key to begin quick sorting\n");
+ getchar();
+ for (zz=0;zz<repet;zz++)
+ {
+ comp=swap=0;
+ for (i=0;i<size;i++)
+ t[i]=s[i];
+ qqsort();
+ }
+ printf("\nsorted\n");
+ printf("\ncompares = %d, swaps = %d\n",comp,swap);
+}
+
+sort()
+{
+ int i,j,h,temp;
+
+ h=1;
+ while (9*h+4<size)
+ h=3*h+1;
+ while (h>0)
+ {
+ for (j=h; j<size; j++)
+ for (i=j-h; i>=0; i-=h)
+ {
+ ++comp;
+ if (t[i]<=t[i+h])
+ break;
+ ++swap;
+ temp=t[i];
+ t[i]=t[i+h];
+ t[i+h]=temp;
+ }
+ h=(h-1)/3;
+ }
+}
+
+qqsort()
+{
+ qsort(0,size-1);
+}
+
+qsort(l,r)
+int l,r;
+{
+ int i,j;
+ unsigned x,w;
+
+ i=l;j=r;
+ x=t[(l+r)>>1];
+ do
+ {
+ while (t[i] < x)
+ {
+ ++comp;
+ i++;
+ }
+ while (x < t[j]) {--j;}
+ if (i<=j)
+ {
+ ++swap;
+ w=t[i];t[i]=t[j];t[j]=w;
+ i++;j--;
+ }
+ }
+ while (i<=j);
+ if (l<j) qsort(l,j);
+ if (i<r) qsort(i,r);
+}
diff --git a/bcc/misc/test/stdio.t b/bcc/misc/test/stdio.t
new file mode 100644
index 0000000..e7e174d
--- /dev/null
+++ b/bcc/misc/test/stdio.t
@@ -0,0 +1,87 @@
+/* stdio.h */
+
+#asm
+
+#define BUFSIZ 512
+#define _NFILE 20
+
+#define _IOREAD 1
+#define _IOWRITE 2
+#define _IODIRTY 4
+#define _IOEOF 8
+#define _IOERR 16
+#define _IOMYBUF 32 /* says if stream routines allocated buffer */
+#define _IOUNBUF 64
+
+#define EOF (-1)
+#define NULL 0
+
+#endasm
+
+#define stdin (&_iob[0])
+#define stdout (&_iob[1])
+#define stderr (&_iob[2])
+
+#define FILE struct _iobuf
+
+struct _iobuf
+{
+ char *_ptr;
+ char *_base;
+ char *_rtop;
+ char *_wtop;
+ char _flags;
+ char _fd;
+}
+ _iob[_NFILE];
+
+#define clearerr(fp) ((fp)->flags&=~_IOERR)
+#define getchar() getc(stdin)
+#define feof(fp) ((fp)->_flags&_IOEOF)
+#define ferror(fp) ((fp)->_flags&_IOERR)
+#define fileno(fp) ((fp)->_fd)
+#define putchar(c) putc((c),stdout)
+
+#define void int
+
+FILE *fdopen();
+char *fgets();
+FILE *fopen();
+FILE *freopen();
+long ftell();
+
+long lseek();
+unsigned read();
+unsigned write();
+
+char *malloc();
+char *realloc();
+char *sbrk();
+
+char *index();
+char *rindex();
+char *strcat();
+char *strcpy();
+char *strncat();
+char *strncpy();
+
+#asm
+
+BLANK EQU 32
+COEOL EQU 10
+EOL EQU 13
+MAXCONTROL EQU 31
+
+* struct _iobuf translated into offsets
+
+ BLOCK 0
+PTR RMB 2
+BASE RMB 2
+RTOP RMB 2
+WTOP RMB 2
+FLAGS RMB 1
+FD RMB 1
+IOB.SIZE
+ ENDB
+
+#endasm