0

I always have this confusion,in arm assembly, is the stack a separate memory unit or a partition of the main memory itself?

In my understanding,the main memory(RAM) is divided into stack and heap.The stack is pointed by the stack pointer R13 register or sp.From this pointer we can do the stack operations.

Also what I understand is that stack stores local variables in high level languages and function calls.How does it translate to assembly?

I am not able to find the answers to these questions on google.

VerilogCoder
  • 106
  • 7
  • It's just part of main memory. "stack" vs. "heap" is only about how you choose to use it, not hardware. "the heap" isn't even a real thing; dynamic memory allocation is usually not contiguous in modern systems. If you want to see asm, look at compiler output for example: https://godbolt.org/ [How to remove "noise" from GCC/clang assembly output?](https://stackoverflow.com/q/38552116). – Peter Cordes Jan 31 '21 at 04:58
  • @PeterCordes thank you!So stack would just be a part of the main memory and we access then using the stack pointer then right? – VerilogCoder Jan 31 '21 at 05:03
  • 1
    Yeah, that's all, nothing special. – Peter Cordes Jan 31 '21 at 05:08
  • @PeterCordes thank you.If you would write it as an answer,I can mark it as the solution. – VerilogCoder Jan 31 '21 at 05:18
  • There are some good canonical answers that say this (among other things) on [What and where are the stack and heap?](https://stackoverflow.com/a/79936/224132), so fortunately I don't need to spend time writing something worthy of being a full answer. – Peter Cordes Jan 31 '21 at 05:23
  • For good measure, I threw in some other duplicate links, take a look at the list of duplicates. – Peter Cordes Jan 31 '21 at 05:26
  • 1
    @PeterCordes thank you.The third link answers my question completely. – VerilogCoder Jan 31 '21 at 05:35
  • the arm documentation can be found through google. – old_timer Feb 01 '21 at 02:04
  • heap is a high level software notion it is not related to hardware. – old_timer Feb 01 '21 at 02:04

0 Answers0