KEIL中函数的调用在其帮助文档中有一个详细的解释,引用如下:

The Call Tree

The best way to demonstrate how the call tree is generates is with an example. Based on the following program flowchart, the startup code calls the main C function which subsequently calls func_a, func_b, and func_c sequentially. The functions call no other routines in our program.

The arguments and local variables of func_a, func_b, and func_c meet the rules listed in theTheory of Operation and, therefore, may be overlaid. The source code for this flowchart is as follows:

char func_a (char arg1, char arg2, char arg3)
{
return (arg1+arg2+arg3);
}

int func_b (int arg1, int arg2, int arg3)
{
return (arg1+arg2+arg3);
}
long func_c (long arg1, long arg2, long arg3)
{
return (arg1+arg2+arg3);
}
void main (void)
{
char var_a;
int  var_b;
long var_c;
var_a = func_a(1,2,3);
var_b = func_b(1,2,3);
var_c = func_c(1,2,3);

while (1);
}

When the program is linked, the linker generates a call tree which it outputs to the map file.

FUNCTION/MODULE              BIT_GROUP   DATA_GROUP
--> CALLED FUNCTION/MODULE  START  STOP  START  STOP
====================================================
?C_C51STARTUP               ----- -----  ----- -----
 
 +--> ?PR?MAIN?MAIN
MAIN/MAIN                   ----- -----  0008H 000EH
  +--> ?PR?FUNC_A?MAIN
  +--> ?PR?FUNC_B?MAIN
  +--> ?PR?FUNC_C?MAIN
FUNC_A/MAIN                 ----- -----  000FH 0011H

FUNC_B/MAIN                 ----- -----  000FH 0014H

FUNC_C/MAIN                 ----- -----  000FH 001AH

Based on the call tree, the linker reserves the memory used by the functions' arguments and local variables. The linker creates several specialOverlay Groups (BIT_GROUP, DATA_GROUP, and so on) that contain the overlaid segments.

As you can see from the call tree above, the DATA_GROUP for func_a, func_b, and func_c starts at 000Fh. This shows that the linker believes the arguments and variables for these functions may be safely overlaid. Refer to the memory map for the memory range used by the _DATA_GROUP_.

 
START     STOP      LENGTH    ALIGN  RELOC    MEMORY CLASS   SEGMENT NAME
=========================================================================
* * * * * * * * * * *   D A T A   M E M O R Y   * * * * * * * * * * * * *
000000H   000007H   000008H   ---    AT..     DATA           "REG BANK 0"
000008H   00001AH   000013H   BYTE   UNIT     DATA           _DATA_GROUP_
00001BH   00001BH   000001H   BYTE   UNIT     IDATA          ?STACK

Note

  • The linker generates overlay information that is accurate. However, in some instances the default analysis of the call tree is ineffective or incorrect. This occurs with functions that are called by both the main program and an interrupt and with functions called through function pointers.
  • Functions that are called by the main program root and by an interrupt service routine or functions that are called by two or more interrupts may not be overlaid.
  • Functions called through pointers require special handling within the linker in order for overlaying to work properly. This topic is discussed inFunction Pointers.

