/* ** Small-C Compiler Version 2.10 ** ** Copyright 1982 J. E. Hendrix ** ** Modified version by F.A.Scacchitti 10/7/84 ** ** Upgrades are in chronological order. For more information regarding ** differences between this version and the one described in J.E.H.'s ** Small-C Manual, refer to CC.DOC. ** ** 2.06 ** -modified error pause to terminate on Control X ** CC22.C error() ** -increased all values to conform to 2.1 ** CC.DEF ** -added autext function per J.E.H.'s 2.1 (37) ** CC32.C primary() ** CC4.C *ccptr, *symtab ** CC41.C trailer() ** 2.07 ** -cleaned up and revised CC11.C to eliminate all that garbage ** mods include : ** -set M80 to always true (no -c option) ** CC11.C ask() ** -added -i option to command line to initialize ** storage areas to zeroes only when desired ** CC1.C int iflag; ** CC11.C ask() ** -redid initialization to default to DS instead ** DB or DW to speed up compile time ** CC11.C dumpzero() ** -removed FULL_C, C80, SMALL_VM, PDS, #defines ** CC.DEF and everyplace else encountered ** -fixed minor bug in auto-external function causing erroneos ** defining of external nothings ** ** 2.08 ** -more cleanup of old garbage got rid of all unnecessary #def's ** including CMD_LINE and NEW_CMD_LN ** CC.DEF, CC11.C and all other places encountered ** -added ## suffixes to all CALL calls to eliminate the CALL ** externals from STDIO.H ** -upgraded peephole() to accomodate new ptr values ** CC41.C, CC42.C ** -removed all unnecessary external defines from CC1.C, CC2.C ** CC3.C and CC4.C (left in as comments) ** ** 2.09 ** -defined HASH ** -defined DYNAMIC ** -changed CCALLOC to calloc and upgraded to conform to J.E.H's 2.1 ** CC11.C ** -changed CCAVAIL to avail and upgraded to conform to J.E.H's 2.1 ** CC21.C ** -modified ifline() to properly nest #ifdef's per J.E.H's 2.1 ** CC22.C ** -modified trailer to autodeclare externals for both DYNAMIC and ** !DYNAMIC defines ** CC41.C ** -modified trailer to link to ULINK (runtime module) if source ** contain a main() ** CC41.C ** -modified runtime module - refer to those modules for specifics ** CLIB.DOC ** -seperated modules into standard C functions and ** genrerated clib.rel ** -modified compiler runtime module to minimize size, eliminate ** redirected input and unnecessary routines ** CCRTL.MAC ** -added permission for *(funct)() syntax as arguments ** CC12.C declglb(), doargs() J.E.H.'s (3) ** ** 2.10 ** -added -n option to compiler runstring to allow return to CP/M's ** CCP rather than return via warm boot ** CC1.C nbflg ** CC11.C ask() ** -added code generation for -n option ** CC4.C nbflg ** CC41.C trailer() ** -added static's to preprocessor to allow non-global definitions ** of static variables ** CC11.C parse() ** CC41.C trailer() ** -added or verified the following fixes to upgrade to J.E.H.'s 2.1 ** #1 - CC13.C, CC21.C ** #3 - CC12.C ** #7 - CC22.C ** #8 - CC12.C ** #9 - CC22.C ** #10 - ** #11 - ** #16 - CC12.C ** #22 - C. A. L. L. ** #24 - CC33.C ** #25 - CC12.C ## #28 - CC41.C ** #30 - CC42.C ** #31 - CC21.C ** #35 - CC41.C ** #37 - CC.DEF, CC32.C, CC41.C ** #40 - CC12.C ** #41 - CC1.C, CC2.C, CC3.C, CC4.C ** ** -added the conditional operator {e1 ? e2 : e3 } ** CC31.C heir1(), ducond() ** -changed stdiol.h to stdio.h -CC1.C, CC2.C, CC3.C, CC4.C ** -problems occur when using the (*funct)() syntax. Consider ** this feature not installed. ** ** Stay tuned folk for the following: ** ** >installed all fixes and pertinent upgrades per J.E.H.'s 2.1 ** (13, 14, 15, 16, 26, 27, 34, 36, 38, ) ** >added multi-dimensioned arrays ** >added arrays of pointers eg. *argv[], *num[i] ** >added multiple levels of indirection eg. **argv, ***ptr ** >added type longs ** >added floating point ** >added structures and unions ** >complete 'C' preprocessor external of compiler */ /* ** Macro Definitions */ /* ** compile options */ #define M80 /* generate m80 compatable library calls */ #define PHASE2 /* 2nd and later compiles */ #define SEPARATE /* compile separately */ #define OPTIMIZE /* compile output optimizer */ #define NOCCARGC /* no calls to CCARGC */ #define HASH /* use hash search for macros */ #define DYNAMIC /* allocate memory dynamically */ /* #define POLL /* poll for operator interruptions */ #define COL /* terminate labels with a colon */ #define TAB 9 /* put out tabs of this value */ #define UPPER /* force symbols to upper case */ #define LINK /* will use with linking loader */ /* ** machine dependent parameters */ #define BPW 2 /* bytes per word */ #define LBPW 1 /* log2(BPW) */ #define SBPC 1 /* stack bytes per character */ #define ERRCODE 7 /* op sys return code */ /* ** symbol table format */ #define IDENT 0 #define TYPE 1 #define CLASS 2 #define OFFSET 3 #define NAME 5 #define OFFSIZE (NAME-OFFSET) #define SYMAVG 10 #define SYMMAX 14 /* ** symbol table parameters */ #define NUMLOCS 25 #define STARTLOC symtab #define ENDLOC (symtab+(NUMLOCS*SYMAVG)) #define NUMGLBS 200 #define STARTGLB ENDLOC #define ENDGLB (ENDLOC+((NUMGLBS-1)*SYMMAX)) #define SYMTBSZ 3050 /* NUMLOCS*SYMAVG + NUMGLBS*SYMMAX */ /* ** System wide name size (for symbols) */ #define NAMESIZE 9 #define NAMEMAX 8 /* ** possible entries for "IDENT" */ #define LABEL 0 #define VARIABLE 1 #define ARRAY 2 #define POINTER 3 #define FUNCTION 4 /* ** possible entries for "TYPE" ** low order 2 bits make type unique within length ** high order bits give length of object */ /* LABEL 0 */ #define CCHAR (1<<2) #define CINT (BPW<<2) /* ** possible entries for "CLASS" */ /* LABEL 0 */ #define STATIC 1 #define AUTOMATIC 2 #define EXTERNAL 3 #define AUTOEXT 4 /* ** "switch" table */ #ifdef PHASE2 #define SWSIZ (2*BPW) #define SWTABSZ (60*SWSIZ) #else /* PHASE2 */ #define SWSIZ 4 #define SWTABSZ 100 #endif /* PHASE2 */ /* ** "while" statement queue */ #define WQTABSZ 30 #define WQSIZ 3 #define WQMAX (wq+WQTABSZ-WQSIZ) /* ** entry offsets in while queue */ #define WQSP 0 #define WQLOOP 1 #define WQEXIT 2 /* ** literal pool */ #define LITABSZ 800 #define LITMAX (LITABSZ-1) /* ** input line */ #define LINEMAX 127 #define LINESIZE 128 /* ** command line */ #define MAXARGS 32 /* maximum number of option arguments */ /* ** output staging buffer size */ #define STAGESIZE 800 #define STAGELIMIT (STAGESIZE-1) /* ** macro (define) pool */ #ifdef HASH #define MACNBR 100 #define MACNSIZE 1100 /* 100*(NAMESIZE+2) */ #define MACNEND (macn+MACNSIZE) #define MACQSIZE 500 /* 100*5 */ #else /* HASH */ #define MACQSIZE 1100 #endif /* HASH */ #define MACMAX (MACQSIZE-1) /* ** statement types */ #define STIF 1 #define STWHILE 2 #define STRETURN 3 #define STBREAK 4 #define STCONT 5 #define STASM 6 #define STEXPR 7 #define STDO 8 /* compile "do" logic */ #define STFOR 9 /* compile "for" logic */ #define STSWITCH 10 /* compile "switch/case/default" logic */ #define STCASE 11 #define STDEF 12 #define STGOTO 13 /* compile "goto" logic */