 | Discussion Forum |  |
|
|
Initialisation of stack pointerNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Ashok patil Posted 1-Aug-2001 10:43 GMT Toolset C51 |  Initialisation of stack pointer Ashok patil How do I initialise the stack pointer location to a memory location 0x80 instead of the default memory location. Also how do i set the stack pointer to point to xdata locations. I have tried to set the stack pointer in the c startup routine written by me,but the controller resets.Please solve my questions. Thanks | | Read-Only Author Hans-Herbert Kirste Posted 1-Aug-2001 12:20 GMT Toolset C51 |  RE: Initialisation of stack pointer Hans-Herbert Kirste How do I initialise the stack pointer location to a memory location 0x80 instead of the default memory location. The instruction
mov sp,#80H loads the value 80H into register SP. However, if you want the first byte to be stacked at address 80H, you should use mov sp,#7FH. Make sure you have enough (free!) internal RAM at address 80H and above. This is not the case for an 8031. In an 8031 the memory ends up at address 7FH. You also have to take in account that the stack grows upwards (to higher addresses).
It is common practice to set the stack pointer to the last byte of used internal ram. The last byte of used ram may reside in DATA oder IDATA space. This gives you the maximum stack size.
Also how do i set the stack pointer to point to xdata locations.
You can't. Stack is always in internal memory.
HHK
| |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|