导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→REENTRANt带来的问题,大家帮忙看看

* 42974: REENTRANt带来的问题,大家帮忙看看

   nasiry 
nasiry发表的帖子 

 REENTRANt带来的问题,大家帮忙看看
REENTRANt带来的问题,大家帮忙看看 

原来的程序仅仅使用DATA(0-128),在使用REENTRANT标记后,可再入的程序变量都存储在IDATA(0-256)的范围,可是我用的不是52机,51机可是没有128-256。
我已经使用了PROGMA SMALL了。
有没有办法能让编译器不使用128-256的范围
是不是我没有说清楚阿?
在keil上看到这样的说法 

QUESTION

In SMALL memory model (all RAM internal, all code in 8K), do reentrant functions use the push and pop instructions to put variables on the stack or do they overlay variables. 

ANSWER

The reentrant stack is simulated using R0 and R1. Variables are "pushed" and "poped" using the MOV @R0/R1 instructions. The hardware stack is not used for these variables. 

When you use the reentrant stack in internal memory, the hardware stack (accessed with SP) starts at the bottom of memory and grows up. The simulated reentrant stack starts at the top of memory (255) and grows down. 

You may use a debugger watch for and test for the collision of these two stacks. 

看来这个也是reentrant stack为什么使用idata的原因,但是解决的办法呢?

再keil上面看到这样的办法
QUESTION

I am using reentrant functions, but I have noticed that the startup.a51 file mentions reentrant stack pointers for each of the memory models (small, compact and large). What are these and do I need to modify startup.a51 to use reentrant functions? 

ANSWER

If you are using reentrant functions then you must have a reentrant stack configured and the pointer initialized. The stack allows the functions to be called many times or recursively. 

In order to set up the reentrant stack you must perform the following steps: 

1. Copy the STARTUP.A51 file from the \KEIL\C51\LIB folder into your project directory. 

2. Open STARTUP.A51. 

3. Scroll down to the section titled 'Reentrant Stack Initialization' and modify the appropriate values for the memory model you use. For example, if you use the large memory model and you want to place the top of the reentrant stack at 1FFFH then you would modify XBPSTACK and XBPSTACKTOP to be: 

XBPSTACK        EQU     1
XBPSTACKTOP     EQU     01FFFH+1


Full details of all the options in STARTUP.A51 are described in the Startup Code section of the C51 Compiler User's Guide. 

4. Save the modified startup.a51 file and include it in your project. 
也只有这样试试看了,要是大家有什么别的
好的办法的话,还是请告诉我!
我的email:lazydaytime@hotmail.com


发表时间:2003年9月30日0:52:32

  
回复该帖

本主题共有 2 帖,分页:>>>>>该主题的所有内容[2]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

  43005.[详细]不用回复了,就是改startup.a51
摘要:......(无内容)
- [nasiry][788次] 2003年9月30日

[上一篇帖子]:你的两个电阻的阻值是多大呀?
[下一篇帖子]:这里是单片机(电子技术)论坛,你还是到专门的机械论坛问吧不行就去清华看看 pro/e就是画机