Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


(--stack-auto) on MCS51

  • perrystg

    My programs tend to have a large number of small functions. With the default settings I find that this is consuming a lot of RAM (function parameters and local variables) so changing compiler and linker options to  (--stack-auto) seems to solve the problem nicely.

    But now I’m worried about the stack? I can review my program manually and estimate worse case stack usage, but … is there a better way?

    Also, am I missing something else about (--stack-auto) usage ?

    I’m using small memory model on MCS51 type CPU. All large data items are declared __xdata so i have 208 bytes available for stack. The program uses floating point and also I intend to use the math.h functions.

    Any suggestions are appreciated.


    • Maarten Brock
      Maarten Brock

      You could run the program in the simulator or on your target and check IRAM afterwards. On startup it was cleared to zeroes so the highest non-zero must heve been used on the stack. This can only give some statistical data however and not an absolute answer. Unfortunatley SDCC cannot build a calling tree to determine necessary stack space.