From e85ee07172eccafd9441362e774f7b184810d008 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Fri, 31 May 1996 21:33:17 +0200 Subject: Import Dev86-0.0.6.tar.gz --- bcc/Makefile | 6 ++ bcc/bcc.c | 75 +++++++++---- bcc/const.h | 4 + bcc/input.c | 24 ++--- bcc/input.h | 2 +- bcc/ncc.c | 215 ++++++++++++++++++++++++++++++++++++ bcc/os.h | 20 ---- bcc/preproc.c | 29 ++--- bcc/scan.c | 4 +- bcc/scan.h | 3 +- bcc/state.c | 23 +++- bcc/table.c | 3 +- bcc/tags | 341 ---------------------------------------------------------- 13 files changed, 336 insertions(+), 413 deletions(-) create mode 100644 bcc/ncc.c delete mode 100644 bcc/tags (limited to 'bcc') diff --git a/bcc/Makefile b/bcc/Makefile index 9cc0f0a..eb09e52 100644 --- a/bcc/Makefile +++ b/bcc/Makefile @@ -11,6 +11,8 @@ else CC=bcc CFLAGS=-Mf LDFLAGS=-s -M +BINDIR=/usr/bin +LIBDIR=/usr/lib/bcc endif OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \ @@ -42,3 +44,7 @@ bcc-cc1: $(OBJS) clean: rm -f bcc bcc-cc1 bcc09 ccc bcc.o $(OBJS) + + +$(OBJS): align.h byteord.h condcode.h const.h gencode.h input.h label.h os.h \ + output.h parse.h proto.h reg.h sc.h scan.h sizes.h table.h type.h types.h diff --git a/bcc/bcc.c b/bcc/bcc.c index 265553b..c5b0074 100644 --- a/bcc/bcc.c +++ b/bcc/bcc.c @@ -6,8 +6,10 @@ #include #include +#ifndef MSDOS #include #include +#endif #include #include #include @@ -25,26 +27,45 @@ #define P(x) () #endif -#define AS "as86" +#ifdef MSDOS +#define LOCALPREFIX "/linux86" +#define EXESUF ".exe" +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else +#define EXESUF +#endif + +#define AS "as86" EXESUF #define BAS86 #define BCC86 -#define CC1 "bcc-cc1" +#define CC1 "bcc-cc1" EXESUF #define CC1_MINUS_O_BROKEN FALSE -#define CPP "bcc-cc1" /* normally a link to /usr/bin/bcc-cc1 */ +#define CPP "bcc-cc1" EXESUF /* normally a link to /usr/bin/bcc-cc1 */ #define CPPFLAGS "-E" #define CRT0 "crt0.o" #define GCC "gcc" -#define LD "ld86" +#define LD "ld86" EXESUF #ifndef NO_ANSI_SUPPORT -#define UNPROTO "unproto" -#endif +#define UNPROTO "unproto" EXESUF +#endif +#ifdef MSDOS +#define STANDARD_CRT0_0_PREFIX LOCALPREFIX "/lib/" +#define STANDARD_EXEC_PREFIX LOCALPREFIX "/lib/" +#define STANDARD_EXEC_PREFIX_2 "/bin/" +#define DEFAULT_INCLUDE "-I" LOCALPREFIX "/libc/include" +#define DEFAULT_LIBDIR0 "-L" LOCALPREFIX "/lib/" +#else #define STANDARD_CRT0_0_PREFIX LOCALPREFIX "/lib/bcc/i86/" #define STANDARD_CRT0_3_PREFIX LOCALPREFIX "/lib/bcc/i386/" #define STANDARD_EXEC_PREFIX LOCALPREFIX "/lib/bcc/" -#define STANDARD_EXEC_PREFIX_2 LOCALPREFIX "/bin/" +#define STANDARD_EXEC_PREFIX_2 "/usr/bin/" #define DEFAULT_INCLUDE "-I" LOCALPREFIX "/include" #define DEFAULT_LIBDIR0 "-L" LOCALPREFIX "/lib/bcc/i86/" #define DEFAULT_LIBDIR3 "-L" LOCALPREFIX "/lib/bcc/i386/" +#endif #ifdef CCC #undef BCC86 @@ -430,9 +451,11 @@ char **argv; if( add_default_lib ) { #ifdef BCC86 +#ifdef DEFAULT_LIBDIR3 if( bits32 ) addarg(&ldargs, DEFAULT_LIBDIR3); else +#endif #endif addarg(&ldargs, DEFAULT_LIBDIR0); } @@ -442,7 +465,9 @@ char **argv; ccargs.prog = fixpath(ccargs.prog, &exec_prefix, X_OK); asargs.prog = fixpath(asargs.prog, &exec_prefix, X_OK); ldargs.prog = fixpath(ldargs.prog, &exec_prefix, X_OK); +#ifdef BAS86 ldrargs.prog = fixpath(ldrargs.prog, &exec_prefix, X_OK); +#endif #ifndef NO_ANSI_SUPPORT unprotoargs.prog=fixpath(unprotoargs.prog, &exec_prefix, X_OK); #endif @@ -452,12 +477,14 @@ char **argv; if (prep_only && !prep_line_numbers) addarg(&cppargs, "-P"); #ifdef BCC86 +#ifdef STANDARD_CRT0_3_PREFIX if (bits32) { bits_arg = "-3"; crt0 = fixpath(CRT0, &crt0_3_prefix, R_OK); } else +#endif { bits_arg = "-0"; crt0 = fixpath(CRT0, &crt0_0_prefix, R_OK); @@ -854,6 +881,9 @@ struct arg_s *argp; } writen(); } +#ifdef MSDOS + status = spawnv(0, argp->prog, argp->argv+arg0); +#else switch (fork()) { case -1: @@ -866,23 +896,24 @@ struct arg_s *argp; fatal(" failed"); default: wait(&status); - for (i = tmpargs.argc - 1; i >= START_ARGS; --i) - if (in_name == tmpargs.argv[i]) - { - my_unlink(in_name); - --tmpargs.argc; - memmove(tmpargs.argv + i, tmpargs.argv + i + 1, - (tmpargs.argc - i) * sizeof tmpargs.argv[0]); - tmpargs.argv[tmpargs.argc] = NUL_PTR; - break; - } - if (status != 0) + } +#endif + for (i = tmpargs.argc - 1; i >= START_ARGS; --i) + if (in_name == tmpargs.argv[i]) { - killtemps(); - runerror = TRUE; + my_unlink(in_name); + --tmpargs.argc; + memmove(tmpargs.argv + i, tmpargs.argv + i + 1, + (tmpargs.argc - i) * sizeof tmpargs.argv[0]); + tmpargs.argv[tmpargs.argc] = NUL_PTR; + break; } - return status; + if (status != 0) + { + killtemps(); + runerror = TRUE; } + return status; } PRIVATE void set_trap() @@ -896,7 +927,7 @@ PRIVATE void set_trap() #endif #else - /* This is being too trap happy! */ + /* This is being too trap happy IMO - Rdb */ #ifndef _NSIG #define _NSIG NSIG #endif diff --git a/bcc/const.h b/bcc/const.h index 8df8bcb..fda6914 100644 --- a/bcc/const.h +++ b/bcc/const.h @@ -28,6 +28,10 @@ /*#define SOS_MSDOS*/ /* source O/S is MSDOS */ /*#define TOS_EDOS*/ /* target O/S is EDOS */ +#ifdef MSDOS +#define SOS_MSDOS +#endif + /* switches for source machine dependencies */ #ifndef SOS_EDOS diff --git a/bcc/input.c b/bcc/input.c index 4cf699a..3d77bbf 100644 --- a/bcc/input.c +++ b/bcc/input.c @@ -89,30 +89,30 @@ more: } ch = *++lineptr; more1: - if (!eof && lineptr >= input.limit) + if (!eofile && lineptr >= input.limit) skipeol(); if (ch == EOL) { --nbackslash; - if (eof) + if (eofile) eofin("backslash-newline"); else { skipeol(); - if (ch == EOL && !eof && lineptr >= input.limit) + if (ch == EOL && !eofile && lineptr >= input.limit) skipeol(); #ifdef COEOL /* XXX - this should go through specialchar() */ if (ch == COEOL) { ch = *++lineptr; - if (ch == EOL && !eof && lineptr >= input.limit) + if (ch == EOL && !eofile && lineptr >= input.limit) skipeol(); } #endif } if (ch == '\\') goto more; - if (nbackslash != 0 && ch == EOL && !eof) + if (nbackslash != 0 && ch == EOL && !eofile) goto more1; if (nbackslash != 0) { @@ -124,7 +124,7 @@ more1: } if (ch == '\\') goto more; - if (ch == EOL && !eof) + if (ch == EOL && !eofile) goto more1; ch = *--lineptr = '\\'; /* pushback */ if (--nbackslash != 0) @@ -165,7 +165,7 @@ PUBLIC void errorloc() return; outstr(infbuf->fname); outbyte(':'); - if (eof) + if (eofile) outstr("eof"); else { @@ -604,7 +604,7 @@ PUBLIC void skipeol() #endif int nread; - if (eof) + if (eofile) return; if (lineptr < input.limit) { @@ -672,7 +672,7 @@ case0: { if (inclevel == 0) { - eof = TRUE; + eofile = TRUE; checknotinif(); } else @@ -705,7 +705,7 @@ more: if (ch == '\\') backslash(); #endif - if (!eof && lineptr >= input.limit) + if (!eofile && lineptr >= input.limit) { skipeol(); #ifdef ARBITRARY_BACKSLASH_NEWLINES @@ -726,7 +726,7 @@ more: } if (*(lineptr + 1) == EOL) { - if (eof) + if (eofile) eofin("backslash-newline"); else { @@ -746,7 +746,7 @@ more: #endif } #ifdef COEOL - if (ch == EOL && !eof) + if (ch == EOL && !eofile) { if (*(lineptr + 1) == EOL && lineptr + 1 >= input.limit) { diff --git a/bcc/input.h b/bcc/input.h index 0563059..0cda8d0 100644 --- a/bcc/input.h +++ b/bcc/input.h @@ -27,7 +27,7 @@ EXTERN bool_t asmmode; /* nonzero when processing assembler code */ /* depends on zero init */ EXTERN char ch; /* current char */ EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */ -EXTERN bool_t eof; /* nonzero after end of main file reached */ +EXTERN bool_t eofile; /* nonzero after end of main file reached */ /* depends on zero init */ EXTERN struct fcbstruct input; /* current input file control block */ /* input.lineptr is not kept up to date */ diff --git a/bcc/ncc.c b/bcc/ncc.c new file mode 100644 index 0000000..d48e522 --- /dev/null +++ b/bcc/ncc.c @@ -0,0 +1,215 @@ + +#include + +/* Normal passes ... + * p: C preprocessor .c -> .0 + * 1: cc1 .1 -> .2 + * 2: opt .2 -> .3 + * 3: cg .3 -> .s + * a: as .s -> .o + * l: ld .o -> .out + * + * c: Is alias for one or more of 0,1,2 + * d: This command. (Semi-colon seperators) + */ + +#define MAXPASSES 16 +#define MAXOPTIONS 32 + +struct pass { + char * command; + char pass_id; + char source; + char result; + char * args; +} passes[MAXPASSES]; + +struct option { + char * optname; + char * subst; +} options[MAXOPTS]; + +/* The default argument list ... */ +extern int standard_argc; +extern char ** standard_argv; + +#ifdef __MSDOS__ +int standard_argc = 0; /* Nothing ... use the files */ +char ** standard_argv = 0; +#endif + +struct { char * opt, *spec; } builtin_models[] = { + { "-0", "i8086" } + { "-3", "i386" } + { "-9", "mc6809" } + {0,0} +}; + +/* What sort of compile ? */ +char model[20] = "-"; +int model_found = 0; +int args_active = 1; + +/* Linker output file */ +char * output_file = "a.out"; + +char ** file_list = 0; +int file_count = 0; +int pass_count = 0; +int opts_count = 0; + +/* A temp buffer */ +char little_buf[128]; + +main(argc, argv) +int argc; +char ** argv; +{ + int ar; + /* First, is there a model ? */ + /* PROBLEM: This doesn't find -b specifiers that are embedded in user opts */ + for(ar=1; ar