打印

IAR编译器,怎么知道HEAP和STACK的地址?

[复制链接]
5061|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
snakeemail|  楼主 | 2010-1-31 15:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
今天看了所长的程序,被下面的难倒了
Memory_Init( (unsigned char idata *)0xff );。
所长自己分配了一个区域,相当于HEAP,动态分配数据空间,那么如何知道这个HEAP的地址呢?
我用的是IAR,想弄到AVR上,怎么搞呢。就发现一个分配堆和stack的大小,没有发现地址呀?

相关帖子

沙发
snakeemail|  楼主 | 2010-1-31 17:08 | 只看该作者
IAR的数据放在三个地方:1.局部变量放在stack, 2.static 和全局放在static memory中,3还有一个heap,用来放动态分配的变量。我是怎么跳过这3个区呢?
● On the stack. This is memory space that can be used by a function as long as it is
executing. When the function returns to its caller, the memory space is no longer
valid.
● Static memory. This kind of memory is allocated once and for all; it remains valid
through the entire execution of the application. Variables that are either global or
declared static are placed in this type of memory. The word static in this context
means that the amount of memory allocated for this type of variable does not
change while the application is running.
● On the heap. Once memory has been allocated on the heap, it remains valid until it
is explicitly released back to the system by the application. This type of memory is
useful when the number of objects is not known until the application executes. Note
that there are potential risks connected with using the heap in systems with a limited
amount of memory, or systems that are expected to run for a long time.

使用特权

评论回复
板凳
snakeemail|  楼主 | 2010-1-31 17:38 | 只看该作者
而且ATMEGA168的pdf说,stack是由最高的地址开始,即压入一个数据,stack指针是减小的。

使用特权

评论回复
地板
snakeemail|  楼主 | 2010-1-31 17:43 | 只看该作者
我现在干脆取巧,先搞一个全局数组unsigned char a[20],放入Memory_Init( a );

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:提供500W线性 交流电源。0~300VAC,45~500Hz 提供10KW,0-330V直流电源,具体见http://blog.21ic.com/user1/3639/archives/2012/88528.html

547

主题

1910

帖子

8

粉丝