Using local variables instead of global variable results in better manageability of the application as side effects are reduced or totally avoided. Using local variables or parameters reduces global memory usage but increases local memory usage.
Memory access capabilities of the target influences the code quality. Depending on the target capabilities, access efficiency to local variables may vary. Allocating a huge amount of local variables may be inefficient because the Compiler has to generate a complex sequence to allocate the memory in the beginning of the function and to deallocate it in the end:
void fun(void) { /* huge amount of local variables: allocate space! */ /* ... */ /* deallocate huge amount of local variables */ }
If the target provides special entry or exit instructions for such cases, allocation of many local variables is not a problem. A solution is to use global or static local variables. This deteriorates maintainability and also may waste global address space.
The RS08 Compiler overlaps parameter or local variables using a technique called overlapping. The Compiler allocates local variables or parameters as global, and the linker overlaps them depending on their use. Since the RS08 has no stack, this is the only solution. However this solution makes the code non-reentrant (no recursion is allowed).