• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2006, Vol. 28 ›› Issue (6): 131-134.

• 论文 • 上一篇    下一篇

一种快速构造汇编器的方法及其应用

陈惠斌 刘春林 胡定磊   

  • 出版日期:2006-06-01 发布日期:2010-05-20

  • Online:2006-06-01 Published:2010-05-20

摘要:

本文给出一种快速构造汇编器的方法.这种方法的特点是:借助lex和yacc分别生成汇编器的词法和语法分析器;指令在汇编器中以一种内部表示的形式存在;指令的编码信息存放在数据表格中,编码一条指令时使用一个通用的过程查询这些表格以决定指令的编码格式,然后调用相应的编码函数产生指令的机器代码.通过这种方法构造的汇编器是易修 改的.本文最后叙述这一方法在实现一款VLIW DSP汇编器时的应用.

关键词: 汇编器 构造 VLIW

Abstract:

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 infor rmation is saved in the data tables, when encoding an instruction a generic procedure is employed to search these tables to decide on its encoding forma t, and then a corresponding encoding function is called to produce its machine code. An assembler constructed using this method is easily modifiable. Fi nally we describe the application of this method when implementing a VLIW DSP' assembler.

Key words: assembler, construction, VLIW