I'm trying to learn a bit more about virtual machines and programming languages in general by implementing some of the stuff that is found in books. The book I'm currently going through keeps the stack and the heap in one memory area. The stack grows upwards and the heap grows downwards. I'd like to know what the benefits of this are other than maybe a simpler strategy for load/store operations because you don't need to distinguish between two different memory areas.
The reason I ask is because I'm thinking of deviating from the plan in the book and having two different memory areas for the stack and the heap. That seems to make more sense to me and I don't have to worry about the stack and heap registers running into each other.
The benefit is that you don't need virtual memory, which makes this concept work on the simplest of CPUs/architectures. Also you don't need an operating system that keeps track of memory areas and their assignment to programs. In other words, such an implementation is well suited for e.g. small-scale embedded systems that typically don't have (and don't need) the processing power of a modern day desktop or server CPU.
I suppose by memory areas you mean the concept of multiple contigous memory spaces which are separated such that they each have an address range of relative indexes
(0, ..., n)
where n is the maximum number of bytes in that area.That makes a lot of sense if you have virtual memory, that is the CPU implements a layer on top of the physical memory that gives programs the illusion of each having a seperate, contigous memory space.