Re: Microcontroller Compilers (C)

"Jan Gray" <jsgray@acm.org>
15 Feb 2001 00:31:04 -0500

          From comp.compilers

Related articles
Microcontroller Compilers (C) mobius@news.eecs.umich.edu (2001-02-12)
Re: Microcontroller Compilers (C) jsgray@acm.org (Jan Gray) (2001-02-15)
Re: Microcontroller Compilers (C) rotter@touch.rotters.de (Klaus Rotter) (2001-02-15)
Re: Microcontroller Compilers (C) nej22@cl.cam.ac.uk (2001-02-15)
Re: Microcontroller Compilers (C) kyle_hayes@pacbell.net (Kyle) (2001-02-15)
Re: Microcontroller Compilers (C) vbdis@aol.com (2001-02-15)
Re: Microcontroller Compilers (C) rpgurd@archelon.com (Preston Gurd) (2001-02-15)
Re: Microcontroller Compilers (C) qarnos@ozemail.com.au (QarnoS) (2001-02-15)
[6 later articles]
| List of all articles for this month |

From: "Jan Gray" <jsgray@acm.org>
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" <mobius@news.eecs.umich.edu> 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
machines.


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
types.


Please see my earlier comp.compilers article on porting lcc to a
16-bit RISC [www.fpgacpu.org/usenet/lcc.html].


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
[//groups.yahoo.com/group/fpga-cpu/message/28].


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.