Can my variables straddle resource boundaries?

|

In general, no. Boundaries created by the hardware or instruction set restrict how the compiler can allocate variables.

Wherever an architecture uses pages or other interrupted address spaces, there is the potential that a variable will straddle such a boundary. The risk is greatest when you specify the address of a variable in terms of another:

int one; //in one area
int two; //in another area
long three @ one; //oh oh... 

Remember the compiler does not take any special precautions for variables whose address is specified using the @ operator.

The compiler can handle most of these situations transparently. To make absolutely sure:

  1. Program using proper C data types. In the situation above, use a union to overlay the variables.

  2. Avoid using the @ operator.

  3. Check the listing file: addresses for compiler-allocated variables appear at the left of the declaration.