Compiler internal variables

Hello all,

In my application I need to access to the value that Stack is initialized, in general C51 does it in the startup code:

MOV SP,#?STACK-1

What I need is to be able to use later on in my code the value "?STACK-1" and copy it to other variable.

Thanks for your help in advance!
Alfredo M.

Parents
  • hi,

    What I need is to be able to use later on in my code the value "?STACK-1" and copy it to other variable.

    Then modify startup.a51 slightly. Just edit this part of its code:

    ?STACK          SEGMENT   IDATA
    
                    RSEG    ?STACK
                    DS      1
    
    upto:
    ?STACK          SEGMENT   IDATA
    
                    RSEG    ?STACK
    STACK:          DS      1
    PUBLIC STACK
    

    Then in your c:
    extern idata STACK;
    
    void main(void)
    {
       void *sp;
    
       sp = &STACK;
    
       while(1);
    }
    

    Be careful: register SP does not point to stack space. For example, if SP contains 0x07 then stack is placed from 0x08 and above.
    As well: think twice before hardcoding over stack and registers!

    Regards,
    Oleg

Reply
  • hi,

    What I need is to be able to use later on in my code the value "?STACK-1" and copy it to other variable.

    Then modify startup.a51 slightly. Just edit this part of its code:

    ?STACK          SEGMENT   IDATA
    
                    RSEG    ?STACK
                    DS      1
    
    upto:
    ?STACK          SEGMENT   IDATA
    
                    RSEG    ?STACK
    STACK:          DS      1
    PUBLIC STACK
    

    Then in your c:
    extern idata STACK;
    
    void main(void)
    {
       void *sp;
    
       sp = &STACK;
    
       while(1);
    }
    

    Be careful: register SP does not point to stack space. For example, if SP contains 0x07 then stack is placed from 0x08 and above.
    As well: think twice before hardcoding over stack and registers!

    Regards,
    Oleg

Children
More questions in this forum