I have attached a Makefile, main.c and 8 artifacts. They are all made from the Makefile and can be cleaned using make clean.
There are 2 rules in the Makefile:
Nobug which builds the code with sdcccall 0, and everything works as expected, and
Bug which builds the code with sdcccall 1, and experiences buggy behavior.
Expected Behavior for both Make rules: Pin PA1 follows PB2.
Nobug Behavior: Exactly as expected.
Bug Behavior: PA1 stays 0, can't see where execution is since i don't have a debugger setup.
The Attached 8 artifacts are from the nobug rule, here is the artifacts from the bug rule.
Have you tried to build with --no-peep to see if this is introduced by the peephole optimizer?
Wich version of SDCC did you use (
sdcc --version)?I current SDCC, using default options, I get the same asm code as you get for the "bug" rule.
But when I test the functions individually, they all work as expected. I didn't test on STM8 hardware, though.
In particular, the following regression test passes:
Even this passes for test-stm8 (but will fail for other targets, since the 0x5000 address range is used otherwise there):
Interestingly, this test fails for pdk15 --stack-auto.
P.S.: Having had a first look at the failure in the simulator, apparently extractBit always returns 0.
Last edit: Philipp Klaus Krause 2023-03-16
The pdk-specific issue is fixed in [r13906].
Related
Commit: [r13906]
I have now tested this on a STM8S105K4T6, and see the bug using the .ihx files you provided. Looks like the bug where a pop a was used to adjust the stack overwriting a still-needed parameter in a just before a tail-call optimized call. That bug was fixed a while ago.
When I compile your code using current sdcc 4.2.14 [r13906], I see pin PA1 follow PB2.
Related
Commit: [r13906]