When compiling the attached code snippet, the nested if statement starting at line 68 is failing at line 80 . Expected is alternating true and false (send over uart in simulation to Putty), but true is always send, the if statement at line 80 is always true independent of the statement. The behavior can be fixed by adding an additional function call at line 77.
Compiled using command:
Simulated using command (executed from windows batch file):
SDCC version: mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.7.2 #10526 (MINGW64)
Windows version: Windows 7 64-bit
For some reason the value of request->interval (struct pointed to by Y) is incorrectly loaded with the value of state (stored on stack):
150 ; main.c: 80: if ((state / request->interval) % 2U)008065 5F [ 1] 151 clrw x008066 7B 01 [ 1] 152 ld a, (0x01, sp)008068 97 [ 1] 153 ld xl, a008069 62 [ 2] 154 div x, aSee also the attached comparison of listing.
And assembly compare with --fverbose-asm
Thanks. Looks like a code generation bug; probably not hard to fix. If no one fixes it earlier, I'll look into it on the 10th of September. Either way it will get fixed before the 3.8.0 release.
Philipp
Fixed in [r10535].
Philipp
Confirm fixed, thanks!
Diff: