On Thu, 8 Mar 2012 00:43:31 -0300 Conrado P. L. Gouvêa wrote: > Hi, > > I've decided to update my mspgcc and I have compiled the 20120224 > version (using Ubuntu 8.04). But I've noticed something strange, it > appears that the compiler is generating incorrect assembly code. This > is simple example: > > void foo() { > volatile int y = 1; > } > > int dummy() { > volatile int x = 0; > return x; > } > > int main(void) { > if (dummy() == 1) { > foo(); > return 1; > } > return 0; > } > > > Compiling with " msp430-gcc -mmcu=msp430f1611 -O2 -fno-inline main.c", > I get the following code for the main function: > > > 0000403e <main>: > 403e: b0 12 62 40 call #0x4062 > 4042: 1f 93 cmp #1, r15 ;r3 As==01 > 4044: 01 24 jz $+4 ;abs 0x4048 > 4046: 0f 43 clr r15 > 4048: b0 12 58 40 call #0x4058 > 404c: 1f 43 mov #1, r15 ;r3 As==01 > > 0000404e <__stop_progExec__>: > > Notice how the second call is executed regardless if the jump is taken > or not, which is incorrect. This causes foo() to be called even if > dummy() does not return 1. > > Can anyone reproduce this issue? Is there a bug or I've messed up > somewhere? I've just tested the Windows build and I get the same > results. > > Thanks! > Conrado
I'm seeing the same code generated. On the other hand, after changing the "int main(void)" statement to "int test(void)", compile, and disassemble then the expected "ret" statements appear. It seems that the "main" function gets special handling. FWIW, I generated the assembly listing using the following commands: msp430-gcc -c -o main.o -mmcu=msp430f1611 -fno-inline -fverbose-asm \ -O2 main.c msp430-objdump -D main.o > main.i Regards, David ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users