Re: Just what makes an architecture "C Friendly"?
- From: "Darin Johnson" <darin@xxxxxxx>
- Date: 3 Jun 2006 20:20:17 -0700
fox@xxxxxxxxxxxxxxxxxxx wrote:
And GCC is clear that it wants a machine with
byte addressing
indexed addressing mode
lots of general purpose registers
32-bits wide or more, preferably in a power of 2
and with enough memory to run GCC.
But "C friendly" means several things. When GCC says this, I'm pretty
sure it means "friendly environment in which to implement a GCC
compiler". So you've got several meanings here:
Friendly for a C programmer to use as the destination platform.
Friendly for C compiler writers (as a destination).
Friendly for running a C compiler on.
I'm pretty sure that the third wasn't what the original question was
asking. The second is interesting of course, but there are far more C
users than C compiler writers. But too much unfriendliness for the
compiler writers can translate into unfriendliness for the compiler
user (or the compiler writers may just decide that it's not worth the
time and money to implement some feature if the expected audience
isn't likely to use it).
It's also not clearly defined what "friendly" means. All features of
C most certainly can be implemented on the PIC16 family, but few would
classify it as C friendly. The snag is that many of the features
come with limitations or efficiency costs (size or speed). So I'd say
that "friendly" means that the author of C code runs into a minimum of
snags and gotchas. Fewer limitations, less effort involved in
getting fast or small code, fewer workarounds, etc.
For instance, the C compiler for the PIC I sometimes use seems to
have a lot of features, and the code it accepts if very much like C.
But it is more difficult for me to maintain the PIC C code in my
job than it is to maintain the 32-bit RISC C code. That's because
of the C style necessary to get fast and small code on the PIC.
It has lots of global variables, long unfactored functions,
miscellaneous unique keywords, and so forth. Some may be due to
the small size of code space, but much is due to other limitations.
So the C compiler for the PIC is unfriendly because in order to use
it efficiently one must be careful of how they write the code and be
aware of the limitations - reading the compiler manual thoroughly is
mandatary, and examining generated output code is highly recommended.
While the PIC assembler writer may have to jump through the same
hurdles as the PIC C compiler writers or C writers, assembler writers
know up front that they're writing non-portable code and what the
various snags are. C authors generally use the language as a tool to
express their application in, and may often find out much later that
what looked like decent code has contributed to bloat or slowness.
So "C friendly" may mean that you can just start writing without
worrying about the target processor and still get a reasonable result.
Here's something to think about from a philosophical point of view.
If a C compiler has to jump through hoops and use lots of instructions
to do something that would be simple on comparable processors, but the
equivalent human written code in assembler has to jump through the
same hoops, then is the C compiler unfriendly? For instance,
accessing constants that are stored in code space. On one hand there
are hurdles for the C programmer, and possible a restricted style of
C has to be used. But on the other hand it may still save a lot of
time and be more maintainable than writing in assembler. The
processor might be considered unfriendly to all programmers, not just
C programmers.
--
Darin Johnson
.
- Follow-Ups:
- Re: Just what makes an architecture "C Friendly"?
- From: fox
- Re: Just what makes an architecture "C Friendly"?
- From: Mel Wilson
- Re: Just what makes an architecture "C Friendly"?
- From: Grant Edwards
- Re: Just what makes an architecture "C Friendly"?
- References:
- Just what makes an architecture "C Friendly"?
- From: Mike G
- Re: Just what makes an architecture "C Friendly"?
- From: Noway2
- Re: Just what makes an architecture "C Friendly"?
- From: Richard
- Re: Just what makes an architecture "C Friendly"?
- From: fox
- Just what makes an architecture "C Friendly"?
- Prev by Date: Re: Logic Analyzer Vs. Oscilloscope
- Next by Date: Re: Logic Analyzer Vs. Oscilloscope
- Previous by thread: Re: Just what makes an architecture "C Friendly"?
- Next by thread: Re: Just what makes an architecture "C Friendly"?
- Index(es):
Relevant Pages
|