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



On Sun, 16 Oct 2005, Everett M. Greene wrote:

> Sergio Masci <sergio@xxxxxxxxxxxxxxxxx> writes:
> > On Sat, 15 Oct 2005, Andreas Schwarz wrote:
> > > Ian Bell schrieb:
> > > > Michael N. Moran wrote:
> > > > > Ian Bell wrote:
> > > > > > Andreas Schwarz wrote:
> > > > > >
> > > > > > > The problem is that you need different instructions to read
> > > > > > > from RAM and
> > > > > > > ROM, so you often end up with two functions that do the same
> > > > > > > thing, one
> > > > > > > for RAM arguments (printf), and one for ROM arguments
> > > > > > > (printf_P).
> > > > > >
> > > > > > Right so the *real* problem is handling large constant strings.
> > > > >
> > > > > Well ... strings are only one part of the problem.
> > > > > Any constant tables/arrays, such as:
> > > > >
> > > > > o state tables
> > > > > o lookup-tables
> > > > > o <shield-up> v-tables <shield-down>
> > > > >
> > > > > are problematic to most traditional compilers/languages that
> > > > > only understand a single contiguous address space.
> > > >
> > > > But surely that is a *compiler* issue not a fault of the underlying
> > > > architecture?
> > >
> > > No. To achive true transparency, the compiler would have to generate code that
> > > can tell a ROM address from a RAM address at runtime. Otherwise functions that
> > > take pointer arguments would not be possible.
> >
> > This is simply wrong. A compiler can trace the use of a pointer
> > throughout the code at compile time.
>
> Particulary not in the face of separate compilation. Even if the
> entire source is available, it still may not be able to determine
> where a pointer points (a number is a number is a number...).

where a pointer points to is not the issue, what a pointer is pointing to
is.

Consider a pointer to a "char". No mater where the pointer is pointing the
compiler knows it is pointing to a "char". Regardless of how you
manipulate the pointer the compiler will always derefernce it as a char
pointer. You can play hide and seek and force a non char pointer into it
but that is not the point. Here "char" is an attribute of the pointer and
the attribute is tracked throughout the use of the pointer at compile time
NOT runtime. Another attribute could easily be the address space (RAM,
CODE, I/O etc). The actual runtime contents is not important, the compile
time attribute is.

With regard to seperate compilation: don't make me laugh!

Yes it may have been necessary 20 years ago to compile a 10,000 line C
program as seperate 1,000 line modules because each module took 5 minutes
to compile (on a state of the art PDP/11). But today a 1,000,000 line
program takes less than 2 minutes to compile AND given that most programs
for a tiny MCU are much smaller than this, seperate compilation is not
necessary and in many cases it is actually counter productive from an
optimisation standpoint.



Regards
Sergio Masci

http://www.xcprod.com/titan/XCSB - optimising PIC compiler
FREE for personal non-commercial use



..


.



Relevant Pages

  • Re: C needs to grow up a little, move with the times, expand its horizons
    ... float myFunction(int a, char* c); ... The compiler would look for the "myFunction" by name, ... If that isn't mangling, what is it? ... RDC will not go further than pointer to pointers. ...
    (comp.lang.c)
  • Re: TEA Implementation
    ... The second argument should be a pointer to pointer to ... It should be the address of a pointer to char. ... compiler won't even accept it at all. ... Seems like a rather confusing way of writing ...
    (comp.lang.c)
  • Re: How to convert Infix notation to postfix notation
    ... and make all strings const save where the intent ... function whose contract is to change the string. ... the compiler "just" prevents the string ... try to do using the pointer you get. ...
    (comp.lang.c)
  • Re: large files: when ubiquitous?
    ... the pointer might be into shared ... compiler will make optimizations giving unexpected ... same with and without optimization, ... to a char pointer type or changing p to be a char ...
    (comp.os.linux.development.system)
  • Re: CASE mis-understanding?
    ... Jabberwocky poem when you dereference a NULL pointer; ... If you type "null pointer exploit" into a search engine, ... Of course the compiler doesn't emit Jabberwocky code. ... If compilers were supposed to do that, then the standard would say so. ...
    (comp.lang.forth)