Hi there, while trying to compile the following code i find that the wrong
value is being passed through of the integer parameter size, while trying to
compile for the t-mote with msp430 using msp430-gcc. I have checked the
runtime using the NoICE simulator and it confirms the mistake.

 

Below is the code, the first part calls the second. The first 4 parameters
are correct (i am guessing as they are passed in registers), however the
size field is not 7 once it has entered channel_select();

 

This value is passed on the stack.

 

For the life of me i can't figure this one out so i (weakly) am choosing to
blame the compiler. Any help would be appreciated.

 

Thanks 

 

Paul Harvey

/*--------------------------------------------------------------------------
-------------------------------*/

int size = 7;

    int filled;

    THIS1 *this_ptr = (THIS1*)this;

    char *rec = (char*)malloc(size);

    Channel chans[3] = {this_ptr->in1, this_ptr->in2 ,this_ptr->in3};

    int whens[3] = {size < 7, size > 7, size == 7};

    

    int choice;

    int num_chans = 3;

    while(1)

    {

        PRINTF("call channel_select, buffer size %d\n", size);

        choice = channel_select(num_chans, chans, whens, 0,rec, size,
&filled);

        PRINTF("\t\tThread1 receive, %s \n choice  = %d\n", rec, choice);

   }

 

/***************************************************************/

 

int channel_select(int nchans, Channel *chans, int *whens, int def,

                   void *buffer, int size, int *len)

{

    Channel ready[nchans];

    int index[nchans];

    int i = 0, j = 0;

 

    PRINTF("channel select, buffer size is %d\nnumber of chans %d\ndef
%d\n", size, nchans, def);

 

(etc)

}

 

/*--------------------------------------------------------------------------
-------------------------------*/

 

Reply via email to