----- Ursprüngliche Nachricht ----- Von: Bragg Nate Gesendet am: 26 Aug 2010 19:36:45 > I am having some issues returning a long long from a function of mine. I > found somewhere on the mspgcc website that when returning a quad word, the > msp430 loads r15, r14, r13, and r12. > I am seeing some odd behavior on the other hand.
Using long long or any other large local variables (e.g. structs) which are created on stack may cause problems. The optimizer sometimes messes up the frame pointer (or replaces it by the stack pointer even if the stack pointer is altered later). It mostly happens if parameters are passed on stack too. A look into the generated assembly code - with and without optimisation - is sometimes very enlightening. A workaround is to declare this kind of local variables as register variables, if possible. I think long long variables are not considered to be register variables by default (they will block 4 registers each, limiting the optimisation possibilities of the compiler, which isn't a bad thing in this case). Another possible workaround is to define the local variable static. So it isn't placed on stack too. But consumes 4 bytes static memory. Maybe still an advantage in longer functions. JMGross
