Multiplication bug on EDE Crossview for M16C?

Feb 09, 2008 4 Replies

Hi to all recently i noticed a strange behavior debugging a a simple code that i wrote in C for the Mitsubishi-Renesas microcontroller M16C:



void Function_multiply(void) { unsigned char term1,term2,result; term1=6; term2=8;



result= term1 * term2; } I expect that result=48 ,with no loss of data,being the 2 terms small numbers



instead i have result=6 ,same with other small numers



To have result=48 i need to declare the local variable as unsigned int.



I dont think that i s a real bug,but i find strange that some option in the compiler could generate this unexpecyed situation



Thanks you for your attention Have a nice weekend



Diego,Milan Italy


If this is the exact code that you were using, how did you verify the result ?

As stated, the function has no side effects, and the result value is ignored, so the compiler is free to optimize (part of) the function body away. If you use a debugger to look at the result, your results may not be reliable.

i =

ll

int.

=

=

dy =

t =

It would be very helpful to see what assembly is produced, if the assemb= ly is correct then the compiler is fine and its probably a debugger fault. = =

Interesting tho.

wrote

the

thanks for helping me No,this is not the exact code,in fact i use the result and it leads me to a bigger error let me know your hints

Diego

It would be very helpful to see what assembly is produced, if the assembly is correct then the compiler is fine and its probably a debugger fault. Interesting tho.

ok,but i have it at work so i have to wait til next week to copy the section relative to the problem many thanks to you

have you all a nice weekend

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required