[comp.os.os9] Buggy Microware 6809 C Compiler

paulr@umbc5.umbc.edu (Paul Riddle) (07/08/90)

Hi everybody,

I was feeling bored yesterday, so I decided to dust off my old Berkeley 2.9BSD
source tape and see how many of the utilities I could get to compile and run
on my CoCo 3 running 6809 OS-9 level 2.  I'm using the original Microware
Level 1 C compiler, with a new compiler driver (cc2) and the Krieder C Library.
I don't know if it's the latest version of the library, I confess I haven't
really kept up with the OS-9 scene lately.  I chose 2.9 over 4.3 because the
2.9 code predates the ancient level 1 C compiler, so I figured I'd have an
easier time getting the code to compile (no void types, etc).

Well, I didn't have to wait too long before I encountered problems; I compiled
'cat', ran it, and my computer locked up.  I was able to isolate the problem
to the following:

#include <stdio.h>

main (argc, argv)
   int argc;
   char *argv[];
{
   FILE *fp;
   if (--argc && (fp = fopen (*++argv, "r"))) {
      copy (fp);
      exit (0);
   }
   exit (1);
}

copy (fp)
   FILE *fp;
{
   int c;
loop:
   c = getc (fp);
   if (c == EOF)
      return;
   putchar (c);
   goto loop;
}

(Note:  It didn't lock up immediately; it ran through about half the file
and then died.  It did this with every file I tried.)

I agree this is twisted (I didn't write the code!), but there is no reason
why it shouldn't work.  I re-arranged the routine a little bit and eliminated
the goto, and it worked fine.

So, my question is:  does anyone have a documented list of nasty little bugs
like this?  I haven't tried the standard Microware C library with the original
code, but I kind of doubt that the Krieder Library is at fault here.  Of
course, I could be wrong.

Thanks,
Paul Riddle                         | paulr@umbc3.umbc.edu
Systems Programmer / Administrator  | ...!{uunet,haven}!umbc3!paulr
UMBC, Computer Science Department   |
Baltimore, MD 21228                 | (301) 455-3962

koonce@brahms.berkeley.edu (tim koonce) (07/10/90)

In article <3583@umbc3.UMBC.EDU> paulr@umbc5.umbc.edu (Paul Riddle) writes:
>So, my question is:  does anyone have a documented list of nasty little bugs
>like this?  I haven't tried the standard Microware C library with the original
>code, but I kind of doubt that the Krieder Library is at fault here.  Of
>course, I could be wrong.
>

I've seen a couple of bug lists around.  The two worst ones I know are:

- Goto handling is pretty messed up.  Greg Law on Delphi studied this,
  and concluded that it's the result of a well-intentioned attempt to
  neatly handle the stack frame.  Turns out that using Goto's will
  cause the stack to walk.

- Multi-dimensional arrays are interpreted in a different order within
  functions than without.  i.e. don't use global multi-dimensional
  arrays.

- Eddie Kuns ran across a problem where for statements with a null
  increment statement were handled incorrectly.  Don't remember the
  details.

Not too bad for a 10-year old compiler running on an 8-bit processor
that I managed to pick up on sale for only $50, but annoying
nonetheless.

                              - Tim Koonce

knudsen@cbnewsd.att.com (michael.j.knudsen) (07/10/90)

OK, you found the same bug that I did -- Microware 6809 C cannot
have a goto'ed label as the first executable stmt in a function.
If it does, the funny wasteful code inserted (to make jumps in and
out of blocks with local variables) causes the stack pointer to
"walk."

Some folks on the Coco mail list may have saved bugs over the years.
I some in various files.  At one time a certain Microware employee was
saving them, but maybe his boos wouldn't like to see them all
posted at once ^-).

BTW, #define void int  helps a lot with newer sources.
I use it for my own stuff.
-- 

"Round and round the while() loop goes;
        Whether it stops," Turing says, "no one knows."

