Skip to contentSkip to conversation

More dev86 changes (0.16.7)

DISCUSSION Robert de Bath 3 participants 12 messages Aug 2, 2002 – Aug 11, 2002

lore
Share & tools
lore
#0 lore raw

Rather than joining in this discussion I've been adding about a thousand lines of new code (and another of old) to dev86. The result is a nice shiny new CPP. My problem now is that I've run out of bugs in it and need your help to find some more. ;-)

Advantages:
The new CPP is fully ansi capable including '#' '##' and '??='. It's also a proper K&R preprocessor if you want.

My next step will be to rip the old CPP out of bcc completely, hopefully making it lots smaller and so small enough to easily fit in an ELKS a.out.

This version uses the new cpp by default, -e will make it fall back to the old one (for the moment).

With this version __STDC__ is now defined as "1" not "0" as it was before because cpp is now fully ansi compliant (crosses fingers).

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>
#1 lore raw

Hello Robert,

Quoted 4 lines · Robert de Bath

Rather than joining in this discussion I've been adding about a thousand lines of new code (and another of old) to dev86. The result is a nice shiny new CPP. My problem now is that I've run out of bugs in it and need your help to find some more. ;-)

I'll be happy to give it a try, but it won't be until next week. I just got a rush contract job that I need to have done by Monday.

Quoted 4 lines

Advantages:
The new CPP is fully ansi capable including '#' '##' and '??='. It's also a proper K&R preprocessor if you want.

Quoted 8 lines

My next step will be to rip the old CPP out of bcc completely, hopefully making it lots smaller and so small enough to easily fit in an ELKS a.out.

This version uses the new cpp by default, -e will make it fall back to the old one (for the moment).

With this version __STDC__ is now defined as "1" not "0" as it was before because cpp is now fully ansi compliant (crosses fingers).

Excellent! Looking forward to trying it with my uClibc stuff.

Manuel

#2 lore raw

Re: More dev86 changes (0.16.7) [About the optimiser]

In reply to Robert de Bath

Hi Robert,

lately I was studing the assembly code bcc was generating and I noticed
that it generates a lot of code like this :

mov ax, 6[bp]
mov bx, 8[bp]
xchg ax, bx

Will it be hard to convince the compiler to generate

mov ax, 8[bp]
mov bx, 6[bp]

instead?

Harry

#3 lore raw

Re: More dev86 changes (0.16.7) [About the optimiser]

Quoted 9 lines · Harry Kalogirou

Hi Robert,

lately I was studing the assembly code bcc was generating and I noticed
that it generates a lot of code like this :

mov ax, 6[bp]
mov bx, 8[bp]
xchg ax, bx

Quoted 6 lines

Will it be hard to convince the compiler to generate

mov ax, 8[bp]
mov bx, 6[bp]

instead?

There's aren't many places xchg is used by bcc, I'd guess this one is shifting longs but it'd help a lot if you gave me some of the original C code too.

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>
#4 lore raw

Re: More dev86 changes (0.16.7) [About the optimiser]

In reply to Harry Kalogirou
Quoted 3 lines · Harry Kalogirou

mov ax, 6[bp]
mov bx, 8[bp]
xchg ax, bx

Actually, looking at it copt can do this easily just add the attached rules to the end of rules.86 (or put them in the lib dir and use -Ols)

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>
#5 lore raw

Re: More dev86 changes (0.16.7) [About the optimiser]

Την Σαβ, 03-08-2002 στις 14:31, ο/η Robert de Bath έγραψε:

Quoted 13 lines · Harry Kalogirou
Quoted 4 lines

mov ax, 6[bp]
mov bx, 8[bp]
xchg ax, bx

Actually, looking at it copt can do this easily just add the attached rules to the end of rules.86 (or put them in the lib dir and use -Ols)

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>

Thanks Robert!

Harry

-
To unsubscribe from this list: send the line "unsubscribe linux-8086" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Robert de Bath

Hello Robert,

Sorry it took so long to do some testing, but I've been swamped.

Tried to build some of my uClibc stuff and found a bug with the new cpp that is illustrated with the following test case.

test.c:

   #define X  (1UL)

   #if X == 0
   #error this shouldn't happen
   #endif

With the new cpp, what shouldn't happen... does.
Here's the output for "ncc -ansi -E test.c".

test.c:3: warning: Unexpected text following preprocessor command test.c:5: error: #error this shouldn't happen
# 1 "test.c"

Output without -ansi is:

# 1 "test.c"
test.c:3: warning: Unexpected text following preprocessor command test.c:5: error: #error this shouldn't happen

