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

Reentrant stack & hardware stack ...

From Cx51 User's guide, I learned that:

The simulated stack area for reentrant functions is organized from top to bottom—it stacks down. The 8051 hardware stack is just the opposite and is organized bottom to top—it stacks up. When using the SMALL memory model, both the simulated stack and the 8051 hardware stack share the same memory area but grow towards each other...

My question is: if overlap occurs will Keil C compiler show any error message ?

Thanks in advance...

Parents
  • That would be a pointless situation anyhow!

    The reason for supporting a software ("reentrant") stack is that the hardware stack can only ever live in IDATA and, thus, is absolutely limited to the size of IDATA - which is a mere 128 or 256 bytes, depending on derivative.

    There would be no point in putting the software stack into IDATA: it's too small to be worthwhile, and you might just as well let the hardware stack use it!

    With the software & hardware stacks in different memory spaces, overlap is physically impossible!

Reply
  • That would be a pointless situation anyhow!

    The reason for supporting a software ("reentrant") stack is that the hardware stack can only ever live in IDATA and, thus, is absolutely limited to the size of IDATA - which is a mere 128 or 256 bytes, depending on derivative.

    There would be no point in putting the software stack into IDATA: it's too small to be worthwhile, and you might just as well let the hardware stack use it!

    With the software & hardware stacks in different memory spaces, overlap is physically impossible!

Children
  • Thanks for your explanation.

    I guess the only reason why we put reentrant stack into IDATA is as follows:

    1. our project utilizes ROM+RAM for firmware
    2. we put common/general routines in ROM and specific ones in RAM. Once chip back ROM content is fixed and never change unless tape-out new chip...
    3. if we did NOT use keyword "small reentrant" for routines in ROM,then the local variables & passing arguments of these routines will be packed into "_DATA_GROUP_" and arranged at "DATA area"
    4. if now we want to add functions and use local variables then "_DATA_GROUP_" is changed(bigger in size) and thus affects the "layout of DATA area"...This might cause "mismatch" between ROM and RAM code...

    But if we use "small reentrant" then local variables & passing arguments will be put to IDATA area and it is "stacks down"... This does not cause mismatch !!!

    This is what we want...(of course, the resulting code size is bigger and execute speed slower due to "IDATA"...)

    Please advise if anything wrong...

    Thanks in advance...