jejones@mcrware.UUCP (James Jones) (07/10/90)

In article <1990Jul9.180504.26844@agate.berkeley.edu> koonce@brahms.berkeley.edu.UUCP (tim koonce) writes:
>- Eddie Kuns ran across a problem where for statements with a null
>  increment statement were handled incorrectly.  Don't remember the
>  details.

Here are the details: the 6809 compiler will generate a goto for
continue statements in for loops with null "increment" parts
that will bypass the test part, and thus the compiled program
may have an unfortunate tendency to never escape the loop.

	James Jones

cmf@obie.cis.pitt.edu (Carl M. Fongheiser) (07/25/90)

Is it still possible to get Microware 6809 C?  I recently acquired a Coco3
running OS9 level II, and I desperately want a C compiler for it.  I don't
really feel like dealing with Basic09.


					Thanks,
					Carl Fongheiser
					cmf@unix.cis.pitt.edu

johnt@usdsd1.Dayton.NCR.COM (John Teague) (07/25/90)

In article <26203@unix.cis.pitt.edu> cmf@obie.cis.pitt.edu (Carl M. Fongheiser) writes:
>Is it still possible to get Microware 6809 C?  I recently acquired a Coco3
>running OS9 level II, and I desperately want a C compiler for it.  I don't
>really feel like dealing with Basic09.
>
Microware's C compiler is still available from most Radio Shacks for around 
$99.  It is the same C compiler that ran under Level I.

frans@sis.uucp (Frans Lichtenberg) (07/27/90)

In article <115@usdsd1.Dayton.NCR.COM> johnt@usdsd1.UUCP (John Teague) writes:
>In article <26203@unix.cis.pitt.edu> cmf@obie.cis.pitt.edu (Carl M. Fongheiser) writes:
>>Is it still possible to get Microware 6809 C?  I recently acquired a Coco3
>>running OS9 level II, and I desperately want a C compiler for it.  I don't
>>really feel like dealing with Basic09.
>>
>Microware's C compiler is still available from most Radio Shacks for around 
>$99.  It is the same C compiler that ran under Level I.


In Canada you can get the same C-compiler at Radio Shacks for US$25.

               Frans.......

cmf@obie.cis.pitt.edu (Carl M. Fongheiser) (07/29/90)

In article <1662@sis.uucp> frans@sis.uucp (Frans Lichtenberg) writes:
>In article <115@usdsd1.Dayton.NCR.COM> johnt@usdsd1.UUCP (John Teague) writes:
>>Microware's C compiler is still available from most Radio Shacks for around 
>>$99.  It is the same C compiler that ran under Level I.
>
>
>In Canada you can get the same C-compiler at Radio Shacks for US$25.

OK, is this a special order item, or should it be available in the
stores?  I haven't seen it in *any* of the Radio Shacks in the area.
If it is special order, what's the catalog number?

If it is available in stores, where?  (Especially in Canada -- my
brother goes to RIT and makes frequent forays to Toronto and environs.)

				Thanks again,
				Carl Fongheiser
				cmf@unix.cis.pitt.edu

frans@sis.uucp (Frans Lichtenberg) (07/30/90)

Their are two C-compileirs sitting in a RS store on Speers Rd. in
Oakville west of Toronto.

                 Frans......

johnt@usdsd1.Dayton.NCR.COM (John Teague) (07/31/90)

In article <26313@unix.cis.pitt.edu> cmf@obie.cis.pitt.edu (Carl M. Fongheiser) writes:
>
>OK, is this a special order item, or should it be available in the
>stores?  I haven't seen it in *any* of the Radio Shacks in the area.
>If it is special order, what's the catalog number?
>
Catalog number 26-3038.  Some Radio Shacks carry very little os9 software.
However, with the catalog number you should be able to have it ordered 
from any RS Store.  Of course, if you have to order it, I doubt you'll
get it for the $25 mentioned in a previous article.