public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
From: mjn3@codepoet.org (Manuel Novoa III)
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Ken Martwick <kenm@efn.org>, linux-8086@vger.kernel.org
Subject: Re: Small-C revisited
Date: Wed, 5 Jun 2002 12:56:25 -0600	[thread overview]
Message-ID: <20020605185625.GA22247@codepoet.org> (raw)
In-Reply-To: <1023298283.2443.11.camel@irongate.swansea.linux.org.uk>

[-- Attachment #1: Type: text/plain, Size: 2696 bytes --]

Hello,

On Wed, Jun 05, 2002 at 06:31:23PM +0100, Alan Cox wrote:
> I've been pondering the question of how to make bcc fit. One way is a
> better optimiser, but the other approach that might be easier to
> implement would be an optional 'size before speed' piece of code.
> 
> Take the entire existing tree, scan it for identical sequences of asm
> instructions where the stack is balanced (ie equal push/pop and never
> pops below the level on entry) generate a library of them and then
> replace those sequences with calls if bcc is called with some suitable
> option to run the replacer. We'd trade a few clock cycles for bytes each
> time the substitution occurred.
> 
> That way bcc would probably actually fit 
> 

As an interim approach, you could try just #ifdef-ing out the floating
point support.  I just ran a quick test of simply removing floatop.c
from the dependencies and #ifdef'ing out the necessary code blocks in
genloads.c, glogcode.c, softop.c, hardop.c, and assign.c.  It buids,
and at least the preprocessor works with elksemu.  I'm not sure what
compiler misbehavior might result if any floating point code is
encountered though.

[mjn3@mars bcc]$ file bcc bcc-cc1
bcc:     Linux-8086 executable
bcc-cc1: Linux-8086 executable
[mjn3@mars bcc]$ size86 bcc bcc-cc1
text    data    bss     dec     hex     filename
11776   1328    744     13848   3618    bcc
65424   5896    8848    80168   13928   bcc-cc1

This is for bcc from dev86-0.16.3, but with some additional tweaks to
the preprocessor to support "#elif" and non-ansi token pasting macros,
as well as enabling the "asm" statement outside of a function so that
I could do things like the following (bcc patch for this is attached).
I meant to post the patch sometime before this, but I've been pretty
busy with some uClibc projects.

Manuel


/* Put this immediately before the function being aliased. */
#define __BCC_ALIAS(X,Y)        asm("export _" "X" "\n_" "X" " = _" "Y")

#ifdef __AS386_16__
#define __BCC_CTOR(X) asm( \
"  loc  1\n"         /* Make sure the pointer is in the correct segment */ \
"auto_func:\n"       /* Label for bcc -M to work. */ \
".word  _" "X" "\n"  /* Pointer to the autorun function */ \
".word no_op\n"      /* Space filler cause segs are padded to 4 bytes. */ \
".text\n"            /* So the function after is also in the correct seg. */ \
)
#endif

#ifdef __AS386_32__
#define __BCC_CTOR(X) asm( \
"  loc  1\n"         /* Make sure the pointer is in the correct segment */ \
"auto_func:\n"       /* Label for bcc -M to work. */ \
".long  _" "X" "\n"  /* Pointer to the autorun function */ \
".text\n"            /* So the function after is also in the correct seg. */ \
)
#endif


