Just a NOTICE, hope to help:)
*Be very careful when using integers of different types in an arithmetic
expression. NesC compiler doesn't seem to convert them into one appropriate
type during evaluation.
*
Because TinyOS doesn't have a full-featured debugging mechanism(though I
appreciate printf, which is really a gift), I used to work in VS2005 before
I transplant the code onto micaz. And recently I wrote something like this:
int8_t i, j;
uint8_t input[SIZE];
uint32_t sum = 0;
for(i = SIZE-1; i >= 0; i--){
for(j = 0; j < SIZE; j++){
carry += input[j] * input[i>=j+1?i-j-1:SIZE+i-j-1];
}
carry >>= 8;
}
It works fine in VS2005, yet has trouble on micaz. input[j] *
input[i>=j+1?i-j-1:SIZE+i-j-1] can produce negative product though both
operands are unsigned int. I fixed it like this:
carry += (uint32_t)input[j] * (uint32_t)input[i>=j+1?i-j-1:SIZE+i-j-1];
While VS2005 is tolerant, one should still pay attention to coding style in
case of compiler confusion.
--
Best Regards
Wyatt
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help