Re: Portability: Harmony between PC and microcontroller
- From: Chris Dollin <chris.dollin@xxxxxx>
- Date: Tue, 06 May 2008 13:40:21 +0100
Tomás Ó hÉilidhe wrote:
On May 6, 12:33 pm, Chris Dollin <chris.dol...@xxxxxx> wrote:
That just means that those microcontrollers aren't a natural fit
to C, so programmers writing looks-like-C for them need to be
aware that natural-C idioms might not work as nicely.
This is what I'm against. When I first started programming in C for
embedded systems, I was weary of the compiler's compliance to the
Standard. I was hesitant to rely on rules from the Standard when it
came to things like:
* Minimum size of integer types
* Behaviour of overflow
* Existance and usage of a stack
Having written a fully working program though in C for embedded
systems, and also having looked at the assembler produced to check
what it's actually doing, I've seen that my embedded compile is
extremely compliant. I defined an object as "long unsigned", and lo
and behold the assembler produced used four bytes to store it (even
though it can only do arithmetic on 8-Bit numbers).
I don't see a problem here.
The problem comes with writing portable code.
No, it doesn't. Not if the compiler conforms to the standard.
For instance, I'm
currently writing code to implement an internet protocol router. The
code show be able to run on both a microcontroller and on a PC.
However, if the code uses "int" then the code will be less efficient
on a microcontroller.
Your problem is not with portability; it's with performance.
Different platforms can have differing performance profiles
at whim, and portable code may need tweaking for best performance
on /any/ of them. Singling out performance issues on 8-bit
micros and thinking everyone should write code so that it
(by /hypothesis/) performs equally (well, badly) on those
implementations is, I think, obsession over microefficiency.
--
"The one you're playing, I think." /The Lion Game/
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
.
- Follow-Ups:
- Re: Portability: Harmony between PC and microcontroller
- From: Tomás Ó hÉilidhe
- Re: Portability: Harmony between PC and microcontroller
- References:
- Portability: Harmony between PC and microcontroller
- From: Tomás Ó hÉilidhe
- Re: Portability: Harmony between PC and microcontroller
- From: Chris Dollin
- Re: Portability: Harmony between PC and microcontroller
- From: Tomás Ó hÉilidhe
- Portability: Harmony between PC and microcontroller
- Prev by Date: Re: pointer to integer to pointer conversions
- Next by Date: String literals and storage duration
- Previous by thread: Re: Portability: Harmony between PC and microcontroller
- Next by thread: Re: Portability: Harmony between PC and microcontroller
- Index(es):
Relevant Pages
|