Hi ,
I am using ARM Cortex M4 . When I compile my code I get "No space in Execution region with .ANY selector matching section .const data .When I decrease the code size I am able to compile the code properly.I think I am overusing the data section which in my controller is 32KB.
I want to know where are all local variables stored in ARM KEIL IDE.Is it stored in Stack dynamically or stored in DATA memory Statically .
Thanks in advance
Regards, Dhanush
"The ARM just uses the Stack - overlaying would be of no benefit."
Yes, general-purpose processors are great at doing pointer-indirect addressing with optional offsets.
That means taht they can access local variables on the stack just as fast - and sometimes faster - than they can access a global variable.
A global variable requires the address to that variable. A local variable can make do with a short offset relative to the "base pointer" of the current stack frame.
Same when accessing function parameters.
The 8051 has extremely bad support for indexed accesses. While it has one or more index registers, they aren't intended for use with offsets. And the 8051 can't even perform indexed accesses for all memory regions. So implementing C on a 8051 is a brutally hard exercise. And the required workarounds should stay on the 8051 and not be mirrored on processors that doesn't needs them.
Not only that, but the 8051 also has an extremely small stack size limit.
So small that it is not realistically usable for automatic variable storage.
So, even if it did have decent indexed access modes, it hasn't got the stack space to put automatic variables there as "normal" targets (like ARM) do.
"the required workarounds should stay on the 8051 and not be mirrored on processors that don't needs them"
Absolutely!
"So small that it is not realistically usable for automatic variable storage."
Yes, some processors has a stack just intended to handle a couple of levels of return addresses.
Real general-purpose processors on the other hand allows an arbitrary chunk of the RAM to be used as stack - or as multiple stacks in case of use with an OS that allows threads.
The 8051 is better suited for a language like Forth, with software-implemented push and pop operations. Most high-level procedural languages expects arbitrary access to an arbitrary amount of local variables.
I wonder if its designers ever envisaged it being programmed in anything other than assembler...?