From: SourceForge.net <noreply@so...>  20080915 11:48:52

Bugs item #1900961, was opened at 20080224 19:28 Message generated for change (Settings changed) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1900961&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: Icode generator Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Philipp Krause (spth) >Assigned to: Maarten Brock (maartenbrock) Summary: int8_t x uint8_t multiplication broken Initial Comment: Multiplication of int8_t by uint8_t (and vice vers) is broken on Z80. To see the bug remove the first #ifndef SDCC_z80 in the regression test support/regression/tests/onebyte.c sdcc generates a call to the multiplication function for int8_t x int8_t, so the unsigned number is treated as a signed number which gives wrong results if it's greater than 127. Philipp  Comment By: Maarten Brock (maartenbrock) Date: 20080713 10:26 Message: Logged In: YES user_id=888171 Originator: NO Using either the signed or unsigned 8 bit multiplication for mixed operands can only give the wrong result if the result is 16 bits. If the result is only 8 bits it doesn't matter. See also genMultOneByte() in mcs51/gen.c. Maarten  Comment By: Philipp Krause (spth) Date: 20080712 20:35 Message: Logged In: YES user_id=564030 Originator: YES While Inoticed this problem in the Z80 port it probably affects all ports that use support functions for 8bit multiplication: There are just two multiplication support functions: One for signed, one for unsigned multiplication. The one for signed multiplication is used for mixed multiplications, too, which gives wrong results. I suggest the following fix: Promote operands of mixed char multiplications to int, do an int multiplication. This is slower, but gives the correct result and I expect mixed char multiplications through support functions to be rare anyway. Philipp  You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1900961&group_id=599 