摘要
本文给出一种快速构造汇编器的方法。这种方法的特点是借助lex和yacc分别生成汇编器的词法和语法分析器;指令在汇编器中以一种内部表示的形式存在;指令的编码信息存放在数据表格中,编码一条指令时使用一个通用的过程查询这些表格以决定指令的编码格式,然后调用相应的编码函数产生指令的机器代码。通过这种方法构造的汇编器是易修改的。本文最后叙述这一方法在实现一款VLIWDSP汇编器时的应用。
In this article we propose a method for quickly constructing an assembler, The method has the following features: it uses lex and yacc to generate the lexer and parser of an assembler respectively; an instruction exists as an internal representation in the assembler; the instructions' encoding information is saved in the data tables, when encoding an instruction a generic procedure is employed to search these tables to decide on its encoding format, and then a corresponding encoding function is called to produce its machine code. An assembler constructed using this method is easily modifiable. Finally we describe the application of this method when implementing a VLIW DSP' assembler.
出处
《计算机工程与科学》
CSCD
2006年第6期131-134,共4页
Computer Engineering & Science
基金
国家863计划资助项目(2002AA1Z1110)