Local variables

The address of a local variable is determined at compile time. The compiler creates and examines a call tree of the program to determine which local variables can share memory. If the local variables of one function are never in scope at the same time as those of another function, then the two sets of local variables will share the same memory.

Figure 5-4. overlapping local variables var3.c

void function1(void)
{
        int a,b,c;
}

void function2(void)
{
        int a,b,c;
        function1();
}

void function3(void)
{
        int a,b,c;
}

    

Figure 5-5. local variables and interrupts var3.c

int global_variable;

void __INT(void)
{
        SaveContext();

        int var_in_interrupt;

        var_in_interrupt++;

        RestoreContext();
}

    

Figure 5-6. local variables and parameters var3.lst

0249 DF 07     LD     S,#007                function4(1,2,3);
024B 9F 7C     LD     B,#07C
024D 9B 01     LD     [B-],#001
024F 9B 02     LD     [B-],#002
0251 9E 03     LD     [B],#003
0253 32 42     JSR    00242