Re: Just what makes an architecture "C Friendly"?
- From: fox@xxxxxxxxxxxxxxxxxxx
- Date: 1 Jun 2006 23:41:08 -0700
Richard wrote:
+ Easy stack manipulation (C by its nature likes to use a stack).
+ No hard limits on stack size (other than the amount of RAM naturally).
+ Decent number of registers for use by the compiler.
+ Instruction set that is easily mappable to C constructs.
+ etc.
Yes, but I would go much further.
byte addressing
indexed addressing mode
Technically a stack in only accessed from one end. Last-in First-out.
I don't know if it is 'by nature' but perhaps it is. But C in practice
often uses a single stack to hold stack frames, and stack frames
are not Last-in First-out access that defines a 'stack'
Using a stack for stack frames requires "easy stack manipulation"
as you put it. And it requires an indexed addressing mode and
the ability to index into a stack frame to get at arrays in memory.
And putting arrays in memory inside of stack means that you want,
as you put it, want "no hard limits" on stack size.
Forth does not use the strict computer science definition of a
stack either because many common Forth words access the top
two cells on the stack, not just the top one. And many Forth
provide a way to index deep into a stack and build stack frames
like in C. But parameters are passed between words on one
stack while return address and control flow parameters and locals
may go on a different stack. So two LIFO stacks might be all
that is needed there. And it might be easily demonstrated that
complex apps may need very few data stack and return stack cells
and could be very happy with what would be seen as serverely
size limited stacks from a C programmer's perspective.
But C will usually want byte addressing and indexed addressing and
the ability to put arrays of arbitrary size into stack frames and
manipuate stack pointers into memory easily. So C would not
like a hardware LIFO stack very much especially if it was small.
There are many people who love Unix and Linux and GNU and GCC
and all that great stuff. They are likely to feel that what makes an
architecture "C Friendly" is that it runs what C was designed to write.
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.
And I think that there are other things needed to support traditional
multi-user, multi-tasking, OS protected systems running potentially
hostile or destructive programs in a modern way. You are going to
need to trap many errors and have a way out.
Stack overflow.
Stack underflow.
Watchdog timer recovery from certain deadlock conditions,
Interrupts,
Memory protection faults,
Divide by zero,
Etc.
C strictly speaking doesn't need any of this stuff. But if
architectures
don't have it people will definately tell you that it is not C
friendly.
Take my Pic.
Please!
.
- Follow-Ups:
- Re: Just what makes an architecture "C Friendly"?
- From: Grant Edwards
- Re: Just what makes an architecture "C Friendly"?
- From: Darin Johnson
- 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
- Just what makes an architecture "C Friendly"?
- Prev by Date: Re: keil compiler
- Next by Date: Re: what's wrong with a pic ?
- 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
|