I thought I knew this for a while but then I read some more and now I am beginning to think that I messed up my understanding somewhere. I'd be glad if someone cleared it up for me. Here goes:
1. What memory exactly are we referring to when we say 'load from memory'? I thought it meant RAM. But aren't constants and arrays and other data stored in Flash? More generally, isn't everything present on the Flash immediately upon programming?
2. What does it mean to say that some memory type is 'executable'? I've come across many posts across the internet which say things like 'so-and-so processor can execute out of RAM' and 'smaller controllers execute out of Flash'.
Doesn't everything just execute out of the CPU? If we're talking about the source of the instructions and data to execute - isn't Flash memory the only source as it is the only part which we can program (and hence the only part which isn't empty) on reset?
Also related in this context (and I've always found this confusing), is the RAM usage of a program. I feel I've always used (abused?) the general definition thrown around that RAM is like a scratch-pad for the CPU where it stores all the run-time data and where all the calculations take place. Say, we have an assignment operation:
From what I've read, the processor maps the 8-bit variable 'num' onto the RAM and the constant '10' onto Flash. What this would mean is that there must occur some time before this assignment takes place, a procedure to somehow 'associate' the value with the variable.
Searching for this, I stumbled upon linker scripts and how we can direct the output to be 'placed' into either Flash or RAM address space which made it even harder to understand. Basically, how can you 'control' what goes into RAM?
Any hints on how to approach this are welcome.
Thanks!
1. What memory exactly are we referring to when we say 'load from memory'? I thought it meant RAM. But aren't constants and arrays and other data stored in Flash? More generally, isn't everything present on the Flash immediately upon programming?
2. What does it mean to say that some memory type is 'executable'? I've come across many posts across the internet which say things like 'so-and-so processor can execute out of RAM' and 'smaller controllers execute out of Flash'.
Doesn't everything just execute out of the CPU? If we're talking about the source of the instructions and data to execute - isn't Flash memory the only source as it is the only part which we can program (and hence the only part which isn't empty) on reset?
Also related in this context (and I've always found this confusing), is the RAM usage of a program. I feel I've always used (abused?) the general definition thrown around that RAM is like a scratch-pad for the CPU where it stores all the run-time data and where all the calculations take place. Say, we have an assignment operation:
Rich (BB code):
uint8_t num = 10; // Initialized variable
Searching for this, I stumbled upon linker scripts and how we can direct the output to be 'placed' into either Flash or RAM address space which made it even harder to understand. Basically, how can you 'control' what goes into RAM?
Any hints on how to approach this are welcome.
Thanks!