Hi All, I'm having a real hard time coming up with a reason why using a local var as an index into a struct fails but that same line with an immediate value specified works properly. Here's what I mean..
void main(void) { unsigned char cTemp, cValue; // Do whats required to get under way. //---------------------------------------------------------------------------- MAIN_System_Init(); // Endless While loop that the micro runs forever (hopefully). //---------------------------------------------------------------------------- while(gcTRUE) { cValue = 0x0C; cTemp = *port[0x0C].lsr; cTemp = *port[0x0C].txrx; cTemp = *port[cValue].lsr; cTemp = *port[cValue].txrx; } }
From the code you provide, I cannot tell if *port is declared volatile. If not, the compiler simply says, "Why bother doing this again?" - Mark
To be sure, try an immediate value that is different from that of cValue. In this case, the compiler would not have an excuse for omitting the piece of code.