从堆还是栈分配内存?
我读到, 在8085
中,处理器的起始地址是00000H
。 然而, 在8086
中,处理器的起始地址是FFFF0H
。
现在我还了解到内存的顶部是堆
,而下面是堆栈
。我现在很困惑的是在8085中,内存是否是从堆栈分配的,而在8086中是从堆分配的?
请帮我澄清这个概念。谢谢
I read that,
In 8085
the starting address of processor is 00000H
.
Where as,
In 8086
the starting address of the processor is FFFF0H
.
Now I have also learnt that the top portion of the memory is heap
while below lies the stack
. What I am confused now is whether in 8085, memory is allocated from stack whereas in 8086 from heap?
Please help me out to clear the concept. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
堆分配是比汇编语言更高级的概念(C、Java 等),在 808x 汇编语言中没有这样的东西。您不“分配”内存。
另一方面,堆栈是 808x 以及无数微处理器(和虚拟机)的原生概念,例如每次使用“CALL”时都会用到它(PC 被推入堆栈)。当您返回时,返回的 PC 地址将从堆栈中弹出。您也可以将寄存器/数据压入堆栈。
Heap allocation is a higher-level (C, java, etc) concept than assembly language, you don't have such thing in 808x assembly. You don't "allocate" memory.
On the other hand, the stack is a native concept of the 808x, as well as countless microprocessors (and virtual machines), it is used each time you use "CALL" for example (the PC is pushed onto the stack). When you RET, the return PC address is popped from the stack. And you can push registers / data onto the stack also.
有关为什么 8085 的起始地址为
0000H
(这是四个零,而不是五个,因为处理器仅支持 16 位地址)的讨论,请参阅 这个线程。至于堆栈的位置:通过修改
SP
,您可以将堆栈移动到您想要的任何位置,但由于它向下增长,因此将其移动到地址空间的最末尾是有意义的。For a discussion about why the 8085's start address is
0000H
(that's four zeros, not five since the processor only supports 16 bit addresses) see this thread.As to the location of the stack: by modifying
SP
you can move the stack to wherever you want, but since it grows downward it simply makes sense to move it to the very end of the address space.