Menu

#3737 Broken math code generated depending on loop condition

closed-out-of-date
None
Z80
1
2025-08-07
2024-05-23
No

This time there is a true bug very hard to investigate.
The two C file differ of a single line: the condition in the WHILE loop at line 77
In one case a Key is tested to exit
In the other the loop is infinite
Nevertheless, the code generated for the math at lines 150-163 (3D rotation) which stay equal, differ drastically. The good file is using much less instructions and generate a working rotation.
The bad file is using heavily the stack generating dull sequences of data loading on (IX).
Not only the code is slow and long, but it is also broken. Numerically the results of the math are not equivalent and this bad code generate numeric errors and invalid rotation.

The C code is exactly the same, except for the condition of the while (!)
The math is totally different and in the bad code does not work

5 Attachments

Related

Wiki: NGI0-Commons-SDCC

Discussion

  • Ragozini Arturo

    Ragozini Arturo - 2024-05-23

    You need also this file to compile the C.
    I am using Version 4.4.1 #14868 (MINGW64)

     

    Last edit: Ragozini Arturo 2024-05-23
  • Philipp Klaus Krause

    Realistically, for SDCC devs to look into this, we need a small self-contained code sample to reproduce the issue. The code provided so far is big, and has external dependencies.

     
    👍
    1
  • Benedikt Freisen

    • labels: bad code -->
    • summary: Broken code --> Broken math code generated depending on loop condition
     
  • Philipp Klaus Krause

    • status: open --> closed-out-of-date
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    Can't check if this still affects current SDCC, since we do not have a self-contained code sample to reproduce the issue.

     

Log in to post a comment.

MongoDB Logo MongoDB