From: SourceForge.net <no...@so...> - 2010-08-08 12:54:01
|
Bugs item #1757671, was opened at 2007-07-20 18:40 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1757671&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: Philipp Krause (spth) >Assigned to: Maarten Brock (maartenbrock) Summary: Floating point comparison problem. Initial Comment: I have a problem in the following function: struct c { float r; float i; }; void clamp(struct c *l) { if(l->r > 240.0f) l->r = 240.0f; if(l->r < 1.0f) l->r = 1.0f; } The function seems to work for l->r > 0, but the results are wrong for l->r < 0. strangely void clamp(struct c *l) { if(l->r < 1.0f) l->r = 1.0f; } works as it should. Philipp I compiled using sdcc --std-c99 -mz80 sdcc --version SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.2 #4861 (Jun 26 2007) (UNIX) ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2010-08-08 14:54 Message: The test passes on test-z80, but then other regression tests fail. I'll file another bug report for that. I've fixed the ucsim z80 simulator to set the flags correctly and fixed src/z80/gen.c in SDCC 2.9.7 #5918. ---------------------------------------------------------------------- Comment By: Philipp Krause (spth) Date: 2010-08-07 17:55 Message: There's always the old simulator: Do a make test-z80 instead of make test-ucz80. IMO the old simulator is much less buggy. Philipp ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2010-08-07 16:00 Message: If I add the following code below the release label in genCmp() it still fails to compare (long)0xBF80 0000 <= (long)0x3F80 0000 correctly in the regression test. release: tlbl = newiTempLabel (NULL); /* check for overflow */ emit2 ("jp PO,!tlabel", tlbl->key + 100); emit2 ("xor a,!immedbyte", 0x80); emitLabel (tlbl->key + 100); I'm beginning to doubt whether the simulator sets the P/V flag incorrectly for this overflow or that I misunderstand the Z80 behaviour. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2010-08-07 12:00 Message: The problem is not in the library but in the z80 code generation for signed comparison. ---------------------------------------------------------------------- Comment By: Philipp Krause (spth) Date: 2007-07-20 18:52 Message: Logged In: YES user_id=564030 Originator: YES It seems the f(l->r < 1.0f) is correct, but sdcc generates code that thinks that (l->r > 240.0f) is true for negative l->r. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1757671&group_id=599 |