Hello,

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.  

My function looks like this:

-----------------------------------
static long long TickCounter;

long long StartTimer (ushort delay)
{
   long long temp;

   temp = TickCounter + delay - 1;
   if( temp == RESERVED_FOR_EXPIRATION)
      temp++;
   return temp;
}

static long long ledtimer;

void someFunction()
{
   ...
   ledtimer = StartTimer(LED_FTC);
   ...
}
-----------------------------------

When called, "temp" will equal the correct value (which in this case, happens 
to be 0x1DF), and r12-114 = 0, while r15 = 0x1DF.  However, ledtimer winds up 
being equal to 0x01DF01DF01DF01DF, and r12-r15 all have a value of 0x01DF.

Now here's the interesting part: when I wrap everything up in this struct, it 
WORKS:

-----------------------------------
typedef struct {
   union {
      struct{
         long lo;
         long hi;
      };
      long long q;
   };
} QUAD;
-----------------------------------

Any insight into this would be great, as I would much rather not have to resort 
to this awkward struct everywhere.


Regards,

Nate Bragg 

Reply via email to