Hello
The symptoms you are describing are not directly related to optimization but rather to ANSI C standard definition.
You say "promotions to longs, the way certain #defines are taken when their size is not specified".
Please remember that ANSI C standard defines that integral promotion rule apply for arithmetic operation which do not involve a long operand.
That means if you have an assignment as follows:
myLong = myInt1*myInt2;
the expression myInt1*myInt2 will be evaluated on 16-bit and then signed extended to 32-bits.
To make sure the expression is evaluated on 32-bits, you have to cast one of the operands as a long.
This is done as follows:
myLong = (long)myInt1*myInt2;
for operand defined as macro (in a define), just add the suffix L to the constant to make sure it is interpreted as a long.
For example
#define myInt1 10L
If you really want to disable optimization proceed as follows:
- Open the project in the IDE
- Open the Target Settings dialog (Press ALT + F7)
- Switch to "Compiler for HC12" panel
- Click on the "Options" button
- THere are a lot of optimization you can disable there. This will be taken only for the current project.
However note that some optimization cannot be disable at al.
I hope this helps.
CrasyCat