Re: Microcontroller Compilers (C)

"Jan Gray" <>
15 Feb 2001 00:31:04 -0500

          From comp.compilers

Related articles
Microcontroller Compilers (C) (2001-02-12)
Re: Microcontroller Compilers (C) (Jan Gray) (2001-02-15)
Re: Microcontroller Compilers (C) (Klaus Rotter) (2001-02-15)
Re: Microcontroller Compilers (C) (2001-02-15)
Re: Microcontroller Compilers (C) (Kyle) (2001-02-15)
Re: Microcontroller Compilers (C) (2001-02-15)
Re: Microcontroller Compilers (C) (Preston Gurd) (2001-02-15)
Re: Microcontroller Compilers (C) (QarnoS) (2001-02-15)
[6 later articles]
| List of all articles for this month |

From: "Jan Gray" <>
Newsgroups: comp.compilers
Date: 15 Feb 2001 00:31:04 -0500
Organization: Gray Research LLC
References: 01-02-046
Keywords: C
Posted-Date: 15 Feb 2001 00:31:03 EST

"Matt Guthaus" <> wrote in message
> What would people recommend for the fastest way to get a prototype
> compiler working? GCC or LCC? Another compiler with a portable
> backend?

In my experience, lcc has the advantages that it is simple, well
documented, and provides very good support for targeting non-32-bit

In particular, 1) the machine-description Interface structure has
fields to specify the size of all the builtin types, znc the "right
things" happen with respect to integral promotion if sizeof(int) <
sizeof(long), etc.; and 2) the "ops" utility will print the minimal
dag operator set required for a machine with various sizes of builtin

Please see my earlier comp.compilers article on porting lcc to a
16-bit RISC [].

Even though the three machine descriptions bundled with lcc are 32-bit
(MIPS, x86, SPARC), lcc does work well with 16-bit ints and pointers.
In limited use of my lcc port, only one word size related bug has been
noted, which pertained to integral promotion of unsigned hexadecimal
constants, and which was easily found and fixed

If you go with lcc you still need an assembler and linker. In the
spirit of minimalism, I wrote a simple assembler/simulator (2000 lines
of code). For separate compilation, instead of an object code linker,
I just copy assembly source to .o "object files", and "link" them in
the assembler, essentially by assembling their catenation and doing
the right thing with .extern's. In practice this is adequate for
simple embedded development.

In the long run, you may want to do a GCC port as well, to unlock the
treasure chest of languages, libraries, OSs, and applications that
require it. I do!

Jan Gray, Gray Research LLC

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.