From: SourceForge.net <no...@so...> - 2006-06-06 06:34:23
|
Bugs item #1444425, was opened at 2006-03-06 21:07 Message generated for change (Comment added) made by tecodev You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1444425&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: pic16 target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Borut Razem (borutr) Assigned to: Raphael Neider (tecodev) Summary: onebyte.c regression tes fails on pic16 Initial Comment: 1 - sample code: ------------------------ void main(void) { char cL; volatile char cR; volatile char r16; cL = -1; cR = 1; r16 = cL * cR; } ------------------------ 2 - sdcc command: >sdcc -mpic16 -S t.c 3 - sdcc version: >sdcc -v SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.5.4 #1216 (Mar 5 2006) (MINGW32) 4 - error message: Internal error: validateOpType failed in OP_SYMBOL(IC_LEFT(ic)) @ main.c:918: expected symbol, got value This code is extracted from onebyte.c regression test. Borut ---------------------------------------------------------------------- >Comment By: Raphael Neider (tecodev) Date: 2006-06-06 06:34 Message: Logged In: YES user_id=1115835 Hmm, the given example is void: neither can -150 be represented in 8 bit using 2's complement nor is -300=112 (mod 256). It should read: -100 * 4 = -400 = 112 (mod 256). The conclusions remain the same, though. Probably multiplication should always be defined as an N x N -> 2N bit operation (except for long, obviously) and the result be cropped as required? Raphael ---------------------------------------------------------------------- Comment By: Raphael Neider (tecodev) Date: 2006-06-05 21:50 Message: Logged In: YES user_id=1115835 I wonder why SDCC tried to multiply two signed chars here... Should it not promote them to int first, as the result is 16 bit wide (hm, possibly promotion rules apply only to input operands?)!? -150 * 2 should be -300, but will yield -144=112 with the current _mulschar: s8 x s8 -> s8. Sign-extending the result to 16 bit does not suffice (MSB is clear)... Modifying _mulschar's signature to s8 x s8 -> s16 would help, but it is not curerntly declared so. Am I wrong? Is SDCC wrong? How I hate promotion ;-) If I were to implement _mulschar: s8 x s8 -> s8, would I have to throw away the upper byte and sign-extend the result or can I use the unsigned case, which produces a correct 16 bit wide result! Or do we have to clip u8 x u8 -> u16 to 8 bits and clear the upper byte as well?!? Hoping for illumination, Raphael ---------------------------------------------------------------------- Comment By: Borut Razem (borutr) Date: 2006-05-21 10:43 Message: Logged In: YES user_id=568035 Now the linker displays the folowing error: error: missing definition for symbol "__mulschar", required by "t.o" The following code compiles without errors: void main(void) { volatile char cL; volatile char cR; volatile char r16; cL = -1; cR = 1; r16 = cL * cR; } It uses the "MOVFF PRODL, _main_r16_1_1" istruction for multiplication. The same approach should be probably used for the failing case. Borut ---------------------------------------------------------------------- Comment By: Raphael Neider (tecodev) Date: 2006-03-08 10:00 Message: Logged In: YES user_id=1115835 Fixed in src/pic16/main.c 1.68, SDCC #1221. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1444425&group_id=599 |