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 and On-Chip Ram


I am using an external Stack.

suppose i decalre a function like this.

func(data char ch)
{
data char s;
.
.
.
}

Both ch and s will be stored in On-

Chip RAM. But usually function

parameters and local variables will be

stored in SIACK only. So, where will

ch and s will be stored.



  • Are you using the REENTRANT stack? If so, function arguments and local variables will be stored on that stack.

    Keil Support

  • func(char ch) reentrant large
    {
        char data s;
    }

    If the function is in the large reentrant model, ch will be placed in XDATA. Your attempt to put func()'s parameter in DATA space will be ignored by the compiler, you can only type what memory spaces pointers point to (e.g. char data *ptr, is a pointer var. in the default memory model that points only to the DATA space).

    In the second case of 's', you can stick this in DATA by overriding the large model, but now your function is no longer reentrant since 's' will be overwritten upon each reentrance into func(). Leave the memory type specifiers off when using reentrancy.

    Note, all functions do not have to be reentrant if you just need recursion instead of true reentrancy.

    Also, note that Keil has switched to a new syntax:
    char data var;
    instead of the old form:
    data char var;
    - Mark