摘要
提出了一种符合IEC61131标准的结构化文本语言虚拟机指令高效解释执行的实现方案。结构化文本语言编译器将程序组织单元编译为二进制文件,该文件包括数据区、指令区。解释器内嵌各条指令对应的C执行函数和系统库函数。解释器在初始化中读取指令文件,构建数据区、指令节点链表、以跳转标号为关键字的指令序号hash表。指令节点记录形参地址、执行函数指针。在周期执行的任务中,顺次遍历指令链表。对于常规运算指令,调用指令节点关联的内嵌函数。对于跳转指令,根据跳转标号从hash表获取指令序号,动态调整当前执行的节点位置。该方案解决了线性指令表结构顺序执行时无法支持跳转和可变形参的问题,提高了解释器的执行效率,满足了工控系统的实时性要求。
In the paper,an efficient implementation scheme is proposed for the interpretation and execution of structured text language virtual machine instructions in accordance with IEC61131 standard.The structured text language compiler compiles a program organization unit into a binary file that includes data areas and instruction areas.C execution functions and system library functions corresponding to each instruction are embedded in the interpreter.The interpreter reads the instruction file during initialization,and constructs the data area,the instruction node chain table,and the instruction sequence number hash table with the jump label as the key word.The instruction node records the actual parameter address and the execution function pointer.For normal operation instructions,the embedded function associated with the instruction node is called.For the jump instruction,the instruction sequence number is obtained from the hash table according to the jump label,and the node position currently executed is dynamically adjusted.This scheme solves the problem that jump and deformable parameter cannot be supported in the sequential execution of the linear instruction list,improves the execution efficiency of the interpreter,and satisfies the real-time requirement of the industrial control system.
作者
赵奎
陈宏君
吴波
张磊
文继锋
Zhao Kui;Chen Hongjun;Wu Bo;Zhang Lei;Wen Jifeng(NR Electric Co.,Ltd.,Nanjing 211102,China)
出处
《单片机与嵌入式系统应用》
2018年第12期15-18,共4页
Microcontrollers & Embedded Systems
关键词
结构化文本
解释器
指令条目
structure text
interpreter
instruction item