Also, with the old cpp one could use "-I" to not include the default include dirs. This feature seems to be lacking in the new version.

Manuel

#7 lore raw
Quoted 7 lines · Manuel Novoa III

Hello Robert,

Sorry it took so long to do some testing, but I've been swamped.

Tried to build some of my uClibc stuff and found a bug with the new cpp that is illustrated with the following test case.

Quoted 6 lines

test.c:

   #define X  (1UL)

   #if X == 0
   #error this shouldn't happen

Oops, you _really_ shouldn't put that "single quote" there, ansi preprocessors that follow the standard explicitly will whinge.

Quoted 9 lines
   #endif

With the new cpp, what shouldn't happen... does.
Here's the output for "ncc -ansi -E test.c".

test.c:3: warning: Unexpected text following preprocessor command test.c:5: error: #error this shouldn't happen
# 1 "test.c"

Quoted 5 lines

Output without -ansi is:

# 1 "test.c"
test.c:3: warning: Unexpected text following preprocessor command test.c:5: error: #error this shouldn't happen

Okay, "UL" is now added as a valid type specifier for integers. However specifing the type will make no difference as the integer type for preprocessor expressions is supposed to be the largest available integer however you express it.

I'm not even sure specifing a type is actually legal, but I think it's covered by the phrase "identifier-nondigit" in the syntax table.

Quoted 2 lines

Also, with the old cpp one could use "-I" to not include the default include dirs. This feature seems to be lacking in the new version.

That is a bug in the new bcc.c that's been there since it first appeared, (Errm, 0.16.2) ho hum nobody noticed before. (Including me!!!)

Okay fixed, and I'll be uploading a new version tomorrow with those and a few other changes.

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>
#8 lore raw

Robert,

Quoted 8 lines · Robert de Bath

Okay, "UL" is now added as a valid type specifier for integers. However specifing the type will make no difference as the integer type for preprocessor expressions is supposed to be the largest available integer however you express it.

I'm not even sure specifing a type is actually legal, but I think it's covered by the phrase "identifier-nondigit" in the syntax table.

ANSI/ISO C99 seems to allow an integer suffix on integer constants in the constant expressions following an #if. At least, I don't see anything indicating otherwise.

Quoted 8 lines
Quoted 2 lines

Also, with the old cpp one could use "-I" to not include the default include dirs. This feature seems to be lacking in the new version.

That is a bug in the new bcc.c that's been there since it first appeared, (Errm, 0.16.2) ho hum nobody noticed before. (Including me!!!)

Okay fixed, and I'll be uploading a new version tomorrow with those and a few other changes.

Great. I should have time tomorrow to download it and run some more tests.

Manuel

#9 lore raw

dev86-0.16.8 cpp bugs

Hello Robert,

Some bugs in 0.16.8's cpp I'm afraid. Try the following.

Manuel

#define X 2
#define Y 4
#undef TEST

#if 1

#ifdef TEST
#warning in test
#if X >= 4
#warning x
#elif Y >= 4
#warning y
#else
#warning other
#endif
#else /* TEST */
#warning not in test so should be no other warnings #endif

#else

#ifndef TEST
#warning not in test so should be no other warnings #else
#warning in test
#if X >= 4
#warning x
#elif Y >= 4
#warning y
#else
#warning other
#endif
#endif

#endif

#10 lore raw

Re: dev86-0.16.8 cpp bugs

Quoted 3 lines · Manuel Novoa III

Hello Robert,

Some bugs in 0.16.8's cpp I'm afraid. Try the following.

Okay, looks like I wasn't correctly ignoring nested #elif's. The patch attached should fix that.

The type change for the if_stack allows it to work with any #if nesting unless you make a nesting error (It will fail to detect some).

Signature · 2 lines
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                       <http://www.cix.co.uk/~mayday>
cpp/cpp.c +8 -1
diff -Nurd linux86.old/cpp/cpp.c linux86/cpp/cpp.c
@@ -83,7 +83,7 @@
 static int if_false = 0;
 static int if_has_else = 0;
 static int if_hidden = 0;
-static int if_stack = 0;
+static unsigned int if_stack = 0;
 
 struct arg_store {
    char * name;
@@ -905,6 +905,13 @@
 int type;
 {
    int ch = 0;
+   if(if_false && if_hidden)
+   {
+      if( type != 3 ) if_hidden++;
+      do_proc_tail();
+      return 0;
+   }
+
    if( type == 3 )
    {
       if( if_count == 0 )
#11 lore raw

Re: dev86-0.16.8 cpp bugs

Robert,

Applied your if-patch.diff and things seem to be working fine now. Haven't noticed any other problems, but I'll continue testing.

Manuel