LOCAL Memory

Byte Craft compilers determine all variable locations at compile time. The

#pragma memory LOCAL [size] @ location;

directive allows the compiler to reuse this space for local variable storage.

LOCAL memory availability changes the way the compiler generates code for function calls. The compiler will pass any number of parameters into a function, using LOCAL memory to store the passed-in values. Without LOCAL memory, the compiler will only pass two bytes (or one 16-bit word) through parameters, requiring you to pass other values through global variables.

If size is given as 0, the compiler determines the amount of space needed, and only allocates as much as necessary. If size is specified, the compiler will not reclaim unused LOCAL space for global variables.

The If size is given as 0, the compiler builds LOCAL memory down from location. If a size other than 0 is specified, the compiler starts at location and allocates size bytes, going up.

The size of local variable space may be architecturally-restricted depending on the target controller.

 
 
#pragma memory LOCAL [0] @0x7f;
long term1, term2, term3;
long sum(long a, long b, long c)
{
  return (a+b+c);
}

void main(void){
 long result;
 term1=1;
 term2=6;
 term3=0;
 result=sum(term1,term2,term3);
}