Hi All,
I had sent this mail to mspgcc mailing list but did not get any response.
I use TinyOS 1.x on a Tmote Sky.
I wrote a function which has a set of nested if-else blocks.
Ultimately, the function returns a result.
After many months of successful operation, the code stopped working
as intended.
While investigating the problem, I did some unrelated code change
and the problem disappeared.
On reading the assembly code before and after the change,
I observed:
a) In the working code, there is a mov.b instruction as below:
ce84: 4f 49 mov.b r9, r15 ;
This seems to copy the value of result (stored in r9) to r15
before doing a return.
b) In the original code, there was an and instruction not connected
to the program's logic:
ce84: 3f f0 00 ff and #-256, r15 ;#0xff00
I do not understand why this instruction was generated.
I wonder if this a bug in code generation ?
Has anyone else seen this happen before ?
The original code looked like this:
result_t addEntry(Entry_t b)
{
bool exists = FALSE;
int result = SUCCESS;
if (fSize == 0)
{
// Do something
}
else
{
// If entry does not exist
if(exists == FALSE)
{
// Do something else
if (fSize == MAX_ENTRIES)
{
if ()
{
// do something
}
}
else
{
fSize++;
}
}
else
{
}
}
return result;
}
Part of the assembly code generated for this function is below:
ce7c: d2 53 57 29 inc.b &0x2957 ;
ce80: 01 3c jmp $+4 ;abs 0xce84
ce82: 49 43 clr.b r9 ;
ce84: 3f f0 00 ff and #-256, r15 ;#0xff00
ce88: 31 50 06 00 add #6, r1 ;#0x0006
ce8c: 39 41 pop r9 ;
ce8e: 3a 41 pop r10 ;
ce90: 3b 41 pop r11 ;
ce92: 30 41 ret
On performing the totally unrelated code change,I got the
following
assembly code generated:
ce7c: d2 53 57 29 inc.b &0x2957 ;
ce80: 01 3c jmp $+4 ;abs 0xce84
ce82: 49 43 clr.b r9 ;
ce84: 4f 49 mov.b r9, r15 ;
ce86: 31 50 06 00 add #6, r1 ;#0x0006
ce8a: 39 41 pop r9 ;
ce8c: 3a 41 pop r10 ;
ce8e: 3b 41 pop r11 ;
ce90: 30 41 ret
Regards,
Harish
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help