Hello,
For the RS08 devices, the situation is a little more complex because they do not have a stack. Therefore, the compiler needs to create temporary variables that are allocated to the .overlap section within RAM. The total size of this section will normally significantly exceed the total memory requirement for the project global variables. As Daniel suggested, check the actual RAM allocations within the project map file.
As an example, I created a very simple project with two 32-bit global variables, one 16-bit global variable, and one 8-bit global variable. The project contained two simple functions, with both returning a 32-bit value. One function required a 16-bit and a 32-bit parameter, and the second function required two 32-bit parameters.
unsigned long func1( unsigned int x, unsigned long y);
unsigned long func2( unsigned long x, unsigned long y);
This project required a total of 40 bytes of RAM (in addition to the "reserved" tiny RAM). The globals occupied 11 bytes, and the remainder were temporary variables, according to the map file..
A method of reducing the number of temporary variables, is for function parameters to be called by reference, rather than be called by value. This is particularly so for any 32-bit parameters. The function prototypes then became -
unsigned long func1( unsigned int x, unsigned long *y);
unsigned long func2( unsigned long *x, unsigned long *y);
The result of doing this was to reduce the total RAM requirement from 40 to 31 bytes, a very worthwhile reduction.
Of course, MCU types that provide a stack, including the MC9S08 types, can have run-time problems if the stack size is made too small, perhaps because of limited RAM.
Regards,
Mac