Team,
I finally got around to taking a look at what happens to ram usage
(both static and stack) when you turn on the -s compiler optimization
option. It goes way down!!
So, using the -s optimization option is a clear winner.
I took a look at the assembly code to see what is going on in the
following areas:
1. Program space goes down by around 20%.
2. Global variables stay the same, so that does not change.
3. Variables defined by the source code used locally in a function do
not change.
4. "Scratch pad" generated by the compiler to handle things like
function calls with large argument list goes way down.
In one case I noticed the stack usage for telemetry for Mark's Quad
code dropped from 96 bytes (which does not even include the print
buffer) to 4 bytes!!!
I did not look closely enough at the assembly code to see why that was
exactly, but I think it had something to do with the setup of the call
to printf.
By the way, the way that I compared the stack usage was by searching
the assembly code for "lnk", which appears at the beginning of each
subroutine uses the stack. It allots space on the stack for that
routine. I compared the amount of stack space allotted by each
subroutine with and without optimization, and saw that the amount of
stack usage usually went down by a lot. Sometimes it stayed the same,
but it never went up.
Anyway, as far as the users are concerned, if you get tight on program
space, you definitely want to use the -s compiler optimization.
As far as developers are concerned, we should develop without compiler
optimization, to make sure we are leaving enough memory margin for the
UDB3.
Best regards,
Bill