KEIL C51 Call Tree的更多相关文章

  1. Keil C51 中的函数指针和再入函数

    函数指针是C语言中几个难点之一.由于8051的C编译器的独特要求,函数指针和再入函数有更多的挑战需要克服.主要由于函数变量的传递.典型的(绝大部分8051芯片)函数变量通过堆栈的入栈和出栈命令来传递. ...

  2. Keil C51中函数指针的使用

    函数指针在C语言中应用较为灵活.在单片机系统中,嵌入式操作系统.文件系统和网络协议栈等一些较为复杂的应用都大量地使用了函数指针.Keil公司推出的C51编译器是事实上80C51 C编程的工业标准,它针 ...

  3. Keil C51汉字显示的bug问题

    一.缘起 这两天改进MCU的液晶显示方法,采用“即编即显”的思路,编写了一个可以直接显示字符串的程序.如程序调用disstr("我是你老爸");液晶屏上就会显示“我是你老爸”. 二 ...

  4. KEIL、uVision、RealView、MDK、KEIL C51区别比较

    KEIL uVision,KEIL MDK,KEIL For ARM,RealView MDK,KEIL C51,KEIL C166,KEIL C251 从接触MCS-51单片机开始,我们就知道有一个 ...

  5. Keil C51程序调试过程

    用Keil C51编写程序时,经常需要调试,如果不是经常用这个软件的话,很容易忘记这些调试步骤,现在举一个例子“验证延迟函数delay()使其延迟的时间为500ms”说明. 源程序写完后,就可以调试了 ...

  6. Keil C51软件的使用

    进入 Keil C51 后,屏幕如下图所示.几秒钟后出现编辑界 启动Keil C51时的屏幕 进入Keil C51后的编辑界面 简单程序的调试:学习程序设计语言.学习某种程序软件,最好的方法是直接操作 ...

  7. Keil c51现No Browse information available

    keil c51 不能使用:Go to Definition of....的解决方法 最近使用keil c51 开发usb固件,当向vc一样使用Go to Definition of....时,出现警 ...

  8. Keil C51总线外设操作问题的深入分析

    阅读了<单片机与嵌入式系统应用>2005年第10期杂志<经验交流>栏目的一篇文章<Keil C51对同一端口的连续读取方法>(原文)后,笔者认为该文并未就此问题进行 ...

  9. KEIL C51 中嵌入汇编以及C51与A51间的相互调用

    如何在 KEIL C51(v6.21) 中调用汇编函数的一个示例 有关c51调用汇编的方法已经有很多帖子讲到,但是一般只讲要点,很少有对整个过程作详细描述,对于初学者是不够的,这里笔者通过一个简单例子 ...

随机推荐

  1. [转]RegOpenKeyEx函数失败的问题

    在使用这个函数RegOpenKeyEx的时候,老是执行不成功,函数本身返回2,GetLastError返回0.在CSDN上查阅资料说是返回2的原因是注册表中对应路径不存在,可是我电脑中注册表那个键值明 ...

  2. Android android.support.v7.appcompat.R$styleable

    引入第三方jar或者library时比如自定义控件.突然报如下错误: 07-17 09:22:25.430: E/CrashHandler(14102): Caused by: android.vie ...

  3. BZOJ2292: 【POJ Challenge 】永远挑战

    2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 513  Solved: 201[Submit][ ...

  4. mysql插入数据时,中文乱码

    MySQL 插入数据时,中文乱码问题的解决(转) 当向 MySQL 数据库插入一条带有中文的数据形如 insert into employee values(null,'张三','female','1 ...

  5. VSCode

    下载: 打开终端控制器 wget http://download.microsoft.com/download/0/D/5/0D57186C-834B-463A-AECB-BC55A8E466AE/V ...

  6. html5+css3中的background: -moz-linear-gradient 用法 (转载)

    转载至-->http://www.cnblogs.com/smile-ls/archive/2013/06/03/3115599.html 在CSS中background: -moz-linea ...

  7. float position的測试案例

    依据<a target=_blank href="http://blog.csdn.net/goodshot/article/details/44348525">htt ...

  8. CFGYM 2013-2014 CT S01E03 D题 费用流模版题

    题意: n行, a房间的气球,b房间的气球 i行需要的气球,与a房的距离,b房的距离 求最小距离 #include <stdio.h> #include <string.h> ...

  9. java foreach循环为什么不能赋值

    直接上代码 public class test4 { public static void main(String args[]){ int [] a=new int[3]; for(int j:a) ...

  10. [置顶] VB6基本数据库应用(三):连接数据库与SQL语句的Select语句初步

    同系列的第三篇,上一篇在:http://blog.csdn.net/jiluoxingren/article/details/9455721 连接数据库与SQL语句的Select语句初步 ”前文再续, ...