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. Cross-compiling Qt Embedded 5.5 for Raspberry Pi 2

    This tutorial shows how to cross-compile the Embedded build of Qt 5.5 for Raspberry Pi 2. The Embedd ...

  2. logstash ArgumentError: comparison of String with 5 failed

    <pre name="code" class="html"><pre name="code" class="ht ...

  3. 【转】Date类学习总结(Calendar Date 字符串 相互转换 格式化)

    原文网址:http://www.blogjava.net/jerry-zhaoj/archive/2008/10/08/233228.html Date类学习总结 1.计算某一月份的最大天数 Cale ...

  4. cf493A Vasya and Football

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. Go语言中的管道(Channel)总结

    管道(Channel)是Go语言中比较重要的部分,经常在Go中的并发中使用.今天尝试对Go语言的管道来做以下总结.总结的形式采用问答式的方法,让答案更有目的性. Q1.管道是什么? 管道是Go语言在语 ...

  6. hdu 2853

    虚拟赛一开始lyf就对我说这是一道匹配的题目,我一看明显裸的最优匹配,敲完提交wrong, 题目要求改变尽量少的公司,就是如果遇到相等的权值,优先选择跟他原来匹配的,KM匹配是按序号大小来的,如果一个 ...

  7. EBS OAF开发中的Java 实体对象(Entity Object)验证功能补充

    EBS OAF开发中的Java 实体对象(Entity Object)验证功能补充 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) EO理论上 ...

  8. Vagrant入门[转]

    Vagrant是一个简单易用的部署工具,用英文说应该是orchestration tool.它能帮助开发人员迅速的构建一个开发环境,帮助测试人员构建测试环境. Vagrant的基本工作原理大致如下: ...

  9. [ES6] ITERATORS

    Iterables return an iterator object. This object knows how to access items from a collection 1 at a ...

  10. 关于SVN版本控制器的问题与解决方法

    1.SVN Working copy is too old 有个.svn的文件夹,去掉在commit试试! 2.中文字符变乱码 尽量不要用中文命名文件,因为很多软件对中文的支持还是有不好的地方.