Chris Hills (in
[email protected]) said:
| In article <
[email protected]>,
| (e-mail address removed) writes
||
|| Chris Hills wrote:
|||
||| I rarely see portability high on anyone's list out side C.l.c
||
|| I'm astonished.
|
| It's true. Some people woke in an environment where portability is a
| concern. A lot of the people like PJP who write libraries and
| components etc do write portable code but the majority of the C I
| see is definitely NOT portable. There is not point to having it
| portable and in fact if it were portable C the programmer would
| probably be fired.
|
| Why because in most embedded systems you are talking directly to HW
| there is no OS. Their architectures require non standard C.
|
| To write it as portable C would make it slower and larger. If
| Larger so that it requires more memory it could add 50cents to a
| unit... over 100K units a year that is 50,000 USD a year... that is
| why small and fast and never mind the portability is way it works.
That's an interesting observation. My experience has been somewhat
different, in that I've been able to efficiently isolate processor-
and device-specific code and write the remainder in standard C. By so
doing, I've made possible the re-use of large amounts of expensively
produced code. One can isolate PHY-, MAC-, and timer-specific code and
implement the remainder of an ethernet driver portably. Interestingly,
rewriting large amounts of the code in a cable modem product as
standard C allowed turning on full gcc optimization resulting (all by
itself) in both smaller and faster code. I believe that since that
time, that firm has replaced the MIPS processor with an ARM and, if
so, very probably saved enough by reusing the standard-conforming
modules to make the $50K savings seem almost trivial.
In my next embedded system project, I wrote a p-code processor in
standard C that used an array of function pointers to dispatch /all/
of the hardware-specific functions which allowed that code to be used
to control all of the company's products that used embedded
controllers - where they had previously developed (from scratch)
complete software controller packages for each _model_ of every
product line. The expected short-intermediate term savings were huge
(I could happily retire on a new ocean-going yacht for less than 10%
of that.)
| Besides once you have invested in the tools for a particular
| processor IE compilers and ICE you don't want to buy a new set. the
| code is usually "portable" to another MCU in the same family anyway.
I'll agree with what you say about "want" and 'same-family
portability'; but there's often a (winning) business case for moving
on to newer, more-efficient architectures.
I'm not questioning the validity of your experience - just pointing
out that my own has been somewhat different.