Menu

#2807 Nested if statement failing

closed-fixed
None
other
7
2018-10-14
2018-08-28
Henk
No

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:

  • sdcc.exe main.c -mstm8 -o main.ihx

Simulated using command (executed from windows batch file):

  • start putty.exe -telnet localhost 10000
  • sstm8.exe -V -g -t S003 -S uart=1,port=10000 main.ihx

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

1 Attachments

Discussion

  • Henk

    Henk - 2018-08-31

    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 x
    008066 7B 01 [ 1] 152 ld a, (0x01, sp)
    008068 97 [ 1] 153 ld xl, a
    008069 62 [ 2] 154 div x, a
    See also the attached comparison of listing.

     
  • Henk

    Henk - 2018-08-31

    And assembly compare with --fverbose-asm

     
  • Philipp Klaus Krause

    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

     
  • Philipp Klaus Krause

    • Priority: 5 --> 7
     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in [r10535].

    Philipp

     
  • Henk

    Henk - 2018-09-03

    Confirm fixed, thanks!

     
  • Maarten Brock

    Maarten Brock - 2018-10-14
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,8 +1,12 @@
     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:
    +
     * sdcc.exe main.c -mstm8 -o main.ihx
    +
     Simulated using command (executed from windows batch file):
    +
     * start putty.exe -telnet localhost 10000
     * sstm8.exe -V -g -t S003 -S uart=1,port=10000 main.ihx
    +
     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
    
     

Log in to post a comment.

MongoDB Logo MongoDB