summaryrefslogtreecommitdiff
path: root/bcc
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1996-09-03 22:06:58 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:31:01 +0200
commit0936b9aeab611665645a4e6bafaded7ca76dd189 (patch)
treefe6384035e96adc260f621d27909be67ad2e724a /bcc
parente85ee07172eccafd9441362e774f7b184810d008 (diff)
downloaddev86-0936b9aeab611665645a4e6bafaded7ca76dd189.tar.gz
Import Dev86-0.0.7.tar.gzv0.0.7
Diffstat (limited to 'bcc')
-rw-r--r--bcc/Makefile6
-rw-r--r--bcc/bcc.doc9
-rw-r--r--bcc/codefrag.c32
-rw-r--r--bcc/const.h15
-rw-r--r--bcc/exptree.c12
-rw-r--r--bcc/function.c4
-rw-r--r--bcc/gencode.c2
-rw-r--r--bcc/gencode.h2
-rw-r--r--bcc/genloads.c23
-rw-r--r--bcc/glogcode.c4
-rw-r--r--bcc/hardop.c2
-rwxr-xr-xbcc/idcc311
-rw-r--r--bcc/input.c9
-rw-r--r--bcc/label.c2
-rw-r--r--bcc/ncc.c215
-rw-r--r--bcc/scan.c12
-rw-r--r--bcc/state.c4
-rw-r--r--bcc/table.c14
-rw-r--r--bcc/type.c2
19 files changed, 432 insertions, 248 deletions
diff --git a/bcc/Makefile b/bcc/Makefile
index eb09e52..c97048b 100644
--- a/bcc/Makefile
+++ b/bcc/Makefile
@@ -2,7 +2,7 @@
# bcc Makefile
# $Id$
#
-BCCDEFS=-DLOCALPREFIX="\"/usr\"" -DDEFARCH=0
+BCCDEFS=-DLOCALPREFIX="\"/usr/bcc\"" -DDEFARCH=0
ifneq ($(TOPDIR),)
include $(TOPDIR)/Make.defs
@@ -10,7 +10,7 @@ BCCDEFS=-DLOCALPREFIX="\"$(BCCHOME)\"" -DDEFARCH=0
else
CC=bcc
CFLAGS=-Mf
-LDFLAGS=-s -M
+LDFLAGS=-s -Mf
BINDIR=/usr/bin
LIBDIR=/usr/lib/bcc
endif
@@ -20,7 +20,7 @@ OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \
loadexp.o longop.o output.o preproc.o preserve.o scan.o softop.o \
state.o table.o type.o assign.o
-all: bcc bcc-cc1
+all: bcc-cc1 bcc
install: all
install -d $(LIBDIR)
diff --git a/bcc/bcc.doc b/bcc/bcc.doc
index 1c5e930..acf4ab0 100644
--- a/bcc/bcc.doc
+++ b/bcc/bcc.doc
@@ -126,14 +126,14 @@ name basename of the source name
-0 start with 16-bit code segment
-3 start with 32-bit code segment
-a enable partial compatibility with asld
--b produce binary file, filename may follow (obsolete)
-g only put global symbols in object file
-j force all jumps to be long
-l produce list file, filename may follow
-m print macro expansions in listing
-n name of module follows (goes in object instead of source name)
-o produce object file, filename follows
--s produce symbol file, filename follows (obsolete)
+-b produce binary file, filename may follow
+-s produce symbol file, filename follows
-u take undefined symbols as imported-with-unspecified segment
-w don't print warnings
@@ -142,6 +142,11 @@ cc1 output and Minix's make does the wrong thing with .s files left around.
However, all assembler code not written by compilers should assemble with
them turned off.
+The -b flag now produces a 'raw' binary file with no header, if there's no
+-s flag the file starts at location 0. The -s generates an ASCII symbol
+table, if a binary file doesn't start at location zero the first two items
+are the start and end addresses of the binary file.
+
ld options
----------
diff --git a/bcc/codefrag.c b/bcc/codefrag.c
index e42b05b..5d3aa82 100644
--- a/bcc/codefrag.c
+++ b/bcc/codefrag.c
@@ -141,6 +141,7 @@ PUBLIC void comment()
}
PUBLIC void ctoi()
{
+#ifdef I80386
if (i386_32)
{
outmovzx();
@@ -148,6 +149,7 @@ PUBLIC void ctoi()
outncregname(BREG);
}
else
+#endif
{
outxor();
outhiaccum();
@@ -345,12 +347,14 @@ PUBLIC void outword()
}
PUBLIC void sctoi()
{
+#ifdef I80386
if (i386_32)
{
outmovsx();
outncregname(BREG);
}
else
+#endif
outnop1str("cbw");
}
PUBLIC void stoi()
@@ -592,7 +596,7 @@ PRIVATE seg_t segment; /* current seg, depends on init to CSEG = 0 */
PUBLIC void adc0()
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
adjcarry();
@@ -616,8 +620,12 @@ offset_t offset;
store_pt reg;
{
#ifdef I8088
+#ifdef I80386
if ((i386_32 && (uoffset_t) offset + 1 <= 2) /* do -1 to 1 by dec/inc */
|| (!i386_32 && (uoffset_t) offset + 2 <= 4)) /* do -2 to 2 */
+#else
+ if ((uoffset_t) offset + 2 <= 4) /* do -2 to 2 */
+#endif
{
if (reg == ALREG)
reg = AXREG; /* shorter and faster */
@@ -673,7 +681,7 @@ store_pt reg;
if ((store_t) reg != AXREG)
#endif
bumplc();
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -702,7 +710,7 @@ label_t label;
#ifdef MC6809
outcregname(LOCAL);
#endif
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -726,8 +734,10 @@ offset_t offset;
outncimmadr((offset_t) (topbits >> (INT16BITSTO - CHBITSTO)));
#else
outandac();
+#ifdef I80386
if (i386_32)
bumplc2();
+#endif
outncimmadr(offset);
return;
#endif
@@ -767,9 +777,11 @@ PUBLIC label_t casejump()
outj1switch();
outlabel(jtablelab = getlabel());
outj2switch();
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
+#endif
#ifdef MC6809
if (posindependent)
{
@@ -833,7 +845,7 @@ uoffset_t value;
uoffset_t longlow;
longlow = value & (uoffset_t) intmaskto;
-#ifdef I8088
+#ifdef I80386
if (i386_32)
defdword();
else
@@ -1157,7 +1169,7 @@ store_pt reg;
if (reg != BREG)
{
bumplc();
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -1463,7 +1475,7 @@ PUBLIC void outimmed()
PUBLIC void outjumpstring()
{
outop3str(jumpstring);
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -1571,7 +1583,7 @@ store_pt targreg;
PUBLIC void sbc0()
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
adjcarry();
@@ -1624,7 +1636,7 @@ PUBLIC void slconst(shift, reg)
value_t shift;
store_pt reg;
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
if ((shift = (uvalue_t) shift % INT32BITSTO) != 0)
@@ -1675,7 +1687,7 @@ PUBLIC void srconst(shift, uflag)
value_t shift;
bool_pt uflag;
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
if ((shift = (uvalue_t) shift % INT32BITSTO) != 0)
@@ -1767,9 +1779,11 @@ PRIVATE void opregadr()
outccname(opregstr);
outindright();
bumplc2();
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
+#endif
#ifdef MC6809
outregname(OPREG);
outtab();
diff --git a/bcc/const.h b/bcc/const.h
index fda6914..f41fe8b 100644
--- a/bcc/const.h
+++ b/bcc/const.h
@@ -10,10 +10,23 @@
#define SELFTYPECHECK /* check calculated type = runtime type */
#ifdef I8088
-# define DYNAMIC_LONG_ORDER 1 /* long word order spec. at compile time */
# define FRAMEPOINTER /* index locals off frame ptr, not stack ptr */
# define HOLDSTRINGS /* hold strings for dumping at end
* since assembler has only 1 data seg */
+# define DYNAMIC_LONG_ORDER 1 /* long word order spec. at compile time */
+
+#ifdef __AS386_16__
+
+/* Humm, not this is nasty :-) */
+#define float no_hope
+#define double no_hope
+#define atof atol
+#define NOFLOAT
+typedef long no_hope;
+
+#else
+# define I80386 /* Little BCC doesn't need 386 */
+#endif
#endif
#ifdef MC6809
diff --git a/bcc/exptree.c b/bcc/exptree.c
index c4da1c4..6b24eff 100644
--- a/bcc/exptree.c
+++ b/bcc/exptree.c
@@ -13,7 +13,11 @@
#include "sizes.h"
#include "type.h"
+#ifdef __AS386_16__
+#define ETREESIZE 300
+#else
#define ETREESIZE 1200
+#endif
#define errtype itype
#define redtype ctype
#define uredtype uctype
@@ -96,7 +100,7 @@ register struct nodestruct *nodeptr;
nodeptr->right = castnode(nodeptr->nodetype, right);
}
}
-#ifdef I8088
+#ifdef I80386
else if (i386_32 && bothscalar & SHORT)
{
nodeptr->nodetype = itype;
@@ -133,7 +137,11 @@ struct nodestruct *nodeptr;
PRIVATE void etreefull()
{
+#if ETREESIZE == 1200
limiterror("expression too complex (1201 nodes)");
+#else
+ limiterror("expression too complex (ETREESIZE)");
+#endif
}
PUBLIC void etreeinit()
@@ -1043,7 +1051,7 @@ struct nodestruct *nodeptr;
nodeptr->right = castnode(rscalar & UNSIGNED
? ultype : targtype, right);
}
-#ifdef I8088
+#ifdef I80386
else if (i386_32 && lscalar & INT)
{
if (rscalar & SHORT)
diff --git a/bcc/function.c b/bcc/function.c
index 1d48a19..7beaa14 100644
--- a/bcc/function.c
+++ b/bcc/function.c
@@ -234,7 +234,7 @@ struct symstruct *target;
PRIVATE void out_callstring()
{
outop3str(callstring);
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -305,7 +305,7 @@ PUBLIC void reslocals()
pushlist(doubleargregs);
break;
case 4:
-# ifdef I8088
+# ifdef I80386
if (!i386_32)
# endif
{
diff --git a/bcc/gencode.c b/bcc/gencode.c
index fa098ea..2f7ce5f 100644
--- a/bcc/gencode.c
+++ b/bcc/gencode.c
@@ -378,7 +378,7 @@ register uvalue_t number;
PUBLIC void codeinit()
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
/* Need DATREG2 for doubles although handling of extra data regs is
diff --git a/bcc/gencode.h b/bcc/gencode.h
index 370817a..a6b99ec 100644
--- a/bcc/gencode.h
+++ b/bcc/gencode.h
@@ -26,7 +26,7 @@ EXTERN offset_t framep; /* hardware relative frame ptr */
EXTERN uoffset_t func1saveregsize; /* choice of next two values */
EXTERN uoffset_t funcdsaveregsize; /* funcsaveregsize adjusted for doubles */
EXTERN uoffset_t funcsaveregsize; /* tot size of framelist/calleemask regs */
-#ifdef I8088
+#ifdef I80386
EXTERN bool_t i386_32; /* nonzero to generate 386 32 bit code */
/* depends on zero init */
#endif
diff --git a/bcc/genloads.c b/bcc/genloads.c
index 2056cb7..9c77032 100644
--- a/bcc/genloads.c
+++ b/bcc/genloads.c
@@ -124,7 +124,7 @@ PUBLIC store_pt getindexreg()
if (!(reguse & INDREG2))
return INDREG2;
#if NOTFINISHED
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
if (!(reguse & DATREG1))
@@ -579,7 +579,7 @@ store_pt targreg;
{
if ((store_t) targreg & ALLDATREGS && source->type->scalar & CHAR)
targreg = BREG;
-#ifdef I8088
+#ifdef I80386
if (i386_32 && source->type->scalar & SHORT &&
source->indcount <= 1)
{
@@ -642,7 +642,7 @@ struct symstruct *adr;
outshex(adr->offset.offi);
}
bumplc2();
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -691,7 +691,11 @@ struct symstruct *adr;
#ifdef I8088
case DATREG1:
case DATREG2:
+#ifdef I80386
if (indflag && !i386_32)
+#else
+ if (indflag)
+#endif
{
outnl();
badaddress();
@@ -784,8 +788,10 @@ struct symstruct *adr;
case GLOBAL:
#ifdef I8088
bumplc();
+#ifdef I80386
if (i386_32)
bumplc2();
+#endif
if (!indflag)
outimmed();
else
@@ -1014,8 +1020,11 @@ struct symstruct *source;
#ifdef I8088
else if ((source->indcount == 1 &&
(sscalar & (SHORT | INT | LONG | FLOAT) ||
- source->type->constructor & POINTER)) ||
- (source->storage == CONSTANT && i386_32))
+ source->type->constructor & POINTER))
+#ifdef I80386
+ || (source->storage == CONSTANT && i386_32)
+#endif
+ )
{
size = source->type->typesize;
if (size == 1)
@@ -1033,6 +1042,7 @@ struct symstruct *source;
outpshs();
bumplc();
outtab();
+#ifdef I80386
if (i386_32)
{
if (source->storage == CONSTANT)
@@ -1048,6 +1058,7 @@ struct symstruct *source;
else
outdword();
}
+#endif
outadr(source);
sp -= size;
}
@@ -1200,7 +1211,7 @@ struct symstruct *target;
unbumplc();
outnnadr(target);
outcomma();
-#ifdef I8088
+#ifdef I80386
if (i386_32 && target->type->scalar & SHORT)
{
outshortregname(sourcereg);
diff --git a/bcc/glogcode.c b/bcc/glogcode.c
index e2d086b..2f39080 100644
--- a/bcc/glogcode.c
+++ b/bcc/glogcode.c
@@ -64,7 +64,7 @@ ccode_t *pcondtrue;
cmplocal(source, target, pcondtrue);
#if 0
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
if (*pcondtrue == LO)
@@ -475,12 +475,14 @@ ccode_t *pcondtrue;
if (target->offset.offi != 0 && cc_signed(*pcondtrue))
load(target, targreg);
+#ifdef I80386
/* Extension was not done in exptree for the == 0 case, to allow
* optimization here - which we don't do for shorts. (foo--) is
* newfoo == -1 here and used to be missed.
*/
if (i386_32 && target->type->scalar & SHORT)
extend(target);
+#endif
if (target->offset.offi == 0)
{
diff --git a/bcc/hardop.c b/bcc/hardop.c
index 098d22b..51f9616 100644
--- a/bcc/hardop.c
+++ b/bcc/hardop.c
@@ -352,7 +352,7 @@ struct symstruct *target;
}
else
outregname(BREG);
-# ifdef I8088
+# ifdef I80386
if (i386_32 && !(sscalar & CHAR))
bumplc2();
# endif
diff --git a/bcc/idcc b/bcc/idcc
new file mode 100755
index 0000000..a04afc8
--- /dev/null
+++ b/bcc/idcc
@@ -0,0 +1,311 @@
+#!/bin/ash
+#
+# This is a shell version of the bcc compiler driver. It's a little slower
+# than a C version but overall seems to be a lot cleaner, perhaps a C version
+# based on this might be a good idea ...
+#
+# The compiler works on a 'modal' basis certain flags given to it put the
+# compiler into specific modes, it can only be in one mode for a run.
+#
+# The mode defines the basic passes and specific options that are available
+#
+# To define a mode see the functions 'run_0' and 'run_3' for examples. The
+# variable assignments just above the definitions enable the functions.
+#
+# This script is specifically designed so the there is as little interaction
+# between the modes as is possible.
+#
+# It's run using ash because this appears to be _much_ faster than bash, it's
+# also reasonable with ksh.
+# (On other interpreters I think perl would be too big, but awk might work...)
+#
+
+TMPFIL="/tmp/cc$$"
+trap "rm -f $TMPFIL.* ; exit 1" 1 2 3 15
+TMPCNT=0
+
+FILES=
+OPTS=
+RESEXTN=
+OPTIM=no
+VERBOSE=no
+MULTISRC=no
+
+LDOPTS=
+DESTDEF=no
+LDDEST=a.out
+DEFMODE=0
+
+ccmode=
+LIBPATH="/lib:/usr/lib:/usr/bin"
+
+main() {
+ scanargs "$@"
+
+ PATH="$LIBPATH:$PATH"
+ [ "$EXEC_PREFIX" != "" ] && PATH="$EXEC_PREFIX:$PATH"
+
+ rv=0
+ LDFILES=
+ [ "$MULTISRC" = yes -o "$RESEXTN" = "" ] && DESTDEF=no
+
+ for FILE in $FILES
+ do
+ case "$FILE" in
+ *.c ) PASS=cpp ; BASE="`basename $FILE .c`" ;;
+ *.s ) PASS=as ; BASE="`basename $FILE .s`" ;;
+ * ) PASS=lnk ;;
+ esac
+
+ NAME="`basename $FILE`"
+ DEST="`dirname $FILE`/"
+ [ "$DEST" = "./" ] && DEST=
+ DEST="$DEST$BASE.$RESEXTN"
+ [ "$DESTDEF" = yes ] && DEST="$LDDEST"
+
+ STEMP=0 INTEMP=0
+ [ "$PASS" = "cpp" ] && { compile $FILE || rv=$? ; }
+ [ "$PASS" = "as" ] && { assem $FILE || rv=$? ; }
+ if [ "$PASS" = "lnk" ]
+ then
+ LDFILES="$LDFILES $FILE"
+ else
+ # If there's a fail can't link - still assembling to temps tho.
+ [ "$RESEXTN" = "" ] && RESEXTN=O
+ fi
+ [ "$STEMP" = 1 ] && rm -f "$SFILE"
+ [ "$INTEMP" = 1 ] && RMFILES="$RMFILES $FILE"
+ done
+
+ [ "$RESEXTN" != "" ] && exit $rv
+
+ [ "$VERBOSE" = yes ] &&
+ echo "$LD $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS"
+
+ $LD $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS
+ rv=$?
+ [ "$RMFILES" != "" ] && rm -f $RMFILES
+ exit "$rv"
+}
+
+scanargs() {
+ WILDOPT=no
+
+ while [ "$#" -gt 0 ]
+ do
+ case "$1" in
+ -[DU]* ) CPPDEFS="$CPPDEFS $1" ;;
+ -B?* ) PATH="`echo '.$1:$PATH' | sed 's/...//'`" ;;
+ -I?* ) CPPFLAGS="$CPPFLAGS $1" ;;
+ -L?* ) LDOPTS="$LDOPTS $1" ;;
+ -o ) LDDEST="$2"; DESTDEF=yes ; shift ;;
+ -b ) . /usr/lib/idcc/opts_$2 || exit 1; shift ;;
+ -E ) RESEXTN=i ;;
+ -S ) RESEXTN=s ;;
+ -c ) RESEXTN=o ;;
+ -O ) OPTIM=yes ;;
+ -v ) VERBOSE=yes ;;
+ -l?* ) FILES="$FILES $1" ; MULTISRC=yes ;;
+ -* ) OPTS="$OPTS `echo .$1 | sed 's/..//'`" ;;
+ * ) [ "$FILES" != "" ] && MULTISRC=yes ; FILES="$FILES $1" ;;
+ esac
+ shift
+ done
+
+ while [ "$OPTS" != "" -o "$DEFMODE" != "" ]
+ do
+ # So they can try again ... with DEFMODE if needed
+ MOPTS="$OPTS"
+ OPTS=
+
+ for opt in $MOPTS
+ do
+ # Option can be defined only for specific mode so if we haven't seen
+ # the mode yet save the opt. If we have check for conflicts too.
+ [ "$ccmode" = "" -a "$DEFMODE" != "" ] && {
+ eval "[ \"\$opt_$opt\" = yes ]" || { OPTS="$OPTS $opt" ; opt= ; }
+ }
+ [ "$opt" != "" ] && {
+ [ "$ccmode" = "" ] || {
+ eval "[ \"\$mode_$opt\" = yes ]" && {
+ echo Option "-$opt incompatible with -$ccmode" 1>&2
+ exit 2
+ }
+ }
+
+ eval "[ \"\$opt_$opt\" = yes ]" || {
+ { eval "[ \"$WILDOPT\" = yes ]" && wild_opt "-$opt" ; } || {
+ echo Option '-'$opt unknown for this mode 1>&2
+ exit 3
+ }
+ }
+
+ eval "[ \"\$opt_$opt\" = yes ]" && run_$opt
+ eval "[ \"\$mode_$opt\" = yes ]" && ccmode="$opt"
+ }
+ done
+ [ "$ccmode" = "" -a "$DEFMODE" != "" ] && OPTS="$DEFMODE $OPTS"
+ DEFMODE=
+ done
+}
+
+compile() {
+ [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; }
+
+ [ "$RESEXTN" = "i" ] && {
+ cpp_only $FILE
+ return
+ }
+
+ # Loop for the pass list
+ # The CCX variables _are_ expanded again.
+
+ ret=1
+ for pass in $PASSLIST
+ do
+ for extn in '' pre post inf res opt
+ do eval "CCX$extn=\"\$CC$pass$extn\""
+ done
+
+ [ "$CCX" = "" ] && continue;
+ [ "$OPTIM" = "" -a "$CCXopt" = yes ] && continue;
+
+ shuffel "$RESEXTN" $CCXres
+ [ "$VERBOSE" = yes ] &&
+ eval "echo \"$CCX $CCXpre $SFILE $CCXinf $FILE $CCXpost\""
+ eval "$CCX $CCXpre $SFILE $CCXinf $FILE $CCXpost" || return 1
+ ret=0
+ done
+ [ "$ret" = 1 ] && { echo 'CC configuration error' 1>&2 ; return $ret ; }
+
+ [ "$RESEXTN" != "s" ] && PASS=as
+ return 0
+}
+
+assem() {
+ [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; }
+
+ shuffel "$RESEXTN" o
+
+ n=
+ [ "$ASNAME" != "" ] && n="$ASNAME$NAME"
+
+ [ "$VERBOSE" = yes ] && echo "$AS $ASFLAGS $n $SFILE -o $FILE"
+ $AS $ASFLAGS $n $SFILE -o $FILE || return
+
+ [ "$RESEXTN" != "o" ] && PASS=lnk
+ return 0
+}
+
+if [ "2" = "$[1+1]" ] ; then inc_tmpcnt() { TMPCNT="$[$TMPCNT+1]" ; }
+else inc_tmpcnt() { TMPCNT="`expr $TMPCNT + 1`" ; }
+fi
+
+shuffel() {
+ [ "$STEMP" = 1 ] && rm -f "$SFILE"
+
+ SFILE="$FILE"
+ STEMP="$INTEMP"
+
+ if [ "$1" = "$2" ]
+ then
+ FILE="$DEST"
+ INTEMP=0
+ else
+ inc_tmpcnt
+ FILE="$TMPFIL.$TMPCNT.$2"
+ INTEMP=1
+ fi
+}
+
+mode_0=yes opt_0=yes
+run_0()
+{
+ SYSINC="-I/usr/bcc/include"
+ SYSLIB="-L/usr/bcc/lib/bcc/i86/"
+ LIBPATH="/usr/bcc/lib/bcc"
+ CRT0="-C0"
+ LIBS="-lc"
+ CGEN=
+ DEFS=
+
+ CPP="cpp"
+
+ PASSLIST=2
+ CC2="bcc-cc1" CC2pre='$SYSINC $DEFS $CPPFLAGS'
+ CC2inf='-o' CC2post='-0 $CGEN $CPPDEFS' CC2res=s
+ AS="as86" ASFLAGS='-u -w -0' ASNAME='-n '
+ LD="ld86" LDFLAGS='-i -0'
+
+ opt_ansi=yes
+ run_ansi()
+ {
+ PASSLIST="0 1 2"
+ CC0="bcc-cc1" CC0pre='$SYSINC $DEFS $CPPFLAGS' CC0inf='-o'
+ CC0post='-0 -E -D__STDC__=0 $CPPDEFS' CC0res=i
+ CC1="unproto" CC1pre='' CC1inf='' CC1post='' CC1res=k
+ CC2="bcc-cc1" CC2pre='$CGEN' CC2inf='-o' CC2post='-0' CC2res=s
+ }
+ opt_I=yes; run_I() { SYSINC= ; }
+ opt_L=yes; run_L() { SYSLIB= ; }
+ opt_s=yes; run_s() { LDFLAGS="$LDFLAGS -s" ; }
+ opt_Mf=yes; run_Mf() { LIBS=-lc_f ; CGEN='-f -c' ;}
+ opt_Md=yes; run_Md() { LIBS=-ldos ; DEFS='-D__MSDOS__' LDFLAGS='-i -0 -d' ;}
+
+ WILDOPT=yes
+ wild_opt()
+ {
+ case "$1" in
+ -O* ) OPTIM=yes ; OPTFLG="$OPTFLG $1" ;;
+ * ) return 1 ;;
+ # For normal CC operation unknowns go to the linker. ie:
+ # * ) LDFLAGS="$LDFLAGS $1" ; return 0 ;;
+ esac
+ return 0
+ }
+}
+
+mode_3=yes opt_3=yes
+run_3()
+{
+ SYSINC="-I/usr/bcc/include"
+ SYSLIB="-L/usr/bcc/lib/bcc/i386/"
+ LIBPATH="/usr/bcc/lib/bcc"
+ CRT0="-C0"
+ LIBS="-lc"
+ CGEN=
+ DEFS=
+
+ CPP="cpp"
+
+ PASSLIST=2
+ CC2="bcc-cc3" CC2pre='$SYSINC $DEFS $CPPFLAGS'
+ CC2inf='-o' CC2post='-3 $CGEN $CPPDEFS' CC2res=s
+ AS="as86" ASFLAGS='-u -w -3' ASNAME='-n '
+ LD="ld86" LDFLAGS='-i -3'
+
+ opt_ansi=yes
+ run_ansi()
+ {
+ PASSLIST="0 1 2"
+ CC0="bcc-cc3" CC0pre='$SYSINC $DEFS $CPPFLAGS' CC0inf='-o'
+ CC0post='-3 -E -D__STDC__=0 $CPPDEFS' CC0res=i
+ CC1="unproto" CC1pre='' CC1inf='' CC1post='' CC1res=k
+ CC2="bcc-cc1" CC2pre='$CGEN' CC2inf='-o' CC2post='-3' CC2res=s
+ }
+ opt_I=yes; run_I() { SYSINC= ; }
+ opt_L=yes; run_L() { SYSLIB= ; }
+ opt_s=yes; run_s() { LDFLAGS="$LDFLAGS -s" ; }
+
+ WILDOPT=yes
+ wild_opt()
+ {
+ case "$1" in
+ -O* ) OPTIM=yes ; OPTFLG="$OPTFLG $1" ;;
+ * ) return 1 ;;
+ esac
+ return 0
+ }
+}
+
+main "$@"
diff --git a/bcc/input.c b/bcc/input.c
index 3d77bbf..c6fbb32 100644
--- a/bcc/input.c
+++ b/bcc/input.c
@@ -466,7 +466,9 @@ char *argv[];
#endif
fd = 0; /* standard input */
memset(flag, 0, sizeof flag);
+#ifdef I80386
flag['3'] = sizeof (int) >= 4;
+#endif
fname = "stdin";
(incptr = &incfirst)->incnext = &inclast;
initout();
@@ -486,6 +488,8 @@ char *argv[];
{
#ifdef I8088
case '0': /* generate 16-bit code */
+#endif
+#ifdef I80386
case '3': /* generate 32-bit code */
#endif
case 'c': /* caller saves */
@@ -539,12 +543,14 @@ ts_s_includelist += sizeof *incnew;
}
}
#ifdef I8088
+#ifdef I80386
if (flag['3'])
{
i386_32 = TRUE;
definestring("__AS386_32__");
}
else
+#endif
definestring("__AS386_16__");
#endif
#ifdef MC6809
@@ -585,6 +591,9 @@ ts_s_includelist += sizeof *incnew;
definestring("__POS_INDEPENDENT__");
}
#endif
+#ifdef NOFLOAT
+ definestring("__HAS_NO_FLOATS__");
+#endif
ctext = flag['t'];
watchlc = flag['w'];
setoutbufs();
diff --git a/bcc/label.c b/bcc/label.c
index 5b07af9..394a47c 100644
--- a/bcc/label.c
+++ b/bcc/label.c
@@ -316,9 +316,11 @@ label_t label;
outbyte(' ');
outtab();
bumplc2();
+#ifdef I80386
if (i386_32)
bumplc();
#endif
+#endif
#ifdef MC6809
outcond(cond);
bumplc();
diff --git a/bcc/ncc.c b/bcc/ncc.c
deleted file mode 100644
index d48e522..0000000
--- a/bcc/ncc.c
+++ /dev/null
@@ -1,215 +0,0 @@
-
-#include <stdio.h>
-
-/* 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<argc; ar++)
- if(argv[ar][0] == '-') switch(argv[ar][1])
- {
- case 'o': ar++; break;
- case 'b': if(argv[ar][2]) break;
- ar++;
- if( argv[ar] == 0 ) fatal("-b needs specifier");
- strncpy(model, argv[ar], sizeof(model)-1);
- break;
- default: /* Scan builtin_models */
- }
-
- /* Space for filenames */
- file_list = calloc(argc, sizeof(char*));
- if( file_list == 0 ) fatal("Out of memory");
-
- /* Perhaps: make builtin_models[0].spec the default ? */
-
- for(ar=0; ar<standard_argc; )
- ar += decode_arg(standard_argv[ar], standard_argv[ar+1]);
-
- /* The model isn't in the standard args ... */
- if( !model_found )
- {
- strcat(little_buf, exec_paths[0]);
- strcat(little_buf, "/spec");
- include_file(little_buf);
- }
- if( !model_found && strcmp(model, "-") != 0 )
- {
- strcat(little_buf, exec_paths[0]);
- strcat(little_buf, "/spec.");
- strcat(little_buf, model);
- include_file(little_buf);
- }
- if( !model_found ) fatal("Unable to find compiler specification");
-
- /* Now we can do the command line for real */
- for(ar=1; ar<argc; )
- ar += decode_arg(argv[ar], argv[ar+1]);
-
- /* Compile all the files to objects; save the names back in file_table */
- for(ar=0; ar<file_count; ar++)
- do_compile(file_table[ar]);
-
- /* If everything was OK then find the pass with a nul result type */
- if( exit_status == 0 )
- do_link_command();
-
- return exit_status;
-}
-
-decode_arg(arg1, arg2)
-char * arg1;
-char * arg2;
-{
- if(arg1[0] == '-' && arg1[2] == '\0') switch(arg1[1])
- {
- case 'v': verbose++; return 1;
- case 'o': if( arg2 == 0 ) fatal("-o needs filename");
- output_file = arg2;
- return 2;
- case 'b': if( arg2 == 0 ) fatal("-b needs specifier");
- args_active = 1;
- if( strcmp(arg2, "-") == 0)
- return 2;
- else if( strcmp(arg2, model) == 0)
- ;
- else if( strcmp(model, "-") == 0)
- strncpy(model, arg2, sizeof(model)-1);
- else
- {
- args_active=0;
- return 2;
- }
- model_found = 1;
- return 2;
-
- default: /* Lookup item in conversion table */
- }
- else if( args_active == 0 )
- return 1;
- else if(arg1[0] == '-' ) switch(arg1[1])
- {
- case '@': include_file(arg1+2); return 1;
- case 'B': add_path(exec_path, arg1+2); return 1;
- case 'W': command_W(arg1+2); return 1;
- case 'T': command_T(arg1+2); return 1;
- /* -T0,bcc-cc1,-0,-i,$1,$2,-o,$3 ie add standard args */
-
- default: /* Lookup item in conversion table */
- }
- else
- {
- file_names[file_count++] = arg1;
- return 1;
- }
-
- /* Do conversion ... */
- /*
- * 1) Locate arg in options
- * 2) for each semicolon seperated item
- * 3) pass it to decode_arg
- * 4) remember to give it 2 args for '-b'
- *
- * Note: char '*' in the options table matches the rest of the arg.
- */
- return 1;
-}
-
-include_file(fname)
-char * fname;
-{
- FILE * fd;
- char line_buffer[512];
- char * p;
-
- RIGHT HERE
-
- fd = fopen(fname, "r");
- if( fd == 0 ) fatal("Cannot open command line file");
-
- while( fgets(line_buffer, sizeof(line_buffer), fd) )
- {
- if( line_buffer[0] == '#' ) continue;
-
- }
- fclose(fd);
-}
-
-command_T(arg1)
-char * arg1;
-{
- /* Is it an option specifier ? */
- if(arg1[0] == '-')
- {
- argend = strchr(arg1, ';');
-
-
- }
- else /* Must be a pass specifier or modifier */
- {
-
- }
-}
diff --git a/bcc/scan.c b/bcc/scan.c
index 5b7bb9a..9ff697d 100644
--- a/bcc/scan.c
+++ b/bcc/scan.c
@@ -724,8 +724,16 @@ PUBLIC void stringorcharconst()
if (ch == terminator)
{
*charptr++ = terminator;
- gch1();
- break;
+
+ /* This adds ansi string concatenation BUT only on one line */
+ do { gch1(); } while(SYMOFCHAR(ch) == WHITESPACE);
+ if( ch == terminator ) /* Hang on .. that's another string ... */
+ {
+ charptr--; /* Stick it together */
+ gch1();
+ }
+ else
+ break;
}
}
}
diff --git a/bcc/state.c b/bcc/state.c
index 36140c2..1d0dd04 100644
--- a/bcc/state.c
+++ b/bcc/state.c
@@ -342,7 +342,7 @@ PRIVATE void docont()
#ifdef MC6809
outcregname(LOCAL);
#endif
-#ifdef I8088
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
@@ -669,9 +669,11 @@ offset_t offset;
outswstacklab();
#ifdef I8088
bumplc();
+#ifdef I80386
if (i386_32)
bumplc2();
#endif
+#endif
}
PUBLIC void outswstacklab()
diff --git a/bcc/table.c b/bcc/table.c
index e2580da..7f4a1ac 100644
--- a/bcc/table.c
+++ b/bcc/table.c
@@ -25,10 +25,18 @@
#define GOLDEN 157 /* GOLDEN/HASHTABSIZE approx golden ratio */
#define HASHTABSIZE 256
#define MARKER ((unsigned) 0x18C396A5L) /* lint everywhere it is used */
+#ifdef __AS386_16__
+#define MAXEXPR 125
+#else
#define MAXEXPR 500
+#endif
#define MAXLOCAL 100
#define NKEYWORDS 35
+#ifdef NOFLOAT
+#define NSCALTYPES 10
+#else
#define NSCALTYPES 12
+#endif
#define STACKSPACE 256 /* punt for normal recursions - switch extra */
struct keywordstruct
@@ -134,8 +142,10 @@ PRIVATE struct typedatastruct scaltypes[NSCALTYPES] =
{ "int", FALSE, UNSIGNED | INT, 2, &uitype, },
{ "long", TRUE, LONG | DLONG, 4, &ltype, },
{ "long", FALSE, UNSIGNED | LONG | DLONG, 4, &ultype, },
+#ifndef NOFLOAT
{ "float", TRUE, FLOAT, 4, &fltype, },
{ "double", TRUE, DOUBLE, 8, &dtype, },
+#endif
};
FORWARD struct symstruct *addkeyword P((char *name, sym_pt code));
@@ -419,7 +429,11 @@ struct symstruct *symptr;
newsymptr = exprptr++;
if (exprptr >= &exprsyms[MAXEXPR])
+#if MAXEXPR == 500
limiterror("expression too complex (501 symbols)");
+#else
+ limiterror("expression too complex (MAXEXPR)");
+#endif
*newsymptr = *symptr;
newsymptr->level = EXPRLEVEL;
newsymptr->name.namep = symptr->name.namea;
diff --git a/bcc/type.c b/bcc/type.c
index 4852c9d..7e40f93 100644
--- a/bcc/type.c
+++ b/bcc/type.c
@@ -179,7 +179,7 @@ struct typestruct *type;
PUBLIC void typeinit()
{
-#ifdef I8088
+#ifdef I80386
if (i386_32)
{
uitype->typesize =