Hello folks,
I have encountered a strange problem while using CodeWarrior v10.7 with S12.
TLDR: under certain circumstances the increment operator (++) used on a 8bit uint compiles to inc.w and therefore the variable allocating the next byte in the memory gets incremented.
The structure containing the variables:
The segment of the code in question:
test_var is a variable mirroring all the operations of the FilterCounter. The only difference is, that it is declared as a static uint8 inside of the function, while the structure from above is declared as static in the .c file (outside of any function)
So, if I compile the code I get the following:
(test_var++ is also there, but it is in a different address)
The reason because I do think this is a bug is, that if I switch the if statement to the one containing test_var
This is what I get:
(also, it does not need to jump in order to increment the second variable)
It is possible to force the 8-bit behaviour by declaring the variable as
In this case the code compiles to the following, independent of which of the if condition are being used:
As for now, I can go with the latter, but I do not think this would be an intended behaviour. Can anyone reproduce this?
Cheers,
As for the screenshots; I know it is strange, but my company guidline does not allow me to share source code, in any form. This is already 'grey zone'.
Hi gellertbalogh
Could you share a simple project to reproduce this behavior?
Best regards
Jorge Alcala