This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What optimization level in V7.05 to use to force all the local variables on the user stack?

Is there a way to force the compiler to place all parameters onto the user stack?

Cx51 compiler User's guide 09.2001 on page 155 talks about General Optimization and it is not clear to me which optimization level to use to force the compiler to use stack for the parameters and for the local variables (local variable may have the same name in two different routines but the variable uses stack instead of fixed location in the memory).

Also, in startup.a51 file , I can setup the stack pointer via
MOV SP, #07h ; Stack pointer Register

How to specify the length of the stack? Since the internal memory space is 128 +128 bytes on Phillips P89C662 chip, is there any guidelines as to how big the stack should be?

  • Unlike "conventional" C Compilers, C51 does not use the stack for locals and parameters - due to the severe limitations of the hardware stack in the 8051 (only 128 bytes!!).
    Look up Overlaying in the manual and the knowledgebase.

    You can force C51 to use a simulated stack for by defining a function as reentrant - but that could certainly not be described as an optimisation!!

    You will find a lot of stuff about this if you search for "function pointers" on this site.