I spent a number of hours in panic yesterday while reading through assembly listings generated by the latest msp430 gcc on my code. My issue was with functions like this:
static bool sleeping; static void checkWake(void) { if (sleeping) { // Send "wakeup" command on ports sleeping = false; } } When I looked at the generated assembly, it seemed that the compiler was ignoring the "if (sleeping)" check - the "checkWake" assembly code went straight to the code for sending the command out on the ports, followed by setting "sleeping = false". It turns out the compiler is /not/ ignoring the conditional and generating wrong code - it is just being smarter than previous gcc versions. The "if (sleeping)" part is being inlined into the caller function, while the body of the conditional is kept in it's own function. On closer inspection, the assembly code is labelled "checkWake.part.0" rather than "checkWake" to make this clear. In many cases, such partial inlining can improve the speed of the code, especially for when the conditional is not taken. It can also improve the size of the code, especially if the caller function in this case already has "sleeping" in a register. But it can certainly lead to confusion while debugging or checking the generated assembly! mvh., David ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users