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

Stack issue.

Hi ALL,
I using STARTUP.A51 in my C51 Project,It will be start the sp at 0x07, becuase I define many idata in my program.When Call a function in C program, The idata overlap the push value make program counter jmup to error address when in debug mode.
Why the compilier don't auto setting stack ?

Thanks.

  • "Why the compilier don't auto setting stack ?"

    Because it doesn't have enough info to do so!

    The Compiler sees only one source file at a time; it does not know how many other modules may (or may not) be included in your project and, therefore, has no idea what else might be using IDATA!

  • Thanks a lot.
    So, How to avoide the event appear when idata overlap stack value.I try to modify the sp, but it seem not good solution for the problem.

  • Hi Free,

    How about modifing the following code in startup.a51:

    ?STACK		SEGMENT   IDATA
    
    		RSEG	?STACK
    		DS		64
    
    		MOV	SP,#?STACK-1
    

    Acturally your stack pointer will be put at the end of idata address you are using. If you got a compile error to tell you that idata overlaps, then you have to shorten your statck length.
    It should be easy to understand when you have a look at the *.m51 file.

    Frank Hu