One thing you can do is to declare your variables __no_init. Then
there is no need for the __low_level_init routine to be implemented by
cstartup. Of course you then have to initialize your variables (if
needed) yourself!
Another small improvement I often use is to make a local copy of
cstartup.s43 ,change it and add it to your project files, so the
changed version is compiled and linked to your project.
I use the following changes:
cstartup.s43:
...
XRSEGCSTART
PUBLIC ?cstart_call_main
I don't need exit-code since I always have a endless-loop at the end
of main(). Furthermore I don't call main, instead I branch to main,
that saves me 2 bytes on the stack.
Every byte counts... ;-)
Reply by Anders Lindgren●March 10, 20082008-03-10
vincbr900 wrote: > --- In m... ,
> "Stuart_Rubin"
> wrote:
> > Out of curiosity, how many precious bytes are being "lost?"
> >
> > I would be surprised if this is your best first pass at optimizing
> > flash memory, but I assume that you've already exhausted the
> > low-hanging fruit (i.e. turned-on the optimizers, using a different
> > (or none) standard library, etc.)
> >
> > Which compiler are you using?
>
> Hi, thanks for your replies on this guys.
>
> I am using the IAR Embedded workbench with the EZ430 which targets
> F2012/3. The Compile is Version 5.11 of the 4kb kickstart from the TI
> website. Optimisation is full and DLIB is used, but it was the
> startup and exit code I wanted to lean off as they are not
> optimisable as are hard coded assembly. I am not familiar with MSP430
> assembly and the startup/exit files are confusing with a lot of
> compiler directives, hence the request for help. I think they have a
> lot of flexibility for features which I would not use on such a small
> target, such as initialising variables, copying data constants into
> RAM etc.
Have you taken a look of what actually is included in your project?
The CStartup-file is designed so that the parts of that you don't need
are excluded by the linker, for example dynamic initialization of C++
objects.
For example, an "empty main" project will only contain an initialization
of SP, a call to main, a call to "exit" and the exit functions. All on
all 26 bytes... > A module map for the 'flashing the LED'
project in C is below. As you
> can see, 40 bytes are used for entry/exit code, which is almost 2% of
> the total available.
This is partly due to the fact that you're linking your application in
debug mode (indicated by the ?__dbg_break symbol). If you rebuild it in
release mode some of the bytes will disappear.
If you still aren't satisfied you can customize the startup code any way
you want.
-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.
Reply by vincbr900●March 10, 20082008-03-10
--- In m..., "Stuart_Rubin"
wrote: > Out of curiosity, how many precious bytes are being
"lost?"
>
> I would be surprised if this is your best first pass at optimizing
> flash memory, but I assume that you've already exhausted the
> low-hanging fruit (i.e. turned-on the optimizers, using a different
> (or none) standard library, etc.)
>
> Which compiler are you using?
Hi, thanks for your replies on this guys.
I am using the IAR Embedded workbench with the EZ430 which targets
F2012/3. The Compile is Version 5.11 of the 4kb kickstart from the TI
website. Optimisation is full and DLIB is used, but it was the
startup and exit code I wanted to lean off as they are not
optimisable as are hard coded assembly. I am not familiar with MSP430
assembly and the startup/exit files are confusing with a lot of
compiler directives, hence the request for help. I think they have a
lot of flexibility for features which I would not use on such a small
target, such as initialising variables, copying data constants into
RAM etc.
A module map for the 'flashing the LED' project in C is below. As you
can see, 40 bytes are used for entry/exit code, which is almost 2% of
the total available.
Out of curiosity, how many precious bytes are being "lost?"
I would be surprised if this is your best first pass at optimizing
flash memory, but I assume that you've already exhausted the
low-hanging fruit (i.e. turned-on the optimizers, using a different
(or none) standard library, etc.)
Which compiler are you using?
Stuart
--- In m..., "vincbr900" wrote: >
> Hi,
> I am using the ez430. I cant help noticing that precious bytes are
> being lost on _exit __exit functions and startup code. Does anyone have
> any lean startup and exit function they would be willing to share,
> along with caveats?
>
> With only 2kbytes to work with everything counts!
>
> Thanks, Vincent
>
Reply by old_cow_yellow●February 29, 20082008-02-29
You can write your own startup and exit in assembly. You can write the
entire program in assembly too.
--- In m..., "vincbr900" wrote: >
> Hi,
> I am using the ez430. I cant help noticing that precious bytes are
> being lost on _exit __exit functions and startup code. Does anyone have
> any lean startup and exit function they would be willing to share,
> along with caveats?
>
> With only 2kbytes to work with everything counts!
>
> Thanks, Vincent
>
Reply by vincbr900●February 29, 20082008-02-29
Hi,
I am using the ez430. I cant help noticing that precious bytes are
being lost on _exit __exit functions and startup code. Does anyone have
any lean startup and exit function they would be willing to share,
along with caveats?