Hi,
debugging and no end.
My code in short form (in reality there are code that does something with the values):
data unsigned char elements_groups[8];
…
void f1(){
char i;
for (i = 0; i < 8; i++){
MIOS_MIDI_TxBufferPut(0xbd); //only debug print
MIOS_MIDI_TxBufferPut((elements_groups >> 4) & 0x0f); //only debug print
MIOS_MIDI_TxBufferPut(elements_groups & 0x0f); //only debug print
}
f2(8, 0);
}
void f2(unsigned char size, unsigned char offset){
unsigned char i;
unsigned char elements_group;
for (i = 0; i < size; i++){
elements_group = elements_groups[i + offset];
MIOS_MIDI_TxBufferPut(0xbc); //only debug print
MIOS_MIDI_TxBufferPut((elements_groups[i+offset] >> 4) & 0x0f);
MIOS_MIDI_TxBufferPut(elements_groups[i+offset] & 0x0f); //only debug print
MIOS_MIDI_TxBufferPut(0xba); //only debug print
MIOS_MIDI_TxBufferPut((elements_group >> 4) & 0x0f);
MIOS_MIDI_TxBufferPut(elements_group & 0x0f); //only debug print
}
}
The array elements_groups has the following values:
{0x81, 0x01, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01}
The first for loop in f1 prints out (via midi)
BD 08 01
BD 00 01
BD 00 01
BD 00 09
BD 00 01
BD 00 01
BD 00 01
BD 00 01
All is ok. From funktion f2 I get the following output:
BC 08 00 //wrong: must be BC 08 01
BA 08 01 //ok
BC 00 00 //wrong: must be BC 00 01
BA 00 01 //ok
BC 00 05 //wrong: must be BC 00 01
BA 00 01 //ok
BC 00 01 //wrong: must be BC 00 09
BA 00 09 //ok
BC 00 0F //wrong: must be BC 00 01
BA 00 01 //ok
BC 00 00 //wrong: must be BC 00 01
BA 00 01 //ok
BC 00 00 //wrong: must be BC 00 01
BA 00 01 //ok
BC 00 00 //wrong: must be BC 00 01
BA 00 01 //ok
Ok. I though this it what I noticed as a rule “use a temporare variable not the array itself”. It seemed that the version with BA is ok. BUT:
If I remove the BC-part I get:
BA 00 00
BA 00 00
BA 00 01
BA 0E 01
BA 00 0F
BA 00 00
BA 00 00
BA 00 00
>:(
What happens here?
I haven’t checked the produced asm output yet.
It’s a simliar problem like the other: SDCC produced different behaviour depending from the surrounding code.
By the way: this is code that works perfectly with the other software version.
It cannot be wrong.
The differences between the software versions are controled by #ifdefs and #if
But this is a common part of all software versions!
Am I the only one who have these problems?
It seems all other program successfully with SDCC?
Is it a problem of code size? (my code goes up to 7d00)