[-- Attachment #2: bcc.diff --]
[-- Type: text/plain, Size: 3118 bytes --]

--- declare.c-dist	Fri Dec 17 11:51:13 1999
+++ declare.c	Sun Apr 21 18:55:33 2002
@@ -36,6 +36,7 @@
 FORWARD void declselt P((struct typestruct *structype, offset_T *psoffset,
 			 struct typelist ** ptypelist));
 FORWARD bool_pt declspec P((void));
+FORWARD void doasm2 P((void));
 FORWARD struct typestruct *declsu P((void));
 FORWARD void idecllist P((void));
 FORWARD void initarray P((struct typestruct *type));
@@ -47,6 +48,23 @@
 FORWARD void rdeclarator P((void));
 FORWARD bool_pt regdecl P((void));
 
+PRIVATE void doasm2()
+{
+    lparen();
+    if (sym!=STRINGCONST)
+    	error("string const expected");
+    else {
+	nextsym();
+	constant.value.s[charptr-constant.value.s]='\0';
+	outnstr("!BCC_ASM");
+	outbyte('\t');
+	outnstr(constant.value.s);
+	outnstr("!BCC_ENDASM");
+	rparen();
+	semicolon();
+    }
+}
+
 PRIVATE struct typestruct *chainprefix(pretype, sufftype)
 struct typestruct *pretype;
 struct typestruct *sufftype;
@@ -487,6 +505,10 @@
 	case UNSIGNDECL:
 	    ++nunsigned;
 	    nextsym();
+	    break;
+	case ASMSYM:
+	    nextsym();
+	    doasm2();
 	    break;
 	default:
 	    goto break2;
--- preproc.c-dist	Sat Jan 12 12:02:18 2002
+++ preproc.c	Sun Apr 21 18:55:43 2002
@@ -53,6 +53,7 @@
 FORWARD void asmcontrol P((void));
 FORWARD void control P((void));
 FORWARD void defineorundefinestring P((char *str, bool_pt defineflag));
+FORWARD void elifcontrol P((void));
 FORWARD void elsecontrol P((void));
 FORWARD void endif P((void));
 FORWARD fastin_pt getparnames P((void));
@@ -193,7 +194,7 @@
     }
     ctlcase = symptr->offset.offsym;
     if (ifstate.ifflag == FALSE &&
-	(ctlcase < ELSECNTL || ctlcase > IFNDEFCNTL))
+	(ctlcase < ELIFCNTL || ctlcase > IFNDEFCNTL))
 	return;
     switch (ctlcase)
     {
@@ -209,6 +210,9 @@
     case DEFINECNTL:
 	define();
 	break;
+    case ELIFCNTL:
+	elifcontrol();
+	break;
     case ELSECNTL:
 	elsecontrol();
 	break;
@@ -345,7 +349,14 @@
 		gch1();
 		skipcomment();
 		/* comment is space in modern cpp's but they have '##' too */
+#if 0
 		ch = *--lineptr = ' ';
+#else
+		/* With this, we can define a paste macro. */
+		--lineptr;
+		gch1();
+		continue;
+#endif
 	    }
 	}
 #ifdef TS
@@ -495,6 +506,29 @@
 	    }
 	    skipline();
 	}
+    }
+}
+
+/* elifcontrol() - process #elif */
+
+PRIVATE void elifcontrol()
+{
+    if (iflevel == 0)
+    {
+	error("elif without if");
+	return;
+    }
+    if (ifstate.elseflag) {
+	register struct ifstruct *ifptr;
+
+	ifptr = &ifstack[(int)--iflevel];
+	ifstate.elseflag = ifptr->elseflag;
+	ifstate.ifflag = ifptr->ifflag;
+
+	ifcontrol(IFCNTL);
+    } else {
+	ifstate.ifflag = ifstate.elseflag;
+	ifstate.elseflag = FALSE;
     }
 }
 
--- table.c-dist	Sat Mar 16 04:28:26 2002
+++ table.c	Sun Apr 21 18:55:58 2002
@@ -30,7 +30,7 @@
 #define MAXEXPR 500
 #endif
 #define MAXLOCAL 100
-#define NKEYWORDS 35
+#define NKEYWORDS 36
 #ifdef NOFLOAT
 #define NSCALTYPES 10
 #else
@@ -116,6 +116,7 @@
 
     { "#asm", ASMCNTL, },
     { "#define", DEFINECNTL, },
+    { "#elif", ELIFCNTL, },
     { "#else", ELSECNTL, },
     { "#endasm", ENDASMCNTL, },
     { "#endif", ENDIFCNTL, },

      reply	other threads:[~2002-06-05 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-05  3:23 Small-C revisited Ken Martwick
2002-06-05  7:00 ` Riley Williams
2002-06-05 17:27 ` Alan Cox
2002-06-05 20:52   ` Harry Kalogirou
2002-06-05 17:31 ` Alan Cox
2002-06-05 18:56   ` Manuel Novoa III [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020605185625.GA22247@codepoet.org \
    --to=mjn3@codepoet.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kenm@efn.org \
    --cc=linux-8086@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox