avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:[avr-gcc-list] Choose where the code is placed in flash memory


From: Andrew Edgecombe
Subject: Re:[avr-gcc-list] Choose where the code is placed in flash memory
Date: Thu, 05 Dec 2002 15:33:54 +1100

> My question is: For what reason is it justified to lock something to a 
> specific address instead of allowing the compiler/linker do it's job?
> 
> What makes this any different then using "Magic number" and global variables 
> that are difficult to maintain and support?
> 
> Jeff

Hi,
Obviously I can't answer for this particular case (not being the person
that asked the question ;-)
But, cases where being able to set the location of functions is useful
in a number of different cases.
To name a couple:
One is being able to set a function to execute out of ram, to enable
flash upgrade functionality.

Another is to (on some platforms) produce faster blocks of code, where
you can guarantee the juxtaposition of functions that are common to the
a functional block, and so be sure that short jumps can be used.
For the same reason, it might be used to optimise a chunk of table
driven code, in that you might be able to simplify the mapping between 
(let's say) a 1 byte command from a protocol, and the handler for that
command.

It's true that this does make the code less generic than allowing the
linker to generate all of the locations, but as long as this type of
trick is used sparingly, and comes with complete documentation, it's
quite a reasonable thing to do. Particular if it's the difference
between the project working and not.

Anyone have change for 2 cents? :-)
-- 
Andrew Edgecombe <address@hidden>

avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]