At 10:30 AM 1/9/98 +0100, you wrote: >I'm a engineer student, for the next exam i have to make a C compiler for >the PIC microcontroller. I know the C language for Unix, Dos, windows, ecc. >but I don't now the characteristic of a C for a microcontroller. >There are some special instruction? I had read some source of PIC C >program, what is the content of ? and ? >Any suggestion is welcome. >Thanks in advance. >Giorgio Alboni. If you make the C compiler, then YOU decide what features to include. You are the one who writes the functions. You will need to concentrate on the I/O, timer, and interrupts. Make sure the functions you give to a programmer will do most of the things that embedded programmers need to do. You may want to check out the BASIC Stamp instructions to get ideas. Things like "shiftout", "debug", and port configuration (setting bits as inputs or outputs, then reading from them or writing to them. It sounds to me like you've taken on a monumental task for a college class. You need to use a small PIC as your target to keep it easier on you. I'd use one of the small 8 pin PICS as the target (12c509, etc). You can use yacc and lex if you want to create a state-machine parser, but recursive descent is easier. I'd choose to use a public domain Small C compiler, and just create a code generator (and maybe an optimizer) for it. You'll also need to create a run-time library for it. Will your teacher allow that (so you don't have to write a lexer, parser, etc)? Do a Web search for "GNU pic" and you'll see some stuff about folks who are converting some GNU tools to target the PIC. I don't know if they have a working C compiler yet. There is a good referance book on Small C by James Hendrix. Dr Dobbs Journal has published a CD with that complete book, and lots of other similar stuff on it. The only part that needs changing is the code generator (and, of couse, you'll need a RTL). You will have to be very fluent with PIC assembler in order to create a code generator for the PIC. Another option would be the Micro C compiler. Dave Dunfield wrote the Micro C compiler - it already has code generators for many different embedded processors. Do a Web search for Dunfield and "Micro C". Eric Engler