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

external stack

Hello,

1)I would like to check the stack of the reentrant function in order to know that i don't have any overflow. Do you know how i can do it?
2) Is it possible to use an external stack (stack in xdata) without declaring the function as reentrant?

Thank you
Kaoru

Parents Reply Children
  • The following assembly routine returns the large model reentrant stack pointer.

    	PUBLIC	get_xbp
    	EXTRN DATA (?C_XBP)
    
    ?PR?get_xbp?get_xbp        SEGMENT CODE
    RSEG    ?PR?get_xbp?get_xbp
    
    ; void xdata *get_xbp (void)
    
    get_xbp:
    	USING	0
    
    	MOV	R6, ?C_XBP
    	MOV	R7, ?C_XBP+1
    
    	RET
    
    END

    You must include the following function prototype in your C program:

    void xdata *get_xbp();

    To get the current stack pointer, just call get_xbp. It returns the xdata address of the pointer. You can then compare this address with the bottom of the stack.

    Remember that the reentrant stacks stack down (not up). So the stack grows from 0xFFFF down to 0x0000.

    Jon

  • Thank you,


    I have a XRAM with a size of 4k only, in this case, the stack will begin at 0xFFF?

    Kaoru