summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-08-11 08:50:48 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:48 +0200
commit26ade8d624457b7164502ed9c190ca3f146bda0c (patch)
tree75a70b6a562bc595c971e170994a8e302a8c7b3b
parent660429af0232d4afcb3e03fb0437053dd6e16286 (diff)
downloaddev86-26ade8d624457b7164502ed9c190ca3f146bda0c.tar.gz
Import Dev86src-0.16.8.tar.gzv0.16.8
-rw-r--r--Changes33
-rw-r--r--Makefile2
-rw-r--r--Mk_dist77
-rw-r--r--bcc/assign.c2
-rw-r--r--bcc/bcc.c17
-rw-r--r--bcc/codefrag.c2
-rw-r--r--bcc/debug.c4
-rw-r--r--bcc/declare.c27
-rw-r--r--bcc/function.c26
-rw-r--r--bcc/gencode.h1
-rw-r--r--bcc/genloads.c18
-rw-r--r--bcc/input.c3
-rw-r--r--bcc/preserve.c14
-rw-r--r--bcc/state.c1
-rw-r--r--copt/copt.c28
-rw-r--r--copt/rules.18610
-rw-r--r--copt/rules.3864
-rw-r--r--copt/rules.86182
-rw-r--r--copt/rules.end5
-rw-r--r--copt/rules.i6
-rw-r--r--copt/rules.start4
-rw-r--r--cpp/Makefile14
-rw-r--r--cpp/c.c10
-rw-r--r--cpp/cpp.c75
-rw-r--r--cpp/hash.c2
-rw-r--r--cpp/main.c42
-rw-r--r--cpp/token1.c5
-rw-r--r--cpp/token1.h117
-rw-r--r--cpp/token2.c5
-rw-r--r--cpp/token2.h139
-rw-r--r--libc/bios/Makefile2
-rw-r--r--libc/bios/bios_disk.c6
-rw-r--r--libc/include/stdarg.h2
-rw-r--r--libc/include/stdlib.h13
-rw-r--r--libc/string/string.c1
-rw-r--r--makefile.in2
-rw-r--r--man/bcc.112
37 files changed, 756 insertions, 157 deletions
diff --git a/Changes b/Changes
index f3ee981..49a943f 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,38 @@
For version 0.16.*.
+> The fopen function (and friends) is now a real function not a macro.
+
+> Ctype.h updated to ansi.
+
+> Libraries appear to compile properly with -O and -ansi now.
+
+> Copt's hash string table adjusted; should now have fewer pathological cases.
+
+> Order of copt's rule processing reversed; it now works from the top of a
+ rule file to the bottom. Also comment lines may be include in the match
+ lines. !BCC_EOS added to bcc-cc1 for 'end of statment'.
+
+> bcc-cc1's asm("") now works in declare mode too.
+
+> New independed cpp added, has both K&R and Ansi modes.
+ Changes made to the embedded cpp too to try and fix some bad bits.
+
+> Conditional assembler added around push and pop of 'si' and 'di' if the
+ optimiser (and as86's optimiser) are to be run.
+
+> Signed keyward added to bcc-cc1 for 'signed char' also words with other
+ int types but is usually just a noiseword.
+
+> As86 macro syntax altered, you new don't have to include any brackets.
+
+> Various test and old document files removed.
+
+> Gcc warnings in ar86 cleaned up.
+
+> Mk_dist now make incremental patch files too.
+
+> Update magic file.
+
> Various updates to the bios libc, the vt52 and ansi emulations are
now seperated (and can be both included if needed) and don't have
to be linked. Conio functions work properly in bios and msdos.
diff --git a/Makefile b/Makefile
index 92fb9ae..e6c51c0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
# This file is part of the Linux-8086 Development environment and is
# distributed under the GNU General Public License.
-VERSION=0.16.7
+VERSION=0.16.8
TARGETS= \
clean bcc unproto copt as86 ld86 elksemu \
diff --git a/Mk_dist b/Mk_dist
index a72b9c9..86218e8 100644
--- a/Mk_dist
+++ b/Mk_dist
@@ -1,4 +1,4 @@
-#!/bin/sh -
+#!/bin/bash -
#
# This script builds _and checks_ all the distribution files from my source
# directory. It's very selective because I've got a lot of historical and
@@ -68,15 +68,46 @@ mkdir ${TMPDIST}/doselks
rm -f /tmp/bootblocks.tar.gz /tmp/doselks.tar.gz /tmp/libc-8086-$VERSION.tar.gz
-echo Extracting previous version
-rm -f $ARCDIR/Dev86src-$VERSION.tar.gz
+MINOR=${VERSION##*.}
+MAJOR=${VERSION%.*}
+MID=${MAJOR##*.}
+MAJOR=${MAJOR%.*}
+OLDVER=
+
+case "$VERSION" in
+0.0.0 ) BASEVER=0.0.0.0 ;; # Naa.
+*.0.0 ) BASEVER=$((MAJOR-1)).$MID.$MINOR ;;
+*.*.0 ) BASEVER=$MAJOR.$((MID-1)).$MINOR ;;
+* ) BASEVER=$MAJOR.$MID.$((MINOR-1))
+ OLDVER=$MAJOR.$MID.0
+ ;;
+esac
+if [ "$MAJOR.$MID.$((MINOR-1))" != "$BASEVER" ]
+then PATCHNAME="$VERSION-$BASEVER"
+else PATCHNAME="$VERSION"
+fi
+
+[ -f $ARCDIR/Dev86src-$BASEVER.tar.gz ] && {
+ echo "Extracting previous version ($BASEVER)"
+
+ mkdir ${TMPDIST}.tmp
+ ( cd ${TMPDIST}.tmp
+ tar xzf $ARCDIR/Dev86src-$BASEVER.tar.gz
+ mv * ${TMPDIST}.old
+ )
+ rmdir ${TMPDIST}.tmp
+}
-mkdir ${TMPDIST}.tmp
-( cd ${TMPDIST}.tmp
- tar xzf `ls -tr $ARCDIR/Dev86src*.0.tar.gz | tail -1`
- mv * ${TMPDIST}.old
-)
-rmdir ${TMPDIST}.tmp
+[ "$OLDVER" != "" -a -f $ARCDIR/Dev86src-$OLDVER.tar.gz ] && {
+ echo "Extracting previous version ($OLDVER)"
+
+ mkdir ${TMPDIST}.tmp
+ ( cd ${TMPDIST}.tmp
+ tar xzf $ARCDIR/Dev86src-$OLDVER.tar.gz
+ mv * ${TMPDIST}.vold
+ )
+ rmdir ${TMPDIST}.tmp
+}
# ARCDIR=${TMPDIR}/arc ; mkdir -p ${ARCDIR}
cd ${TMPDIST}
@@ -101,21 +132,39 @@ cd ${TMPDIST}
rm -f $EXCL
rm -f `find . -type l`
-echo Generating patch against previous .0 version.
-
cd ${TMPDIR}
+[ -d ${TMPSRC}.old ] && {
+echo "Generating patch against version $BASEVER."
+
mv ${TMPSRC}.old/bootblocks boot.old
mv ${TMPSRC}/bootblocks boot
-diff -Nurd ${TMPSRC}.old ${TMPSRC} > ${ARCDIR}/Dev86src-$VERSION.patch
+diff -Nurd ${TMPSRC}.old ${TMPSRC} > ${ARCDIR}/patch-$PATCHNAME
mv boot.old ${TMPSRC}.old/bootblocks
mv boot ${TMPSRC}/bootblocks
-diff -Nurd ${TMPSRC}.old/bootblocks ${TMPSRC}/bootblocks >> ${ARCDIR}/Dev86src-$VERSION.patch
+diff -Nurd ${TMPSRC}.old/bootblocks ${TMPSRC}/bootblocks >> ${ARCDIR}/patch-$PATCHNAME
+
+gzip -f9 ${ARCDIR}/patch-$PATCHNAME
+}
+
+[ -d ${TMPSRC}.vold ] && {
+echo "Generating patch against version $OLDVER."
+
+mv ${TMPSRC}.vold/bootblocks boot.old
+mv ${TMPSRC}/bootblocks boot
+
+diff -Nurd ${TMPSRC}.vold ${TMPSRC} > ${ARCDIR}/patch-$VERSION-$OLDVER
+
+mv boot.old ${TMPSRC}.vold/bootblocks
+mv boot ${TMPSRC}/bootblocks
+
+diff -Nurd ${TMPSRC}.vold/bootblocks ${TMPSRC}/bootblocks >> ${ARCDIR}/patch-$VERSION-$OLDVER
-gzip -f9 ${ARCDIR}/Dev86src-$VERSION.patch
+gzip -f9 ${ARCDIR}/patch-$VERSION-$OLDVER
+}
echo Creating full source archive.
ln -s ${TMPSRC} dev86-$VERSION
diff --git a/bcc/assign.c b/bcc/assign.c
index 2dce7c4..f6b08c7 100644
--- a/bcc/assign.c
+++ b/bcc/assign.c
@@ -356,7 +356,7 @@ struct symstruct *target;
load(target, DREG);
if (target->type == sctype)
sctoi();
-#ifdef I8088
+#if defined(I8088) && defined(I80386)
else if (tscalar & SHORT)
{
if (tscalar & UNSIGNED)
diff --git a/bcc/bcc.c b/bcc/bcc.c
index 289767e..1a0d4e3 100644
--- a/bcc/bcc.c
+++ b/bcc/bcc.c
@@ -302,9 +302,9 @@ struct file_list * file;
command_opts('p');
if (!opt_e)
{
- command_opts('c');
if (opt_arch<5 && !do_as)
command_opt("-t");
+ command_opts('c');
}
if (!opt_I)
@@ -337,6 +337,9 @@ struct file_list * file;
command_reset();
newfilename(file, !(do_optim || do_as), 's', (opt_arch != 3 && opt_arch<5));
+ if (opt_arch<5 && !do_as)
+ command_opt("-t");
+
command_opts('c');
command_arch();
@@ -361,8 +364,8 @@ struct file_list * file;
}
command_opt(optim_rules);
- command_opt("rules.start");
command_opts('o');
+ command_opt("rules.start");
if (opt_O)
{
sprintf(buf, "rules.%c86", opt_O);
@@ -435,6 +438,9 @@ run_link()
command_opt("-o");
command_opt(executable_name);
+ if (opt_arch < 2)
+ command_opt("-y");
+
command_opts('l');
if (opt_arch != 2)
{
@@ -754,6 +760,9 @@ char ** argv;
case 'X':
append_option(opt_arg, 'l');
break;
+ case 'u':
+ append_option(opt_arg, 'u');
+ break;
case 'L':
append_option(argv[ar], 'l');
@@ -767,6 +776,8 @@ char ** argv;
do_optim=1;
if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '3' ))
opt_O = opt_arg[0];
+ else if (opt_arg[0] == '-')
+ append_option(opt_arg, 'o');
else
{
char * p = xalloc(strlen(opt_arg)+8);
@@ -935,6 +946,8 @@ char ** argv;
opt_arch = 2;
prepend_option("-D__unix__", 'p');
prepend_option("-D__linux__", 'p');
+ /* This one works (in Debian potato), /usr/bin/gcc crashes. */
+ add_prefix("/usr/bin/i486-linuxlibc1-");
break;
case '8': /* Use 'c386' program as compiler */
opt_arch = 3;
diff --git a/bcc/codefrag.c b/bcc/codefrag.c
index 041a148..7783562 100644
--- a/bcc/codefrag.c
+++ b/bcc/codefrag.c
@@ -375,6 +375,7 @@ PRIVATE void tfrlohi()
outhiaccum();
outncregname(BREG);
}
+#ifdef I80386
PUBLIC void ustoi()
{
outmovzx();
@@ -383,6 +384,7 @@ PUBLIC void ustoi()
outshortregname(DREG);
outnl();
}
+#endif /* I80386 */
#endif /* I8088 */
#ifdef MC6809
diff --git a/bcc/debug.c b/bcc/debug.c
index e437f78..2b1e12e 100644
--- a/bcc/debug.c
+++ b/bcc/debug.c
@@ -161,7 +161,7 @@ struct nodestruct *exp;
{
if (!debugon)
return;
- comment();
+ outstr("! Debug: ");
if (exp->tag < FIRSTOP && exp->tag > LASTOP)
outstr("unknown op");
else
@@ -186,7 +186,7 @@ struct nodestruct *exp;
PUBLIC void debugswap()
{
if (debugon)
- outnstr("* swapping");
+ outnstr("! Debug: expression subtree swapping");
}
PRIVATE void outindchars(byte, count)
diff --git a/bcc/declare.c b/bcc/declare.c
index 3dfb26b..1b9e00a 100644
--- a/bcc/declare.c
+++ b/bcc/declare.c
@@ -693,8 +693,34 @@ PRIVATE void declfunc()
if( main_flag > 2 )
globl("environ");
}
+#ifdef I8088
+ regfuse = 0;
+#endif
lbrace();
compound();
+#ifdef I8088
+ if (regfuse & callee1mask) {
+ outstr("! Register");
+ if (regfuse & INDREG0 & callee1mask) outstr(" BX");
+ if (regfuse & INDREG1 & callee1mask) outstr(" SI");
+ if (regfuse & INDREG2 & callee1mask) outstr(" DI");
+ outstr(" used in function ");
+ outnstr(funcname);
+ if (optimise && !callersaves) {
+ outstr(funcname);
+ outnstr(".off = 0");
+ }
+ } else
+ if (optimise && !callersaves) {
+ outstr(funcname);
+ outstr(".off = ");
+#ifndef I80386
+ outnhex(4);
+#else
+ outnhex(i386_32?12:4);
+#endif
+ }
+#endif
clearfunclabels();
}
@@ -1122,6 +1148,7 @@ PUBLIC void rparen()
PUBLIC void semicolon()
{
+ outnstr("!BCC_EOS");
if (sym != SEMICOLON)
need(';');
else
diff --git a/bcc/function.c b/bcc/function.c
index e3dcd61..1f8b6f3 100644
--- a/bcc/function.c
+++ b/bcc/function.c
@@ -271,7 +271,18 @@ PRIVATE void out_callstring()
PUBLIC void popframe()
{
#ifdef STUPIDFRAME
- poplist(callee1mask); /*XXX: Add if round this */
+#ifndef NO_DEL_PUSH
+ if (optimise && !callersaves) {
+ outstr("if ");
+ outstr(funcname);
+ outnstr(".off=0");
+ }
+ poplist(callee1mask);
+ if (optimise && !callersaves)
+ outnstr("endif");
+#else
+ poplist(callee1mask);
+#endif
poplist(FRAMEREG);
#else
poplist(frame1list);
@@ -313,7 +324,18 @@ PUBLIC void reslocals()
pushreg(FRAMEREG);
regtransfer(STACKREG, FRAMEREG);
framep = sp;
- pushlist(callee1mask); /*XXX: Add if round this */
+#ifndef NO_DEL_PUSH
+ if (optimise && !callersaves) {
+ outstr("if ");
+ outstr(funcname);
+ outnstr(".off=0");
+ }
+ pushlist(callee1mask);
+ if (optimise && !callersaves)
+ outnstr("endif");
+#else
+ pushlist(callee1mask);
+#endif
# else /* not STUPIDFRAME */
# ifdef CANHANDLENOFRAME
if (stackarg || softsp != -frameregsize) /* args or locals */
diff --git a/bcc/gencode.h b/bcc/gencode.h
index 6c3908b..63d0614 100644
--- a/bcc/gencode.h
+++ b/bcc/gencode.h
@@ -47,6 +47,7 @@ EXTERN bool_t scanf_fp; /* nonzero if *scanf called with ptr-to-FP */
EXTERN offset_T softsp; /* software sp (leads sp during declares) */
EXTERN offset_T sp; /* hardware relative stack ptr */
/* depends on zero init */
+EXTERN store_t regfuse; /* registers in use in function. */
#ifdef FRAMEPOINTER
EXTERN bool_t stackarg; /* nonzero to show function has arg on stack */
#endif
diff --git a/bcc/genloads.c b/bcc/genloads.c
index 9aff996..c3ac56a 100644
--- a/bcc/genloads.c
+++ b/bcc/genloads.c
@@ -784,10 +784,19 @@ struct symstruct *adr;
bumplc();
else
{
+ int off;
if (switchnow != NULL && adr->flags == TEMP)
- outswoffset(adr->offset.offi);
+ outswoffset(off = adr->offset.offi);
else
- outoffset(adr->offset.offi - framep);
+ outoffset(off = adr->offset.offi - framep);
+#ifndef NO_DEL_PUSH
+ if (optimise && !callersaves && off < 0)
+ {
+ outstr("+");
+ outstr(funcname);
+ outstr(".off");
+ }
+#endif
}
outindleft();
}
@@ -948,12 +957,15 @@ store_pt reg;
#endif
case INDREG0:
outstr(ireg0str);
+ regfuse |= INDREG0;
break;
case INDREG1:
outstr(ireg1str);
+ regfuse |= INDREG1;
break;
case INDREG2:
outstr(ireg2str);
+ regfuse |= INDREG2;
break;
case LOCAL:
outstr(localregstr);
@@ -996,7 +1008,7 @@ store_pt reg;
}
}
-#ifdef I8088
+#if defined(I8088) && defined(I80386)
/* print register name for short type */
PUBLIC void outshortregname(reg)
diff --git a/bcc/input.c b/bcc/input.c
index 259ae04..4ce121d 100644
--- a/bcc/input.c
+++ b/bcc/input.c
@@ -609,6 +609,9 @@ ts_s_includelist += sizeof *incnew;
definestring("__HAS_NO_FLOATS__");
#endif
ctext = flag['t'];
+#ifdef DEBUG
+ if (ctext) debugon = 1;
+#endif
watchlc = flag['w'];
setoutbufs();
inputinit(fname, fd);
diff --git a/bcc/preserve.c b/bcc/preserve.c
index c8a8cea..779efc2 100644
--- a/bcc/preserve.c
+++ b/bcc/preserve.c
@@ -6,6 +6,7 @@
#include "gencode.h"
#include "reg.h"
#include "type.h"
+#include "scan.h"
/* change stack ptr without changing condition codes */
@@ -18,11 +19,20 @@ bool_pt absflag;
#ifdef FRAMEPOINTER
if (newsp != framep || (!(bool_t) absflag && switchnow != NULL))
{
+ int off;
outleasp();
if (!(bool_t) absflag && switchnow != NULL)
- outswoffset(newsp);
+ outswoffset(off = newsp);
else
- outoffset(newsp - framep);
+ outoffset(off = newsp - framep);
+#ifndef NO_DEL_PUSH
+ if (optimise && !callersaves && off < 0)
+ {
+ outstr("+");
+ outstr(funcname);
+ outstr(".off");
+ }
+#endif
outindframereg();
outnl();
}
diff --git a/bcc/state.c b/bcc/state.c
index a290e43..fef7bbd 100644
--- a/bcc/state.c
+++ b/bcc/state.c
@@ -779,6 +779,7 @@ more:
semicolon();
break;
case SEMICOLON:
+ outnstr("!BCC_EOS");
nextsym();
return;
case ASMSYM:
diff --git a/copt/copt.c b/copt/copt.c
index 35588d3..350c163 100644
--- a/copt/copt.c
+++ b/copt/copt.c
@@ -43,7 +43,11 @@
#define KEEPCOMMENTS
#define MAXLINE 1024
+#ifdef __BCC__
#define HASHSIZE 107
+#else
+#define HASHSIZE 1999
+#endif
#define NOCHAR '\177'
#define VARNUM 10
@@ -112,7 +116,7 @@ static char *install(char *str, int slen)
struct hash_s *hp;
char *chkstr;
char *cp;
- int hashval;
+ unsigned int hashval;
/* Clear the hashing table if not already done */
if (!hash_init) {
@@ -131,7 +135,7 @@ static char *install(char *str, int slen)
/* Determine hashing value of string */
hashval = 0;
for (cp = chkstr; *cp; cp++)
- hashval += *cp;
+ hashval = hashval*75 + *cp;
hashval %= HASHSIZE;
/* Check if the string is already in the hashing table */
@@ -238,14 +242,25 @@ static void readpattern(char *rulesdir, char *filename)
rp = (struct rule_s *)mymalloc(sizeof(struct rule_s));
rp->old = readlist(fp, '=', '#');
rp->new = readlist(fp, '\0', '#');
- rp->next = first;
if (rp->old == NULL || rp->new == NULL) {
free(rp);
break;
}
+
+/* This put the rules into the table in reverse order; this is confusing *
+ rp->next = first;
first = rp;
if (last == NULL)
last = rp;
+*/
+ rp->next = NULL;
+ if (last) {
+ last->next = rp;
+ last = rp;
+ } else {
+ first = last = rp;
+ }
+
}
/* Close pattern file */
@@ -679,6 +694,11 @@ static struct line_s *optline(struct line_s *cur)
if (!ins->comment_flg)
pat = pat->next;
+ else if (ins->text[0]==pat->text[0]) /* Matching a comment! */
+ {
+ if (match(ins->text, pat->text))
+ pat = pat->next;
+ }
ins = ins->next;
}
@@ -688,7 +708,7 @@ static struct line_s *optline(struct line_s *cur)
lp1 = cur;
cur = cur->prev;
while (lp1 != ins) {
-#if 0 /* I'd like to keep the comment lines but this doesn't work XXX */
+#if 0
if( lp1->comment_flg )
{
lp2 = lp1;
diff --git a/copt/rules.186 b/copt/rules.186
index 4d4522c..90db16e 100644
--- a/copt/rules.186
+++ b/copt/rules.186
@@ -28,3 +28,13 @@ push bx
=
push #%1
+mov ax,*%1
+push ax
+=
+push *%1
+
+mov bx,*%1
+push bx
+=
+push *%1
+
diff --git a/copt/rules.386 b/copt/rules.386
index 6875e40..955d4b6 100644
--- a/copt/rules.386
+++ b/copt/rules.386
@@ -1,5 +1,7 @@
# Rules to optimize BCC assembler output for 386
+# Many of these rules are very broken, ho hum.
+
# Rules for loading a long constant
xor ax,ax
@@ -351,7 +353,7 @@ push word ptr %0[%1]
mov %[ax|bx|cx|dx|si|di]2,%[#|*]0%1
push %[ax|bx|cx|dx|si|di]2
=
-push word %0%1
+push %0%1
# Shifting rules
diff --git a/copt/rules.86 b/copt/rules.86
index f0654f4..15b0749 100644
--- a/copt/rules.86
+++ b/copt/rules.86
@@ -2,76 +2,90 @@
# Rules for loading short variables
-mov %0$0[%2],%3
-=
-mov %0[%2],%3
-
mov %2,%[ax|bx|cx|dx]1
mov %[ax|bx|cx|dx]1,%2
=
mov %2,%1
-# Breaks: a = b = 125;
-# mov %[ax|bx|cx|dx]3,%[#|*]0%1
-# mov %2[%4],%[ax|bx|cx|dx]3
-# =
-# mov word ptr %2[%4],%0%1
-
-# This gets a few back.
+# Assign a constant
mov %[ax|bx|cx|dx]3,%[#|*]0%1
mov %2[%4],%[ax|bx|cx|dx]3
-mov %[ax|bx|cx|dx]3,%5
+!BCC_EOS
=
mov word ptr %2[%4],%0%1
-mov %3,%5
+!BCC_EOS
-mov %[ax|bx|cx|dx]3,%[#|*]0%1
-mov %[ax|bx|cx|dx]2,%[ax|bx|cx|dx]3
+# Assign a constant char
+mov al,%[#|*]0%1
+mov %2,al
+!BCC_EOS
=
-mov %2,%0%1
-
-# Breaks: a = b = 'a';
-# mov al,%[#|*]0%1
-# mov %2,al
-# =
-# mov byte ptr %2,%0%1
+mov byte ptr %2,%0%1
+!BCC_EOS
+# Assign a constant long from a small int
xor ax,ax
mov bx,%[#|*]0%1
mov [%2],ax
mov [%2+2],bx
+!BCC_EOS
=
mov word ptr [%2],#0
mov word ptr [%2+2],%0%1
+!BCC_EOS
+# Assign a constant long from a 2^16 mod int.
mov ax,%[#|*]0%1
xor bx,bx
mov [%2],ax
mov [%2+2],bx
+!BCC_EOS
=
mov word ptr [%2],%0%1
mov word ptr [%2+2],#0
+!BCC_EOS
+# Assign a constant long from a big int
mov ax,%[#|*]4%1
mov bx,%[#|*]5%3
mov [%2],ax
mov [%2+2],bx
+!BCC_EOS
=
mov word ptr [%2],%4%1
mov word ptr [%2+2],%5%3
+!BCC_EOS
+# rule for (char*) *x++
+mov bx,%1
+%[inc|dec]2 bx
+mov %1,bx
+mov al,-1[bx]
+xor ah,ah
+=
+mov bx,%1
+%2 word ptr %1
+mov al,[bx]
+xor ah,ah
# Rules for incrementing short variables
+mov %[ax|bx|si|di]2,%1
+%[inc|dec]3 %[ax|bx|si|di]2
+mov %1,%[ax|bx|si|di]2
+!BCC_EOS
+=
+%3 word ptr %1
+!BCC_EOS
-mov %[ax|bx]2,%1
-%[inc|dec]3 %[ax|bx]2
-mov %1,%[ax|bx]2
+mov %[ax|bx|si|di]2,%1
+%[inc|dec]3 %[ax|bx|si|di]2
+mov %1,%[ax|bx|si|di]2
=
%3 word ptr %1
mov %2,%1
-# Rules for manipulating characters
+# Rules for manipulating characters with register char*s
inc %[si|di]*
inc %[si|di]*
@@ -140,37 +154,44 @@ cld
# Rules for manipulating short values
-# This is the broken rule - Chad
-
-#mov %[ax|bx]2,%1
-#%[add|and|xor|sub|or]4 %[ax|bx]2,%3
-#mov %1,%[ax|bx]2
-#=
-#mov %2,%3
-#%4 %1,%2
+# These rules only apply at end of statment.
+mov %[ax|bx]2,%1
+%[add|and|xor|sub|or]4 %[ax|bx]2,%3
+mov %1,%[ax|bx]2
+!BCC_EOS
+=
+mov %2,%3
+%4 %1,%2
+!BCC_EOS
mov %[ax|bx]2,%1
%[add|and|xor|or]4 %[ax|bx]2,%3
mov %3,%[ax|bx]2
+!BCC_EOS
=
mov %2,%1
%4 %3,%2
-
-mov %[ax|bx]4,%1
-%[add|and|xor|sub|or]2 %[si|di]3,%[ax|bx]4
-=
-%2 %3,%1
+!BCC_EOS
mov al,%1
xor ah,ah
%[add|and|xor|sub|or]2 ax,%[#|*]0%3
mov %1,al
+!BCC_EOS
=
%2 byte ptr %1,%0%3
+!BCC_EOS
+# This is safe with an embedded assign.
+mov %[ax|bx]4,%1
+%[add|and|xor|sub|or]2 %[si|di]3,%[ax|bx]4
+=
+%2 %3,%1
# Rules for comparing short values
+# Compare doesn't need to leave any register in a specific state.
+
mov %[ax|bx]3,%1[%4]
cmp %[ax|bx]3,%[#|*]0%2
=
@@ -348,9 +369,11 @@ jmp .%1
jmp .%1
.%2:
+!BCC_EOS
.%1:
=
.%2:
+!BCC_EOS
.%1:
jmp .%1
@@ -445,4 +468,83 @@ pop bx
pop cx
pop dx
=
-! push/pop
+! push/pop float
+
+# Long right shift by 16 unsigned
+mov ax,%1
+mov bx,%2
+xchg bx,ax
+xor bx,bx
+=
+mov ax,%2
+xor bx,bx
+
+# Long right shift by 16 signed
+mov ax,%1
+mov bx,%2
+xchg bx,ax
+cwd
+=
+mov ax,%2
+cwd
+
+# Load long and exchange
+mov ax,%1
+mov bx,%2
+xchg bx,ax
+=
+mov bx,%1
+mov ax,%2
+
+# Repeated clear.
+xor bx,bx
+xchg bx,ax
+xor ax,ax
+=
+xchg bx,ax
+xor ax,ax
+
+# Long expression assigned to an int
+cwd
+mov bx,dx
+mov %1,ax
+!BCC_EOS
+=
+mov %1,ax
+!BCC_EOS
+
+# Load unsigned into high word of long
+mov ax,%1
+xchg bx,ax
+xor ax,ax
+=
+mov bx,%1
+xor ax,ax
+
+# Souped up strcpy; "while(*d++ = *s++);" in a function with no reg vars.
+.%3:
+!BCC_EOS
+.%4:
+mov bx,%1
+inc bx
+mov %1,bx
+mov si,%2
+inc si
+mov %2,si
+mov al,-1[bx]
+mov -1[si],al
+test al,al
+jne .%3
+=
+.%4:
+mov si,%1
+mov di,%2
+.%3:
+lodsb
+stosb
+test al,al
+jne .%3
+mov %1,si
+mov %2,di
+!BCC_EOS
+
diff --git a/copt/rules.end b/copt/rules.end
index cf2c6df..5f6eaba 100644
--- a/copt/rules.end
+++ b/copt/rules.end
@@ -15,8 +15,3 @@ pop si
pop di
pop bp
ret
-
-pmov %1,%2
-=
-push %1
-mov %1,%2
diff --git a/copt/rules.i b/copt/rules.i
index 3cb8aca..917a995 100644
--- a/copt/rules.i
+++ b/copt/rules.i
@@ -57,7 +57,7 @@ call ___set_es
inc sp
inc sp
=
-mov ax,#%1
+mov ax,%0%1
mov es,ax
mov ax,%[#|*]0%1
@@ -66,7 +66,7 @@ call ___set_es
inc sp
inc sp
=
-mov ax,#%1
+mov ax,%0%1
mov es,ax
push %0[%1]
@@ -290,5 +290,5 @@ mov ax,%1
mov ax,ax
=
-!
+!mov ax,ax
diff --git a/copt/rules.start b/copt/rules.start
index 5a38888..f494305 100644
--- a/copt/rules.start
+++ b/copt/rules.start
@@ -17,7 +17,3 @@ ret
=
proc_end
-push %1
-mov %1,%2
-=
-pmov %1,%2
diff --git a/cpp/Makefile b/cpp/Makefile
index b5d5322..0ea43cc 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -5,11 +5,11 @@ all: bcc-cpp
bcc-cpp: main.o cpp.o hash.o token1.o token2.o
$(CC) $(CFLAGS) -o bcc-cpp main.o cpp.o hash.o token1.o token2.o
-realclean: clean
- rm -f bcc-cpp token1.h token2.h
+clean realclean:
+ rm -f bcc-cpp main.o cpp.o hash.o token1.o token2.o tmp.h
-clean:
- rm -f main.o cpp.o hash.o token1.o token2.o
+maintclean: realclean
+ rm -f token1.h token2.h
main.o: cc.h
cpp.o: cc.h
@@ -20,7 +20,9 @@ token1.o: token1.h
token2.o: token2.h
token1.h: token1.tok
- gperf -aptTc -N is_ctok -H hash1 token1.tok > token1.h
+ gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h
+ mv tmp.h token1.h
token2.h: token2.tok
- gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > token2.h
+ gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h
+ mv tmp.h token2.h
diff --git a/cpp/c.c b/cpp/c.c
index 5e1ef4e..89f3120 100644
--- a/cpp/c.c
+++ b/cpp/c.c
@@ -1,14 +1,14 @@
#include <stdio.h>
#include <errno.h>
-#if __STDC__
+#if __STDC__ == (1UL)
#define strong_alias(Y,X) asm("export _" #X, "_" #X " = _" #Y )
#else
#define strong_alias(Y,X) asm("export _" "X", "_" "X" " = _" "Y" )
#endif
#if __STDC__
-#define comb(x,y) x##y
+#define comb(x,y) x ## y
#warning Using Ansi combine
#elif __BCC__
#define comb(x,y) x/**/y
@@ -36,7 +36,13 @@ main()
int i1, i2, i3;
printf("sizeof(long double) = %d\n", sizeof(long double));
+#ifdef __GNUC__
+ printf("sizeof(long float) = ERROR!\n");
+ printf("sizeof(long long) = %d\n", sizeof(long long));
+#else
printf("sizeof(long float) = %d\n", sizeof(long float));
+ printf("sizeof(long long) = ERROR!\n");
+#endif
printf("sizeof(double) = %d\n", sizeof(double));
printf("sizeof(float) = %d\n", sizeof(float));
diff --git a/cpp/cpp.c b/cpp/cpp.c
index 57cbda0..030535e 100644
--- a/cpp/cpp.c
+++ b/cpp/cpp.c
@@ -28,6 +28,12 @@
* TODO:
* #asm -> asm("...") translation.
* ?: in #if expressions
+ * __DATE__ and __TIME__ macros.
+ * Add #line directive.
+ * Poss: Seperate current directory for #include from errors (#line).
+ * Poss: C99 Variable macro args.
+ * \n in "\n" in a stringized argument.
+ * Comments in stringized arguments should be deleted.
*/
#define KEEP_SPACE 0
@@ -44,7 +50,11 @@ FILE * curfile;
char * c_fname;
int c_lineno = 0;
+#ifdef __BCC__
+typedef long int_type; /* Used for preprocessor expressions */
+#else
typedef int int_type; /* Used for preprocessor expressions */
+#endif
static int curtok = 0; /* Used for preprocessor expressions */
static int fi_count = 0;
@@ -132,7 +142,7 @@ gettok()
}
/* Special for quoted strings */
- *curword = 0;
+ *curword = '\0';
ch = chget();
if( ch == EOF ) return ch;
@@ -274,6 +284,12 @@ break_break:
{
if( state < 6 )
{
+ if( ch == 'u' || ch == 'U' )
+ {
+ if( cc < WORDSIZE-1 ) *p++ = ch; /* Clip to WORDSIZE */
+ *p = '\0'; cc++;
+ ch = chget();
+ }
if( ch == 'l' || ch == 'L' )
{
if( cc < WORDSIZE-1 ) *p++ = ch; /* Clip to WORDSIZE */
@@ -406,7 +422,7 @@ break_break:
*p++ = ch;
} else
unchget(ch);
- *p = 0;
+ *p = '\0';
return TK_STR;
}
@@ -720,26 +736,23 @@ do_proc_include()
if( ch == ch1 )
{
*p = '\0';
+ p = strdup(curword);
- fd = open_include(curword, "r", (ch=='"'));
- if( fd == 0 )
- cerror("Cannot open include file");
- do { ch = pgetc(); } while(ch == ' ' || ch == '\t'); unchget(ch);
+ do { ch1 = pgetc(); } while(ch1 == ' ' || ch1 == '\t');
+ unchget(ch1);
do_proc_tail();
- if( fd )
- {
- saved_files[fi_count] = curfile;
- saved_fname[fi_count] = c_fname;
- saved_lines[fi_count] = c_lineno;
- fi_count++;
-
- curfile = fd;
- c_fname = malloc(strlen(curword)+1);
- if( c_fname == 0 ) cfatal("Preprocessor out of memory");
- strcpy(c_fname, curword);
- c_lineno = 1;
- }
+ saved_files[fi_count] = curfile;
+ saved_fname[fi_count] = c_fname;
+ saved_lines[fi_count] = c_lineno;
+
+ fd = open_include(p, "r", (ch=='"'));
+ if( fd ) {
+ fi_count++;
+ curfile = fd;
+ } else
+ cerror("Cannot open include file");
+
return;
}
*p++ = ch;
@@ -778,7 +791,7 @@ do_proc_define()
len = WORDSIZE;
ptr = malloc(sizeof(struct define_item) + WORDSIZE);
if(ptr==0) cfatal("Preprocessor out of memory");
- ptr->value[cc=0] = 0;
+ ptr->value[cc=0] = '\0';
/* Add in arguments */
if( ch1 == '(' )
@@ -832,7 +845,7 @@ do_proc_define()
}
if (cc)
ptr->value[cc++] = ' ';/* Byte of lookahead for recursive macros */
- ptr->value[cc++] = 0;
+ ptr->value[cc++] = '\0';
#if CPP_DEBUG
if (cc == 1)
@@ -1212,8 +1225,10 @@ get_exp_value()
value = get_expression(0);
if (curtok == ')')
curtok = get_onetok(SKIP_SPACE);
- else
+ else {
curtok = '$';
+ cerror("Expected ')'");
+ }
}
return sign<0 ? -value: value;
@@ -1248,7 +1263,7 @@ int arg_count;
arg_list[ac].name = realloc(arg_list[ac].name, len);
}
arg_list[ac].name[cc++] = *data_str;
- arg_list[ac].name[cc] = 0;
+ arg_list[ac].name[cc] = '\0';
}
for(;;) {
@@ -1290,7 +1305,7 @@ int arg_count;
#endif
arg_list[ac].value[cc++] = ch;
- arg_list[ac].value[cc] = 0;
+ arg_list[ac].value[cc] = '\0';
}
if (commas_found || args_found) args_found = commas_found+1;
@@ -1359,12 +1374,12 @@ int arg_count;
}
#endif
- rv = malloc(4); *rv = 0; len = 4;
+ rv = malloc(4); *rv = '\0'; len = 4;
while(*data_str) {
p = curword;
- if (dialect != DI_KNR) {
+ if (dialect == DI_ANSI) {
if (in_quote == 2)
in_quote = 1;
else if (in_quote) {
@@ -1396,7 +1411,7 @@ int arg_count;
data_str+=2;
while(*data_str == ' ' || *data_str == '\t')
data_str++;
- if (*data_str == 0) { /* Hummm */
+ if (*data_str == '\0') { /* Hummm */
data_str--;
cerror("'##' operator at end of macro");
}
@@ -1417,7 +1432,7 @@ int arg_count;
rv[cc++] = *data_str++;
continue;
}
- *p = 0; s = curword;
+ *p = '\0'; s = curword;
for (ac=0; ac<arg_count; ac++) {
if (*curword == arg_list[ac].name[0] &&
strcmp(curword, arg_list[ac].name) == 0)
@@ -1445,7 +1460,7 @@ int arg_count;
while(cc>0 && (rv[cc-1] == ' ' || rv[cc-1] == '\t'))
cc--;
rv[cc++] = '"';
- rv[cc++] = 0;
+ rv[cc++] = '\0';
ansi_stringize = 0;
s = "";
break;
@@ -1465,6 +1480,6 @@ int arg_count;
cc = strlen(rv);
}
- rv[cc] = 0;
+ rv[cc] = '\0';
return rv;
}
diff --git a/cpp/hash.c b/cpp/hash.c
index 3d340e8..11c32da 100644
--- a/cpp/hash.c
+++ b/cpp/hash.c
@@ -23,7 +23,7 @@ struct hashentry
struct hashentry ** hashtable;
int hashsize = 0xFF; /* 2^X -1 */
int hashcount = 0;
-static int hashvalue();
+static int hashvalue _P((int namespace, char * word));
void *
read_entry(namespace, word)
diff --git a/cpp/main.c b/cpp/main.c
index b2935dd..0cbdaa3 100644
--- a/cpp/main.c
+++ b/cpp/main.c
@@ -21,6 +21,8 @@ void define_macro _P((char *));
void undefine_macro _P((char *));
void cmsg _P((char * mtype, char * str));
char * token_txn _P((int));
+void pr_indent _P((int));
+void hash_line _P((void));
char * include_paths[MAXINCPATH];
@@ -28,6 +30,7 @@ char last_name[512] = "";
int last_line = -1;
int debug_mode = 0;
int p_flag = 0;
+int exit_code = 0;
char * outfile = 0;
FILE * ofd = 0;
@@ -146,7 +149,7 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
print_toks_cpp();
if (outfile) fclose(ofd);
- exit(0);
+ exit(exit_code);
}
void
@@ -192,24 +195,34 @@ char * fname;
char * mode;
int checkrel;
{
- FILE * fd;
+ FILE * fd = 0;
int i;
- char buf[256];
+ char buf[256], *p;
if( checkrel )
{
- fd=fopen(fname, mode);
- if( fd ) return fd;
+ strcpy(buf, c_fname);
+ p = strrchr(buf, '/');
+ if (p) *++p = 0; else *(p=buf) = 0;
+ strcpy(p, fname);
+
+ fd=fopen(buf, mode);
+ }
+ if (!fd) {
+ for(i=0; i<MAXINCPATH; i++)
+ if (include_paths[i]) {
+ strcpy(buf, include_paths[i]);
+ if (buf[strlen(buf)-1] != '/') strcat(buf, "/");
+ strcat(buf, fname);
+ fd=fopen(buf, mode);
+ if( fd ) break;
+ }
}
- for(i=0; i<MAXINCPATH; i++)
- if (include_paths[i]) {
- strcpy(buf, include_paths[i]);
- if (buf[strlen(buf)-1] != '/') strcat(buf, "/");
- strcat(buf, fname);
- fd=fopen(buf, mode);
- if( fd ) return fd;
- }
- return 0;
+ if (!fd) return fd;
+ c_fname = strdup(buf);
+ c_lineno = 1;
+
+ return fd;
}
/*----------------------------------------------------------------------*/
@@ -242,6 +255,7 @@ void
cerror(str)
char * str;
{
+ exit_code = 1;
cmsg("error", str);
}
diff --git a/cpp/token1.c b/cpp/token1.c
index e53f563..4b966f7 100644
--- a/cpp/token1.c
+++ b/cpp/token1.c
@@ -3,4 +3,9 @@
#include <string.h>
#include "cc.h"
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int hash1 _P((register const char *, register unsigned int));
+
#include "token1.h"
diff --git a/cpp/token1.h b/cpp/token1.h
new file mode 100644
index 0000000..2e2b9eb
--- /dev/null
+++ b/cpp/token1.h
@@ -0,0 +1,117 @@
+/* C code produced by gperf version 2.7.1 (19981006 egcs) */
+/* Command-line: gperf -aptTc -N is_ctok -H hash1 token1.tok */
+
+#define TOTAL_KEYWORDS 23
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 3
+#define MIN_HASH_VALUE 2
+#define MAX_HASH_VALUE 63
+/* maximum key range = 62, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int
+hash1 (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static unsigned char asso_values[] =
+ {
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 1, 64, 64, 64, 3, 25, 64,
+ 64, 64, 13, 18, 64, 8, 30, 15, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 5, 0, 20, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 30, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 23, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64
+ };
+ return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+struct token_trans *
+is_ctok (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static struct token_trans wordlist[] =
+ {
+ {""}, {""},
+ {"==", TK_EQ_OP},
+ {"!=", TK_NE_OP},
+ {""},
+ {"%=", TK_MOD_ASSIGN},
+ {""},
+ {"<=", TK_LE_OP},
+ {"<<=", TK_LEFT_ASSIGN},
+ {""},
+ {"-=", TK_SUB_ASSIGN},
+ {""},
+ {"<<", TK_LEFT_OP},
+ {""}, {""},
+ {"*=", TK_MUL_ASSIGN},
+ {""},
+ {"/=", TK_DIV_ASSIGN},
+ {"--", TK_DEC_OP},
+ {""},
+ {"+=", TK_ADD_ASSIGN},
+ {""},
+ {">=", TK_GE_OP},
+ {">>=", TK_RIGHT_ASSIGN},
+ {""},
+ {"|=", TK_OR_ASSIGN},
+ {""},
+ {"&=", TK_AND_ASSIGN},
+ {""}, {""},
+ {"->", TK_PTR_OP},
+ {""},
+ {"^=", TK_XOR_ASSIGN},
+ {""}, {""}, {""}, {""}, {""},
+ {"++", TK_INC_OP},
+ {""}, {""}, {""},
+ {">>", TK_RIGHT_OP},
+ {""}, {""}, {""}, {""}, {""},
+ {"||", TK_OR_OP},
+ {""}, {""}, {""},
+ {"&&", TK_AND_OP},
+ {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+ {"..", TK_WORD},
+ {"...", TK_ELLIPSIS}
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register int key = hash1 (str, len);
+
+ if (key <= MAX_HASH_VALUE && key >= 0)
+ {
+ register const char *s = wordlist[key].name;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
+ return &wordlist[key];
+ }
+ }
+ return 0;
+}
diff --git a/cpp/token2.c b/cpp/token2.c
index e113fdd..c535746 100644
--- a/cpp/token2.c
+++ b/cpp/token2.c
@@ -3,4 +3,9 @@
#include <string.h>
#include "cc.h"
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int hash2 _P((register const char *, register unsigned int));
+
#include "token2.h"
diff --git a/cpp/token2.h b/cpp/token2.h
new file mode 100644
index 0000000..62e69b1
--- /dev/null
+++ b/cpp/token2.h
@@ -0,0 +1,139 @@
+/* C code produced by gperf version 2.7.1 (19981006 egcs) */
+/* Command-line: gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok */
+
+#define TOTAL_KEYWORDS 34
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 8
+#define MIN_HASH_VALUE 2
+#define MAX_HASH_VALUE 69
+/* maximum key range = 68, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int
+hash2 (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static unsigned char asso_values[] =
+ {
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 5, 70, 70, 70, 70, 70, 0, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 0, 70, 5, 5, 10,
+ 10, 20, 20, 25, 70, 0, 70, 70, 50, 70,
+ 0, 15, 0, 70, 15, 0, 40, 20, 0, 0,
+ 70, 70, 10, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70
+ };
+ register int hval = len;
+
+ switch (hval)
+ {
+ default:
+ case 3:
+ hval += asso_values[(unsigned char)str[2]];
+ case 2:
+ case 1:
+ hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval;
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+struct token_trans *
+is_ckey (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static struct token_trans wordlist[] =
+ {
+ {""}, {""},
+ {"if", TK_IF},
+ {""},
+ {"void", TK_VOID},
+ {"while", TK_WHILE},
+ {"switch", TK_SWITCH},
+ {""},
+ {"__LINE__", TK_LINE},
+ {""}, {""},
+ {"static", TK_STATIC},
+ {"do", TK_DO},
+ {"__FILE__", TK_FILE},
+ {"case", TK_CASE},
+ {"const", TK_CONST},
+ {"sizeof", TK_SIZEOF},
+ {""},
+ {"continue", TK_CONTINUE},
+ {"char", TK_CHAR},
+ {"short", TK_SHORT},
+ {"struct", TK_STRUCT},
+ {""}, {""},
+ {"else", TK_ELSE},
+ {"union", TK_UNION},
+ {""}, {""},
+ {"unsigned", TK_UNSIGNED},
+ {""},
+ {"break", TK_BREAK},
+ {"signed", TK_SIGNED},
+ {""}, {""}, {""}, {""},
+ {"double", TK_DOUBLE},
+ {"default", TK_DEFAULT},
+ {"for", TK_FOR},
+ {""},
+ {"float", TK_FLOAT},
+ {""}, {""},
+ {"int", TK_INT},
+ {"enum", TK_ENUM},
+ {""}, {""},
+ {"typedef", TK_TYPEDEF},
+ {"register", TK_REGISTER},
+ {"auto", TK_AUTO},
+ {""}, {""}, {""}, {""},
+ {"long", TK_LONG},
+ {""}, {""}, {""},
+ {"volatile", TK_VOLATILE},
+ {""}, {""},
+ {"return", TK_RETURN},
+ {""}, {""}, {""}, {""},
+ {"extern", TK_EXTERN},
+ {""}, {""},
+ {"goto", TK_GOTO}
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register int key = hash2 (str, len);
+
+ if (key <= MAX_HASH_VALUE && key >= 0)
+ {
+ register const char *s = wordlist[key].name;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
+ return &wordlist[key];
+ }
+ }
+ return 0;
+}
diff --git a/libc/bios/Makefile b/libc/bios/Makefile
index 692d535..ffa5027 100644
--- a/libc/bios/Makefile
+++ b/libc/bios/Makefile
@@ -15,7 +15,7 @@ CSRC=bios_min.c
COBJ=bios_putc.o bios_getc.o
DSRC=bios_disk.c
-DOBJ=bios_disk_read.o bios_disk_write.o bios_disk_reset.o bios_get_dpt.o
+DOBJ=bios_disk_rd.o bios_disk_wr.o bios_disk_rs.o bios_get_dpt.o
OBJ=$(AOBJ) $(BOBJ) $(COBJ) $(DOBJ) \
time.o fileops.o fs_dos.o rawio.o vt52.o ansi.o
diff --git a/libc/bios/bios_disk.c b/libc/bios/bios_disk.c
index e0d9961..49b4ec6 100644
--- a/libc/bios/bios_disk.c
+++ b/libc/bios/bios_disk.c
@@ -5,7 +5,7 @@
#include <bios.h>
#include <errno.h>
-#ifdef L_bios_disk_read
+#ifdef L_bios_disk_rd
_bios_disk_read(drive, cyl, head, sect, length, buffer)
{
#asm
@@ -52,7 +52,7 @@ read_err1:
}
#endif
-#ifdef L_bios_disk_write
+#ifdef L_bios_disk_wr
_bios_disk_write(drive, cyl, head, sect, length, buffer)
{
#asm
@@ -127,7 +127,7 @@ func_ok:
}
#endif
-#ifdef L_bios_disk_reset
+#ifdef L_bios_disk_rs
_bios_disk_reset(drive)
{
#asm
diff --git a/libc/include/stdarg.h b/libc/include/stdarg.h
index 321e664..f5f6fbf 100644
--- a/libc/include/stdarg.h
+++ b/libc/include/stdarg.h
@@ -43,5 +43,5 @@
#endif /* __STDARG_H */
#if __FIRST_ARG_IN_AX__
-#error First arg is in a register, stdarg.h cannot take its address
+#warning First arg is in a register, stdarg.h cannot take its address
#endif
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 7831424..aeb7a43 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -14,10 +14,7 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
-extern void * malloc __P ((size_t));
-extern void * calloc __P ((size_t, size_t));
-extern void free __P ((void *));
-extern void * realloc __P ((void *, size_t));
+#include <malloc.h>
extern int rand __P ((void));
extern void srand __P ((unsigned int seed));
@@ -29,6 +26,10 @@ extern unsigned long strtoul __P ((const char * nptr,
extern double strtod __P ((const char * nptr, char ** endptr));
#endif
+extern long int atol __P ((__const char *__nptr));
+extern double atof __P ((__const char *__nptr));
+extern int atoi __P ((__const char *__nptr));
+
/* Returned by `div'. */
typedef struct
{
@@ -43,4 +44,8 @@ typedef struct
long int rem; /* Remainder. */
} ldiv_t;
+
+extern char *getenv __P ((__const char *__name));
+extern char *mktemp __P ((char *__template));
+
#endif /* __STDLIB_H */
diff --git a/libc/string/string.c b/libc/string/string.c
index 705ec55..d672e77 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -139,6 +139,7 @@ sc_1:
xor ax,ax ; so return zero
jmp sc_3
sc_2:
+ cmc
sbb ax,ax ; Collect correct val (-1,1).
orb al,#1
sc_3:
diff --git a/makefile.in b/makefile.in
index bdfe358..2c62caf 100644
--- a/makefile.in
+++ b/makefile.in
@@ -95,7 +95,7 @@ install-all: install install-other
##############################################################################
-LIBARGS= CC=ncc CCFLAGS= AR=$(AR) ARFLAGS=$(ARFLAGS)
+LIBARGS= CC=ncc "CCFLAGS=-O" AR=$(AR) ARFLAGS=$(ARFLAGS)
# Season in the top makefile
ELKSSRC= %ELKSSRC%
diff --git a/man/bcc.1 b/man/bcc.1
index ed7ccd0..fd9b0c6 100644
--- a/man/bcc.1
+++ b/man/bcc.1
@@ -14,6 +14,7 @@ bcc \- Bruce's C compiler
.RB [ -o\ outfile ]
.RB [ -ansi ]
.RB [ -Ccc1_option ]
+.RB [ -Pcpp_option ]
.RB [ -Iinclude_dir ]
.RB [ -Lld_option ]
.RB [ -Ttmpdir ]
@@ -160,10 +161,6 @@ as -Ofile)
.B -c
produce object file
.TP
-.B -e
-run the preprocess pass separately. This takes less memory, and may help
-or harm by giving more traditional semantics like token pasting with /**/.
-.TP
.B -f
error (float emulation not supported)
.TP
@@ -207,12 +204,7 @@ These are all options that the code generator pass
.B bcc-cc1
understands, only some will be useful for the
.B -C
-option of bcc. The code generator is normally used as a combined C preprocessor
-and generator but the
-.B -e
-and
-.B -ansi
-options of bcc split the operation.
+option of bcc.
.TP
.B -0
8086 target (works even on 80386 host, not on 6809)