Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24



In article <43515ad8$0$6777$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Andreas Schwarz <usenet@xxxxxxxxxxxxx> writes
>Ian Bell schrieb:
>> Andreas Schwarz wrote:
>>
>>
>>
>>>Printf was only an example, the same applies to strcmp, puts, and many
>>>more, not to mention your own functions that operate on constant arrays.
>>>And besides, I don't think there's anything wrong with using printf on 8
>>>bit controllers. It makes serial debugging, LCD usage and things like
>>>that much more comfortable, and the additional 2-3 kB scarcely matter.
>>
>>
>> LOL, that 2-3K makes a huge difference in products with 16K ROM or less and
>> there are very many of those.
>
>Optimization (writing a specialized function instead of using one from
>the library is nothing but optimization) is done when necessary, and no
>sooner. If your program with printf & Co. is 14k large and you target a
>16k microcontroller, replacing standard functions with specialized code
>will gain you absolutely nothing, but takes time, is error-prone, makes
>your code larger and hurts maintainability.

This is absolute rubbish. A simple function to put a character or two
out to a serial line will only be a few bytes long.

As printf has to use this functionality to address the hardware, and you
may want to re-direct printf, it is often made available in source form
in the library. All you have to do is get the routine. Typically it is
only 4-5 lines of C.

Or you could do it yourself but if writing a SIMPLE function like this
"takes time, is error prone" should you be programming embedded systems
at all?

It will make you code 2-3K smaller and does NOT hurt maintainability at
all. IT gains you a lot as it makes the test outputting smaller and
faster so it distorts the memory map less than printf and changes the
time by a lot less.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@xxxxxxxxxxxx www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



.



Relevant Pages

  • Re: read in a multi core x86 cpu
    ... There is no really gain, because both CPUs have to fill-in their ... if one core try to access any loacation used by any other core ... the first time i have a thread problem was when my printf like function ... to use one therad syncopation routines, ...
    (alt.lang.asm)
  • Re: nonsense in TR24731, ??6.5.3.1
    ... observes that it may leak information and concludes that printf is wrong and ... The program fragment is certainly a poor choice, ... perhaps not enough of a gain to warrant an "_s for safe" suffix. ...
    (comp.std.c)
  • Re: RegEx needed
    ... Except for possible gain of formatting controls with printf, ... see the advantage of using printf since echo is also a builtin. ...
    (comp.unix.shell)
  • Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
    ... If your program with printf & Co. is 14k large and you target a 16k microcontroller, replacing standard functions with specialized code will gain you absolutely nothing, but takes time, is error-prone, makes your code larger and hurts maintainability. ... This is absolute rubbish. ... Most libraries have a printf ...
    (comp.arch.embedded)