KLIB H SEEK C OPEN C CREAT C TEST2 C ^TEST3 C _TEST4 C rTEST5 C  MACHINE H W MAKE SUB XY LINK SUBZ LINK SUB[are. * */  MACHINE H  MACHINE 68K LINK SUB MAKE SUB ! xopen #define fopen xfopen #define getc xgetc #define getw xgetw #define fcreat xfcreat #define putl xputl #define putw xGETC C  GETCHAR C  PUTC C STRCMP C TEST H BUGDEFS H FPTEST C STEST C  MAKE SUB\]^ MACHINE 68K_ MACHINE H ` MAKE SUBabcare. * */  MAKE SUB"#$ SEND SUB% MACHINE H & MACHINE 68K'putw #define putc xputc #define putchar(x) fputc(x,stdout) #define strcmp xstrcmp #define index xindex #define strcpy xstrcPUTCHAR C CPUTC C DUP C IODEC H STJPTST C PRTFTESTC EXECTESTC EXECGOOBC  LINK SUBd MACHINE 68Ke MACHINE H fSTREAMIOC ghijklmnopqrstuv/* * Seek.c -- Whitesmith's equivalent of V6 seek */ long lseek(); seek(fildes,offset,ptrname) int fildes; /* UNIX / MACHINE VAX( DUMP C :)*+,-./0 FIND C 123456789:;<=>?@ FIND C ABpy /* * Defining the names in this manner allows using the V7 UNIX library * to run the asinine V6 calls in the Alcyon softV6FFLUSHC STRCPY C IOB H PUTL C /* * This file defines procedure names used by the assembler, compiler, * etc. to be the names used in this library. * STREAMIOC wMAKE SUBxyz{TEST C |}~TEST C  WS file descriptor */ int offset; /* File offset, bytes */ int ptrname; /* Sense variable */ { offset &= 0xffff; / RELOC C CDEFGHIJKLMNOPQR RELOC C ST COUT H U MACHINE 68KVware. * */ OUTERR C PUTCHD C COUT H MAKE SUB * (In case you haven't guessed, the "k" in "klib" stands for: * * K L U D G E !) */ #define creat xcreat #define open* Clear sign extension problems*/ if(ptrname > 2) /* Not byte sense seek */ { /* */ offset = offset << 9; /* Mulde,xtype)); /* Call clib routine */ } /****************************/ e open mode: * * 0 => READ access only * 1 => WRITE access only * 2 => Both READ and WRITE * type is 0 for ASCII /**************************************************************************** * * C F I L E C R E A T E R O U T I N ong)offset,ptrname)); } -= 3; /* reset to range 0 .. 2 */ } /********************************/ return(lseek(fildes,(tiply by 512 */ ptrname -= 3; /* reset to range 0 .. 2 */ } /********************************/ return(lseek(fildes,(e,xtype)); /* Call clib routine */ } /****************************/ files, 1 for BINARY * * *****************************************************************************/ #include E * ----------------------------------------- * * The "creat" routine opens a new "C" file and returns a file id. * * /**************************************************************************** * * C F I L E O P E N R O U T I N E *long)offset,ptrname)); } -= 3; /* reset to range 0 .. 2 */ } /********************************/ return(lseek(fildes,(e,xtype)); /* Call clib routine */ } /****************************/  /* */ WORD xopen(fname,mode,xtype) /****************************/ BYTE *fname; /* -> File name */ WORD moCalling Sequence: * * fid = creat(fname,prot,type); * * Where: * * fname is the address of a null terminated file name. ------------------------------------- * * The "open" routine opens a "C" file and returns a file id. * * Calling Sequeong)offset,ptrname)); } -= 3; /* reset to range 0 .. 2 */ } /********************************/ return(lseek(fildes,(e,xtype)); /* Call clib routine */ } /****************************/ de; /* Open mode */ WORD xtype; /* File type */ { /****************************/ return(_open(fname,mo * prot is the UNIX file protection * type is 0 for ASCII, 1 for BINARY * *************************************************nce: * * fid = open(fname,mode,type); * * Where: * * fname is the address of a null terminated file name. * mode is thong)offset,ptrname)); } -= 3; /* reset to range 0 .. 2 */ } /********************************/ return(lseek(fildes,(****************************/ #include WORD xcreat(fname,prot,type) /****************************/ BYTE *fname;next char*/ char cbuf[BLEN]; /*char buffer*/ }; fopen(fname,ibuf,x) char *fname; register struct iob *ibuf; int x; { *****************/ return(_creat(fname,prot,type)); /* Call clib routine */ } /****************************/  return(-1); i |= (j&0377); if(i&0100000) i |= 0xffff0000; /* make it negative */ return(i); }  /* -> File name */ WORD prot; /* Open mode */ WORD type; /* ASCII/BINARY flag */ { /********** ibuf->cc = 0; /*no chars*/ x = (x == 0) ? 0 : 1; return(ibuf->fd=open(fname,0,x)); } getc(ibuf) register struct iob return(-1); i |= (j&0377); if(i&0100000) i |= 0xffff0000; /* make it negative */ return(i); } ******************/ return(_creat(fname,prot,type)); /* Call clib routine */ } /****************************/ *ibuf; { if(ibuf->cc<=0) { ibuf->cp = &(ibuf->cbuf[0]); ibuf->cc = read(ibuf->fd,ibuf->cp,BLEN); } if(ibuf->cc <=return(-1); i |= (j&0377); if(i&0100000) i |= 0xffff0000; /* make it negative */ return(i); } *****************/ return(_creat(fname,prot,type)); /* Call clib routine */ } /****************************/  0) { return(-1); } ibuf->cc--; return((int)(*(ibuf->cp)++)&0xff); } getw(ibuf) register struct iob *ibuf; { #define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ char *cp; /*ptr to *****************/ return(_creat(fname,prot,type)); /* Call clib routine */ } /****************************/ register int j; register int i; if((j=getc(ibuf)) == -1) return(-1); i = (j&0377) << 8; if((j=getc(ibuf)) == -1) } putc(c,ibuf) char c; register struct iob *ibuf; { if(ibuf->cc<=0) { ibuf->cp = &(ibuf->cbuf[0]); if(write(ibufread(fin.fd,fin.cp,BLEN); } if(fin.cc <= 0) { return(0); } fin.cc--; i = *(fin.cp)++; return(i&0xff); } ) != i) __outerr(); return(0); } ,ibuf); putc((int)l &0xff,ibuf); return(l); } ->fd,ibuf->cp,BLEN) != BLEN) __outerr(); ibuf->cc = BLEN; } *(ibuf->cp)++ = c; ibuf->cc--; return(c); } putw(#define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ char *cp; /*ptr to ead(fin.fd,fin.cp,BLEN); } if(fin.cc <= 0) { return(0); } fin.cc--; i = *(fin.cp)++; return(i&0xff); }  != i) __outerr(); return(0); } ,ibuf); putc((int)l &0xff,ibuf); return(l); } #define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ char *cp; /*ptr to w,ibuf) int w; register struct iob *ibuf; { register j; int i; putc((w>>8)&0xff,ibuf); putc(w&0xff,ibuf); returnext char*/ char cbuf[BLEN]; /*char buffer*/ }; fcreat(fname,ibuf,x) char *fname; int x; register struct iob *ibuf; {ead(fin.fd,fin.cp,BLEN); } if(fin.cc <= 0) { return(0); } fin.cc--; i = *(fin.cp)++; return(i&0xff); }  != i) __outerr(); return(0); } ,ibuf); putc((int)l &0xff,ibuf); return(l); } next char*/ char cbuf[BLEN]; /*char buffer*/ } fin; getchar() { char c; register int i; if(fin.fd==0) { if(rean(w); } lputw(x,buff) int *x; struct iobuf *buff; { return(putw(*x,buff)); } myfflush(ibuf) register struct iob *ib ibuf->cc = BLEN; /*no chars*/ ibuf->cp = &(ibuf->cbuf[0]); x = (x == 0) ? 0 : 1; return(ibuf->fd=creat(fname,2,x)); ead(fin.fd,fin.cp,BLEN); } if(fin.cc <= 0) { return(0); } fin.cc--; i = *(fin.cp)++; return(i&0xff); } d(0,&c,1)<=0 || c==4) return(0); i = c; return(i&0xff); } if(fin.cc<=0) { fin.cp = &(fin.cbuf[0]); fin.cc = uf; { register i; i = BLEN - ibuf->cc; ibuf->cc = BLEN; ibuf->cp = &(ibuf->cbuf[0]); if(write(ibuf->fd,ibuf->cp,i /********************************************************************* * STRCMP - compares strings * &(fout.cbuf[0]); if(write(fout.fd,fout.cp,i) != i) __outerr(); /*Die a horrible death!! */ return(0); } return (1); if (a < b) return (-1); } return(0); } MLOCAL BYTE _toupper(c) REG BYTE c; { if(c >= 'a' && c <= 'z')1) { if(write(1,&cc,1) != 1) return(-1); return(cc); } /* buffered output*/ if(fout.cc<=0) { fout.cp = &(fout. * Special version which is case - insensitive. * * WORD strcmp(s1,s2) * BYTE *s1, *s2; * * 'strcmp' compares null termina&(fout.cbuf[0]); if(write(fout.fd,fout.cp,i) != i) __outerr(); /*Die a horrible death!! */ return(0); }  c -= 'a' - 'A'; return(c); } cbuf[0]); if(write(fout.fd,fout.cp,BLEN) != BLEN) __outerr(); /*Die a horrible death!! */ fout.cc = BLEN; } *(foutted strings s1 and s2. * Returns: * strcmp < 0 if s1 0 if s1>s2 **************# include "iodec.h" /** ** put a single character **/ int f_log = 0; cputc(c, fn) char c; int fn; { write(fn,& c -= 'a' - 'A'; return(c); } .cp)++ = cc; fout.cc--; return(cc); } myflush() { register i; i = BLEN - fout.cc; fout.cc = BLEN; fout.cp =*******************************************************/ #include WORD xstrcmp(s1,s2) REG BYTE *s1, *s2; { R#define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ char *cp; /*ptr to c,1); }  c -= 'a' - 'A'; return(c); }  &(fout.cbuf[0]); if(write(fout.fd,fout.cp,i) != i) __outerr(); /*Die a horrible death!! */ return(0); } EG BYTE a,b; BYTE _toupper(); while (*s1 && *s2) { a = _toupper(*s1++); b = _toupper(*s2++); if (a > b) next char*/ char cbuf[BLEN]; /*char buffer*/ } fout = {0,BLEN,&fout.cbuf[0]}; xputchar(cc) char cc; { if(fout.fd <= ,1); } egister int n; { return(n); }  advantage of the fact that * stdout is not closed by Bill Allen's stuff. */ dup(n) #include "iob.h" v6fflush(v6buf) register struct iob *v6buf; { register short i; i = BSIZE - v6buf->cc; v6buf->cc = Batbuf[MAXFILES]; tial buffer size */ int peeksize; /* initial peek size */ }; extern struct param __param; int __st,1); } # define MAXFILES 15 struct fileps { char *buff; /* beginning of buffer */ char *bptr; /* current position */ int ncegister int n; { return(n); }  advantage of the fact that * stdout is not closed by Bill Allen's stuff. */ dup(n) SIZE; v6buf->cp = &(v6buf->cbuf[0]); if(write(v6buf->fd,v6buf->cp,i) != i) return(-1); return(0); } /* * El-Kludg-o Dup routine. Takes advantage of the fact that * stdout is not closed by Bill Allen's stuff. */ dup(n) tbuf[MAXFILES]; tial buffer size */ int peeksize; /* initial peek size */ }; extern struct param __param; int __sthars; /* number of characters internal */ int bsize; /* size of buffer */ char eoferr; /* end of file flag */ char wrflIZE; v6buf->cp = &(v6buf->cbuf[0]); if(write(v6buf->fd,v6buf->cp,i) != i) return(-1); return(0); } register int n; { return(n); }  advantage of the fact that * stdout is not closed by Bill Allen's stuff. */ dup(n) tbuf[MAXFILES]; tial buffer size */ int peeksize; /* initial peek size */ }; extern struct param __param; int __stag; /* mode flag */ char *pbuff; /* bottom of peek buffer */ }; struct fileps __filehdr[MAXFILES]; struct param { IZE; v6buf->cp = &(v6buf->cbuf[0]); if(write(v6buf->fd,v6buf->cp,i) != i) return(-1); return(0); } egister int n; { return(n); }  advantage of the fact that * stdout is not closed by Bill Allen's stuff. */ dup(n) tbuf[MAXFILES]; tial buffer size */ int peeksize; /* initial peek size */ }; extern struct param __param; int __stint bufsize; /* initial buffer size */ int peeksize; /* initial peek size */ }; extern struct param __param; int __st*buffered I/O structure*/ #define BSIZE 512 struct iob { int fd; int cc; char *cp; char cbuf[BSIZE]; }; *s2++ ) /* isn't C fun? */ ; return(s1); } (int)((l>>24)&0xff),ibuf); putc((int)((l>>16)&0xff),ibuf); putc((int)((l>> 8)&0xff),ibuf); putc((int)l &0xff,ibuf); BYTE *strcpy(s1,s2) * BYTE *s1, *s2; * * Copies bytes from s2 to s1, stopping after null has been moved. * Returns s1. * No*buffered I/O structure*/ #define BSIZE 512 struct iob { int fd; int cc; char *cp; char cbuf[BSIZE]; }; *s2++ ) /* isn't C fun? */ ; return(s1); }  return(l); } long lputl(x,buff) long *x; struct iobuf *buff; { return(putl(*x,buff)); }  check for overflow of s1. ***********************************************************************/ #include #in return(l); } long lputl(x,buff) long *x; struct iobuf *buff; { return(putl(*x,buff)); } clude BYTE *strcpy(s1,s2) REG BYTE *s1, *s2; { REG BYTE *cp; cp = s1; /* save for return. */ while( *cp++ =#define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ char *cp; /*ptr to /*buffered I/O structure*/ #define BSIZE 512 struct iob { int fd; int cc; char *cp; char cbuf[BSIZE]; };  return(l); } long lputl(x,buff) long *x; struct iobuf *buff; { return(putl(*x,buff)); }  *s2++ ) /* isn't C fun? */ ; return(s1); } next char*/ char cbuf[BLEN]; /*char buffer*/ }; long putl(l,ibuf) register long l; register struct iob *ibuf; { putc(/********************************************************************** * STRCPY - copies from one string to another * * } efine MAGIC 0x601a /* bra .+26 instruction*/ #define HDSIZE (sizeof couthd) /**.o file header size*/ struct hdr { short ch_magic; /*c.out magic number 060} #include "cout.h" #define BLEN 512 #include struct iob { int fd; /*file descriptor*/ int cc; /*char count*/ fine MAGIC 0x601a /* bra .+26 instruction*/ 016 = $600E*/ long ch_tsize; /*text size*/ long ch_dsize; /*data size*/ long ch_bsi#include __outerr() { fprintf(stderr,"Write error on output file\n"); exit(-1); } } char *cp; /*ptr to next char*/ char cbuf[BLEN]; /*char buffer*/ }; putchd(buf,header) struct iobuf *buf; struct hdr *hfine MAGIC 0x601a /* bra .+26 instruction*/ ze; /*bss size*/ long ch_ssize; /*symbol table size*/ long ch_stksize; /*stack size*/include __outerr() { fprintf(stderr,"Write error on output file\n"); exit(-1); } eader; { register short *p; register int i; p = (short *)header; for(i=0; i __outerr() { fprintf(stderr,"Write error on output file\n"); exit(-1); } $2cp68 -i 0$1 cputc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 cputc.s era $1x.1 era $1x.2 $2as6868 -s 0$1 -f $1 -l -u seek.s era seek.s $2cp68 -i 0$1 STRCMP.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.s 0$1 -f $1 -l -u putc.s era putc.s $2cp68 -i 0$1 putl.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.hange next line to user 5 someday... user 5!make $1 $2 1 -f $1 -l -u getc.s era getc.s $2cp68 -i 0$1 getchar.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.22 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 outerr.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u outerr.s era outerr.s $2cp6 -s 0$1 -f $1 -l -u cputc.s era cputc.s $2cp68 -i 0$1 CREAT.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.11 $1x.2 strcmp.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u STRCMP.s era STRCMP.s $2cp68 -i 0$1 STRCPY.c $1x.i $2c0682 putl.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u putl.s era putl.s $2cp68 -i 0$1 putchar.c $1x.i $2c068 $1x.i $1x. getchar.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u getchar.s era getchar.s $2cp68 -i 0$1 OPEN.c $1x.i $2c068 $1x.i8 -i 0$1 -i 0$1 putchd.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 putchd.s era $1x.1 era $1x.2 $2 $1x.2 creat.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u CREAT.s era CREAT.s $2cp68 -i 0$1 dup.c $1x.i $2c068 $1x.i $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 strcpy.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u STRCPY.s era 1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 putchar.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u putchar.s era putchar.s/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6 $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 open.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u OPEN.s era OPEN.s as68 -s 0$1 -f $1 -l -u putchd.s era putchd.s era klib $2ar68 rf $1 klib putchd.o cputc.o putchar.o putl.o putc.o getchar.o$1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 dup.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u dup.s era dup.s $2cpSTRCPY.s $2cp68 -i 0$1 v6fflush.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 v6fflush.s era $1x.1 $2cp68 -i 0$1 seek.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 seek.s era $1x.1 era $1x.2 $2as8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operating$2cp68 -i 0$1 putc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 putc.s era $1x.1 era $1x.2 $2as68 - getc.o $2ar68 rf $1 klib open.o creat.o seek.o strcmp.o dup.o v6fflush.o strcpy.o outerr.o $2pip $2[g0]=klib era *.o ;C68 -i 0$1 getc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 getc.s era $1x.1 era $1x.2 $2as68 -s 0$ era $1x.2 $2as68 -s 0$1 -f $1 -l -u v6fflush.s era v6fflush.s $2cp68 -i 0$1 -i 0$1 outerr.c $1x.i $2c068 $1x.i $1x.1 $1x. System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ $2pip machine.h=machine.68k $2cp68 -i 0$1 dir.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 dir.sSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ $2lo68 -r -s -o as68.rel -u_nofloat -u_nowildc -f $1 0$1s.o *.o 0$2klib 0$2clib era *.o user 10!make $1 $2 System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 dir.s era dir.s $2cp68 -i 0$1 expr.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ 2lo68 -r -s -o as68.rel -u_nofloat -u_nowildc -f $1 0$1s.o *.o 0$2klib 0$2clib era *.o user 10!make $1 $2 System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ .3 -f era $1x.i $2c168 $1x.1 $1x.2 expr.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 expr.s era expr.s $2cp68 -i 0$18000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M OperatingSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ 2lo68 -r -s -o as68.rel -u_nofloat -u_nowildc -f $1 0$1s.o *.o 0$2klib 0$2clib era *.o user 10!make $1 $2  list.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 list.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  -s 0$1 list.s era list.s $2cp68 -i 0$1 main.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 main.8.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u ar68.s era ar68.s $2cp68 -i 0$1 lo68.c $1x.i $2c068 $1x.i $1x.1 $1x.2 link $1 $2 i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 size68.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u si1x.2 pass2.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 pass2.s era pass2.s $2cp68 -i 0$1 symt.c $1x.i $2c068 $1x.i $.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 prtobj.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u prtobj.s era prtobj.s $s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 main.s era main.s $2cp68 -i 0$1 misc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1$1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 lo68.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u lo68.s era lo68.s $2cp68 -i ze68.s era size68.s $2cp68 -i 0$1 find.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 find.s era1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 symt.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 symt.s era symt.s 2cp68 -i 0$1 reloc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 reloc.s era $1x.1 era $1x.2 $2asx.3 -f era $1x.i $2c168 $1x.1 $1x.2 misc.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 misc.s era misc.s $2cp68 -i 0$0$1 dump.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 dump.s era $1x.1 era $1x.2 $2as68 -s 0$1 - $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u find.s era find.s $2lo68 -s -f $1 -r -u_nofloat -s -o lo68.rel 0$1s.o lo68. link $1 $2 68 -s 0$1 -f $1 -l -u reloc.s era reloc.s $2cp68 -i 0$1 sendc68.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c161 pass1a.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 pass1a.s era $1x.1 era $1x.2 $2as68 -l -u f $1 -l -u dump.s era dump.s $2cp68 -i 0$1 nm68.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 nm$2pip machine.h=machine.68k $2cp68 -i 0$1 ar68.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 ar6o 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -o ar68.rel 0$1s.o ar68.o 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_noflink $1 $2 8 $1x.1 $1x.2 sendc68.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u sendc68.s era sendc68.s $2cp68 -i 0$1 size68.c $1x.-f $1 -s 0$1 pass1a.s era pass1a.s $2cp68 -i 0$1 pass2.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $68.s era $1x.1 era $1x.2 $2as68 -s 0$1 -f $1 -l -u nm68.s era nm68.s $2cp68 -i 0$1 prtobj.c $1x.i $2c068 $1x.i $1x.1 $1xloat -u_nowildc -u_maxfile -s -o dump.rel 0$1s.o dump.o 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -u_nowildc -u_maxfile -o hine.11 $1vsend machine.68k $1vsend machine.vax $1vsend n.c $1vsend nm68.c $1vsend nuxi.c $1vsend prtobj.c $1vsend reloc.System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ era *.o user 11!make $1 $2  /* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6nm68.rel 0$1s.o nm68.o 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -u_nowildc -u_maxfile -o prtobj.rel 0$1s.o prtobj.c $1vsend sendc68.c $1vsend sendc68.h $1vsend size68.c $1vsend send.sub $1vsend iobuf.h $1vsend done $1vsend make.sub $1vsend lo68.rel $1vsend dump.rel $1vsend ar68.rel $1vsend nm68.rel $1vsend reloc.rel $1vsend prtobj.rel System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ ra *.o user 11!make $1 $2  8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operatingo 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -u_nowildc -o reloc.rel 0$1s.o reloc.o 0$2clib $2lo68 -s -f $1 -r -u_no $1vsend sendc68.c $1vsend sendc68.h $1vsend size68.c $1vsend send.sub $1vsend iobuf.h $1vsend done  $1vsend machine.h $1vsend lo68.c $1vsend sendc68.rel $1vsend size68.rel $1vsend find.rel $1vsend down.sub $1vsend ar.h $ra *.o user 11!make $1 $2   System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ float -s -u_nowildc -u_maxfile -o sendc68.rel 0$1s.o sendc68.o 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -u_nowildc -u_m $1vsend sendc68.c $1vsend sendc68.h $1vsend size68.c $1vsend send.sub $1vsend iobuf.h $1vsend done 1vsend ar68.c $1vsend cout.h $1vsend dump.c $1vsend find.c $1vsend libfix.c $1vsend lo68.h $1vsend lo68init.c $1vsend macSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ axfile -o size68.rel 0$1s.o size68.o 0$2klib 0$2clib $2lo68 -s -f $1 -r -u_nofloat -s -o find.rel 0$1s.o find.o 0$2clib /* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6stem*/ #define VMS 1 /* VMS Operating System*/  MC68000 1*/ /* 68000 version */ #define VAX 1 /* VAX Version */ /*#define PDP11 1*/ /* Ptf("Usage: dump [-shhhhhh] file\n"); exit(); } i = 1; filaddr= 0; System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ ctor buffer */ int sector; /* Sector number */ long filaddr; 8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operatingstem*/ #define VMS 1 /* VMS Operating System*/ DP-11 Version*/ /*#define CPM 1*/ /* CP/M Operating System*/ /*#define UNIX 1*/ /* UNIX Operating S /* Zero file address */ if(*argv[1] == '-') { decode(argv[1],&filaddr); /* File address */ int offset; /* Sector Offset */ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ ystem*/ #define VMS 1 /* VMS Operating System*/ /* Get hex file addr */ i=2; } if((fd=openb(argv[i],READ)) < 0) /* Try to open file register i,j,k,l,m; /* Temps. */ int fd; /* File dSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ /* * Kludge hex dump routine for 68K */ #include #include #include "machine.h" #include 3) /* Only 1 file, please! */ { prinSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/ > main(argc,argv) int argc; char **argv; { char buffer[128]; /* Ser = filaddr >> 7; /* Zero sector count */ filaddr &= ~15; /* Round request /* Bump up file address*/ offset += 16; /* and offset */ } )&0xff, (buffer[i*16+j+1]&0xff)); #endif j++; } */ /* ret = decode(string,&address); printf("%04x %02x (%06lx): ",sector,offset,filaddr); for(j=0; j<16; j++) /* 16 bytes / line */ /* ------------------------------ */ /* down */ lseek(fd,filaddr,0); /* Do the seek */ m = (128 - (filaddr & 127)); sector++; /* Increment sector count*/ m = 128; /* printf(" *"); for(j=0; j<16; j++) /* Now ASCII */ */ /* */ /* Where: */ { #if VAX printf(" %02x%02x",(buffer[i*16+j+1])&0xff, */ /* Routine "decode" is called to process the relocation base argumen /* # bytes in sector */ while((l=read(fd,buffer,m)) > 0) /* Until EOF */ { # bytes to read next */ for(j=0; j<128; j++) buffer[j] = 0; } print{ k = buffer[i*16+j] & 0x7f; if ((k < ' ') || (k == 0x7f)) k= '.'; */ /* string -> argument string (usually argv[1]) (buffer[i*16+j]&0xff)); #endif #if PDP11 printf(" %02x%02x",(buffer[i*16+j+1])&0xff, t */ /* from the command line. */ /* l = (l + 15) / 16; /* Number of lines */ offset = filaddr & 127; /* Startinf("\n*** E O F ***\n"); } /****************************************************************************/ /* printf("%c",k); } printf("*\n"); filaddr += 16; */ /* &address -> long word to receive converted value */ /* (buffer[i*16+j])&0xff); #endif #if MC68000 printf(" %02x%02x",(buffer[i*16+j] */ /* Calling sequence: */ /* g Offset */ for(i=0; i= 'A' && c <= 'F') /* Hex */ a = (a << 4) + c - 'A'+ 1 /* Zero out accumulator */ /* */ wONG a; /* Temp return value */ REG BYTE c; /* Temp c */ } /****************************/  */ /****************************************************************************/ WORD decode(string,addr) 0; /* Un-ASCIIfy */ else /* Bad character */ hile(*string) /* Until no more chars */ { /* haracter */ /* */ if(*string++ != ' */ } /****************************/  /* */ /* return(FAILURE); /* So long, sucker!! */ string++; /* Increm */ c = toupper(*string) & 0177; /* Pick up next char */ if (c >= '0' &&-' || *string++ != 's')/* Check for valid switch */ return(FAILURE); /* quit if NFG  */ } /****************************/  */ REG BYTE *string; /* -> Command argument */ LONG *addr; ent pointer */ } /* */ *addr = a; /****************************/ #include /* standard I/O lis,expression,files); * * Where: * * options Is a pointer to a string of options * line buffer */ GLOBAL BYTE line1[129]; /* Temp line buffer */ GLOBAL BYTE first allows the following options: * * OPTION FUNCTION * ------ -------- * -v Print only lines not matcht = FALSE; /* Just count the lines */ GLOBAL BYTE __num = FALSE; /* Print line #'s brary */ #include /* CP/M portability defines */ #include expression Is a pointer to the search pattern * files Is an array of pointers to filenames * **= TRUE; /* used on the list option */ GLOBAL UWORD numfound = 0; /* number of linesing the pattern * -c Print only a count of the lines * -n Print with line numbers * -s Write */ GLOBAL BYTE __sector = FALSE; /* Display the sector */ GLOBAL BYTE __list = FALSE; /**************************************************************************** * * C R U N T I M E G R E P /* char type definitions */ /****************************/ ***************************************************************************/ /* found */ /****************************/ out the sector number in which the pattern was found * -l Write out a list of the files in which the pattern was fo /* Display only a file list */ GLOBAL BYTE __nocase = FALSE; /* Distinguish between cases*/ GLR O U T I N E * ------------------------------------------- * Copyright 1983 by Digital Research Inc. All /* GLOBAL VARIABLES */ /****************************/ /* INCLUDE FILES */ /* FUNCTIONS */ /****************************/ FIund * -y Do not distinguish between upper & lower case * * Calling Sequence: * * grep(optionOBAL FILE *fstream; /* file stream ptr */ GLOBAL BYTE line[129]; /* rights reserved. * * The routine "grep" searches for an ascii character pattern in * a series of files. "Grep" ***************************/ GLOBAL BYTE __match = TRUE; /* Print Matching lines only*/ GLOBAL BYTE __counLE *fopenb(); /* returns a ptr to a file */ /* if(argc < 3) goto usage; /* check for valid args */ expression = argv[2]; /* -> */ } /****************************/ /* array of files */ { /* */ BYTE *expression; /* -> expression */ BYTE **files; /* return(grep(options,expression,files)); /* Call the real function */ } /* ***************************/ /* MAIN */ main(argc,argv) Pattern */ files = &argv[3]; /* -> file list */ } /* */ options = "-ny"; /* Set up option REG BYTE *p; /* temp pointer */ REG UWORD patt_cnt; /* pa -> files */ /* */ if(argc < */ /****************************/ grep(options,expressi /* Entry point */ WORD argc; /* = # args /****************************/ else { /* No options */ if(*argv[1] == '-') /* Options specified? */ { ttern counter */ REG UWORD char_cnt; /* character count */ REG UWORD lin2) /* Must have at least 2 */ { /* on,files) /* */ REG BYTE *options; /* option list */ BYTE **argv; /* -> args */ { */ expression = argv[1]; /* Expression */ files = &argv[2]; /* */ options = argv[1]; /* Yes, use them */ e_cnt; /* line count */ REG UWORD i; /* counter */ usage: printf("Usage: find [-options] pattern files\n"); exit(); /* */ REG BYTE *expression; /* pattern to search for */ BYTE *files[]; /****************************/ BYTE *options; /* Option pointer */ /* file list */ } /****************************/ */ UWORD length; /* length of pattern */ BYTE found; */ case 'l' : __list = TRUE; /* list the files */ break; /* */ case 'c' : __count = TRUE; /* print a count of l if(__count) /* count option has priority*/ { /* ov */ } /****************************/ while(*options) st option has priority */ { /* over these..... */ __cou /* set if pattern is found */ /* */ break; /* */ case 'y' : __nocase= TRUE; /* no case distinctioines */ break; /* */ case 'n' : __num er these..... */ __num = FALSE; /* */ /* if found ........ */ { /* */ nt = FALSE; /* */ __num = FALSE; /* /* */ if(*options != '-') /* Len */ /*break;*/ /* */ } = TRUE; /* number the lines */ break; /* */ __sector = FALSE; /* */ } /* switch(*++options) /* */ { /* */ __sector = FALSE; /* */ } gal option list? */ { /* */ fprintf(std /* */ } /* */ case 's' : __sector= TRUE; /* print sector number */ break; /* */ else /* */ if(__num) */ case 'v' : __match = FALSE; /* print non-matching lines */ /* */ else /* */ err,"FIND--Illegal option list: %s\n",options); /* */ exit(-1); /* Just quit /****************************/ if(__list) /* li /* num option has priority */ __sector = FALSE; /* over the sector option */ ist && !__count) /* if these options are not */ { /* ON then print the */ if((fstream = fopenb(*files,"r")) != NULL)/*try to open the file */ { anslate? */ line[i] = toupper(line1[i]);/* */ else /* */ } /* */ xpression; /* */ for(i=0;i<129;i++) /* Zap out the buffer if(__nocase) /* if no case destinction */ { /* file- */ printf("\nFILE: %s\n",*files); /* name before each search */ printf("----\n"); /* */ char_cnt = 0; /* initialize char count */ /* Don't translate */ line[i] = line1[i]; /* Just copy } /* */ length = strlen(expression); /* cos */ line[i]=line1[i]=0; /* */ fgets(line1,129,fstre */ p = expression; /* */ while /* */ } /* */ line_cnt = 0; /* initialize line # count */ numfound = 0; /* in */ /****************************/ i = 0; unt the characters in */ /* the pattern to match */ while(*files)am); /* read a line */ /****************************/ (*p) /* change expression to */ { /* while(!feof(fstream)) /* go until end of file */ { /* itialize # found */ first = TRUE; /* initialize for list */ if(!__l /* */ while(line[i]) /* scan until a NULL */ /* search all the files */ { /* for(i = 0;line1[i];i++) /* */ if(__nocase) /* Tr */ *p = toupper(*p); /* upper case letters */ p++; */ found = FALSE; patt_cnt = 0; /* */ p = e { /* */ char_cnt++; /* bu */ line_cnt++; /* bump the line count */ prtline(found,char_c /* */ p = expression; /* reset the pattern ptr */ /* number of lines searched */ BYTE *files[]; /* current file found = TRUE; /* set a flag */ p = expression; /* */ } /* */ } mp the char count */ if(line[i] == *p) /* check pattern */ { nt,line_cnt,files);/*then print routine */ } /* */ patt_cnt = 0; /* start the count over */ } /* */ { /****************************/ if((__match && found) || */ patt_cnt = 0; /* */ /****************************/ /* PRINT ROUTINE */ prt /* */ p++; /* look for next char if(__count) /* is count option ON ? */ printf("\n%s: %d",*files,numfound);/ */ i++; /* check next character */ } /* have we a line ? */ (!__match && !found)) /* */ } /* */ } /* line(found,char_cnt,line_cnt,files) /****************************/ BYTE found; /* */ patt_cnt++; /* we found a character */ if(patt_cnt =*print a count of # fnd */ } /* */ fclose(fs /* */ line[i-1] = NULL; /* mask out extra LF { /* */ numfound++; /* */ else /* */ { does line contain pattern*/ UWORD char_cnt; /* number of chars searched */ UWORD line_cnt; = length) /* Have we found the end ? */ { /* */ tream); /* Close the file */ files++; /* go to next file count the # lines found */ if(__count) return; /* nothing to do */ if( */ } /****************************/  { /* */ printf("%5d: ",line_cnt); */ /* */ /****************************************************************************/ #include #include /****************************************************************************/ /* */ /* The /* */ printf("\n%d",char_cnt/128);/* divide count bsymbol table, and trailing zeros in the */ /* data segment are deleted. */ /* */ /* Invokation: */ if(first) /* FIRST pattern found ? */ printf("\n% */ } /****************************/ ts(line1,stdout); /* just print the line */ } /* following code defines the organization of a "long" variable on */ /* either the VAX (11) or 68000. This allows us to use "gey 128 */ return; /* */ } */ /* */ /* A>reloc -bhhhhhh in.68k out.68k */ /* */ /* Where: */ /* hhhhhs",*files); /* print the filename */ first = FALSE; /* turn off flag */ /****************************************************************************/ /* */ /* R e l o c P r o g */ } /****************************/ tw" on the */ /* separate parts of the long and to recombine them for 32-bit */ /* arithmetic operations. */ / /* */ if(__num) /* do we print a line # ? */ h Is the desired new base address (TPA + 100) in hex */ /* in.68k Is the input file */ /* out.68k Is the output file return; /* and return.. */ } /* r a m */ /* ------------------------- */ /* */ /* This program is used to relocate an Alcyon fo* */ /****************************************************************************/ #include "machine.h" #ifdefTREL 6 /* External relative symbol */ #define INSABS 7 /* 1st word of instruction */ /***************************. Any */ /* references to external symbols or relative references are illegal. */ /* */ /********************** */ /* 1). Get relocation base */ /* 2). Open input and output files */ /* 3). Determine data area (ne */ WORD hiword; /* High word first on 68K */ WORD loword; /* */ }; /****************************/ f CPM /* Only defined with CP/M */ EXTERN BYTE _start; /* Start of program */ #endif /* */ /*** UNIX #include #endif #ifdef VAX /****************************/ struct { /* low word first on VAX */*/ /****************************************************************************/ /* */ /* G l o b a l D ******************************************************/ /* */ #define DABS 0 /* Data absolute */ #define Dw) size */ /* */ /* Any errors here are fatal, and cause program termination. */ /* */ /**#endif #ifdef UNIX /****************************/ #define fopenb fopen /* Not in UNIX library */ #endif /***************************/ #include "cout.h" /* Output header area */ /****************************/ /******* WORD loword; /* */ WORD hiword; /* */ }; /****************************/ #endif #ifdef PDP11 a t a */ /* */ /****************************************************************************/ /* RELOC 1 /* Data segment relative */ #define TRELOC 2 /* Text segment relative */ #define BRELOC 3 /* BSS segme**************************************************************************/ VOID main(argc,argv) /**********************************************/ /****************************************************************************/ /* **********************************************************************/ /* */ /* M a i n P r o c e d u r e /****************************/ struct { /* low word first on PDP11 */ WORD loword; /* */ WORD hiword; /* */ BYTE *ifname=0; /* -> Input filename */ BYTE *ofname=0; /* -> Output filename */ LONG base=0; /* New nt relative */ #define EXTVAL 4 /* External variable */ #define LUPPER 5 /* Upper word of long */ #define EX********/ DEFAULT argc; /* Int var from RTL startup */ BYTE **argv; /* -> Arg strings */ { /****************/ /* Relocation bit definitions */ /* */ /* Note that this program is intended only for load module files */ /* --------------------------- */ /* */ /* Here we get things started: */ /* */ }; /****************************/ #endif #ifdef MC68000 /****************************/ struct { /* relocation base */ FILE *fopenb(); /* File open procedure */ LONG ftell(); /* File offset procedure */ #ifde************/ REG LONG i,l; /* Temps */ REG FILE *ifp,*ofp,*rfp; /* File pointers */ /* */ if(arenb(ofname,"w")) == NULL) /* Try to create output */ { /* */ printf("Cannot create %s\n",ifname); /* Complai*/ if((base & 1) != 0) /* In range? */ { /* no */ printf("Illegal base address=%lx\n", /* print ata */ fseek(ifp,l,0); /* Seek to data start */ /* */ i = couthd.ch_dsize; /* Fetch data size *rgv[2]; /* -> Input file name */ ofname = argv[3]; /* -> Output file name */ } else /* Default form */ { /* */ printf("Read error on %s\n",ifname); /* No, complain */ exit(-1); /* and quit */gc != 4 && argc != 3) /* Gotta have right format */ usage(); /* Print out nasty message */ /*********************n */ exit(-1); /* & quit */ } /****************************/ /****************************************/ base); /* message */ exit(-1); /* And quit */ } /****************************/ /* / l = ftell(ifp); /* l <= new data end addr */ /* */ while (i > 0) /* Until all data examined */ { */ { /* */ #ifdef CPM /* On CP/M, */ base = &_start; /* Use start of reloc itself*/ #else /**** } /****************************/ /* */ if(couthd.ch_magic != MAGIC) /* Valid file? */ { /* *******/ if(argc == 4) /* "-bxxxx" form */ { /****************************/ if(decode(argv[1], &base) == FAIL*************************************/ /* */ /* Now read the file header and compute the new data segment size ...*/ if((ifp=fopenb(ifname,"r")) == NULL) /* Try to open input */ { /* */ printf("Cannot open %s\n",ifname); /* */ if(getw(ifp) != 0) /* This data word = 0? */ l = ftell(ifp); /* No, record seek address */ ************************/ base = 0x500; /* 500H is default */ #endif /* */ ifname = argv[1]; /* -> In */ printf("File format error: %s\n", /* Print nasty message */ ifname); /* */ exit(-1); /* QuitURE) /* Convert to binary */ { /* */ printf("Illegal option: %s\n", /* Print offending option */ */ /* */ /****************************************************************************/ /* */ i = /* Complain */ exit(-1); /* & quit */ } /****************************/ /* */ if((ofp=fop i -= 2; /* Down count */ } /****************************/ /**************************************************put filename */ ofname = argv[2]; /* -> Output filename */ } /****************************/ /* */ } /****************************/ /* */ l = couthd.ch_tsize + sizeof couthd; /* Seek address for dargv[1]); /* */ usage(); /* Print reminder messages */ } /****************************/ ifname = a fread(&couthd,1,(sizeof couthd), /* Do the read */ ifp); /* */ if(i != (sizeof couthd)) /* Did it work?? **************************/ /* */ /* Open the file a second time, and perform the proper seeks to align */ /* on[-bhhhhhh] input output\n"); printf(" where: hhhhhh is new base address\n"); printf(" (TPA+100 is defaul-------------------- */ /* */ /* Routine "usage" is used to print out an error message when the */ /* YTE *string; /* -> Command argument */ LONG *addr; /* = return value */ { /****************************/ G)(sizeof couthd),0); /* Seek to text beginning */ fseek(rfp,(LONG)(sizeof couthd) + /* Seek to */ couthd.ch_ts */ /* */ /* ret = decode(string,&address); */ /* */ /* Where: */ /* ste copy of the open file to the beginning of the text segment, and */ /* the other copy to the beginning of the relocation infort base address)\n"); printf(" input is relocatable file\n"); printf(" output is absolute file\n")program is invoked in an improper manner. */ /* */ /* Calling Sequence: */ /* */ /* REG LONG a; /* Temp return value */ REG BYTE c; /* Temp character */ /* */ if(*string++ != '-' |ize+couthd.ch_dsize + /* relocation */ couthd.ch_ssize, 0); /* info*/ /****************************/ring -> argument string (usually argv[1]) */ /* &address -> long word to receive converted value */ /* mation */ /* */ /****************************************************************************/ /* ; exit(-1); } /****************************************************************************/ /* */ /* D e usage(); */ /* */ /* No return is made, "exit()" is called to go back to the O/S. */ /* | *string++ != 'b')/* Check for valid switch */ return(FAILURE); /* quit if NFG */ /* */ a = 0; /* reloc(ifp,rfp,ofp,l); /* Do relocation */ } /****************************/ /**********************************/ /* ret = 0 if successful conversion */ /* = -1 if anything amiss */ /* */ /*************** */ if((rfp=fopenb(ifname,"r")) == NULL) /* Try to open again */ { /* */ printf("Cannot re-open %s\n",ifnac o d e F u n c t i o n */ /* ------------------------------ */ /* */ /* Routine "decode" is cal*/ /****************************************************************************/ VOID usage() { printf("Usage: reloc Zero out accumulator */ /* */ while(*string) /* Until no more chars */ { /* */ c = *s*******************************************/ /* */ /* U s a g e F u n c t i o n */ /* -------*************************************************************/ WORD decode(string,addr) /* */ /* */ REG Bme); /* Print nasty message */ exit(-1); /* and quit */ } /****************************/ fseek(ifp,(LONled to process the relocation base argument */ /* from the command line. */ /* */ /* Calling sequence: tring & 0177; /* Pick up next char */ if (c >= '0' && c <= '9') /* Digit */ a = (a << 4) + c - '0'; /* Un-ASREG FILE *ofp; /* -> Output file */ LONG length; /* = # bytes in the file */ { /*************************** */ /* ifp Is the input stream pointer (positioned at text) */ /* rfp Is a stream pointer positioned at relocation bits size + j; /* New bss size */ x.ch_ssize = 0; /* No symbols */ x.ch_stksize = 0; /* No stack */ x.ch_en/****************************************************************************/ /* */ /* R e l o c F u n c */ /* */ /* Prepare and write the new file header in structure "x". */ /* */ /***************CIIfy */ else if (c >= 'A' && c <= 'F') /* Hex */ a = (a << 4) + c - 'A'+ 10; /* Un-ASCIIfy */ else */ struct hdr x; /* Duplicate header */ REG LONG bytes; /* File offset */ LONG j; /* Temp for long reloca */ /* ofp Is a stream pointer for the output file */ /* length Is the total length of the output file */ /* try = base; /* New base address */ x.ch_rlbflg = -1; /* No relocation bits */ /****************************t i o n */ /* --------------------------- */ /* */ /* Function "reloc" is called to perform the********************************** */ /* */ x.ch_magic = MAGIC; /* Magic word */ x.ch_tsize = coutif (c >= 'a' && c <= 'f') /* Lower case hex */ a = (a << 4) + c - 'a'+ 10; /* Un-ASCII it */ else /* Bad chation */ REG WORD r; /* Relocation word */ REG WORD k; /* Temp data word */ WORD longf; /* Long relocation f */ /****************************************************************************/ VOID reloc(ifp,rfp,ofp,length) // if(fwrite(&x,1,sizeof x,ofp) != /* Do the write */ sizeof x) /* */ { /* Here if failed */ relocation operation and */ /* write the output file simultaneously. */ /* */ /* Calling Sequence: hd.ch_tsize; /* Text size */ j = sizeof couthd + couthd.ch_tsize + /* Compute number of bytes */ couthd.ch_dsize racter */ return(FAILURE); /* So long, sucker!! */ string++; /* Increment pointer */ } /* */ lag */ WORD z; /* Temp for error codes */ LONG bias; /* Relocation bias */ /* */ bias = bas* */ /* */ REG FILE *ifp; /* -> Text information */ REG FILE *rfp; /* -> Relocation info */ printf("Write error on %s\n",ofname); /* print message */ exit(-1); /* Quit */ } /*********************** */ /* */ /* reloc(ifp,rfp,ofp,length); */ /* */ /* Where: */ /* - length; /* moved from data to bss */ x.ch_dsize = couthd.ch_dsize - j; /* New data size */ x.ch_bsize = couthd.ch_b *addr = a; /* Store result */ return(SUCCESS); /* Return all ok */ } /****************************/ e - couthd.ch_entry; /* Compute relocation bias */ /* */ /************************************************* *****/ /****************************************************************************/ /* */ /* Here begins the case DABS: /* If not relocatable, */ case INSABS: /* don't */ break; /****************************g */ } /****************************/ else /* Not a long */ { /* */ j.loword = k; /* Pongf; /* Increment byte count */ /* */ } /* End while loop */ } /* End reloc procedure */*******/ k = getw(ifp); /* get next text/data word */ r = getw(rfp); /* get next relocation word */ /*********UNIX RTL!! */ if((z=putw(j.loword,ofp)) != j.loword) /* Check for write error */ { /* */ printf("Write actual file relocation procedure. Read a word */ /* from the relocation bits and from the file together. If long, */ default: /* Any others illegal */ badrel(r,bytes); /* Print message */ } /**************************ut in low order word */ j.hiword = 0; /* Make top part 0 */ longf = 0; /* Clear flag */ } /** /****************************/ VOID badrel(r,offset) /* Print bad reloc message */ /* */ WORD r; *******************/ if ((r & ~7) != 0) /* Check for validity */ badrel(r,bytes); /* Not valid, quit */ / error on %s ",ofname); /* Had one, */ printf("Offset = %lx data= %x err =%x\n", /* */ bytes,j.loword,z); / /* read another word from each. Perform indicated relocation. */ /* */ /************************************/ if(longf == 0 && j.hiword !=0) /* 16-bit overflow? */ { /* */ printf("16-bit overflow at %ld\n", /* **************************/ switch (r) /* Now do indicated reloc */ { /* */ case TRELOC: /* If relocat/* Relocation bits */ LONG offset; /* File offset */ { /****************************/ printf("Illegal relo* */ if(r == LUPPER) /* Doing a long? */ { /* */ j.hiword = k; /* Yes, get another word *//* Print out message */ exit(-1); /* & quit */ } /****************************/ #else /* Just outpu******************************************/ /* */ bytes = 0; /* No bytes written yet ... */ length -= sizeof(Print out message */ bytes); /* with offset */ exit(-1); /* */ } /********************able, */ case DRELOC: /* relocate */ case BRELOC: /* */ j += bias; /* Add in bias */ c = %x at %lx\n", /* Print error message */ r,offset); /* */ exit(-1); /* quit */ } /*********** j.loword = getw(ifp); /* From both */ r = getw(rfp); /* streams */ longf = 2; /* Set flat and pray... */ putw(j.loword,ofp); /* Output low word */ #endif /****************************/ bytes += 2 + lcouthd); /* Just program, please... */ while (bytes < length) /* until we are done */ { /*****************************/ if(longf != 0) /* Long? */ putw(j.hiword,ofp); /* yes, output high */ #ifndef UNIX /* A bug in *****************/ 8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operating{0}; #define MAGIC 0x601a /* bra .+26 instruction*/  System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating016 = $600E*/ long ch_tsize; /*text size*/ long ch_dsize; /*data size*/ long ch_bsi****************/  System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating{0}; #define MAGIC 0x601a /* bra .+26 instruction*/ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatingze; /*bss size*/ long ch_ssize; /*symbol table size*/ long ch_stksize; /*stack size*/****************/ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating{0}; #define MAGIC 0x601a /* bra .+26 instruction*/ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating long ch_entry; /*entry point*/ short ch_rlbflg; /*relocation bits suppressed flag*/ } couthd/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6****************/ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating={0}; #define MAGIC 0x601a /* bra .+26 instruction*/ 8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operating#define HDSIZE (sizeof couthd) /**.o file header size*/ struct hdr { short ch_magic; /*c.out magic number 060System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating$2  macro.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 macro.s era $1x.1 era $1x.2 $2as68 -l -u -f $2lo68 -f $1 -s -r -u_nofloat -u_nowildc -o cp68.rel 0$1s.o main.o lex.o macro.o cexpr.o util.o 0$2klib 0$2clib era *.o user 12 $1 -s 0$1 macro.s era macro.s $2cp68 -i 0$1 main.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 m2!make $1 $2 pip machine.h=machine.68k $2cp68 -i 0$1 cexpr.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 cexpr2 ain.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 main.s era main.s $2cp68 -i 0$1 util.c $1x.i $2c068 $1x.i $1x.1 $1x.!make $1 $2 .s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 cexpr.s era cexpr.s $2cp68 -i 0$1 lex.c $1x.i $2c068 $1x.i $1x.1 $1x.2 2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 util.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 util.s era util.s link $1 !make $1 $2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 lex.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 lex.s era lex.s $2cp68 -i 0$1$2lo68 -r -s -f $1 -o c068.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2libF.a 0$2clib era *.o user 13!make $1 $2 e.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 icode.s era icode.s $2cp68 -i 0$1 init.c $1x.i $2c068 $1x.i $1x.1 $1x. era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 decl.s era decl.s $2cp68 -i 0$1 disk.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 putexpr.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 putexpr.s era put $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 main.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 main.s era main.s $2c2lo68 -r -s -f $1 -o c068.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2libF.a 0$2clib era *.o user 13!make $1 $2 2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 init.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 init.s era init.s $2cp68 -.3 -f era $1x.i $2c168 $1x.1 $1x.2 disk.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 disk.s era disk.s $2cp68 -i 0$1expr.s $2cp68 -i 0$1 stmt.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 stmt.s era $1x.1 era $1p68 -i 0$1 misc.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 misc.s era $1x.1 era $1x.2 $2as68 -2lo68 -r -s -f $1 -o c068.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2libF.a 0$2clib era *.o user 13!make $1 $2 i 0$1 interf.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 interf.s era $1x.1 era $1x.2 $2as68 -l expr.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 expr.s era $1x.1 era $1x.2 $2as68 -l -u -f $1x.2 $2as68 -l -u -f $1 -s 0$1 stmt.s era stmt.s $2cp68 -i 0$1 symt.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $l -u -f $1 -s 0$1 misc.s era misc.s $2cp68 -i 0$1 node.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $ -u -f $1 -s 0$1 interf.s era interf.s $2cp68 -i 0$1 lex.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 -s 0$1 expr.s era expr.s $2cp68 -i 0$1 icode.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 icod2c168 $1x.1 $1x.2 symt.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 symt.s era symt.s $2cp68 -i 0$1 tabl.c $1x.i $2c0pip machine.h=machine.68k $2cp68 -i 0$1 decl.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 decl.s1x.2 node.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 node.s era node.s $2cp68 -i 0$1 putexpr.c $1x.i $2c068 $1x.i $ $1x.2 lex.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 lex.s era lex.s $2cp68 -i 0$1 main.c $1x.i $2c068 $1x.i $1x.168 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 tabl.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 tabl.s eraSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatingpip machine.h=machine.68k $2cp68 -i 0$1 canon.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 canonSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating tabl.s $2cp68 -i 0$1 tree.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 tree.s era $1x.1 era $/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 canon.s era canon.s $2cp68 -i 0$1 codegen.c $1x.i $2c068 $1x.i $1x.1 $1/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating1x.2 $2as68 -l -u -f $1 -s 0$1 tree.s era tree.s link $1 $2 8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M OperatingSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatingx.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 codegen.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 codegen.s era codegen.s 8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operatingx.2 $2as68 -l -u -f $1 -s 0$1 tree.s era tree.s link $1 $2  System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating $2cp68 -i 0$1 cskels.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 cskels.s era $1x.1 era $1x.2 System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatingx.2 $2as68 -l -u -f $1 -s 0$1 tree.s era tree.s link $1 $2 System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating $2as68 -l -u -f $1 -s 0$1 cskels.s era cskels.s $2cp68 -i 0$1 interf.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.ix.2 $2as68 -l -u -f $1 -s 0$1 util.s era util.s link $1 $2 68 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 tabl.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 tabl.s era2lo68 -s -r -f $1 -o c168.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2clib era *.o user 0!make $1 $2  -f era $1x.i $2c168 $1x.1 $1x.2 putexpr.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 putexpr.s era putexpr.s $2cp68 $2c168 $1x.1 $1x.2 interf.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 interf.s era interf.s $2cp68 -i 0$1 main.c $1 tabl.s $2cp68 -i 0$1 util.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 util.s era $1x.1 era $ -i 0$1 smatch.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 smatch.s era $1x.1 era $1x.2 $2as68 x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 main.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 ma1x.2 $2as68 -l -u -f $1 -s 0$1 util.s era util.s link $1 $2 -l -u -f $1 -s 0$1 smatch.s era smatch.s $2cp68 -i 0$1 sucomp.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $2lo68 -s -r -f $1 -o c168.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2clib era *.o user 0!make $1 $2 in.s era main.s $2cp68 -i 0$1 optab.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $2c168 $1x.1 $1x.2 optab.s era $x.2 $2as68 -l -u -f $1 -s 0$1 util.s era util.s link $1 $2 $1x.1 $1x.2 sucomp.s era $1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 sucomp.s era sucomp.s $2cp68 -i 0$1 tabl.c $1x.i $2c02lo68 -s -r -f $1 -o c168.rel -u_nofloat -u_nowildc 0$1s.o *.o 0$2klib 0$2clib era *.o user 0!make $1 $2 1x.1 era $1x.2 $2as68 -l -u -f $1 -s 0$1 optab.s era optab.s $2cp68 -i 0$1 putexpr.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating#define NRCHECKS 7 /* Number of random i/o checks */ WORD pass_types[NUMPASS][2] = /* Num records, Len records for each pass *System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating/* streamio.c: tests Unix Stream I/O functions */ /* Modifications: */ /* 1/84 verbose error msgs for 68K whf */ /* 9/83 iSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating/* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6/ { 100, MAXRECMAX, 16, 32, 10, 20, 10000, 20 }; /*************************/ /* O.S. dependent values */ #definSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatingmproved error msgs whf */ /* Runs by itself: just compile and exec. It will tell you which functions it is testing. */ /* * Use this file to determine what kind of machine you want the * Alcyon stuff to run on .... */ #define MC68000 1 /* 6System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operatinge BYTE_LEVEL 128 /* Size of sectors: PCDOS = 1, CP/M = 128 */ /*********************************************/ /* PossibleSystem*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating#include #include /************************************************/ /* Possible file size parameter8000 version */ /*#define VAX 1*/ /* VAX Version */ /*#define PDP11 1*/ /* PDP-11 Version*/ #define CPM 1 /* CP/M Operating System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operating kinds of File I/O for each case: */ /* Ascii/Binary I/O indicator */ #define AB_ASCII 1 #define AB_BINARY 0 /* Record/Cs for each pass: */ #define NUMPASS 4 /* Number of passes for this test */ #define MAXRECMAX 128 /* Maximum record size */ System*/ /*#define UNIX 1*/ /* UNIX Operating System*/ /*#define VMS 1*/ /* VMS Operating System*/  CPM 1 /* CP/M Operatinghar/Line indicator */ #define RCL_RECORD 1 #define RCL_CHAR 2 #define RCL_LINE 3 #define NUMCASE 6 /* Number of cases per printf("pass %d:\t\t",pass); printf("number records = %ld, record length = %d\n",rmax,rlen); } BYTE *make_fn(pass,cse,prS; ++ii ) { prt_pass(ii); for( jj=0; jj 1 ) { eof_slack) tfsp = fopen(filename,"a"); else tfsp = fopenb(filename,"a"); /* watch: reclen % 128 != 0 */ if( NULLPTR == tfsp ) re randomly absolute */ for( ii=0; ii */ /* or if reclabel==NULL */put by printf * fmt -> a string specifying how arg1-n are to be printed. * *************************************************> chi ) cc = clo; /* ripple range check */ *record++ = cc++; } *record++ = NULL; /* insure NULL terminated */ *rec chi &= 0xFF; /* defeat sign extension */ if( reclabel != NULLPTR ) { for( ; *reclabel && rlen>0; --rlen )/* copy ap up a set of error messages */ { }  /****************************************************************/ makerec(record,rlen,recnum,reclabel,clo,chi) BYTE **************************/ WORD eprintf(fmt,args) BYTE *fmt, *args; { _doprt(stdout,"\nERROR:\t"); return(_doord++ = NULL; /* insure NULL terminated */ } /***************************************************************************/label to record */ *record++ = *reclabel++; sprintf(lbuf,"#%5.5D#",recnum); /* cvt recnum to ascii */ for( cp=record; /* place to make the record */ UWORD rlen; /* size of the record to make */ LONG recnum; /* record number tprt(stdout,fmt,&args)); } WORD ep_init() /* initiate eprintf for new set of error messages */ { } WORD ep_fini() /* w /***************************************************************************/ /**********************************************$2cp68 -i 0$1 test.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 test.s era $1x.1 era $1x.2 $2as68 -lbuf; *cp && rlen>0; --rlen)/* copy recnum into rec */ *record++ = *cp++; } cc = recnum % (1 + chi - clo); /* choose no make */ BYTE *reclabel; /* label to prepend to each record */ WORD clo, chi; /* range of char values for ripple parap up a set of error messages */ { } ************************** * * Calling sequence: * nchrs = eprintf(fmt,arg1,arg2,...argn); * Where: * nchrs = # chars outf $1 -s 0$1 -l -u test.s era test.s $2lo68 -f $1 -u_nofloat -r -o test.68k 0$1s.o test.o 0$2clib era test.o test.68k era teew place to start */ cc += clo; /* DRC bug... */ for( ; rlen>0; --rlen ) /* generate ripple pattern */ { if( cc ttern */ { BYTE lbuf[10]; /* place to hold chars */ BYTE *cp; /* char ptr */ WORD cc; /* char temp */ clo &= 0xFF;ap up a set of error messages */ { } st.68k $2cp68 test2.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 test2.s era $1x.1 era $1x.2 $2a$1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 stest.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u st2c168 $1x.1 $1x.2 fptest.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u fptest.s era fptest.s $2lo68 -f $1 -r -o fptest.6test.o $2cp68 -i 0$1 execgoob.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 execgoob.s era $1x.1 era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u test4.s era test4.s $2lo68 -f $1 -u_nofloat -r -o test4.68k 0$1s.o test4.o 0$2ci $2c168 $1x.1 $1x.2 prtftest.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u prtftest.s era prtftest.s $2lo68 -f $1 -u_nos68 -f $1 -s 0$1 -l -u test2.s era test2.s $2lo68 -f $1 -u_nofloat -r -o test2.68k 0$1s.o test2.o 0$2clib era test2.o test2.est.s era stest.s $2lo68 -f $1 -u_nofloat -u_nowildc -r -o stest.68k 0$1s.o stest.o 0$2clib era stest.o stest.68k era stest8k 0$1s.o fptest.o 0$2clib 0$2libf.a era fptest.o fptest.68k era fptest.68k $2cp68 fptest.c $1x.i $2c068 $1x.i $1x.1 $1x.ra $1x.2 $2as68 -f $1 -s 0$1 -l -u execgoob.s era execgoob.s $2lo68 -f $1 -u_nofloat -u_nowildc -r -o execgoob.68k 0$1s.o exelib era test4.o test4.68k era test4.68k $2cp68 test5.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.float -u_nowildc -r -o prtftest.68k 0$1s.o prtftest.o 0$2clib era prtftest.o prtftest.68k era prtftest.68k $2cp68 -i 0$1 e68k era test2.68k $2cp68 test3.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 test3.s era $1x.1 er.68k $2cp68 -i 0$1 stjptst.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 stjptst.s era $1x.1 era $2 $1x.3 -e era $1x.i $2c168 $1x.1 $1x.2 fptest.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u fptest.s era fptest.s $2lcgoob.o 0$2clib era execgoob.o exectest era exectest.68k era execgoob.68k $2cp68 -i 0$1 streamio.c $1x.i $2c068 $1x.i $12 test5.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u test5.s era test5.s $2lo68 -f $1 -u_nofloat -r -o test5.68k 0$1s.o xectest.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 exectest.s era $1x.1 era $1x.2 $2as68 -f $1 -sa $1x.2 $2as68 -f $1 -s 0$1 -l -u test3.s era test3.s $2lo68 -f $1 -u_nofloat -r -o test3.68k 0$1s.o test3.o 0$2clib era tes1x.2 $2as68 -f $1 -s 0$1 -l -u stjptst.s era stjptst.s $2lo68 -f $1 -u_nofloat -u_nowildc -r -o stjptst.68k 0$1s.o stjptst.o o68 -f $1 -r -o fptest.68k 0$1s.o fptest.o 0$2clib 0$2libe.a era fptest.o fptest.68k era fptest.68k $2cp68 -i 0$1 stest.c x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 streamio.s era $1x.1 era $1x.2 $2as68 -f $1 -s 0$1 -l -u streamio.s era streatest5.o 0$2clib era test5.o test5.68k era test5.68k $2cp68 fptest.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 -f era $1x.i $ 0$1 -l -u exectest.s era exectest.s $2lo68 -f $1 -u_nofloat -u_nowildc -r -o exectest.68k 0$1s.o exectest.o 0$2clib era exect3.o test3.68k era test3.68k $2cp68 test4.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.i $2c168 $1x.1 $1x.2 test4.s e0$2clib era stjptst.o stjptst.68k era stjptst.68k $2cp68 -i 0$1 prtftest.c $1x.i $2c068 $1x.i $1x.1 $1x.2 $1x.3 era $1x.mio.s $2lo68 -f $1 -u_nofloat -u_nowildc -r -o streamio.68k 0$1s.o streamio.o 0$2clib era streamio.o streamio.68k era streamP p0; /* beginning new declarations as of V3.3 */ struct butblk { struct butblk *nextbutblk; int butno; short args; nt initi = 1; int initk[3] = { 1, 2, 3}; int initl[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; char *initx[] = { "therror(0x0b); if(sizeof(TYPSTR) != 8) error(0x0c); if(sizeof zz[2] != sizeof(TYPSTR)) error(0x0d); if(sizeof(typeary[4])!=3 struct ss { char m1; short int m2; long m3; } s1; char *swt1(); char *swt2(); char *swt3(); char *swt4(); strucpe { char ch; STRUCTYPE ptr; }; int err; /* end new declarations for 3.4 */ main() { register i; int j; regisio.68k era g:*.* ;user 1!make $1 $2  int actno; struct node *ptr; }; struct node { struct node *nfptr; struct butblk *bptr; long actno; /* non-uniat's all, folks...", 0, }; struct { int s_x; long s_l; } inits[] = { 0, 0L, 1, 1L, 2, 2L, }; char initc[20] = "2)error(0x0e); if(sizeof(int[3])!=6)error(0x0f); if(sizeof(typeary*)!=4)error(0x10); i = 0; if(i) error(0x1); if(i!=0) et { char *ptrwd; }; struct { unsigned f1:1; unsigned f2:2; unsigned f3:3; } flags; typedef char CHAR; typedef int ter char *p; int ai2[2][3]; char n; register unsigned u1,u2; unsigned int u3; register long lr1; int *pi; char **aque structure names */ }; struct other { int a; int *b; }; int x[5]; struct other sound[] = { { 1, x+1}, }; /* enthis is it"; char initd[] = "this might be it"; char inite[][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; char *initcc = {"this is alsrror(0x2); if(++i != 1) error(0x3); i<<= 2; if(i != 4) error(0x4); i += i+2; if(i != 10) error(0x5); i *= 3*2; if( INT; typedef struct { CHAR tsc; INT tsi; CHAR *tsp; } TYPSTR; TYPSTR zz[3]; typedef int typeary[4]; char c; st; putstring("Beginning 68000 C Compiler Test"); for(j=0; j<5; j++) { c = 'A'; for(i=0; i<62; i++) { putchar(c); d new declarations as of v3.3 */ /* begin new declarations for 3.4 */ typedef struct xxx34 STRASSIGN; struct xxx34 { longo it"}; int ccinit = '\1\2'; char ac[4]; int ai[4]; int *pai[] = {&ai[1],&ai[3]}; long al[4]; typedef char *CHARP; CHARi != 60) error(0x6); i /= 3; if(i != 20) error(0x7); i = (i+12)|7; if(i != 39) error(0x8); i = i - i/2 - 2; if(i != atic char str[] ="string 1"; static long l; long l1,l2,l3; long addlargs(); long addpargs(); long ldiv(); long ldivr; i c++; } putchar('\n'); } if(12345 != 12345) error(0x0); j = i; if(i != j) error(0x0a); if(sizeof flags != 2) /* Compiler Test Program Part I */ #include #define TVAL 5 #define FVAL 0 union un1{ long ul1; int ui1; } uu; l; char ch; STRASSIGN *pxxx34; }; struct ss *f(); char largear[20000]; typedef struct atype *STRUCTYPE; struct aty18) error(0x9); i = i % 6; if( i != 0 ) error(0x10); j = 0; if(j) error(0x11); if(j!=0) error(0x12); if(++j != 1) er if( strlen("x.s") + 1 != strlen("x.ss") ) error(0x317); if( j = 1, i = 0 ) error(0x318); if( (j=0,i=1) != 1 ) error(0x319) targs(1,1000,-18363); i = addargs(2,7,65); if(i != 74) error(0x30); l1 = 10000L; l2 = 4273; lr1 = 0xabcd5678; if((); if(i != 500) error(0x50); i = 0155555; i ^= i; if(i) error(0x51); s1.m1 = 64; s1.m2 = 1250; s1.m3 = 9264; p =f(l != 20) error(0x27); l = (l+12)|7; if(l != 39) error(0x28); l = l - l/2 - 2; if(l != 18) error(0x29); l = l % 6; 3) error(0x43); for(i=0; i<=3; i++) { if(ai[i] != i) error(0x44); ac[i] = ai[i]; } lab45: for(i=0; i<4; i++) { iror(0x13); j<<= 2; if(j != 4) error(0x14); j += j+2; if(j != 10) error(0x15); j *= 3*2; if(j != 60) error(0x16); j; l1 = -3347; l2 = 7913; if((l=addpargs((char *)&l1,&l2)) != l1+l2) error(0x34); l = 60; if((l *= 9) != 540) error(0x3l=addlargs(l1,l2)) != l1+l2) error(0x310); if( addlargs(l1+l2,l1) != addlargs(l1,l1+l2) ) error(0x311); p = "x.c"; p[strle &s1; if(s1.m1!=64 || p->m1!=64) error(0x52); if(s1.m2!=1250 || p->m2!=1250) error(0x53); if(s1.m3==9264 && p->m3==9264) ;if( l != 0 ) error(0x290); l = 12345L; if(l != 12345) error(0x291); l = 0xfffffffel; if(l != -2) error(0x292); l = 400f(ac[i] != i) error(0x45); al[i] = i*30000; } for(i=0; i<4; i++) { if(al[i] != i*30000) error(0x46); if(al[i]/30000 /= 3; if(j != 20) error(0x17); j = (j+12)|7; if(j != 39) error(0x18); j = j - j/2 - 2; if(j != 18) error(0x19); j =6); c = 0377; if(c != 0377) error(0x36); i = c; if(i != -1) error(0x37); j = c; if(j != -1) error(0x38); l = c; n(p)-1] = 's'; if( eqstr(p,"x.s") == 0 ) error(0x312); if(lr1 != 0xabcd5678) error(0x313); if(eqstr("azx953#;k9","azx953#; else error(0x54); j = -50; if(j >= 0) error(0x55); if(j < 0) ; else error(0x56); l = 7777; if(l < 7776) error(0x57); 00; if( (l/= 10) != 4000 || l != 4000 ) error(0x293); l = 40000; l /= 10; if( l != 4000 ) error(0x294); l = 40000; l /= 10L; != i) error(0x47); if(al[i]/100 != i*300) error(0x48); } n = 3; if(str[n] != 'i') error(0x48a); if(ai[n] != n) error 1229; j <<= 1; if(j != 2458) error(0x20f); l = 0; if(l) error(0x21); if(l!=0) error(0x22); if(++l != 1) error(0x23)if(l != -1) error(0x39); c = 0x1f; if((c&0x10) == 0) error(0x39a); if((c&0x40)) error(0x39b); ai[0] = 0; ai[1] = 1; k9") == 0) error(0x314); if(eqstr("try me","try m") != 0) error(0x315); if( strlen("x.s") == strlen("x.ss") ) error(0x316); if(l > 7776) ; else error(0x58); p = &ac[0]; p0 = &ac[3]; if(p >= p0) error(0x59); if(p <= p0) ; else error(0x60); i if( l != 4000 ) error(0x295); l = 40000; if( (l % 400) != 0) error(0x296); l = 40000; if( (l % 400L) != 0 ) error(0x297); (0x48b); if(ac[n] != 3 || al[n] != n*30000) error(0x48c); i = 0; for(j=0; j<100; j++) i += 5; if(j != 100) error(0x49; l<<= 2; if(l != 4) error(0x24); l += l+2; if(l != 10) error(0x25); l = l*6; if(l != 60) error(0x26); l /= 3; iai[2] = 2; ai[3] = 3; if(ai[0] != 0) error(0x40); if(ai[1] != 1) error(0x41); if(ai[2] != 2) error(0x42); if(ai[3] != f(p == 0) error(0x61); if(p0 != 0) ; else error(0x62); for(i=0; i<2; i++) { for(j=0; j<3; j++) { ai2[i][j] = (i+2)*(j224a); if(p->f2 != 1) error(0x224b); if(p->f3 != 3) error(0x224c); p0 = &flags; p0->f1 = 1; p0->f2 = 2; p0->f3 = 7; 99) error(0x216); i = 1; #if TVAL i++; # if FVAL error(0x217); # else i++; #endif #else i++; #endif; if(i !=i) error(0x255); i = n + 500; if(i != 499) error(0x256); if((n-4) != -5) error(0x257); i = 1, i = 2, i = 3; if( i != 3 ) u1 = 0100000; u2 = 0010000; if(u1 < u2) error(0x209); uu.ui1 = 1; if(uu.ul1 != 0x10000) error(0x210); #if TVAL i = 11; if(u2 != 3) error(0x230); u2 = 12000; u3 = 5; u1 = u2*u3; if(u1 != 60000) error(0x231); l1 = 5; u1 = 60000; l+3); } } for(i=0; i<2; i++) { for(j=0; j<3; j++) { if(ai2[i][j] != (i+2)*(j+3)) error(0x63); } } if(swt1()! if(p0->f1 != 1) error(0x224d); if(p0->f2 != 2) error(0x224e); if(p0->f3 != 7) error(0x224f); i = 13; checklv((long)(i+ 3) error(0x218); #undef FVAL #ifdef FVAL error(0x219); #endif #if ((TVAL*6)/3) != 3*2+8/2 error(0x220); #endif flags error(0x258); if( (i = 3, j = 2, i = 1) != 1 || i != 1 || j != 2 ) error(0x259); if( i++ != 1 || i-- != 2 || i != 1 ) error0; #else i = 5; #endif if(i != 10) error(0x211); i = 0; #ifndef FVAL i++; #endif #ifdef XXYYZZ i++; #endif #if 1 = u1*l1; if(l1 != 300000L) error(0x232); //int<->char n = 100; i = (n<<3) + 2; j = (n<<4) - 2; if(i != 802) error=1) error(0x64); if(swt2()) error(0x65); if(swt3()!= -1) error(0x65); if(swt4()!=4) error(0x66); l1 = 20000; l2 = 105)); checkregs(); chkinits(); if((sizeof(char *)+3) != 7) error(0x225); j = -12; chklext((long)j); u1 = 60000; u2 .f1=1; flags.f2=0; flags.f3=5; if(flags.f1 != 1) error(0x221); if(flags.f2) error(0x222); if(flags.f3 != 5) error(0x22(0x260); if( (i++ + j++) != 3 || i != 2 || j != 3 )error(0x261); ckcast(); if(p=5);else error(0x301); if(p -= 5) errFVAL|TVAL-5 i++; #endif if(i) error(0x212); if(sizeof(uu) != sizeof(uu.ul1)) error(0x213); zz[0].tsi = 14; zz[1].ts(0x240); if(j != 1598) error(0x241); i = 50; if(n <= i) error(0x242); j = 100; if(n != j) error(0x243); pi = &j; i; l3 = ldiv(l1,l2); if(l3 != 2000) error(0x201); if(ldivr) error(0x202); l2 = 9999; if(ldiv(l1,l2) != 2) error(0x203);= u1/20; if(u2 != 3000) error(0x226); l1 = 55123L; l1 = u1 + l1; if(l1 != 115123L) error(0x227); l1 -= u1; if(l1 != 3); flags.f3 += 2; if(flags.f3 != 7) error(0x224); p = &flags; p->f1 = 0; p->f2 = 1; p->f3 = 3; if(p->f1) error(0xor(0x302); if(!(++p&1)) error(0x303); p0 = 0; if(p = p0) error(0x304); p0 = &p0; if(p = p0--);else error(0x305); p =c = 0177; zz[2].tsp = 199999; if(zz[0].tsi != 14) error(0x214); if(zz[1].tsc != 0177) error(0x215); if(zz[2].tsp != 1999f(*pi != n) error(0x243a); if(*pi != j) error(0x243b); l = 100; if(n != l) error(0x244); n = 255; if(n>l || n>=j || n> if(ldivr != 2) error(0x204); l2 = -123; if(ldiv(l1,l2) != -162) error(0x207); if(ldivr != -74) error(0x208); lab209: 55123L) error(0x228); al[3] = 99999L; u1 = 3; if(al[u1] != 99999L) error(0x229); l1 = 180000L; u1 = 60000; u2 = l1/u &ai[2]->ptrwd + zz[3].tsp; //this used to give error msg on conversion p = &zz[2]; zz[2].tsi = 2; if(p->tsi&1) error(0x30 i = 5; l1 <<= i; l2 = l2 << i; if (l1 != l2) error(0xe04); if ((p3 = f()) != -1) error(0xe05); p4.m1 = 'p'; p3 000L; printf("0x111111 = %lx\n",v33l); } v34() /* new for version 3.4 */ { char *q; register struct ss *p3; struct error(0xff13); } if( eqstr(initc,"this is it") == 0 ) error(0xff14); if( eqstr(initd,"this might be it") == 0 ) error(0xfring 1=%s Z=%c\n", n,n,i,i,l,str,c); l = 0xa9b7c3; i = 0xf1e4; printf("0xa9b7c3=%lx 0XF1E4=%x\n",l,i); v33(); v34() if(ss[1].isiv1 != 2) error(0xff2); if(eqstr(ss[2].csiv1,"ghi")==0) error(0xff3); if(ss[0].lsiv1 != 0x3ff41) error(0xff4); 6); if(!p->tsi&2) error(0x307); p = 070; if(p&1) error(0x308); if((p&040)==0) error(0x309); j = 105; p = 105; if(p= &p5; *p3 = p4; if (p3->m1 != p4.m1) error(0xe10); p4.m1 = 'E'; p5 = p4; if (p5.m1 != p4.m1) error(0xe11); p3->m1 = ss p4, p5; char ar34[sizeof (long)]; float f1, f2; int i; double d1, d2; STRUCTYPE sop1; STRASSIGN *ptr, s; if f15); if( eqstr(initcc,"this is also it") == 0 ) error(0xff16); if( sizeof inite != 9 ) error(0xff17); if( sizeof initc !=; if (!err) putstring("Far Freaking Out!!!!"); else putstring("Tough Luck!!!"); } v33() /* new for version 3.3 * if(ss[1].lsiv1 != 143L) error(0xff5); if(ss[2].lsiv1 != 0) error(0xff6); if(ss[1].lsiv1&0200) ; else error(0xff7); if( i != j) error(0x320); ai[3] = 0x8765; j = 1; i = *pai[j]; if(i != 0x8765) error(0x321); p = 1000; a = &p0; *a=pi=p+ '7'; p4 = *p3; if (p4.m1 != p3->m1) error(0xe12); } struct ss * f() { return(-1); } chklext(al9) long al9; { (q&((sizeof(struct ss))-1)); goto a; error(0xe00); a: if (sizeof(largear) < 0) error(0xe01); l = 0x0100000; i = 1 20 ) error(0xff18); if( sizeof initd != 17 ) error(0xff19); if( ccinit != 258 ) error(0xff20); } checkregs() { reg/ { long v33l; struct butblk bb1; struct node bb2; bb2.bptr = &bb1; bb1.butno = 23; printf("%d = %d ",bb1.butno,bniti != 1 ) error(0xff8); for( i = 0; i < 3; i++ ) { if( initk[i] != i+1 ) error(0xff9); if( initl[i][0] != (i*4)+1 ) er1; if(p0 != 1001) error(0x322); chkptrs(); //check pointer code tembedasg(); //complex ptr assignment macrotest(); le if(al9 != -12L) error(0x375); } chkinits() { static long liv1 =999999; static struct xx { char *csiv1; int ; l <<= i; if (l != 0x0200000) error(0xe02); l = 0x010; l <<= i; if (l != 0x020) error(0xe03); l1 = 1L; l2 = 1L; ister rx1,rx2,rx3,rx4,rx5,rx6,rx7,rx8,rx9; rx1 = 1; rx2 = 2; rx5 = 5; rx8 = 8; rx9 = 9; if(rx1+rx2 != 3) error(0x3b2.bptr->butno); x[1] = 99; printf("%d = %d ",x[1],*sound[0].b); v33l = 0x1L + 0x10L + 0x100L + 0x1000L + 0x10000L + 0x100ror(0xff10); if( inits[i].s_x != i ) error(0xff11); if( inits[i].s_l != i ) error(0xff12); if( inite[i][0] != (i*3)+1 )xtest(); cmplxptrpp(); n = 100; i = 1024; l = 31234; c = 'Z'; printf("100=%d $64=%x 1024=%d 02000=%o 31234l=%ld stisiv1; long lsiv1; } ss[] ={"abc",1,0x3ff41,"def",2,143L,"ghi",3}; register int i; if(liv1 != 999999L) error(0xff1); 60); if(rx2+rx5 != 7) error(0x361); if(rx9-rx5 != 4) error(0x362); if(rx8+rx9 != 17) error(0x363); } checklv(alv) lon{ error(0x150); case 60: break; case 10: if(i!=10)error(0x151); continue; case 0: if(i)error(0x1 continue; case 0: if(i!=0)error(0x142); continue; case 1: if(i!=1)error(0x143); continue; careak; } if(j!=4)error(0x176); return((long) j); } ckcast() { struct results { struct results *length; int c++) return(0); } if(*p2) return(0); return(1); } long addlargs(a1,a2) long a1,a2; { register i,j,k; regisx162); continue; case 2: if(j!=2)error(0x163); continue; case 1: if(j!=1)error(0x164); continue; deg alv; { if(alv != 18L) error(0x364e); } error(pc) { printf("error %x\n",pc); err++; } putstring(pc) char *pc; 57); continue; case 20: if(i!=20)error(0x152); continue; case 40: if(i!=40)error(0x153); continue; se 4: if(i!=4)error(0x144); continue; case 2: if(i!=2)error(0x145); continue; case 3: if(i!=3)eutoff; } cst19[3], *arypt; arypt = cst19; arypt->length = 6; (char *)arypt += (long)arypt->length; if(arypt != &cst1ter long lr2; i = 1000; lr2 = 0xbbbbbbbb; targs(1,i,-18363); if(lr2 != 0xbbbbbbbb) error(0xfe02); return(a1+a2); fault: if(j!=16)error(0x165); continue; } break; } if(j!=32)error(0x166); return(-1); } char *swt4() { register char *p; p = pc; while(*p) putchar(*p++); putchar('\n'); } targs(a1,a2,a3) char a1; { if(a1!=1 case 50: if(i!=50)error(0x154); continue; default: if(i!=30)error(0x155); continue; } break; } ifrror(0x146); continue; default: if(i!=5)error(0x147); continue; case 6: break; } break; }9[0]+1) error(0xfe03); } chkptrs() { register char *pc; register int *pi; register char **pl; char *apc; int *a} long addpargs(a1,a2) register long *a1,*a2; { return(*a1+*a2); } // simple switch stmt test char *swt1() { re{ register int i, j; for( i = 0; i < 10; i++ ) { switch(j = 1< &str[4] ) error(0x410); if( pc >= &str[5] ) error(0x441)00000; if(nn&0x8000) ; else error(0x461); lll = 0x3f001; if(lll&0x40) error(0x462); if(lll&0xf00) error(0x463); if(lllsi = -5; p = zz; if((++p)->tsi != 1987) error(0x450); if(p->tsc != -1) error(0x451); if((p+1)->tsi != -5) error(0x452); error(0xfd10); #endif #if ((5*6)/3) == 3*2+8/2 #else error(0xfd11); #endif #define z1(a,b) (a+b) #define z2(a,b) (a*b) c != &str[4] ) error(0x435); ai[0] = 14; ai[1] = 33; ai[2] = 194; ai[3] = 555; if(**pai != 33) error(0x404); pi = 0xfd1); #endif #ifndef x error(0xfd2); #endif #ifdef x #else error(0xfd3); #endif #undef x #ifdef x error(0xfd4); ; if( pc < &str[4] ) error(0x442); if( pc <= &str[3] ) error(0x443); if( pc == &str[3] ) error(0x444); if( pc != &str[4]&0x8000) ; else error(0x464); if(lll&0x10000) ; else error(0x465); if((lll&0xf0000) != 0x30000) error(0x466); } //embede p++; if(p->tsc != 13) error(0x453); if(--p->tsi != -6) error(0x454); if((--p)->tsi != 1987) error(0x454a); p0 = &zz[1] #if z1(z2(2,3),z2(z1(1,1),3)) != 12 error(0xfd12); #endif #if 1>2 error(0xfd13); #endif #if 2<1 error(0xfd14); #endi&ai[1]; if(*++pi != 194) error(0x405); pi--; if(*pi+5 != 38) error(0x406); ai[0] = 0; if(*--pi) error(0x407); api = #endif #ifndef x #else error(0xfd5); #endif #define y(a,b,c) c+a+b #if y(1,2,3)!=6 error(0xfd6); #endif #include "te ) error(0x445); apc = &str[4]; if(*apc++ != 'n') error(0x420); if(*apc-- != 'g') error(0x421); if(*--apc != 'i') errod ptr assignment test tembedasg() { register char *p,mcc; register int t; char ctype[4]; char c9; mcc = 2; cty; if(*p0 != -1) error(0x455); if(p0->tsi != 1987) error(0x456); if((p0->tsi&1)==0 || (p0->tsi&2)==0) error(0x457); if((lf #if 1>=2 error(0xfd15); #endif #if 2-1!=1 error(0xfd16); #endif #if 1-2!= -1 error(0xfd17); #endif #if -1 >= 0 pi + 3; if(*api++ != 555) error(0x408); pl = pai; if(*++pl != &ai[3]) error(0x409); ckstrpt(); } ckstrpt() { st.h" #ifndef test2x error(0xfd7); #endif #define z(a,b,c) \ #define a b+c z(zxx,1,2) #if zxx!=3 error(0xfd8); #endifr(0x422); if(*(apc+4) != '1') error(0x423); apc = &str[4]; if( apc > &str[4] ) error(0x430); if( apc >= &str[5] ) errope[2] = 'Z'; p = ctype; t = ctype[*p++=mcc]; if(t != 'Z') error(0xfe04); if(ctype[0] != 2) error(0xfe05); c9 = 2; c9ong)p&1) error(0x458); p = zz; nn = 2; p += nn; if(p->tsc != 13) error(0x459); if(nn&2) ; else error(0x460); nn = 01error(0xfd18); #endif #if 1 ? 0 : 1 error(0xfd19); #endif #if 0 ? 1 : 0 error(0xfd20); #endif #if (010<<1) != 020 erregister TYPSTR *p; register int nn; register long lll; zz[1].tsi = 1987; zz[1].tsc = 255; zz[2].tsc = 13; zz[2].t #if zxx==3 #else error(0xfd9); #endif /* #define zzz */ #ifdef zzz error(0xfd9); #endif #if ((5*6)/3) != 3*2+8/2 r(0x431); if( apc < &str[4] ) error(0x432); if( apc <= &str[3] ) error(0x433); if( apc == &str[3] ) error(0x434); if( ap |= 1; if(c9 != 3) error(0xfe08); c9 &= 1; if(c9 != 1) error(0xfe09); } macrotest() { #define x 1 #if x!=1 error(ror(0xfd21); #endif #if (020>>1) != 010 error(0xfd22); #endif #if (0xc^0xa) != 0x6 error(0xfd23); #endif #if (0xc&0xa)2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, }; long l0[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1 b1 : 4; unsigned b2 : 12; } low; struct hbits { unsigned b1 : 12; unsigned b2 : 4; } ; struct hbits high; /* be ... v. 4.0 addition */ { long autol, autol1; int i; i = 3; autol = autol1 = 100; autol1 *= i; autol =autol * i; 102) error(0xfe19); } strlen(p) char *p; { register int i; i = 0; while( *p++ ) i++; return(i); } ", "one", "two", "three", "four", "zzstring" }; struct { int a[2]; char b[2]; long c[2]; char *d[2]; } sa != 0x8 error(0xfd24); #endif #if (0xc|0xa) != 0xe error(0xfd25); #endif #if (~2) != -3 error(0xfd26); #endif #if (!0, 11, 12, 13, 14, 15, }; struct Proto { char P_id; int (*P_turnon)(); int (*P_rdmsg)(); int (*P_wrmsg)(); int (*Psure global decl ok... */ int err; int globali = -32768; unsigned globalu = 44000; char ca[10] = { 0, 1, 2, 3, 4, 5, 6, if (autol1 != autol) error(0x00); autol = autol1 = 100; autol1 /= i; autol =autol / i; if (autol1 != autol) error(0x002) error(0xfe19); } strlen(p) char *p; { register int i; i = 0; while( *p++ ) i++; return(i); }  = { 1, 2, 'a', 'b', 3, 4, "abc", "def" }; int gturnon() {} int gturnoff() {} int grdmsg() {} int grddata() {} i1) != 0 error(0xfd26); #endif } // check int extension to long lextest() { int iii; long lll; iii = -10; ll_rddata)(); int (*P_wrdata)(); int (*P_turnoff)(); }; extern int gturnon(), gturnoff(); extern int grdmsg(), grddata();7, 8, 9}; long lconst1 = 5 * 9; long lconst2 = 5L * 9; long lconst3 = 5 * 9L; long lconst4 = 5L * 9L; long lconst5 = (lon1); autol = autol1 = 100; autol1 += i; autol =autol + i; if (autol1 != autol) error(0x02); autol = autol1 = 100; 02) error(0xfe19); } strlen(p) char *p; { register int i; i = 0; while( *p++ ) i++; return(i); } nt gwrmsg() {} int gwrdata() {} main() { l_vs_i(); rl_vs_i(); l_vs_ri(); rl_vs_ri(); v40(); v41(); v42(); vl = iii*2; if(lll != -20L) error(0xfe07); } cmplxptrpp() { int v; int dd[4]; int *pd[4]; register int i; for( extern int gwrmsg(), gwrdata(); struct Proto Ptbl[] = { 'g', gturnon, grdmsg, gwrmsg, grddata, gwrdata, gturnoff, '\0' g)(5 * 9); char c0[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, }; int i0[] = { 0, 1, autol1 -= i; autol =autol - i; if (autol1 != autol) error(0x03); autol = autol1 = 100; autol1 %= i; autol =autol % /* Compiler Test Program Part II - version 4.0 plus */ #define DOHIST '\!' #define QUOTED 128 struct lbits { unsigned42_a(); if (!err) printf("Far Freaking Out\n"); else printf("Tough Luck.....\n"); } l_vs_i() /* longs versus intsv=0; v<4; v++) { pd[v] = &dd[v]; dd[v] = v+100; } v = 1; i = *pd[v]++; if(i != 101) error(0xfe18); if(*pd[v] != }; struct nroff { int a; char *p; char *ctag[5]; char *zz; }; struct nroff star = { 1, "pstring...", "zeroi; if (autol1 != autol) error(0x04); autol = autol1 = 100; autol1 <<= i; autol =autol << i; if (autol1 != autol) errr int i; i = 2; autol = autol1 = 100; autol1 *= i; autol =autol * i; if (autol1 != autol) error(0x20); autol = agl << i; if (regl1 != regl) error(0x15); regl = regl1 = 100; regl1 >>= i; regl = regl >> i; if (regl1 != regl) error*= i; regl = regl * i; if (regl1 != regl) error(0x30); regl = regl1 = 100; regl1 /= i; regl = regl / i; if (regl1 i = 3; regl = regl1 = 100; regl1 *= i; regl = regl * i; if (regl1 != regl) error(0x10); regl = regl1 = 100; regl i; autol =autol >> i; if (autol1 != autol) error(0x26); autol = autol1 = 100; autol1 &= i; autol =autol & i; if (or(0x05); autol = autol1 = 100; autol1 >>= i; autol =autol >> i; if (autol1 != autol) error(0x06); autol = autol1 utol1 = 100; autol1 /= i; autol =autol / i; if (autol1 != autol) error(0x21); autol = autol1 = 100; autol1 += i; a(0x16); regl = regl1 = 100; regl1 &= i; regl = regl & i; if (regl1 != regl) error(0x17); regl = regl1 = 100; reg!= regl) error(0x31); regl = regl1 = 100; regl1 += i; regl = regl + i; if (regl1 != regl) error(0x32); regl = regl1 /= i; regl = regl / i; if (regl1 != regl) error(0x11); regl = regl1 = 100; regl1 += i; regl = regl + i; if (reglautol1 != autol) error(0x27); autol = autol1 = 100; autol1 |= i; autol =autol | i; if (autol1 != autol) error(0x28); = 100; autol1 &= i; autol =autol & i; if (autol1 != autol) error(0x07); autol = autol1 = 100; autol1 |= i; autol =utol =autol + i; if (autol1 != autol) error(0x22); autol = autol1 = 100; autol1 -= i; autol =autol - i; if (autol1 !l1 |= i; regl = regl | i; if (regl1 != regl) error(0x18); regl = regl1 = 100; regl1 ^= i; regl = regl ^ i; if (reg1 = 100; regl1 -= i; regl = regl - i; if (regl1 != regl) error(0x33); regl = regl1 = 100; regl1 %= i; regl = regl 1 != regl) error(0x12); regl = regl1 = 100; regl1 -= i; regl = regl - i; if (regl1 != regl) error(0x13); regl = re autol = autol1 = 100; autol1 ^= i; autol =autol ^ i; if (autol1 != autol) error(0x29); } rl_vs_ri() /* reg longs vautol | i; if (autol1 != autol) error(0x08); autol = autol1 = 100; autol1 ^= i; autol =autol ^ i; if (autol1 != auto= autol) error(0x23); autol = autol1 = 100; autol1 %= i; autol =autol % i; if (autol1 != autol) error(0x24); autoll1 != regl) error(0x19); } l_vs_ri() /* longs versus register ints... v. 4.0 addition */ { long autol, autol1; registe% i; if (regl1 != regl) error(0x34); regl = regl1 = 100; regl1 <<= i; regl = regl << i; if (regl1 != regl) error(0x3gl1 = 100; regl1 %= i; regl = regl % i; if (regl1 != regl) error(0x14); regl = regl1 = 100; regl1 <<= i; regl = reersus reg ints... v. 4.0 addition */ { register long regl, regl1; register int i; i = 3; regl = regl1 = 100; regl1 l) error(0x09); } rl_vs_i() /* register longs versus ints... v. 4.0 addition */ { register long regl, regl1; int i; = autol1 = 100; autol1 <<= i; autol =autol << i; if (autol1 != autol) error(0x25); autol = autol1 = 100; autol1 >>=5); regl = regl1 = 100; regl1 >>= i; regl = regl >> i; if (regl1 != regl) error(0x36); regl = regl1 = 100; regl1ay[2][3][4] != 4) error(0x53); if (lconst1 != 45) error(0x54); /* long constant initialization */ if (lconst2 != 45) error( ammended */ { char ch, *s, *t; ch = max(3,9); if(ch != '9') error(0x50); s = strings(s,t); if (strcmp(s,"s1s2") !== j++ && j++; if( j != 3 ) error(0x6b); if( i != 1 ) error(0x6c); j = 0; i = j++ && j++; if( j != 1 ) error(0x6d); ierror(0x41); l -= 0L; if (l != l1) error(0x42); l *= 0L; if (l != 0L) error(0x43); l1 %= 1L; if (l1 != 0L) error(0x45c); form = 3; 0 ? (form |= (1 << 0)) : (form &= ~(1 << 0)); if (form != 2) error(0x5d); for( i = 0; i < sizeof(ca); i &= i; regl = regl & i; if (regl1 != regl) error(0x37); regl = regl1 = 100; regl1 |= i; regl = regl | i; if (regl10x55); if (lconst3 != 45) error(0x56); if (lconst4 != 45) error(0x57); if (lconst5 != 45) error(0x58); m = 12; n = -1; 0) error(0x51); s = substitute(5); if (strcmp(s,"5,") != 0) error(0x52); saray2[0].y = 4L; saray2[0].xyzzy = 'p'; saray2[f( i != 0 ) error(0x6e); j = 1; i = --j || --j; if( j != -1 ) error(0x6f); if( i != 1 ) error(0x70); j = 1; i = j ? 4); /*SMC Bug - not properly extending i register on stack*/ i = 2; ca[i] = f(); if( ca[i] != f() ) error(0x45); } ++ ) ca[i] = i; i = 0; p = ca; if( ca[*p++]++ != 0 ) error(0x61); if( p != &ca[1] ) error(0x62); if( ca[0] != 1 ) e != regl) error(0x38); regl = regl1 = 100; regl1 ^= i; regl = regl ^ i; if (regl1 != regl) error(0x39); } v40() /* /* arrays involving long mult for indices */ al[2] = 33L; n = al[m + n * 10]; if (n != 33L) error(0x59); al[2L] = 310].x = 450L; saray1[2] = saray2[0]; } int v41_testvalue; v41() { register char *p; register int i; register int j;--j : --j; if( j != 0 ) error(0x71); if( i != 0 ) error(0x72); v41_testvalue = 128; if (v41_testvalue != ((long) 128)) f() { return(0); } struct xyzzytype { long x, y, z; char *xyz, xyzzy; } saray1[3], saray2[4]; #define max(x,y) (rror(0x63); if( ca[i+=1]++ != 1 ) error(0x64); if( i != 1 ) error(0x65); if( ca[1] != 2 ) error(0x66); if( ca[i+= *p++]+ 4.0 fixed and tested */ { long l, l1; register int i; /* bit assignments */ low.b1 = high.b2; high.b1 = low.b2; L; /* arrays involving long indices */ n = al[2]; if (n != 31L) error(0x5a); 1 ? 0 : 2; 1 ? (form = 0) : (form = 1) int form; long m, n; long al[10]; int aray[3][4][5]; aray[2][3][4] = 4; /* multi dimensional arrays */ if (ar error(0x73); if (v41_testvalue != ((int)(long) 128)) error(0x74); if (v41_testvalue != (int)((long) 128)) error(0x75); v4(x > y) ? 'x' : 'y') #define strings(s1,s2) "s1s2" #define substitute(x) "x," v40a() /* bug fixes and enhancements for v 4.0+ != 3 ) error(0x67); if( i != 3 ) error(0x68); if( p != &ca[2] ) error(0x69); if( ca[3] != 4 ) error(0x6a); j = 1; i l = l1 = 45L; /* non-code-generating simple expressions */ l *= 1L; if (l != l1) error(0x40); l += 0L; if (l != l1) ; if (form != 0) error(0x5b); form = 3; 0 ? (form = form | ( 1 << 0)) : (form = form & ~(1<<0)); if (form != 2) error(0x1_testvalue = 128 * 3; if (v41_testvalue != (int)((long) 128*3)) error(0x76); if ((long)p & 0x80000000); } struct qtes int c_line; char c_cc[8]; }; struct termio ttys; int ttysave; v42_a() { long l; bit1.x2 = 1; bit1.x3 = 0; o[6].c,"six")==0) error(0x89); if (eqstr(zippo[7].c,"seven")==0) error(0x8a); tmp = 'd'; index = tmp - 'a'; if (ca[ind error(ernum) int ernum; { printf("error %x\n",ernum); err++; } = 128 * 3; if (v41_testvalue != ((int)(long) 128*3)) error(0x80); case_val = 0200| 'P'; switch(case_val) { case (0200|'ong k; { return (1); } eqstr(ap1,ap2) char *ap1, *ap2; { register char *p1, *p2; p1 = ap1; p2 = ap2; while(*pt { int sar[10]; }; struct zip { int i; char c[6]; int j; } zippo[] = { 0, "zero", 00, 1, "one", 11, 2 bit2.bx2 = 1; bit2.bx3 = 0; if( bit1.x2 != bit2.bx2) error(0x90); if( bit1.x3 != bit2.bx3) error(0x91); if (ch_test(ex] != ca[tmp - 'a']) error(0x8b); if (sizeof(struct Proto) != 26) error(0x8c); if ((sizeof(struct Proto)*2) != sizeof(Ptb error(ernum) int ernum; { printf("error %x\n",ernum); err++; } P'): break; default: error(0x81); break; } if (sizeof(a.sar) != sizeof(aar)) error(0x82); index = 2; aar[index+1] = '1) { if(*p1++ != *p2++) return(0); } if(*p2) return(0); return(1); } ch_test() { return(DOHIST|QUOTED); , "two", 22, 3, "three", 33, 4, 'fo', "ur", 44, 5, "five", 55, 6, 'si', 'x', 0, 0, 0, 66, 7, 'se', 've) != (DOHIST|QUOTED)) error(0x92); l = 0x8000L; if (!(l & 0x8000)) error(0x93); if (iox(0, (('T'<<8)|1), &ttys) >= 0) l)) error(0x8d); tmp = 0x7000; switch(tmp & 0xf000) { default: case_val = tmp&0xf000; error(0x8e); printf("val == %xc'; if (aar[index+'\01'] != 'c') error(0x83); if (c0[3] != 3) error(0x84); if (i0[5] != 5) error(0x85); if (l0[12] != 12} error(ernum) int ernum; { printf("error %x\n",ernum); err++; } ', 'n\0', 77, 0 }; struct Abit { char x0; char x1:1; int x2:1; int x3:1; } bit1; struct Bbit { char bx1; ttysave = ttys.c_oflag; if (eqstr(star.ctag[3],"three")==0) error(0x94); if (sa.a[1] != 2) error(0x95); if (sa.b[1] \n",case_val); case 0x7000: break; } } struct termio { int c_iflag; int c_oflag; int c_cflag; int c_lflag;) error(0x86); if (eqstr(zippo[1].c,"one")==0) error(0x87); if (eqstr(zippo[4].c,"four")==0) error(0x88); if (eqstr(zipp error(ernum) int ernum; { printf("error %x\n",ernum); err++; }  int bx2:1; int bx3:1; } bit2; v42() { int case_val, index, tmp; int aar[10]; struct qtest a; v41_testvalue != 'b') error(0x96); if (sa.c[1] != 4) error(0x97); if (eqstr(sa.d[1],"def")==0) error(0x98); } iox(i,j,k) int i, j; l /* Compiler Test Program Part III - version 4.2 plus */ char *version = "%W% %G%"; int x1[5] = { 0, 1, 2, 3, 4, }; int x2[ck...\n"); else printf("Far Freaking Out...\n"); } error(ernum) int ernum; { printf("error %x\n",ernum); err++; any warnings on init... */ 0xf1e010, 0xf1e011, 0xf1e012, 0xf1e013, 0, }; struct btype { char *p1; int i; chdev; int fi_lock; int fi_spdev; char *fi_rlocks; }; char ca[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }/ }; long arl[5][3] = { 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff }; short ars int i; if ((i=f(3)) > f(1)) ; else error(0x6); if ((regi=f(3)) > f(1)) ; else error(0x7); } if (1) { short coun5] = { 0, 1, 2, 3, 4 }; int x3[5] = { 0, 1, 2, 3, }; unsigned u = -1; char arc[5][3] = { 0x1111, 0x1111, 0x1111, 0x1111} short mstype; typedef struct MODES { short imap; } MODER, *pMODER; static MODER amode; pMODER vmode; v42() { inar c; } B = { "This is a string.....", 35, 'p' }; int err; char string[] = "9876543210"; int fun1(), fun2(); s; int ica[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; char cb[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; char [2][2] = { 0|0100000, 1|0100000, 0xffff, 0x8000|0x040 }; struct Mstruct { int ar[3]; char c; } *mtab[] = { 0, 1, 2,t = 0; mstype = 33; } if (mstype != 33) error(0x8); ff[i=0] = 33; if (ff[0] != 33) error(0x9); if(!main) error(0x, 0x1111, 0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have warnings on init */ }; int ari[5][3] = { 0x1111, 0x1111t i; struct test { int a; long b; struct { char c; int d; }y; } x; if (A[0].b != 1) error(0x1); itruct { int sz; int (*func)(); } fun[2] = { 1, fun1, 2, fun2 }; int fglobal; int global1 = 4, global2 = 5; main() { cc[10] = { '01', '23', '45', '67', '89' }; struct A { int a; long b; } atype[] = { 0, 3, 1, 4, 2, 5 }; int th 'c' }; typedef int tdefa[(5)]; typedef int tdefb [10+(2)]; tdefa a; tdefb b; int ff[(5)]; struct atype { int a10); vmode = &amode; } f(val) int val; { return(val); } struct fi_index { long fi_flags; unsigned fi_count, 0x1111, 0x1111, 0x1111, 0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have 1 warning on init */ }; unsigned int aru[f (A[1].c != 2) error(0x2); if (A[2].a != 3) error(0x3); x.y.d = 3; x.a = 0; { if (!x.y.d) error(0x4); } if (x.a) v42(); test(); test2(); aray(); do_stass(); do_sizeof(); dbra_tst(); new_test(); if (err) printf("Tough Luree[3][3][3] = { 0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2 }; /*char ar_test[0xf0000];*/ aray() { re; long b; int c; } A[] = { { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 }, }; struct atype *mikeC[] = { /* better not have; char fi_groupid; char fi_nlinks; int fi_ownerid; long fi_fsize; long fi_findblk; int fi_5][3] = { 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have 1 warning on init * error(0x5); { char *s = &string; int i; i = *s - '0'; if (i != 9) error(0x5); } { register int regi; gister int n; register char c, *bp; register struct fi_index *fip; struct fi_index xxx; fip = &xxx; xxx.fi_fsize = pTDR; typedef struct { char sbVar[8]; TDR td; long valTy; } TYR, *pTYR; TYR vrgTySpc[] = { /* test of sa[0]._c4 = 'd'; sa[1]._c4 = '8'; sa[1] = sa[0]; if (sa[0]._c4 != sa[1]._c4) error(0x2a); } struct sz_struc { int izeof(xyzzy) != 8 ) error(0x3b); if ( sizeof(l) != 4 ) error(0x3c); if ( sizeof(*p) != 1 ) error(0x3d); if ( sizeof(*pi) != '7'; bp = &ar_test[0]; c = bp[0xa000L]; if (c != '7') error(0x2b); ar_test[0x10000] = 'T'; c = bp[0x10000]; if (c !=long l; char *p; int *pi; if ( sizeof(vrgTySpc) != (2 * sizeof(TYR)) ) error(0x30); if ( sizeof(s->za) != 20 ) error(03; n = 5000; if( n > (4096 - fip->fi_fsize) ) { n = 4096 - fip->fi_fsize; if (n != (4096 - fip->fi_fsize)) error(0 short element initialization */ {"$cBad", '\0', '\0', '\0', '\0', 0}, 0 }; struct one { struct two *p2; struct oza[10]; char zc; char zb[3]; struct xxx { char zd[5]; long ze[2]; }zf; } *s, t; int szaray[10]; typedef struc= 2 ) error(0x3e); if ( sizeof(szaray[4]) != 2 ) error(0x3f); if ( sizeof(struct one) != 8) error(0x40); if ( sizeof(nx) ! 'T') error(0x2c); */ } struct { int _a, _a1, _a2, _a3, _a4; long _b, _b1, _b2, _b3, _b4; char _c, _c2, _c3, _c4; }x31); if ( sizeof(s->zb) != 3 ) error(0x32); if ( sizeof(s->zf) != 14 ) error(0x33); if ( sizeof(s->zf.ze) != 8 ) error(0xx20); } else error(0x21); if (ca[3] != 3) error(0x22); if (ica[7] != 7) error(0x23); if (cb[5] != '5') error(0x2ne *p1; }; struct two { int atwo, btwo, ctwo, dtwo; }; struct one xyzzy[] = { 0, 0 }; char szof[10]; struct At TDS { char st; unsigned fConstant : 1; unsigned width : 7; unsigned bt : 4; unsigned tq1 = sizeof ny) error(0x41); if ( sizeof(ny) != 10) error(0x42); if ( sizeof(abcdef->a) != 3) error(0x43); if ( sizeof(abcdef st, *pt, st2, *pt2, sa[3]; do_stass() { pt = &st; pt2 = &st2; st._b4 = 3; st2._b4 = 9; st = st2; if (st._b4 != st2.34); if ( sizeof(szaray) != 20 ) error(0x35); if ( sizeof(t.za) != 20 ) error(0x36); if ( sizeof(s->za[4]) != 2 ) error(0x4); if (cc[8] != '8') error(0x25); if (atype[2].a != 2) error(0x26); if (atype[0].b != 3) error(0x27); if (three[0][0][2AAAA { char a[3]; int b[3]; long c[3]; double d[3]; char e[3][3]; int f[3][3]; long g[3][3]; double h[3][3]; c: 2; unsigned tq2 : 2; unsigned tq3 : 2; unsigned tq4 : 2; unsigned tq5 : 2; unsigned tq6 : 2; } TDR, *->b) != 6) error(0x44); if ( sizeof(abcdef->c) != 12) error(0x45); if ( sizeof(abcdef->d) != 12) error(0x46); if ( sizeof(_b4) error(0x28); pt->_b1 = 55; pt2->_b1 = 34; *pt = *pt2; if (pt->_b1 != pt2->_b1) error(0x29); st = *pt; *pt = st; 37); if ( sizeof(t.zc) != 1 ) error(0x38); if ( sizeof(p) != 4 ) error(0x39); if ( sizeof(pi) != 4 ) error(0x3a); if ( s] != 0) error(0x28); if (three[1][1][1] != 1) error(0x29); if (three[2][2][0] != 2) error(0x2a); /* ar_test[0xa000L] har i; int j; long k; float l; } *abcdef; do_sizeof() { char nx[sizeof szof]; char ny[sizeof (szof)]; int i; abcdef->e) != 9) error(0x47); if ( sizeof(abcdef->f) != 18) error(0x48); if ( sizeof(abcdef->g) != 36) error(0x49); if ( s (global2 != 5) error(0x5d); rc = 6; c = 8; ri = 2; i = 4; c /= ri; if (c != 4) error(0x5e); c /= i; if (c != 1) error0x54); mask = 1; l = 0xf; mask += (l&1); if (mask != 2) error(0x55); z = 1; (*fun[z].func)(); if (fglobal != 3513L-1); /* error 0x6e */ is_512L(0x6f,512L/1); /* error 0x6f */ } is_512L(enum,lval) int enum; long lval; { if (lv() { register struct saxer *p, *q; register short mask; int dp, z, *zp; long l, lo; register char rc; register int mnem = shifts[(opcode>>9)&3]; is_512L(0x64,512L); /* error 0x64 */ is_512L(0x65,(long)512); /* error 0x65 */ i = 51izeof(abcdef->h) != 36) error(0x4a); if ( sizeof(abcdef->i) != 1) error(0x4b); if ( sizeof(abcdef->j) != 2) error(0x4c); i(0x5f); rc /= 2; if (rc != 3) error(0x60); } casttest(i) int i; { if (i != 0x30) error(0x51); } fun1(l) long l;) error(0x56); typey = 0x71234; fun1(typey); /* error 0x57 */ z = 34; z &= 0; if (z) error(0x58); p = &john[0]; q al != 512L) error(enum); } static f2(a1,a2) char *a1, *a2; { if (a1 != a2) error(0x63); } int i_global; dbra_tri; char c; int i; struct xx xa[8/sizeof(struct xx)]; struct xx xd[8/4]; dp = 0x720; mask = ((dp&0xff)<<1) -1; i2; l = 512; is_512L(0x66,l); /* error 0x66 */ is_512L(0x67,(long)i); /* error 0x67 */ l = 500; i = 12; is_512L(0x68f ( sizeof(abcdef->k) != 4) error(0x4d); if ( sizeof(abcdef->l) != 4) error(0x4e); } typedef long ADRT; ADRT v { fglobal = 2; if (l != 0x71234) error(0x57); } fun2() { fglobal = 3; } char *shifts[4] = { "as", "ls", "rox", = &john[0]; p->u_incr = 2; p->i_incr = 2; p += p->u_incr; q += q->i_incr; if (p != q) error(0x59); if (sizeof(xa) !=st() { register long reg_l; register int localreg; int local; long local_l; local_l = i_global = local = localreg =f (mask != 0x3f) error(0x50); l = 0x7777ff30; casttest((int)(l&0xff)); /* error 0x51 */ lo = 0; l = STL - lo; if (l ,l+i); /* error 0x68 */ is_512L(0x69,512L*1); /* error 0x69 */ is_512L(0x6a,511L+1); /* error 0x6a */ is_512L(0x6b,1*5fp; int PutState() { vfp = 1; /* just needs to compile.... */ } struct saxer { struct saxer *ptr; unsign"ro" }; test2() { int i; long l; int y(); char *mnem; int opcode; l = 0xfe00; /* hex constant should be int v sizeof(xd)) error(0x5a); zp = &z; *zp = 34; *zp != 0; if (*zp != 34) error(0x5b); if (global1 != 4) error(0x5c); if reg_l = 1L; if(--i_global == -1) error(0x70); if(--local == -1) error(0x71); if(--localreg == -1) error(0x72); if(--loc!= 0x400L) error(0x52); l = 0xffffffff; if (!(l & 0x80000000)) error(0x53); l &= 0x80000000; if (l != 0x80000000) error(12L); /* error 0x6b */ is_512L(0x6c,1+511L); /* error 0x6c */ is_512L(0x6d,(long)(512*1));/* error 0x6d */ is_512L(0x6e,ed int u_incr; int i_incr; } john[4]; typedef long X; X typey; #define STL 0x400L struct xx { int a, b; }; testalue, which should go neg */ if (l > 0) error(0x61); l = 32768; if (l < 0) error(0x62); f2(fun2,fun2); /* error 0x63 */al_l == -1) error(0x73); if(--reg_l == -1) error(0x74); if(--i_global == -1) ; else error(0x75); if(--local == -1) ; elsgned increment to pointer */ cp = str; i = u = 3; *(cp+i) = 'c'; if (*(cp+u) != 'c') error(0x87); }  /* typedef and paren'd strangeness */ if(sizeof(tboolx) != sizeof(tbooly)) error(0x80); if(sizeof(tbooly) != 2) error(0x, 3, 4, 5, 6, 7, 8, }; int errors; main() { xtest(); ytest(); ztest(); dec_inc(); div_test(); "p2", }; struct xtype ff2 = { "p1", "zero", "one", "two", "three", "four", "five", "p2" }; struct xtype /* Post 4.2 compilers */ char *version = "%W% %G%"; struct xxx { int x; char m,n,o,p; }; struct zzz { e error(0x76); if(--localreg == -1) ; else error(0x77); if(--local_l == -1L) ; else error(0x78); if(--reg_l == -1L) ; elsened increment to pointer */ cp = str; i = u = 3; *(cp+i) = 'c'; if (*(cp+u) != 'c') error(0x87); } 81); tboolx[1] = 1; tbooly[1] = 1; cp = tboolx; if(*(cp+1) != 1) error(0x82); cp = tbooly; if(*(cp+1) != 1) error(0x83 s_u_test(); next_to_last_test(); last_test(); if(!errors) printf("Far Freaking Out\n"); else ff3 = { "p1", "zero", "one", "two", "three", "four", "five", }; struct xtype ff4 = { "p1", "zero", "one"int b; struct aaa { int f; char g, h, i, j; } bb[3]; int c; } A = { 1, 2, 'a', 'b' error(0x79); } typedef char TBOOL; TBOOL tboolx[2], tbooly[(2)]; struct xtype { char *p1; char *ar[20]; char *ned increment to pointer */ cp = str; i = u = 3; *(cp+i) = 'c'; if (*(cp+u) != 'c') error(0x87); } ); /* assignment as a subscript */ str[i=0] = 3; if(str[i] != 3) error(0x84); if(i != 0) error(0x85); /* structure point printf("Tough Luck\n"); } error(enum) int enum; { printf("error %x\n",enum); errors++; } char *xstr1 = ", "two", "three", "four", "five" }; struct xtype ff5 = { "p1", "zero", "one", "two", }; struct xtype ff6, 'c', 'd', 3, 'e', 'f', 'g', 'h' }; struct yyy { int a; struct xxx y[3]; int q; } B = { 1, p2; }; struct xtype newff = { "p1", "zero", "one", }; char *xfp = "abc"; struct xtype ff0 = { 0L, 1L, 2L,ned increment to pointer */ cp = str; i = u = 3; *(cp+i) = 'c'; if (*(cp+u) != 'c') error(0x87); } er array initializations */ newff.ar[1] = "xyz"; if(*xfp != 'a' || *(xfp+1) != 'b' || *(xfp+2) != 'c') error(0x86); /* unsi8999999988"; char *xstr2 = "8999999988"; char *xstr3 = "8999999988"; xtest() { register char *rcp, rc; char *cp, = { "p1", "zero", "one", "two" }; new_test() { char *cp; extern int err; char str[9]; int i; unsigned u; 2, 'a', 'b', 'c', 'd', 3, 'e', 'f', 'g', 'h' }; char ar[3][3] = { 'a', 'b', 'c', 'd', 'e' }; int x[2][2][2] = { 1, 2 3L, 4L, 5L, 6L, 7L, }; struct xtype ff1 = { "p1", "zero", "one", "two", "three", "four", "five", c; int i; long *laddr; int *iaddr; short *saddr; long addr; if(A.bb[1].i != 'g') error(0x1); 1 || p != &xar[1] ) error(0x14); c = (*p++)++; if( c != 1 || xar[1] != 2 || p != &xar[2] ) error(0x15); c = 2; 2, 3, 4, 5, 6, 7, 8, 9, 10 }; dec_inc() { register struct bfs **bfp; register char *p, *q, c; bfx.bf1 = 0; ri = rl2 / ri2; rl = rl2 / ri2; i = l2 / i2; l = l2 / i2; if(ri != i) error(0x24); if(rl != l++ == '9') *cp = '0'; if(strcmp(xstr1,"9000000988") != 0) error(0x9); if(strcmp(xstr2,"9000000988") != 0) err error(0x1c); } multest() { char *s; register int i; int j; s = &j; *s = 2; s[1] = 0; if(A.bb[1].i != B.y[1].o) error(0x2); if(A.c != 0) error(0x3); if(B.y[3].f != 0) error(0x4); i = 257; i = if( (*p++)++ != c || xar[2] != 3 || p != &xar[3] ) error(0x16); --(*--p); if( xar[2] != 2 || p != &xar[2] ) error(0 bfp = &bfa[2]; (*--bfp)->bf1 += 1; if( bfx.bf1 != 1 ) error(0x10); p = &xar[10]; (*--p)++; if( xar) error(0x25); if(rl != rl2) error(0x26); if(ri == rl) error(0x27); } struct fcbflags { unsigned online : 1; or(0xa); if(strcmp(xstr3,"9000000988") != 0) error(0xb); rc = '9'; rc = *rcp++ = '3'; if(rc != '3') error(i = 2; return(i * *s); } div_test() { int i, i2; long l, l2; register int ri, ri2; register long r (char)(i + 3); if (i != 4) error(0x5); saddr = laddr = iaddr = addr = 0xff000; if(laddr != addr) error(0x6); x17); c = --(*--p); if( c != 1 || xar[1] != 1 || p != &xar[1] ) error(0x18); c = 0; if( --(*--p) != c || xar[9] != 10 || p != &xar[9] ) error(0x11); c = (*--p)++; if( c != 8 || xar[8] != 9 || p != &xar[8] ) error(0x12); unsigned buffer_dirty : 1; unsigned open_mode : 2; unsigned device_type : 3; unsigned file_type : 2; un0xc); if(*(rcp-1) != '3') error(0xd); c = '8'; c = (char)0; if(c != '\0') error(0xe); if(multest() !=l, rl2; rl2 = l2 = 70000; ri = rl2 / 10; rl = rl2 / 10; i = l2 / 10; l = l2 / 10; if(ri != i if(iaddr != addr) error(0x7); if(saddr != addr) error(0x8); rcp = &xstr1[6]; while((*rcp)++ == '9') [0] != 0 || p != &xar[0] ) error(0x19); --(*p++); if( xar[0] != -1 || p != &xar[1] ) error(0x1a); c = --(*p++); c = 7; if( (*--p)++ != c || xar[7] != 8 || p != &xar[7] ) error(0x13); p = &xar[0]; (*p++)++; if( xar[0] != signed unbuffered : 1; }; struct fcb { int fcbfd; char *fcpfp; struct fcbflags fcbflg; char name; }; 4) error(0xf); } struct bfs { int bf1: 1; } bfx, *bfa[3] = { (char *)-1, &bfx, (char *)-1} ; char xar[] = { 0, 1, ) error(0x20); if(rl != l) error(0x21); if(i != 7000) error(0x22); if(i != l) error(0x23); i2 = ri2 = 1; *rcp-- = '0'; rcp = &xstr2[7]; while((*--rcp)++ == '9') *rcp = '0'; cp = &xstr3[7]; while((*--cp) if( c != 0 || xar[1] != 0 || p != &xar[2] ) error(0x1b); c = 1; if( --(*p++) != c || xar[2] != 1 || p != &xar[3] ) #define ONE 1 #define TWO 2 #define IADDRESS ((int *)0xfff900) #define CADDRESS ((char *)0xfff900) #define LADDRE if(func1(3) != 0x30) error(0x3f); /* equal-shift tests */ rpi = &ari[3]; rpl = &arl[3]; *rpi = 0x3f02; *rpi return values */ l = 0xf00030; ctest(0x34,0x35,(int)l,27); /* errors 34 & 35 */ ctest2(0x36,(int)l); if(hdr2.y != 3) error(0x4b); /* typedef cast inside structure initialization */ if(ht1.p2 != 30) error(0x4c); /* ind ari[5]; long l, arl[5]; char buf[40]; struct exec hdr, hdr2; /* bit field arguments */ i = 1; p = &fs; l = &IADDRESS[TWO]; if(l != 0xfff904) error(0x45); l = &LADDRESS[TWO]; if(l != 0xfff908) error(0x46); l = &SS ((long *)0xfff900) #define SADDRESS ((struct device *)0xfff900) struct device { int mts; char mtc; long mt++ >>= 1; if(ari[3] != 0x1f81) error(0x40); *--rpi <<= 2; if(ari[3] != 0x7e04) error(0x41); *rpl = 0x6af010; /* error 36 */ l = 0xfff30; ctest(0x37,0x38,((int)l)&0xff,27); /* errors 37 & 38 */ ctesexing test with register index variables */ i = j = ri1 = ri2 = 1; if (x[ri1][ri2][ri1] != x[1][1][1]) error(0x4d); p->fcbflg.unbuffered = (i == 0) ? 0 : 1; if (!p->fcbflg.unbuffered) error(0x30); i = 0; p->fcbflg.unbuffered CADDRESS[TWO]; if(l != 0xfff902) error(0x47); l = &(SADDRESS->mtc); if(l != 0xfff902) error(0x48); l = &(SADl; int mti; }; struct exec { int xx[19]; int y; }; typedef char *charp; struct t { char *p1; *rpl++ >>= 4; if(arl[3] != 0x6af01) error(0x42); *--rpl <<=5; if(arl[3] != 0xd5e020) error(0x43); /* sethyt2(0x39,((int)l)&0xff); /* error 39 */ ctest(0x3a,0x3b,(int)(l&0xff),27); /* errors 3a & 3b */ ctest2 if (x[i][j][i] != x[1][1][1]) error(0x4e); } struct zxx { int a,b,c,d,e; }; ztest() { register long longtm= (i == 0) ? 0 : 1; if (p->fcbflg.unbuffered) error(0x31); /* constant coersion */ l = 32768; if (l != 32768L)DRESS->mtl); if(l != 0xfff904) error(0x49); l = &(SADDRESS->mti); if(l != 0xfff908) error(0x4a); /* structure aschar *p2; } ht1 = { 0, ((charp) 30) }, ht2 = { 0, 0 }; ytest() { register struct fcb *p; register long -ulman easy expression */ i = 10; j = 3; a = (long)i * (long)i - (long)j * (long)j; if(a != 91) error(0x44); /* (0x3c,(int)(l&0xff)); /* errors 3c */ if(func1(1) != 0x30) error(0x3d); if(func1(2) != 0x30) error(0x3e); p; int i, j, k; char *cp1, *cp2; int *ip1, *ip2; long *lp1, *lp2, l; struct zxx *sp1, *sp2; /* int's error(0x32); l = 32 * 1024; if (l != 32768L) error(0x33); /* long to integer conversions including as parameters andsigned to non structure item... */ hdr.y = 3; hdr2.y = 5; *(struct exec *)buf = hdr; hdr2 = *(struct exec *)buf; rl; register int *rpi; register long *rpl; register int ri1, ri2; struct fcb fs; long a; int i, j,tricky coercion of constant to integer pointer with array subscript */ /* indexing off of int/long/char/struct pointers */ cast to pointers... */ i = 0x234; cp1 = i; cp2 = (char *)i; ip1 = i; ip2 = (int *)i; lp1 = i; lp2 = (long * { long a; int b,c,d,e,f; }; struct _y { int t; struct _x s; } _yz = { 33, { 1, 2, 3, 4, 5 } if(longtmp != l) error(0x7a); if(k != l) error(0x7b); } struct _b { long y; int x; } bs; union rec { s.a != 11) error(0x5d); ones.b = 12; if(ones.b != 12) error(0x5e); if(f1.b != 0) error(0x5f); if(f2.b != 0) g)i * (long)i - (long)j * (long)j; l = (long)i * (long)i - (long)j * (long)j; if(longtmp != l) error(0x76); if(k if(recs.l.x != 4) error(0x53); if(tys.c != 'a') error(0x54); if(as.x != 5) error(0x55); recs.f.c = 'b'; re)i; sp1 = i; sp2 = (struct zxx *)i; if(cp1 != cp2) error(0x70); if(ip1 != ip2) error(0x71); if(lp1 != lp2) e }; struct _y _yq = { 33, 1, 2, 3, 4, 5 }; struct _s1 { int a; int b; }; struct _s2 { struct _s1 c; struct _b l; struct { char c; int w; } f; } recs; struct ty { int c; } tys; structerror(0x60); f1.b = f2.b = 0; ones.q.y = 13; if(ones.q.y != 13) error(0x61); if(f1.b != 0) error(0x62); != l) error(0x77); /* exclusive or.... */ k = i * i ^ j * j; longtmp = (long)i * (long)i ^ (long)j * (long)j; l cs.f.w = 6; if(recs.f.c != 'b') error(0x56); if(recs.f.w != 6) error(0x57); if(tys.c != 'a') error(0x58); twrror(0x72); if(sp1 != sp2) error(0x73); /* long easy code skeleton tests */ i = 0x24; j = 0x11; /* addition.... */ int d; }; struct _s2 test0 = { { 10, 20 }, 30 }; struct _s2 test1 = { { 10, 20 } }; struct _s2 test2 = { { 10 }, 30 }; _a { int x; } as; union one { int a; long b; struct { int y; int x; } q; } ones if(f2.b != 0) error(0x63); f1.b = f2.b = 0; ones.q.x = 14; if(ones.q.x != 14) error(0x64); if(f1.b != 0) er= (long)i * (long)i ^ (long)j * (long)j; if(longtmp != l) error(0x78); if(k != l) error(0x79); /* inclusive or.... */os.a = 7; twos.b = 8; twos.q.y = 9; twos.q.x = 10; ones.a = 11; f1.b = 0; f2.b = 0; if(twos.a != 7) err k = i * i + j * j; longtmp = (long)i * (long)i + (long)j * (long)j; l = (long)i * (long)i + (long)j * (long)j; struct _s2 test3 = { 10, 20, 30 }; s_u_test() { bs.y = 1; bs.x = 2; recs.l.y = 3; recs.l.x = 4; tys, f1, f2; struct two { int a; long b; struct { int y; int x; } q; } twos; struct _xror(0x65); if(f2.b != 0) error(0x66); /* initialization tests */ if(_yz.s.c != 3) error(0x67); if(_yq.s.c k = i * i | j * j; longtmp = (long)i * (long)i | (long)j * (long)j; l = (long)i * (long)i | (long)j * (long)j; or(0x59); if(twos.b != 8) error(0x5a); if(twos.q.y != 9) error(0x5b); if(twos.q.x != 10) error(0x5c); if(one if(longtmp != l) error(0x74); if(k != l) error(0x75); /* subtraction.... */ k = i * i - j * j; longtmp = (lon.c = 'a'; as.x = 5; if(bs.y != 1) error(0x50); if(bs.x != 2) error(0x51); if(recs.l.y != 3) error(0x52); != 3) error(0x68); if(test0.d != 30) error(0x69); if(test0.c.b != 20) error(0x6a); if(test1.d != 0) error(0x6b); nting with pointers and other strange things */ p_ca2 = &ca2; ca2.x_p[1][1] = 'c'; x = 1; y = 1; p_ca2->x_p[x][y++] = 'd x = '\f'; if(x != 014) error(0x81); x = '\t'; if(x != 011) error(0x82); x = '\n'; if(x != 012) errln; c = 0xf4; *cp++ |= (c & 0xf); if(ln[0] != 0x65) error(0x96); /* 'a' | 0x4 */ cp = flxtv.c[1]; if(*cp != 'f' || *(c..... */ int ret; { long l; l = 0xf0030; if(ret==1) return((int)l); l = 0xfff30; if(ret==2) return(b:4; }; struct atbh2 { unsigned a:4, b:4, c:4; }; last_test() { struct atbh1 x; struct atbh2 y; int i; char c, *cp; if(test2.c.b != 0) error(0x6c); if(test3.c.b != 20) error(0x6d); if(test3.d != 30) error(0x6e); if(test2.d !'; if(ca2.x_p[1][1] != 'd') error(0x8a); if(y != 2) error(0x8b); /* struct with function arg return */ x = 1; x = (*sffor(0x83); x = '\r'; if(x != 015) error(0x84); x = '\b'; if(x != 010) error(0x85); x = '\\'; if(x !p+1) != 'o' || *(cp+2) != 'u' || *(cp+3) != 'r') error(0x97); } artl(last_test) int last_test; /* argument with same nam((int)l)&0xff); return((int)(l&0xff)); /* return 3 */ } struct { char x_p[3][3]; } *p_ca2, ca2; int artl(); s /* bit field manipulation */ x.sevensta = 2; x.sevenstb = 1; if(x.sevensta != 2) error(0x90); if(x.sevenstb != 1) er= 30) error(0x6f); } ctest(err1,err2,value1,value2) /* value1 had better be an integer !!! */ int err1, err2, value1, valu[x].ss_ff)(); if (x != 4) error(0x8c); /* character's compared to integer and long constants */ ch = 127; if(ch > 0xfffff= 0134) error(0x86); /* character indices... */ ar[1] = '5'; ar[2] = '6'; x = 1; ar[ c = (x==1) ? 2 : 1 ] = '3'; if (c !=e as function !!! */ { last_test = 4; return(last_test); } truct { int ss_x_z; int (*ss_ff)(); } sff[] = {3, 0L, 4, &artl}; next_to_last_test() { char ch; int x, y; charror(0x91); y.a = 3; y.b = 2; y.c = 1; i = (int)y.a; if (i != 3) error(0x92); i = (int)y.b; if (i != 2) error(0x93); e2; { if(value1 != 0x30) error(err1); if(value2 != 27) error(err2); } ctest2(err,value) /* value had better be f) error(0x8d); if(ch > 0xfff) error(0x8e); if(ch != 127) error(0x8f); } struct { char *a; char *b; char *c[3]; } 2) error(0x87); if(ar[2] != '3') error(0x88); ar[c & ~128] = '5'; if(ar[2] != '5') error(0x89); /* array indices increme as function !!! */ { last_test = 4; return(last_test); }  ar[9]; register char c; /* defined character constants handled properly ?? */ x = '\0'; if(x != 0) error(0x80); i = (int)y.c; if (i != 1) error(0x94); /* character manipulation */ i = ln[0] * ln[1]; if(i != 9506) error(0x95); cp = an integer !!! */ int err, value; { if(value != 0x30) error(err); } func1(ret) /* had better return an integer.. flxtv = { "one", "two", "three", "four", "five" }; char ln[3] = "ab"; struct atbh1 { unsigned sevensta:16, sevenst as function !!! */ { last_test = 4; return(last_test); } ster int ri = 1000; long l; register long rl; char *p1, *p2; int *pi; if ((array[32999] = 'z') == 'z') printf("ar 12/12/83"; /* the following code is a battery of tests directed 'against' the C compiler. these tests reflect difficu",(int)(p1-p2)); } error(enum) int enum; { printf("error - %d\n",enum); } = %ld, ", s[0].d); printf("10 octal = %lo, ", s[1].d); printf("10 hex = %lx\n", s[2].d); printf("100000000 = %ld, " as function !!! */ { last_test = 4; return(last_test); } ray[32999] is accessible\n"); else printf("can't access array[32999]\n"); pi = &array[0]; pi += 0x4000L; if (pi != &alties dicovered in prior compiler releases. cr */ char array[33000]; /* test for array size > 32k bytes */ struct ,(int)(p1-p2)); } error(enum) int enum; { printf("error - %d\n",enum); } , s[3].d); printf("-99999999 = %ld, ", s[4].d); l = i * i; /* test assembler code (long=int*int) */ rl = i * i; /rray[0x8000L]) error(0x1); printf("1 = %d, ", s[0].a); printf("-32768 = %d, ", s[1].a); printf("0 = %d, ", s[2].a); prin{ int a; char b[7]; long d; } s[5] = { /* test structure array initialization */ 1, "one", 10, -32768, "two",,(int)(p1-p2)); } error(enum) int enum; { printf("error - %d\n",enum); } * ditto */ rl = i * ri / i; /* test sign extend of 32-bit product */ i = 4; printf("-4 / i = %d, ",-4/i); printf("-tf("32767 = %d, ", s[3].a); printf("-1 = %d\n", s[4].a); printf("one = [%s], ", s[0].b); printf("two = [%s], ", s[1].b); 010, 0, "three", 0x10, 32767, "four h", 1000000000, -1, "five", -99999999 }; main() { int i = 100; regi,(int)(p1-p2)); } error(enum) int enum; { printf("error - %d\n",enum); } /* Copyright 1983 Alcyon Corporation 8716 Production Ave. San Diego, Ca. 92121 */ char *version = "@(#)test9.c 1.3 4 / 4 = %d\n",-4/4); p1 = 0; p2 = 4; printf("(0-4)ptr - ptr = (long)%ld, ", p1-p2); printf("(0-4)ptr - ptr = (int)%d\n printf("three = [%s], ", s[2].b); printf("four h = [%s], ", s[3].b); printf("five = [%s]\n", s[4].b); printf("10 decimal define test2x pr) printf("\n\tassertion succeeded: expr\n") #define FALSE_COND(expr) printf("\n\tassertion failed: expr\n") #define TEST_OK,x4) /********************** end of C Puzzle's "defs.h" ***********************/ #define PRINT_EXPR(format,expr) printf("\n\/* macro's and define's useful to write test programs and to build test suites */ /* NOV 83 - Bill Fitler */ /* FEB 84 - K(expr) if (expr) TRUE_COND(expr) #define TEST_NOK(expr) if (expr) FALSE_COND(expr) #define PRS(b,c) printf("\n\t%s: succeeded #define test2x texpr = format\n",(expr)) #define PRE(fmt,expr,val) printf("\n\texpected value of expr = %fmt",val) #define PRA(fmt,expr) prinen Chai */ /*********************** From "C Puzzle Book": ****************************/ #define PR(format,value) printf("\n\for %s model", c, b) #define PRF(b,c) printf("\n\t%s: failed for %s model", c, b) #define ASSER(a,b) {if (a) PRS(model,b) ; eldefine test2x tf("\n\tactual value of expr = %fmt\n",(expr)) #define MODEL_NAME ((sizeof(char *) == 2) ? \ (sizeof(char (*tvalue = %format\t",(value)) #define NL printf("\n") #define PRINT1(f,x1) PR(f,x1); NL #define PRINT2(f,x1,x2) PR(f,x1)se PRF(model,b); } #define PRI(format,val) printf("\n\twe expect to see %format", val) #define ASSERT(cond) {{model=MODEL_NAMEdefine test2x )())==2 ? "small" : "medium") : \ (sizeof(char (*)())==2 ? "compact" : "big") ) #define TRUE_COND(ex; PRINT1(f,x2) #define PRINT3(f,x1,x2,x3) PR(f,x1); PRINT2(f,x2,x3) #define PRINT4(f,x1,x2,x3,x4) PR(f,x1); PRINT3(f,x2,x3;} ; ASSER(cond,bugnum); } #define ASSRT(cond) ASSER(cond,bugnum) /* #define PRS68(c) printf("\n\t%s: succeeded", c) #defloat *f1(); float f2(); float ret_0(); struct type { float ft; double dt; float *pft; } fstruc; char *fstr = "-2.); } float * f1() { return(fstruc.pft); } float f2() { return(2.0); } float ret_0() { return(0.0); } */ ,f,i); } l = 7L; f = l; printf("6.9 < %f < 7.1\n",f); i = 7; f = i; printf("6.9 < %f < 7.1\n",f); f = atof(astr); ine PRF68(b) printf("\n\t%s: failed", b) #define ASSER68(a,b) {if (a) PRS68(b) ; else PRF68(b); } #define PRI(format,val) prin3E-4"; char *astr = "8.6324"; float ar[10]; float global_f; int err = 0; main() { double d; float f, fp2, *fp; c if_test(pf) float pf; { float af, *ptr; ar[2] = 0.0; af = 0.0; ptr = ⁡ if (global_f) error(0x10); if (ar[2]) printf("%s ==> ~ %f or %e\n",astr,f,f); f = 0; if (f != 0.0) error(0xf6); i = 3; ar[i] = 3.0; f = 4.0; fp2 = 10.0;tf("\n\twe expect to see %format", val) #define ASSERT68(cond) ASSER68(cond,bugnum) #define ASSRT68(cond) ASSER68(cond,bugnum)har *s, buf[20]; long l; int i; if ((fp = f1()) != fstruc.pft) error(0xf1); if ((f = f2()) != 2.0) error(0xf2); d = error(0x11); if (af) error(0x12); if (pf) error(0x13); if (*ptr) error(0x14); if (ret_0()) error(0x14); } infinity( printf("%f += ",ar[i]); printf("%f * %f ==> ",f,fp2); ar[i] += f * fp2; printf("%f\n",ar[i]); global_f = 0.0; f = 0 */ f; if (d != f) error(0xf3); f = atof(fstr); s = ftoa(f,buf,6); printf("%s => %f => %s\n",fstr,f,s); f = 3.4; l = f; #include typedef struct { double a[6]; } joint; static joint lower_limit = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 }; f) { float a, b; a = 1.0E+6; b = 0.0; while(a > b) { printf("%e > %e\n",a,b); b = a; a = a * a; } print.0; if_test(f); infinity(); ar_test(); if (!err) printf("Far Freaking Out....\n"); else printf("Tough Luck...\n"*/  if (l != 3L) { error(0xf4); printf("%f => %ld != 3L\n",f,l); } i = f; if (i != 3) { error(0xf5); printf("%f => %d != 3\n"f("%e <= %e\n",a,b); } ar_test() { float a[5], b[5], c[5], d[5]; int i; a[0] = 0.0; b[0] = 0.0; c[0] = 0.0; d[0] = err() { printf("Buserr exception!\n"); } zdiv() { printf("Zero divide exception\n"); } error(enum) int enum; { printf("error: %x\n",enum); err++; } SSERT(TRUE) ; printf("\n\tExiting test routine"); exit(); } /* if (xret != 0) */ recur(); } /* stjptst main 1.0 + 1.0\n",c[1]); printf("%f = 2.0 + 2.0\n",c[2]); printf("%f = 3.0 + 3.0\n",c[3]); printf("%f = 4.0 + 4.0\n",c[4]); } /* This program tests DRC/rtl setjmp & longjmp functions. program written by Bill Fitler modified by Ken Chai 20-Dec-83 0.0; a[1] = 1.0; b[1] = 1.0; c[1] = 1.0; d[1] = 1.0; a[2] = 2.0; b[2] = 2.0; c[2] = 2.0; d[2] = 2.0; a[3] = 3.0; b[3] = 3.err() { printf("Buserr exception!\n"); } zdiv() { printf("Zero divide exception\n"); }#include #include main() { REG WORD *a,b,c; WORD berr(),zdiv(); signal(10,berr); signal( 8,zdiv)function */ recur() { EXTERN WORD i; WORD ret; while(i <= 100) { i +=1; recur(); } /* while(i <= error(enum) int enum; { printf("error: %x\n",enum); err++; } */ #include #include #include "bugdefs.h" jmp_buf env; GLOBAL WORD i; GLOBAL BYTE *model, *bu0; c[3] = 3.0; d[3] = 3.0; a[4] = 4.0; b[4] = 4.0; c[4] = 4.0; d[4] = 4.0; for(i = 0 ; i < 5; i++) { a[i] += b[i]; c[i; a = -1; b = *a; printf("Return from BUSERR\n"); c = 0; b = 1; b = b/c; printf("Return from Zero divide\n"); } 100) */ longjmp(env,ret); } /* recur */  error(enum) int enum; { printf("error: %x\n",enum); err++; } gnum="stjptst: \ttest of setjmp & longjmp\ \n\t\t\t" ; main() { EXTERN WORD i; WORD xret,ret; printf("\n\tThis r] = c[i] + d[i]; } printf("0.0 += 0.0 => %f\n",a[0]); printf("1.0 += 1.0 => %f\n",a[1]); printf("2.0 += 2.0 => %f\n",a[2berr() { printf("Buserr exception!\n"); } zdiv() { printf("Zero divide exception\n"); }00) */ longjmp(env,ret); } /* recur */  error(enum) int enum; { printf("error: %x\n",enum); err++; } outine tests SETJMP & LONGJMP\n"); i = 0; xret= setjmp(env); printf("\n\tXRET= %d",xret); if (xret != 0) { A]); printf("3.0 += 3.0 => %f\n",a[3]); printf("4.0 += 4.0 => %f\n",a[4]); printf("%f = 0.0 + 0.0\n",c[0]); printf("%f = 00) */ longjmp(env,ret); } /* recur */ intf("test\t%%D: %D, %D, %D\n",(LONG)w1,(LONG)w2,(LONG)w3); printf("test\t%%u: %u, %u, %u\n",w1,w2,w3); printf("test\t%%U: %e absolute values are less than 0.05. program written by Bill Fitler modified by Ken Chai 21-Dec-83 */ #include j,j,w3); printf("\t\t%%-0%d.%dd: %-0*.*d %-0*.*d %-0*.*d\n", j,j,j,j,w1, j,j,w2, j,j,w3); printf("\n"); } /* for( U, %U, %U\n",(LONG)w1,(LONG)w2,(LONG)w3); printf("test\t%%o: %o, %o, %o\n",w1,w2,w3); printf("test\t%%O: %O, %O, %O\n",(LONG"bugdefs.h" #include BYTE *signon = {"testing printf\n"}; main() { WORD w1,w2,w3; WORD j; BYTE *model, *j=0; j<7; j++ ) */ ASSERT(TRUE) ; } /* prtftest */ )w1,(LONG)w2,(LONG)w3); printf("test\t%%x: %x, %x, %x\n",w1,w2,w3); printf("test\t%%X: %X, %X, %X\n",(LONG)w1,(LONG)w2,(LONGbugnum="prtftest: \tdiverse tests of printf function\ \n\t\t\t" ; w1 = 100; w2 = -20; w3 = -3000; write(1,signon,strlen(s/* exectest.c This program tests to see if execl function works as specified. execl calls execgood for small model ; =0; j<7; j++ ) */ ASSERT(TRUE) ; } /* prtftest */ )w3); for( j=1; j<7; j++ ) { printf("test '*'\t%%%dd:\t%*d %*d %*d\n",j,j,w1,j,w2,j,w3); printf("\t\t%%-%d.%dd:\t%-*.*d ignon)); printf("test\t%%s: %s\n",signon); printf("test\t%%c: %c\n",'c'); printf("test\t%%d: %d, %d, %d\n",w1,w2,w3); pr calls execgoob for big model ; program written by Bill Fitler program modified by Ken Chai 22-Dec-83 */ #incl/* prtftest.c performs tests on different formats except floating # formats. Everything works except f format for numbers whos=0; j<7; j++ ) */ ASSERT(TRUE) ; } /* prtftest */ %-*.*d %-*.*d\n", j,j,j,j,w1, j,j,w2, j,j,w3); printf("\t\t%%0%d.%dd:\t%0*.*d %0*.*d %0*.*d\n", j,j,j,j,w1, j,j,w2,ude "bugdefs.h" #include GLOBAL char model[10] ; char bugnum[80] ; char progname[10] ; char *chptr ; chal,"model",\ (char *) 0); } /* exectest.c */  execgood.c main function */ r *strcpy() ; main() { strcpy(bugnum,"exectest: \ttest of execl function\n\t\t\t") ; printf("\nBegin test of execl fun /* 'execgood.c': test routine for exectest.c written by: Ken Chai 15 Dec. 83 */ #include #include "bugdl,"model",\ (char *) 0); } /* exectest.c */ ction\n"); if (sizeof(chptr)==2) strcpy(model,"small" ); else strcpy(model,"big") ; if (!strcmp(model,"small") efs.h" main(ac,av) int ac; char **av; { int ii; printf("%s %s %s %s %s", av[1], av[2], av[3], av[4], av[5]) ; } /) strcpy(progname,"execgood") ; else strcpy(progname,"execgoob") ; execl(progname,progname,"test's","good","for",mod* execgood.c main function */ el,"model",\ (char *) 0); } /* exectest.c */  execgood.c main function */