The invention discloses a data area multiplexing processing method for function, which includes the following steps: step 1, scanning the source program lexically and grammatically to form a grammar tree; extracting the variables and function lists of the program, distributing the data area in the order of input variables, output variables, function variables and temporary variables, and identical functions. Only one instance of data area is allocated, and function data area is allocated in order of function input variables and function return value variables. Step 2, semantic analysis is carried out according to the grammar tree to form machine-independent binary instructions, and data replication instructions of function real participation parameters are inserted before the instruction of calling function is output. Explain the execution instruction file, execute the data replication instruction before calling the function, copy the actual parameter values to the data area allocated by the function, and then execute the function call instruction, pass in the first address of the data area of the function. This method simplifies the implementation of the interpreter and improves reliability.
【技术实现步骤摘要】
一种功能函数的数据区复用处理方法
本专利技术属于工业控制编程领域,特别涉及一种功能函数的数据区复用处理方法。
技术介绍
IEC61131-3标准定义的结构化文本(ST)是一种是类似于Pascal的高级编程语言,特别适合复杂的应用算法设计编程。ST代码可编译为目标机器直接运行的文件,但通常在应用过程中,存在以程序组织单元(POU)为单位的在线无扰更新的需求,此时不适合使用编译型产物,需要解释执行与机器无关的二进制伪指令。ST程序中经常调用标准功能函数,函数的调用实现通常使用堆栈的方法,存在形参和实参的入栈、出栈操作,加大了解释器的设计难度,并影响了嵌入式系统运行效率。基于此,本案专利技术人深入研究功能函数的数据区的解决方案,本案由此产生。
技术实现思路
本专利技术的目的,在于提供一种功能函数的数据区复用处理方法,通过同名函数复用数据区的方法,通过解释器程序高效率运行。为了达成上述目的,本专利技术的解决方案是:一种功能函数的数据区复用处理方法,包括如下步骤:步骤1,对源程序进行词法、语法扫描,形成语法树;提取程序的变量、函数列表,按照输入变量、输出变量、函数变量、临时变量 ...
【技术保护点】
1.一种功能函数的数据区复用处理方法,其特征在于包括如下步骤:步骤1,对源程序进行词法、语法扫描,形成语法树;提取程序的变量、函数列表,按照输入变量、输出变量、函数变量、临时变量的顺序分配数据区,同名函数只分配一个数据区实例,函数数据区按照函数输入变量、函数返回值变量顺序分配;步骤2,根据语法树,进行语义分析,形成与机器无关的二进制指令,在输出调用函数的指令前插入函数实参与形参的数据复制指令;步骤3,解释执行指令文件,调用函数前,执行数据复制指令,将实际形参值复制到该函数所分配的数据区,之后执行函数调用指令时,传入函数数据区的首地址。
【技术特征摘要】
1.一种功能函数的数据区复用处理方法,其特征在于包括如下步骤:步骤1,对源程序进行词法、语法扫描,形成语法树;提取程序的变量、函数列表,按照输入变量、输出变量、函数变量、临时变量的顺序分配数据区,同名函数只分配一个数据区实例,函数数据区按照函数输入变量、函数返回值变量顺序分配;步骤2,根据语法树,进行语义分析,形成与机器无关的二进制指令,在输出调用函数的指令前插入函数实参与形参的数据复制指令;步骤3,解释执行指令文件,调用函数前,执行数据复制指令,将实际形参值复制到该函数所分配的数据区,之后执行函数调用指令时,传入函数数据区的首地址。2.如权利要求1所述的一种功能函数...
【专利技术属性】
技术研发人员:陈宏君,张磊,文继锋,吴波,周磊,谭良良,牛洪海,徐卫峰,黄伟,刘克金,
申请(专利权)人:南京南瑞继保电气有限公司,南京南瑞继保工程技术有限公司,
类型:发明
国别省市:江苏,32
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。