窗户组装堆和栈? [英] Windows assembly heap and stack?

查看:173
本文介绍了窗户组装堆和栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Windows 7 32位

OS: Windows 7 32bit

因此​​,在C ++等人有堆和栈。但我最近一直在开始组装一些学习和没见过的那种,只有一个堆栈的任何东西,但它只是看起来像纯粹的记忆。
那么,堆和栈具体实现的C ++和其他语言?还是你仍然可以分配在一个组装堆和栈?当启动一个可执行文件是什么窗口在过程中分配内存方面呢?
以及如何做一个进程知道堆栈大小需要多大呢?

So in like c++ one has a heap and a stack. But i've been starting on some assembly learning lately and haven't seen anything of the sort, only a stack but it just looks like pure memory. So is heap and stack implementation specific for c++ and other languages? Or do you still get allocated a heap and stack in assembly? When starting a executable what does windows do in terms of allocating memory for the process? And how does a process know how big the stack size needs to be?

请告诉我去

编辑:也许有人能提供关于如何堆和栈内存由CPU / OS的进程处理的链接

Perhaps someone could provider a link on how heap and stack memory is handled for a process by the CPU/OS

推荐答案

该协议栈主要由CPU(PUSH / POP / CALL / RET指令)维护。堆纯粹是一个OS /运行时库功能。因此堆栈连接在装配自然。堆访问你只需要调用使用汇编code相关的API(HeapAlloc / HeapFree,或从其他库)。不像栈,也有堆内存管理汇编语言没有低级原语。

The stack is maintained mostly by the CPU (PUSH/POP/CALL/RET commands); the heap is purely an OS/run-time library feature. Therefore stack access is natural in assembly. For heap access you just call the relevant APIs from your assembly code (HeapAlloc/HeapFree, or from some other library). Unlike stack, there are no low-level primitives in the assembly language for heap memory management.

您不必担心在Windows堆栈大小。当您使用了越来越多的,它会透明地成长。在低级别的条款时,Windows设置下的堆栈底部保护内存页面(假设堆栈向下增长)。当你的筹码达到保护页,在CPU中会生成一个访问冲突异常。 Windows内核会抓住它,发现情况和成长堆栈。

You don't have to worry about stack size on Windows. As you use up more and more of it, it will grow transparently. In low-level terms, Windows sets up a guard memory page below the stack bottom (assuming stack grows down). When your stack reaches the guard page, an access violation exception is generated in the CPU. Windows kernel would catch it, notice the situation and grow the stack.

这篇关于窗户组装堆和栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