Posted on February 01, 2013 at 12:05Hi. I'm using the Cosmic STM8 compiler (''free'' version, v4.3.9) and it appears to generate unexpected results for the following test :- static char test(unsigned int x, unsigned int y) { return (int)(x - y) <...
Posted on February 08, 2013 at 15:47But the code for delta_1() and delta_2() are the same. Both feature an unsigned subtraction followed by a cast to int and a comparison with 0. The compiler should ideally generate the same code for both cases, fai...
Posted on February 08, 2013 at 12:42 I've attached a file which includes generated assembly etc. Fundamentally the compiler generates different code for these two cases, which is an error as they are functionally identical. void delta_...
Posted on February 08, 2013 at 12:39We don't all agree. If, for example, ''x'' and ''y'' are values read from a counter timer they are intrinsically unsigned quantities, they just happen to wrap at 16 bits. Though the values are unsigned the differe...
Posted on February 08, 2013 at 12:36I don't think we all agree. Both ''x'' and ''y'' are unsigned quantities, they just happen to wrap at the 16-bit boundary. If you consider them as values read from a counter for example, they are unsigned values b...
Posted on February 01, 2013 at 13:42This is quite a normal construct to use when working with values that can wrap (tick counts, buffer indexes etc). The fact that the compiler generates a different result for the inline / non-inline case would indi...