Truncated match.
PICList
Thread
'C compiler in java for PIC'
1998\01\09@043558
by
Giorgio Alboni
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 <pic.h>? and <conio.h>?
Any suggestion is welcome.
Thanks in advance.
Giorgio Alboni.
===================================================
Alboni Giorgio
Faenza (Ra) ITALY
E-Mail: spam_OUTrac1337TakeThisOuT
racine.ravenna.it
www.geocities.com/SiliconValley/Heights/5444
(Last Update: 29/09/97)
===================================================
1998\01\09@070252
by
anick
|
Remeber that a compiler generates the machine language (i.e. op codes
with data) for the target processor.
So you would need to learn the PIC opcodes and such so that you can
compile the C code into PIC opcodes.
Since you are suppose to wrate a compiler I woulde assume that your free
to design it as you wish.
Giorgio Alboni wrote:
{Quote hidden}>
> 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 <pic.h>? and <conio.h>?
> Any suggestion is welcome.
> Thanks in advance.
> Giorgio Alboni.
>
> ===================================================
> Alboni Giorgio
> Faenza (Ra) ITALY
> E-Mail:
.....rac1337KILLspam
@spam@racine.ravenna.it
>
> www.geocities.com/SiliconValley/Heights/5444
> (Last Update: 29/09/97)
> ===================================================
1998\01\09@173634
by
Giorgio Alboni
At 07.01 09/01/98 -0500, you wrote:
>Remeber that a compiler generates the machine language (i.e. op codes
>with data) for the target processor.
>So you would need to learn the PIC opcodes and such so that you can
>compile the C code into PIC opcodes.
The output of the compiler is assembler code (text file) for the mplab.
>Since you are suppose to wrate a compiler I woulde assume that your free
>to design it as you wish.
OK, but i prefer use a standar grammar for the source code with the
neccessary extension at C lenguager for manege a assembler code.
Giorgio Alboni.
===================================================
Alboni Giorgio
Faenza (Ra) ITALY
E-Mail: rac1337
KILLspamracine.ravenna.it
www.geocities.com/SiliconValley/Heights/5444
(Last Update: 29/09/97)
===================================================
1998\01\10@203622
by
Eric W. Engler
|
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 <pic.h>? and <conio.h>?
>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
1998\01\11@125641
by
orgio Alboni
|
At 18.10 10/01/98 -0700, you wrote:
>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).
I'm doing the last year of university (engineering).
I use the PIC 16C84.
>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)?
I'm using a recursive descent parser (or a table driven?), it's easy to make.
The real problem is run-time library. PIC microcontroller haven't a stack
area, so there are some problem to pass variables and manage the free
register.
{Quote hidden}>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".
>
Thanks for your help, I've found some good compiler at:
http://hem.passagen.se/zeela/
Bye.
===================================================
Alboni Giorgio
Faenza (Ra) ITALY
E-Mail: .....rac1337KILLspam
.....racine.ravenna.it
www.geocities.com/SiliconValley/Heights/5444
(Last Update: 29/09/97)
===================================================
1998\01\11@143927
by
Walter Banks
> I'm using a recursive descent parser (or a table driven?), it's easy to
make.
> The real problem is run-time library. PIC microcontroller haven't a stack
> area, so there are some problem to pass variables and manage the free
> register.
There is often an assumption that C needs a stack frame for locals or
argument passing. There is nothing in the language that dictates this. One
of the reasons that C as a language is popular is that it maps quite well
on many different processor architectures.
A lot of the recent work we have been doing with C tools for
embedded systems has shown that C can have diverse memory spaces
far more than Harvard architecture processors have. We have shown that
Locals and argument passing can be handled in ways unique to each
processor and the resulting compilers can pass both standard C
conformance tests and portability tests.
Walter Banks
1998\01\11@195209
by
John Payson
|
> > I'm using a recursive descent parser (or a table driven?), it's easy to
> make.
> > The real problem is run-time library. PIC microcontroller haven't a stack
> > area, so there are some problem to pass variables and manage the free
> > register.
>
>
> There is often an assumption that C needs a stack frame for locals or
> argument passing. There is nothing in the language that dictates this. One
> of the reasons that C as a language is popular is that it maps quite well
> on many different processor architectures.
One simple approach that works well for local variables (somewhat less well
for argument passing) is to figure out where on the stack each variable would
go, worst-case, on a stack-based machine. For non-recursive programs, it's
always possible to assign addresses in this way, and the number of addresses
required by this method will equal the maximum depth that the program could
need if it used a stack.
The only drawback to this approach (or a bottom-up approach which yields the
same memory requirements, but orders things differently) is that special
care needs to be used for parameter marshalling. For example, consider this
program:
int foo(int p, int q) {return p+q;}
int boz(int s, int t) {return s*t;}
int bar(int u, int v) {return u-v;}
int floozle(int ss, int tt, int uu, int vv)
{
return foo(boz(ss,tt),bar(uu,vv));
}
It isn't possible to use a fixed address for foo's parameters unless some
other area is used for "parameter martialling". In particular, a compiler
given the above code should translate the last function into:
int floozle(int ss, int tt, int uu, int vv)
{
int temp1;
boz.s = ss; boz.t = tt; CALL boz;
temp1 = RESULT;
bar.u = uu; bar.v = vv; CALL bar;
foo.p = temp1; foo.q = RESULT; CALL foo;
}
where function.param is the variable allocated to that function's parameter,
and RESULT is a system global used to hold function return values. If the
compiler always allocates a temp for all but one of the "complex" parameters
to a function, it will work okay though it will in many cases generate data
moves that turn out to be redundant. On the other hand, all of the PIC-based
compiles I've seen choke on the above example program, so maybe parameter
marshalling may be safely ignored in practice (since such programs are rare).
1998\01\13@053027
by
Giorgio Alboni
part 0 653 bytes
thanks John, this method seems to me that is good. Not so good for argument
passing but for a beta it can be ok.
My goal is to make a simple c compiler thats product a asm code for MPLAB,
full commented and easy to modify with a no run time support (or very small
and easy to understand = modify).
Take a look at the grammar.
Bye.
Attachment converted: wonderland:Grammar.htm (TEXT/ttxt) (0000FA14)
===================================================
Alboni Giorgio
Faenza (Ra) ITALY
E-Mail: EraseMErac1337spam_OUT
TakeThisOuTracine.ravenna.it
www.geocities.com/SiliconValley/Heights/5444
(Last Update: 29/09/97)
===================================================
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- Today
- New search...