From: SourceForge.net <no...@so...> - 2011-06-10 20:28:42
|
Bugs item #3299577, was opened at 2011-05-09 20:38 Message generated for change (Comment added) made by spth You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3299577&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: z80 port Group: None Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Oleg N. Cher (oleg-n-cher) Assigned to: Philipp Klaus Krause (spth) Summary: Z80 multiplication code bug Initial Comment: 1. // This SDCC test program demonstrates a serious Z80 multiplication bug // This bug present with internal loop if called a procedure with statement // if we define THE_BUG, the bug is present. DoProc() not returns. #define THE_BUG // if we define CORRECT, the bug is hidden (masked). DoProc() returns. //#define CORRECT void TheBug (void); void DoProc (signed char col, signed char row, unsigned char spr); unsigned char y; int main (void) { y=1; TheBug(); return 0; } void TheBug (void) { unsigned char i,j,n,spr; for (j=0; j<=1; j++) { for (n=1; n<=7; n++) { for (i=2; i<=7; i++) { #ifdef THE_BUG DoProc(30, i*y, spr); // Here i*y == 1 every time #endif #ifdef CORRECT DoProc(30, y*i, spr); // Here is correct #endif } } } } void DoProc (signed char col, signed char row, unsigned char spr) { if(row!=1) return; for(;;); } 2. sdcc\sdcc -mz80 --code-loc 26000 --data-loc 0xF000 --no-std-crt0 --opt-code-size --funsigned-char --disable-warning 59 -L z80 testbug.c 3. SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.2 #6489 (May 9 2011) (MINGW32) 4. if change 'y*i' to 'i*y', we will have the serious problem. Possible reasons are deep internal loop + statement calculated in calling a fn + optimizations in SDCC code generation. I've no ideas, sorry. Thanks 5. My e-mail is allot )at( ukr.net ---------------------------------------------------------------------- >Comment By: Philipp Klaus Krause (spth) Date: 2011-06-10 22:28 Message: I don't remember, but suppose that initializing it e.g. to 0 wouldn't change the behaviour, since the initialization would be outside all control structures. Philipp ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2011-06-10 15:47 Message: Is the fact that spr is uninitialized part of this bug or can we initialize it in the regression test to remove the warning? ---------------------------------------------------------------------- Comment By: Philipp Klaus Krause (spth) Date: 2011-05-26 11:23 Message: Fixed in revision #6555. Philipp ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3299577&group_id=599 |