JP2002351672A - Device and method for processing assembler, and program for making computer execute the same method - Google Patents

Device and method for processing assembler, and program for making computer execute the same method

Info

Publication number
JP2002351672A
JP2002351672A JP2001156968A JP2001156968A JP2002351672A JP 2002351672 A JP2002351672 A JP 2002351672A JP 2001156968 A JP2001156968 A JP 2001156968A JP 2001156968 A JP2001156968 A JP 2001156968A JP 2002351672 A JP2002351672 A JP 2002351672A
Authority
JP
Japan
Prior art keywords
instruction
bit
code
assembler
instruction code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2001156968A
Other languages
Japanese (ja)
Inventor
Akira Hirata
明 平田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2001156968A priority Critical patent/JP2002351672A/en
Publication of JP2002351672A publication Critical patent/JP2002351672A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To generate a program capable of performing the same processing even when it is operated by any of a big endian and a little endian. SOLUTION: In this assembler processor 1 having an instruction set consisting of 16 bit length instruction and 32 bit length instruction and to generate an instruction code corresponding to a processor in which execution orders of two 16 bit length instruction codes are replaced when it is operated by a different endian, it is provided with a temporary storage buffer 5 to temporarily store the 16 bit length instruction code converted from a source file, an arrangement converting part 6 to replace the two 16 bit length instruction codes arranged in the temporary storage buffer 5 on the boundary of 32 bit and an file output part 7 to output the two replaced 16 bit length instruction codes to an object file.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】この発明はソースファイルか
らプロセッサが実行する命令コードからなるオブジェク
トファイルを生成するアセンブラ処理装置、アセンブラ
処理方法およびその方法をコンピュータに実行させるプ
ログラムに関するものであり、特にバイエンディアン・
プロセッサで実行される命令コード(機械語)を生成す
るアセンブラ処理装置、アセンブラ処理方法およびその
方法をコンピュータに実行させるプログラムに関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an assembler processing apparatus, an assembler processing method, and a program for causing a computer to execute an assembler processing method for generating, from a source file, an instruction file to be executed by a processor.・
The present invention relates to an assembler processing device that generates an instruction code (machine language) to be executed by a processor, an assembler processing method, and a program that causes a computer to execute the method.

【0002】[0002]

【従来の技術】図18は、ソースファイルを入力しオブ
ジェクトファイルに変換して出力する従来のアセンブラ
の構成を示すブロック図である。従来のアセンブラは、
図18に示すように、ファイル入力部12と、構文解析
部13と、コード変換部14と、オブジェクトファイル
出力部17とを備えた構成となっている。また、図19
は、従来のアセンブラによるアセンブラ処理のフローチ
ャートであり、図14はコード変換部14で参照される
コード変換テーブル10の一部を示す説明図である。こ
こで、図14において、コード変換テーブル10は、ア
センブリ言語のニーモニック18と各ニーモニックから
変換される機械語(命令コード)19とを対応させたテ
ーブルである。
2. Description of the Related Art FIG. 18 is a block diagram showing a configuration of a conventional assembler for inputting a source file, converting the source file into an object file, and outputting the converted object file. Conventional assembler
As shown in FIG. 18, the configuration includes a file input unit 12, a syntax analysis unit 13, a code conversion unit 14, and an object file output unit 17. FIG.
Is a flowchart of assembler processing by a conventional assembler. FIG. 14 is an explanatory diagram showing a part of the code conversion table 10 referred to by the code conversion unit 14. Here, in FIG. 14, the code conversion table 10 is a table in which mnemonics 18 in assembly language are associated with machine languages (instruction codes) 19 converted from each mnemonic.

【0003】図19に示すように、従来のアセンブラで
は、ソースファイルをファイル入力部12から読み込
み、読み込んだソースファイルに記述された命令を構文
解析部13によって解析する。そして、解析を行った
後、コード変換部14がコード変換テーブル10を参照
することによって、ニーモニックから機械語(命令コー
ド)に変換する。変換された機械語は、ファイル出力部
17によってファイルへ順次出力してオブジェクトファ
イルを生成するようになっている。
As shown in FIG. 19, in a conventional assembler, a source file is read from a file input unit 12, and a command described in the read source file is analyzed by a syntax analysis unit 13. After the analysis, the code conversion unit 14 converts the mnemonic into a machine language (instruction code) by referring to the code conversion table 10. The converted machine language is sequentially output to a file by the file output unit 17 to generate an object file.

【0004】ビッグエンディアンとリトルエンディアン
とを切り替えて動作可能なプロセッサが近年登場してい
る。ここで、ビッグエンディアンとは、データの最上位
バイトがメモリ上の最下位アドレスに割り当てられるバ
イト順序付け方式であり、リトルエンディアンとはデー
タの最下位バイトがメモリ上の最下位アドレスに割り当
てられるバイト順序付け方式のことをいう。プロセッサ
が双方のエンディアン(バイエンディアン)に対応して
いる場合、ビッグエンディアン、リトルエンディアンの
どちらで動作する場合でも、プロセッサで実行する機械
語そのものはエンディアンに関係なく共通するものであ
る。バイエンディアン対応の従来のアセンブラは、機械
語をオブジェクトファイルに出力する際に機械語や扱う
データはそれぞれのエンディアンに従ったバイトの並び
に変えてメモリイメージとして出力する。
[0004] In recent years, processors that can operate by switching between big endian and little endian have appeared. Here, big endian is a byte ordering scheme in which the most significant byte of data is assigned to the lowest address in memory, and little endian is byte ordering in which the least significant byte of data is assigned to the lowest address in memory. Refers to the method. When the processor supports both endians (bi-endian), the machine language itself executed by the processor is common regardless of the endian regardless of whether the processor operates in big endian or little endian. When a conventional bi-endian assembler outputs a machine language to an object file, the machine language and data to be handled are output as a memory image by changing a byte sequence according to each endian.

【0005】図15はニーモニックを機械語に変換した
時の16進数表記のコードとメモリに配置したときの状
態を示す説明図である。図15では、アセンブリ言語で
記述されたニーモニック20と、ニーモニック20に対
応する機械語(命令コード)21と、各命令がメモリ上
に配置された時のアドレス22との関係を示している。
また、図15では、命令Aは32ビット長の命令、命令
B,Cは16ビット長の命令を表し、命令A,B,Cの
順に実行するように記述したプログラムを一例として示
している。
FIG. 15 is an explanatory diagram showing a state in which a mnemonic is converted into a machine language and stored in a memory in hexadecimal notation and a memory. FIG. 15 shows a relationship between a mnemonic 20 described in an assembly language, a machine language (instruction code) 21 corresponding to the mnemonic 20, and an address 22 when each instruction is arranged on a memory.
In FIG. 15, instruction A represents a 32-bit instruction, instructions B and C represent 16-bit instructions, and shows, as an example, a program described to be executed in the order of instructions A, B, and C.

【0006】図16と図17は、このプログラムをアセ
ンブラ11を用いて機械語に変換したコードをオブジェ
クトファイルとして出力し、このオブジェクトファイル
の機械語をプログラムを実行するシステムのメモリ上に
展開した時のメモリイメージを示す説明図である。図1
6はビッグエンディアン動作を行う場合のメモリ上での
命令コードの配置23を示し、図17はリトルエンディ
アン動作を行う場合でのメモリ上での命令コードの配置
24を表している。どちらの状態においてもアセンブラ
で生成した命令コードは、アドレス0番地に命令A、ア
ドレス4番地に命令B、アドレス6番地に命令Cが配置
され、通常のプロセッサはアドレス順に、命令A、命令
B、命令Cの順序で実行を行う。
FIGS. 16 and 17 show a case where a code obtained by converting the program into a machine language using the assembler 11 is output as an object file, and the machine language of the object file is expanded on a memory of a system for executing the program. FIG. 4 is an explanatory diagram showing a memory image of FIG. FIG.
6 shows an arrangement 23 of instruction codes on a memory when performing a big endian operation, and FIG. 17 shows an arrangement 24 of instruction codes on a memory when performing a little endian operation. In either state, the instruction code generated by the assembler has an instruction A at address 0, an instruction B at address 4 and an instruction C at address 6, and a normal processor has instructions A, B, Execution is performed in the order of the instruction C.

【0007】[0007]

【発明が解決しようとする課題】ビッグエンディアンで
動作し16ビットと32ビットの2種類の命令長を持つ
プロセッサが従来から一般的に知られている。図12は
この種のプロセッサの命令コードを示した模式図であ
る。また、図13は、このプロセッサの動作を示すフロ
ーチャートである。図13に示す通り、プロセッサは、
オブジェクトファイルから32ビット単位でデータを取
り込む。そして取り込んだデータが32ビット長の命令
コードである場合にはその命令コードを実行する。一
方、取り込んだデータが2命令からなる16ビット長の
命令コードであった場合には上位16ビットの命令コー
ド(図12中、16bit命令1)を先に実行し、下位
16ビット(図12中、16bit命令2)の命令コー
ドを後に実行する。また、下位16ビットの最上位ビッ
トを同時実行フラグビットとし、このビットが1であっ
た場合は読み込んだ2つの命令コードを並列に実行し、
0であった場合には上述のように2つの16ビット長命
令コードを順次実行するようになっている。
A processor operating in big endian and having two instruction lengths of 16 bits and 32 bits has been generally known. FIG. 12 is a schematic diagram showing instruction codes of this type of processor. FIG. 13 is a flowchart showing the operation of the processor. As shown in FIG. 13, the processor comprises:
Data is read from the object file in 32-bit units. If the fetched data is a 32-bit instruction code, the instruction code is executed. On the other hand, if the fetched data is a 16-bit instruction code consisting of two instructions, the upper 16-bit instruction code (16-bit instruction 1 in FIG. 12) is executed first, and the lower 16 bits (in FIG. 12). , 16-bit instruction 2). Also, the most significant bit of the lower 16 bits is used as a simultaneous execution flag bit, and when this bit is 1, the two read instruction codes are executed in parallel,
When it is 0, two 16-bit instruction codes are sequentially executed as described above.

【0008】このようなビッグエンディアンで動作する
プロセッサのバス・インタフェースに修正を加え、従来
と異なるリトルエンディアンで動作できるようにしたプ
ロセッサがある。このような修正を加えたプロセッサに
おいても図13のフローチャートと同様に命令実行の処
理を行っている。
There is a processor in which the bus interface of such a processor operating in big endian is modified so that it can operate in little endian different from the conventional one. The processor with such a modification also executes the instruction execution processing as in the flowchart of FIG.

【0009】このプロセッサがビッグエンディアンで動
作した場合、図16に示したメモリイメージの命令を実
行すると、0番地の32ビット[0x90F0123
4]を読出し命令Aとして実行する。つぎに、4番地の
32ビット[0x00C27F20]を読出し、4番地
の命令B、6番地の命令Cの順で実行する。
When this processor operates in the big endian mode, when the instruction of the memory image shown in FIG. 16 is executed, the 32-bit [0x90F0123] of the address 0 is obtained.
4] as a read instruction A. Next, 32-bit [0x00C27F20] at address 4 is read, and instruction B at address 4 and instruction C at address 6 are executed in this order.

【0010】一方、プロセッサがリトルエンディアンで
動作した場合は図17に示したメモリイメージにおい
て、0番地の32ビット[0x90F01234]を読
出し、命令Aとして実行する。つぎに、4番地の32ビ
ット[0x7F2000C2]を読出し、6番地の命令
C、4番地の命令Bの順で実行する。
On the other hand, when the processor operates in little endian, 32 bits [0x90F01234] at address 0 are read out from the memory image shown in FIG. Next, 32 bits [0x7F2000C2] at address 4 are read and executed in the order of instruction C at address 6, instruction B at address 4.

【0011】このように、プロセッサでは16ビット長
の2つの命令コードを順次実行した場合、ビッグエンデ
ィアンとリトルエンディアンとで命令の実行順が逆とな
り、リトルエンディアンの動作ではアドレス上で逆行す
る動作となる。
As described above, when two instruction codes having a 16-bit length are sequentially executed in the processor, the execution order of the instructions is reversed between the big endian and the little endian. Become.

【0012】このため、リトルエンディアン動作におい
て以上の動作を行うプロセッサで実行するプログラムを
作成する場合には、2つの16ビット長命令コードを順
次実行したときにアドレスと逆行することを意識したコ
ーディングを行う必要がある。しかしながら、アセンブ
リ言語で記述する場合、使用する命令が32ビット長で
あるか16ビット長であるかを意識して記述することは
ないため、このような制限下でプグラムを記述すること
は困難であり、ソフトウェアの生産効率が悪くなる問題
点があった。
For this reason, when creating a program to be executed by the processor performing the above operation in the little endian operation, coding is performed in consideration of the fact that the address is reversed when two 16-bit instruction codes are sequentially executed. There is a need to do. However, when writing in assembly language, it is difficult to describe a program under such restrictions because it is not necessary to describe whether the instruction to be used is 32-bit length or 16-bit length. There was a problem that the production efficiency of software deteriorated.

【0013】この発明は上記に鑑みてなされたもので、
どちらのエンディアンで動作しても同一の処理を行うプ
ログラムを生成でき、アセンブリ言語プログラム開発を
効率よく行って、ソフトウェアの生産効率を向上させる
ことができるアセンブラ処理装置を得ることを目的とす
る。
The present invention has been made in view of the above,
It is an object of the present invention to provide an assembler processing apparatus capable of generating a program that performs the same processing regardless of which endian is operated, efficiently developing an assembly language program, and improving software production efficiency.

【0014】[0014]

【課題を解決するための手段】上記目的を達成するた
め、この発明にかかるアセンブラ処理装置は、16ビッ
ト長命令と32ビット長命令からなる命令セットを有す
るとともに異なるエンディアンで動作する時に2個の1
6ビット長命令コードの実行順序が入れ替わるプロセッ
サに対応した命令コードを生成するアセンブラ処理装置
において、ソースファイルからコード変換された16ビ
ット長命令コードを一時的に格納する記憶手段と、前記
記憶手段に32ビット境界で配置された2個の16ビッ
ト長命令コードを、動作対象のエンディアンに応じて入
れ替える配置変換手段と、入れ替えられた2個の16ビ
ット長命令コードを、オブジェクトファイルへ出力する
ファイル出力手段とを備えたことを特徴とする。
In order to achieve the above object, an assembler processing apparatus according to the present invention has an instruction set consisting of a 16-bit instruction and a 32-bit instruction, and operates at different endians. 1
In an assembler processing apparatus for generating an instruction code corresponding to a processor in which the execution order of a 6-bit instruction code is exchanged, a storage means for temporarily storing a 16-bit instruction code code-converted from a source file; An arrangement conversion means for exchanging two 16-bit instruction codes arranged on a 32-bit boundary in accordance with an endian of an operation target, and a file output for outputting the two exchanged 16-bit instruction codes to an object file Means.

【0015】この発明によれば、ソースファイルからコ
ード変換された16ビット長命令コードを記憶手段に一
時的に格納し、記憶手段に32ビット境界で配置された
2個の16ビット長命令コードを動作対象のエンディア
ンに応じて入れ替えて、2個の16ビット長命令コード
を、オブジェクトファイルへ出力するので、プロセッサ
がビッグエンディアンとリトルエンディアンのどちらの
エンディアンで動作する場合でも、アセンブリ言語記述
の同一ソースファイルを用いて同一の処理を実行するオ
ブジェクトファイルを生成することができ、ソフトウェ
アの生産性を改善することができる。
According to the present invention, the 16-bit instruction code code-converted from the source file is temporarily stored in the storage means, and the two 16-bit instruction codes arranged at the 32-bit boundary are stored in the storage means. Since two 16-bit instruction codes are output to the object file by replacing them according to the endian of the operation target, the same source of the assembly language description can be used even if the processor operates in either big endian or little endian endian. It is possible to generate an object file that executes the same processing using the file, and it is possible to improve the productivity of software.

【0016】つぎの発明にかかるアセンブラ処理装置
は、上記の発明において、前記配置変換手段は、16ビ
ット長命令コードが前記記憶手段に格納されたときに、
更に16ビット長のNOP命令コードを前記記憶手段に
追加するものであることを特徴とする。
[0016] In the assembler processing apparatus according to the next invention, in the above-mentioned invention, the arrangement conversion means, when a 16-bit instruction code is stored in the storage means,
Further, a 16-bit NOP instruction code is added to the storage means.

【0017】この発明によれば、16ビット長命令コー
ドが記憶手段に格納されたときに、更に16ビット長の
NOP命令コードを記憶手段に追加するので、全ての1
6ビット長命令を32ビットの境界に配置して、リトル
エンディアン動作時において16ビット長命令がアドレ
スに逆行した実行動作となることを無視することができ
る。また、逆アセンブルでメモリイメージとニーモニッ
クの対応表示を行った場合にはコーディングした手順が
そのまま出力されるため、検証には都合がよくソフトウ
ェア開発の効率化を行うことができる。
According to the present invention, when the 16-bit instruction code is stored in the storage means, a 16-bit NOP instruction code is further added to the storage means.
By arranging a 6-bit instruction at a 32-bit boundary, it is possible to ignore that a 16-bit instruction is an execution operation that goes backward to an address during little endian operation. Further, when the correspondence between the memory image and the mnemonic is displayed in the disassembly, the coded procedure is output as it is, so that the verification is convenient and the software development can be made more efficient.

【0018】つぎの発明にかかるアセンブラ処理装置
は、16ビット長命令と32ビット長命令からなる命令
セットを有するとともに異なるエンディアンで動作する
時に2個の16ビット長命令コードの実行順序が入れ替
わるプロセッサに対応した命令コードを生成するアセン
ブラ処理装置において、2個の16ビット長命令を組み
合わせて1個の32ビット長命令として定義した複合命
令のニーモニックと、前記複合命令の命令コードとを対
応づけたコード変換テーブルと、ソースファイルから読
み出した前記複合命令を、前記コード変換テーブルを参
照して前記複合命令に対応する命令コードに変換するコ
ード変換手段と、を備えたことを特徴とする。
An assembler processing apparatus according to the next invention is a processor having an instruction set consisting of a 16-bit instruction and a 32-bit instruction and in which the execution order of two 16-bit instruction codes is switched when operating in different endian. In an assembler processing apparatus for generating a corresponding instruction code, a code associating a mnemonic of a compound instruction defined as one 32-bit instruction by combining two 16-bit instructions and an instruction code of the compound instruction A conversion table and code conversion means for converting the compound instruction read from a source file into an instruction code corresponding to the compound instruction with reference to the code conversion table are provided.

【0019】この発明によれば、2個の16ビット長命
令を組み合わせた1個の32ビット長命令を複合命令と
して定義するとともに、この複合命令のニーモニックと
命令コードとを対応づけたコード変換テーブルを定義し
ておく。そして、このコード変換テーブルを用いて、ソ
ースファイルから読み出した複合命令を複合命令の命令
コードにコード変換するので、生成される命令コードは
すべて32ビット長となる。このため、プロセッサのリ
トルエンディアン動作時における命令の逆転実行を確実
になくすことができ、また、コード量の最適化を図るこ
とができる。
According to the present invention, one 32-bit instruction obtained by combining two 16-bit instructions is defined as a compound instruction, and a code conversion table in which mnemonics of the compound instruction are associated with instruction codes. Is defined. Then, since the composite instruction read from the source file is code-converted into the instruction code of the composite instruction using the code conversion table, all the generated instruction codes have a 32-bit length. For this reason, the reverse execution of the instruction during the little endian operation of the processor can be reliably eliminated, and the amount of code can be optimized.

【0020】つぎの発明にかかるアセンブラ処理方法
は、16ビット長命令と32ビット長命令からなる命令
セットを有するとともに異なるエンディアンで動作する
時に2個の16ビット長命令コードの実行順序が入れ替
わるプロセッサに対応した命令コードを生成するアセン
ブラ処理方法において、ソースファイルからコード変換
された16ビット長命令コードを、記憶手段に一時的に
格納する記憶ステップと、前記記憶手段に32ビット境
界で配置された2個の16ビット長命令コードを、動作
対象のエンディアンに応じて入れ替える配置変換ステッ
プと、入れ替えられた2個の16ビット長命令コード
を、オブジェクトファイルへ出力するファイル出力ステ
ップとを含むことを特徴とする。
The assembler processing method according to the next invention is directed to a processor having an instruction set including a 16-bit length instruction and a 32-bit length instruction, and in which the execution order of two 16-bit length instruction codes is switched when operating in different endian. In an assembler processing method for generating a corresponding instruction code, a storage step of temporarily storing a 16-bit instruction code converted from a source file in a storage means; And a file output step of outputting the replaced two 16-bit instruction codes to an object file. I do.

【0021】この発明によれば、ソースファイルからコ
ード変換された16ビット長命令コードを記憶手段に一
時的に格納し、記憶手段に32ビット境界で配置された
2個の16ビット長命令コードを動作対象のエンディア
ンに応じて入れ替えて、2個の16ビット長命令コード
を、オブジェクトファイルへ出力するので、プロセッサ
がビッグエンディアンとリトルエンディアンのどちらの
エンディアンで動作する場合でも、アセンブリ言語記述
の同一ソースファイルを用いて同一の処理を実行するオ
ブジェクトファイルを生成することができ、ソフトウェ
アの生産性を改善することができる。
According to the present invention, the 16-bit instruction code code-converted from the source file is temporarily stored in the storage means, and the two 16-bit instruction codes arranged on the 32-bit boundary are stored in the storage means. Since two 16-bit instruction codes are output to the object file by replacing them according to the endian of the operation target, the same source of the assembly language description can be used even if the processor operates in either big endian or little endian endian. It is possible to generate an object file that executes the same processing using the file, and it is possible to improve the productivity of software.

【0022】つぎの発明にかかるアセンブラ処理方法
は、上記の発明において、前記配置変換ステップは、1
6ビット長命令コードが前記記憶手段に格納されたとき
に、更に16ビット長のNOP命令コードを前記記憶手
段に追加するものであることを特徴とする。
[0022] In the assembler processing method according to the next invention, in the above-mentioned invention, the layout conversion step may include:
When a 6-bit instruction code is stored in the storage means, a 16-bit NOP instruction code is further added to the storage means.

【0023】この発明によれば、16ビット長命令コー
ドが記憶手段に格納されたときに、更に16ビット長の
NOP命令コードを記憶手段に追加するので、全ての1
6ビット長命令を32ビットの境界に配置して、リトル
エンディアン動作時において16ビット長命令がアドレ
スに逆行した実行動作となることを無視することができ
る。また、逆アセンブルでメモリイメージとニーモニッ
クの対応表示を行った場合にはコーディングした手順が
そのまま出力されるため、検証には都合がよくソフトウ
ェア開発の効率化を行うことができる。
According to the present invention, when the 16-bit instruction code is stored in the storage means, the 16-bit NOP instruction code is further added to the storage means.
By arranging a 6-bit instruction at a 32-bit boundary, it is possible to ignore that a 16-bit instruction is an execution operation that goes backward to an address during little endian operation. Further, when the correspondence between the memory image and the mnemonic is displayed in the disassembly, the coded procedure is output as it is, so that the verification is convenient and the software development can be made more efficient.

【0024】つぎの発明にかかるアセンブラ処理方法
は、16ビット長命令と32ビット長命令からなる命令
セットを有するとともに異なるエンディアンで動作する
時に2個の16ビット長命令コードの実行順序が入れ替
わるプロセッサに対応した命令コードを生成するアセン
ブラ処理方法において、2個の16ビット長命令を組み
合わせて1個の32ビット長命令として定義した複合命
令のニーモニックと前記複合命令の命令コードとを対応
づけたコード変換テーブルを参照して、ソースファイル
から読み出した前記複合命令を前記複合命令に対応する
命令コードに変換するコード変換ステップを含むことを
特徴とする。
The assembler processing method according to the next invention is directed to a processor which has an instruction set consisting of a 16-bit instruction and a 32-bit instruction, and which switches the execution order of two 16-bit instruction codes when operating in different endians. In an assembler processing method for generating a corresponding instruction code, code conversion in which a mnemonic of a compound instruction defined as one 32-bit instruction by combining two 16-bit instructions and an instruction code of the compound instruction are associated with each other. A code conversion step of converting the compound instruction read from the source file into an instruction code corresponding to the compound instruction with reference to a table.

【0025】この発明によれば、2個の16ビット長命
令を組み合わせた1個の32ビット長命令を複合命令と
して定義するとともに、この複合命令のニーモニックと
命令コードとを対応づけたコード変換テーブルを定義し
ておく。そして、このコード変換テーブルを用いて、ソ
ースファイルから読み出した複合命令を複合命令の命令
コードにコード変換するので、生成される命令コードは
すべて32ビット長となる。このため、プロセッサのリ
トルエンディアン動作時における命令の逆転実行を確実
になくすことができ、また、コード量の最適化を図るこ
とができる。
According to the present invention, one 32-bit instruction combining two 16-bit instructions is defined as a compound instruction, and a code conversion table in which mnemonics of the compound instruction are associated with instruction codes. Is defined. Then, since the composite instruction read from the source file is code-converted into the instruction code of the composite instruction using the code conversion table, all the generated instruction codes have a 32-bit length. For this reason, the reverse execution of the instruction during the little endian operation of the processor can be reliably eliminated, and the amount of code can be optimized.

【0026】つぎの発明にかかるプログラムは、上述し
た発明のいずれか一つに記載されたアセンブラ処理方法
をコンピュータに実行させるプログラムであり、そのプ
ログラムが機械読み取り可能となり、これによって、上
記の発明のいずれか一つの動作をコンピュータによって
実行することができる。
A program according to the next invention is a program for causing a computer to execute the assembler processing method according to any one of the above-described inventions, and the program becomes machine-readable, thereby enabling the computer to execute the above-described invention. Any one of the operations can be performed by a computer.

【0027】[0027]

【発明の実施の形態】以下に添付図面を参照して、この
発明にかかるアセンブラ処理装置、アセンブラ処理方法
およびその方法をコンピュータに実行させるプログラム
の好適な実施の形態を詳細に説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Preferred embodiments of an assembler processing apparatus, an assembler processing method and a program for causing a computer to execute the method according to the present invention will be described below in detail with reference to the accompanying drawings.

【0028】実施の形態1.図1は、この発明の実施の
形態1であるアセンブラの構成を示すブロック図であ
る。実施の形態1のアセンブラは、アセンブラ言語で記
述されたソースファイルからビッグエンディアン用の命
令コード(機械語)とリトルエンディアン用の命令コー
ド(機械語)をオブジェクトファイルとして出力するバ
イエンディアン対応アセンブラである。また、実施の形
態1のアセンブラは、上述した図12に示す命令コード
を有し、かつ上述した図13のフローチャートに示す動
作を行うプロセッサで実行される命令コードを生成する
ものである。
Embodiment 1 FIG. 1 is a block diagram showing a configuration of the assembler according to the first embodiment of the present invention. The assembler according to the first embodiment is a bi-endian-compatible assembler that outputs an instruction code for big endian (machine language) and an instruction code for little endian (machine language) from a source file described in an assembler language as an object file. . Further, the assembler according to the first embodiment has an instruction code shown in FIG. 12 described above and generates an instruction code executed by a processor that performs the operation shown in the flowchart in FIG. 13 described above.

【0029】図1に示すように、実施の形態1のバイエ
ンディアン対応アセンブラ1は、ソースファイルを読み
出すファイル入力部2と、ファイル入力部2で読み出し
たソースファイルに記述されたアセンブリ言語のソース
コードを構文解析する構文解析部3と、コード変換テー
ブル10と、コード変換テーブル10を参照して、アセ
ンブリ言語のニーモニックを命令コード(機械語)に変
換するコード変換部4と、変換された命令コードを一時
的に記憶する一時保管バッファ5と、一時保管バッファ
5に保存された命令コードの配置を変換する配置変換部
6と、変換された命令コードまたは一時保管バッファ5
に記憶されている変換された命令コードを、オブジェク
トファイルとして出力処理を行うファイル出力部7とを
備えている。
As shown in FIG. 1, a bi-endian assembler 1 according to the first embodiment includes a file input unit 2 for reading a source file, and an assembly language source code described in the source file read by the file input unit 2. A code analysis unit 3, a code conversion table 10, a code conversion unit 4 that converts the assembly language mnemonic into an instruction code (machine language) with reference to the code conversion table 10, and a converted instruction code Temporary storage buffer 5 for temporarily storing the instruction code, an arrangement conversion unit 6 for converting the arrangement of the instruction code stored in the temporary storage buffer 5, a converted instruction code or the temporary storage buffer 5
And a file output unit 7 that performs an output process on the converted instruction code stored in the file as an object file.

【0030】コード変換テーブル10は、アセンブラ言
語のニーモニック表記と命令コードとを対応付けた表で
あり、図14はコード変換テーブル10の一例を示す説
明図である。一時保管バッファは、アセンブラ1が実行
されるときに、記憶手段としてのメモリ上に4個のバイ
トデータの配列(char BUF[3])を確保され
る。配置変換部6は、一時保管バッファ5に記憶された
命令コードの配置を、動作するエンディアンに応じてバ
イト単位で変換するものである。
The code conversion table 10 is a table in which mnemonic notation of the assembler language is associated with instruction codes, and FIG. 14 is an explanatory diagram showing an example of the code conversion table 10. In the temporary storage buffer, when the assembler 1 is executed, an array of four byte data (char BUF [3]) is secured on the memory as the storage means. The arrangement conversion unit 6 converts the arrangement of the instruction codes stored in the temporary storage buffer 5 in byte units according to the operating endian.

【0031】つぎに、以上のように構成されたバイエン
ディアン対応アセンブラによる、ビッグエンディアン用
の命令コード生成の処理手順について説明する。図2
は、ビッグエンディアン用命令コード生成の処理手順を
示すフローチャートである。
Next, a description will be given of a processing procedure for generating an instruction code for big endian by the bi-endian-compatible assembler configured as described above. FIG.
9 is a flowchart showing a processing procedure for generating an instruction code for big endian.

【0032】アセンブラ1は、まず、一時保管バッファ
5としてメモリ上に4個のバイトデータの配列(cha
r BUF[3])を確保して、これを初期化する(ス
テップS201)。そして、ファイル入力部2によりア
センブリ言語で記述されたソースファイルを一行分読み
込み(ステップS202)、読み込んだソースコードを
構文解析部3によって構文解析する(ステップS20
3)。構文解析終了後、コード変換部4においてニーモ
ニックと命令コード(機械語)の対応表が記されている
コード変換テーブル10(図14)を参照してソースコ
ードを命令コード(機械語)に変換する(ステップS2
04)。
The assembler 1 first stores an array of four byte data (cha) in the memory as the temporary storage buffer 5.
r BUF [3]) is secured and initialized (step S201). Then, one line of the source file described in the assembly language is read by the file input unit 2 (step S202), and the read source code is parsed by the parsing unit 3 (step S20).
3). After the syntax analysis, the code conversion unit 4 converts the source code into an instruction code (machine language) with reference to a code conversion table 10 (FIG. 14) in which a correspondence table between mnemonics and instruction codes (machine language) is described. (Step S2
04).

【0033】そして、配置変換部6では、更に以下のビ
ッグエンディアン用の命令コード生成のための配置変換
処理を行う。まず、コード変換された命令コードのサイ
ズをチェックする(ステップS205)。命令コードが
32ビット長であった場合には、更に一時保管バッファ
5に前回変換分の命令コードが残存しているか否かをチ
ェックする(ステップS206)。残存していなけれ
ば、変換された命令コードの上位バイトから1バイトず
つ4バイト分を、一時保管バッファ5にBUF[0]、
BUF[1]、BUF[2]、BUF[3]の順で格納
する(ステップS209)。そして、ファイル出力部7
によって、一時保管バッファ5に格納された命令コード
をオブジェクトファイルに出力する(ステップS21
3)。出力する順番及びバイトごとの配置は、BUF
[0]、BUF[1]、BUF[2]、BUF[3]の
順番で、ビッグエンディアンに対応すさせてオブジェク
トファイルの下位アドレス(即ち、MSB)から出力す
る。
Then, the arrangement conversion unit 6 further performs the following arrangement conversion processing for generating an instruction code for big endian. First, the size of the code-converted instruction code is checked (step S205). If the instruction code has a 32-bit length, it is further checked whether or not the instruction code corresponding to the previous conversion remains in the temporary storage buffer 5 (step S206). If not, four bytes, one byte at a time, from the upper byte of the converted instruction code are stored in the temporary storage buffer 5 as BUF [0],
BUF [1], BUF [2], and BUF [3] are stored in this order (step S209). Then, the file output unit 7
Output the instruction code stored in the temporary storage buffer 5 to the object file (step S21).
3). The output order and the arrangement for each byte are BUFF
[0], BUF [1], BUF [2], and BUF [3] are output in order from the lower address (that is, MSB) of the object file in correspondence with big endian.

【0034】ステップS205におけるコードサイズの
チェックの結果、変換された命令コードが16ビット長
であった場合は、一時保管バッファ5に前回変換分の命
令コードが残存しているか否かをチェックする(ステッ
プS210)。残存していなければ、16ビット長命令
コードの上位8ビットを一時保管バッファ5のBUF
[0]に、下位8ビットをBUF[1]に保管する(ス
テップS211)。
As a result of the code size check in step S205, if the converted instruction code has a 16-bit length, it is checked whether or not the previously converted instruction code remains in the temporary storage buffer 5 (step S205). Step S210). If not, the upper 8 bits of the 16-bit instruction code are stored in the BUF of the temporary storage buffer 5.
The lower 8 bits are stored in BUF [1] in [0] (step S211).

【0035】つぎに、ファイル入力部2においてソース
ファイルからつぎの一行のソースコードを読み出し(ス
テップS202)、同様にステップS205までの処理
を行う。この命令が16ビット長命令コードであった場
合、一時保管バッファ5に前回変換分の命令コードが残
存しているか否かをチェックするが(ステップS21
0)、この場合、BUF[0]とBUF[1]に残存し
ているので、新たに変換した命令コードの上位8ビット
をBUF[2]に、下位8ビットをBUF[3]に保存
する(ステップS212)。そして、ファイル出力部7
によって、一時保管バッファ5に格納された命令コード
を、BUF[0]、BUF[1]、BUF[2]、BU
F[3]の順番で、ビッグエンディアンに対応させてオ
ブジェクトファイルの下位アドレス(即ち、MSB)か
ら出力する(ステップS213)。
Next, the next one line of source code is read from the source file in the file input unit 2 (step S202), and the processing up to step S205 is similarly performed. If this instruction is a 16-bit instruction code, it is checked whether or not the instruction code of the previous conversion remains in the temporary storage buffer 5 (step S21).
0) In this case, the upper 8 bits of the newly converted instruction code are stored in BUF [2] and the lower 8 bits are stored in BUF [3] because they remain in BUF [0] and BUF [1]. (Step S212). Then, the file output unit 7
The BUF [0], BUF [1], BUF [2], BUF
In the order of F [3], the object file is output from the lower address (ie, MSB) of the object file in correspondence with the big endian (step S213).

【0036】ステップS205で、16ビット長命令コ
ードのつぎに読み出して変換された命令コードが32ビ
ット長命令であった場合には、一時保管バッファ5に前
回変換分の命令コードが残存しているか否かをチェック
するが(ステップS206)、この場合、BUF[0]
とBUF[1]に残存しているので、ステップS207
へ進み、一時保管バッファ5のBUF[2]、BUF
[3]に16ビットの無処理命令(NOP)を追加保存
する。そして、ファイル出力部7によって、一時保管バ
ッファ5に格納された命令コードを、BUF[0]、B
UF[1]、BUF[2]、BUF[3]の順番で、ビ
ッグエンディアンに対応させてオブジェクトファイルの
下位アドレス(即ち、MSB)から出力し(ステップS
208)、続いて次の32ビット長命令コードの一時保
管バッファ5への保存(ステップS209)およびオブ
ジェクトファイルへの出力を行う(ステップS21
3)。
In step S205, if the instruction code read and converted following the 16-bit instruction code is a 32-bit instruction code, whether the instruction code of the previous conversion remains in the temporary storage buffer 5 or not. It is checked whether or not it is not (step S206).
And BUF [1], so step S207
To BUF [2] and BUF of the temporary storage buffer 5
A 16-bit no-processing instruction (NOP) is additionally stored in [3]. Then, the instruction code stored in the temporary storage buffer 5 is converted by the file output unit 7 into BUF [0], B
Output in order of UF [1], BUF [2], and BUF [3] from the lower address (that is, MSB) of the object file corresponding to big endian (step S).
208) Then, the next 32-bit instruction code is stored in the temporary storage buffer 5 (step S209) and output to the object file (step S21).
3).

【0037】図4(a)は、一例としてソースコードが
32ビット長の命令コードA,16ビット長の命令コー
ドB,および16ビット長の命令コードCにこの順番で
コード変換された場合の、ビッグエンディアン用の各命
令コードの一時保管バッファ5への格納状態、およびオ
ブジェクトファイルへの出力状態を示す説明図である。
図4(b)は、一例としてソースコードが16ビット長
の命令コードB,32ビット長の命令コードAにこの順
番でコード変換された場合の、各命令コードの一時保管
バッファ5への格納状態、およびオブジェクトファイル
への出力状態を示す説明図である。
FIG. 4A shows an example in which the source code is converted into a 32-bit instruction code A, a 16-bit instruction code B, and a 16-bit instruction code C in this order. FIG. 4 is an explanatory diagram showing a storage state of each instruction code for big endian in a temporary storage buffer 5 and an output state to an object file.
FIG. 4B shows, as an example, a state of storing each instruction code in the temporary storage buffer 5 when the source code is converted into an instruction code B having a length of 16 bits and an instruction code A having a length of 32 bits in this order. FIG. 9 is an explanatory diagram showing a state of output to an object file.

【0038】プロセッサがビッグエンディアンで動作す
る場合、プロセッサがオブジェクトファイルからメモリ
上にロードされた命令コードを0番地、4番地、6番地
の順に実行していくが、図4(a)および(b)からわ
かるように、オブジェクトファイルへの各命令コードの
格納配置はビッグエンディアンの場合に命令コードの実
行順に配置されるよう変換されるので、ソースファイル
の命令の順番と命令の実行順が一致したものとなる。
When the processor operates in big endian, the processor executes the instruction code loaded from the object file onto the memory in the order of addresses 0, 4, and 6, as shown in FIGS. 4 (a) and 4 (b). ), The storage arrangement of each instruction code in the object file is converted so that it is arranged in the execution order of instruction codes in the case of big endian, so that the instruction order of the source file and the instruction execution order match. It will be.

【0039】つぎに、実施の形態1のアセンブラ1によ
るリトルエンディアン用の命令コード生成の処理手順に
ついて説明する。図3は、リトルエンディアン用命令コ
ード生成の処理手順を示すフローチャートである。アセ
ンブラ1は、ビッグエンディアン用命令コード生成処理
との場合と同様に、一時保管バッファ5の初期化(ステ
ップS301)、ソースファイルから一行読出し(ステ
ップS302)、構文解析(ステップS303)、コー
ド変換を行う(ステップS304)。そして配置変換部
6では、更に以下のリトルエンディアン用の命令コード
生成のための配置変換処理を行う。まず、コード変換さ
れた命令コードのサイズをチェックする(ステップS3
05)。命令コードが32ビット長であった場合には、
更に一時保管バッファ5に前回変換分の命令コードが残
存しているか否かをチェックする(ステップS30
6)。残存していなければ、コード変換された命令コー
ドの下位バイトから1バイトずつ4バイト分を、一時保
管バッファ5にBUF[0]、BUF[1]、BUF
[2]、BUF[3]の順で格納する(ステップS30
9)。そして、ファイル出力部7によって、一時保管バ
ッファ5に格納された命令コードをオブジェクトファイ
ルに出力する(ステップS313)。出力する順番及び
バイトごとの配置は、BUF[0]、BUF[1]、B
UF[2]、BUF[3]の順番で、リトルエンディア
ンに対応させてオブジェクトファイルの下位アドレス
(即ち、LSB)から出力する。
Next, a description will be given of a processing procedure for generating an instruction code for little endian by the assembler 1 of the first embodiment. FIG. 3 is a flowchart illustrating a processing procedure for generating a little endian instruction code. The assembler 1 initializes the temporary storage buffer 5 (step S301), reads one line from the source file (step S302), analyzes the syntax (step S303), and performs code conversion, as in the case of the big endian instruction code generation processing. Perform (step S304). Then, the arrangement conversion unit 6 further performs the following arrangement conversion processing for generating an instruction code for little endian. First, the size of the converted instruction code is checked (step S3).
05). If the instruction code is 32 bits long,
Further, it is checked whether or not the instruction code of the previous conversion remains in the temporary storage buffer 5 (step S30).
6). If not, BUF [0], BUF [1], BUF [1], BUF [1]
[2] and BUF [3] are stored in this order (step S30).
9). Then, the instruction code stored in the temporary storage buffer 5 is output to the object file by the file output unit 7 (step S313). The output order and the arrangement for each byte are BUF [0], BUF [1], B
The data is output from the lower address (that is, LSB) of the object file in the order of UF [2] and BUF [3] in correspondence with little endian.

【0040】ステップS305におけるコードサイズチ
ェックの結果、変換された命令コードが16ビット長で
あった場合は、一時保管バッファ5に前回変換分の命令
コードが残存しているか否かをチェックする(ステップ
S310)。残存していなければ、16ビット長命令コ
ードの上位8ビットを一時保管バッファ5のBUF
[3]に、下位8ビットをBUF[2]に保管する(ス
テップS311)。
As a result of the code size check in step S305, if the converted instruction code is 16 bits long, it is checked whether or not the previously converted instruction code remains in the temporary storage buffer 5 (step S305). S310). If not, the upper 8 bits of the 16-bit instruction code are stored in the BUF of the temporary storage buffer 5.
The lower 8 bits are stored in BUF [2] in [3] (step S311).

【0041】つぎに、ファイル入力部2においてソース
ファイルからつぎの一行のソースコードを読み出し(ス
テップS302)、同様にステップS305までの処理
を行う。この命令が16ビット長命令コードであった場
合、一時保管バッファ5に前回変換分の命令コードが残
存しているか否かをチェックするが(ステップS31
0)、この場合、BUF[3]とBUF[2]に残存し
ているので、新たに変換した命令コードの上位8ビット
をBUF[1]に、下位8ビットをBUF[0]に保存
する(ステップS312)。そして、ファイル出力部7
によって、一時保管バッファ5に格納された命令コード
を、BUF[0]、BUF[1]、BUF[2]、BU
F[3]の順番で、リトルエンディアンに対応させてオ
ブジェクトファイルの下位アドレス(即ち、LSB)か
ら出力する(ステップS313)。
Next, the next one line of source code is read from the source file in the file input section 2 (step S302), and the processing up to step S305 is similarly performed. If the instruction is a 16-bit instruction code, it is checked whether or not the instruction code of the previous conversion remains in the temporary storage buffer 5 (step S31).
0) In this case, the upper 8 bits of the newly converted instruction code are stored in BUF [1] and the lower 8 bits are stored in BUF [0] because they remain in BUF [3] and BUF [2]. (Step S312). Then, the file output unit 7
The BUF [0], BUF [1], BUF [2], BUF
In the order of F [3], output is performed from the lower address (that is, LSB) of the object file in correspondence with little endian (step S313).

【0042】ステップS305で、16ビット長命令コ
ードのつぎに読み出して変換された命令コードが32ビ
ット長命令であった場合には、一時保管バッファ5に前
回変換分の命令コードが残存しているか否かをチェック
するが(ステップS306)、この場合、BUF[3]
とBUF[2]に残存しているので、ステップS307
へ進み、一時保管バッファ5のBUF[1]、BUF
[0]に16ビットの無処理命令(NOP)を追加保存
する。そして、ファイル出力部7によって、一時保管バ
ッファ5に格納された命令コードを、BUF[0]、B
UF[1]、BUF[2]、BUF[3]の順番で、リ
トルエンディアンに対応させてオブジェクトファイルの
下位アドレス(即ち、LSB)から出力し(ステップS
308)、続いて次の32ビット長命令コードの一時保
管バッファ5への保存(ステップS309)およびオブ
ジェクトファイルへの出力を行う(ステップS31
3)。
In step S305, if the instruction code read and converted after the 16-bit instruction code is a 32-bit instruction code, whether the instruction code of the previous conversion remains in the temporary storage buffer 5 or not. It is checked whether or not it is not (step S306). In this case, BUF [3]
And BUF [2], so step S307
To BUF [1] and BUF in the temporary storage buffer 5
A 16-bit no-processing instruction (NOP) is additionally stored in [0]. Then, the instruction code stored in the temporary storage buffer 5 is converted by the file output unit 7 into BUF [0], B
Output in the order of UF [1], BUF [2], and BUF [3] from the lower address (ie, LSB) of the object file corresponding to little endian (step S).
308) Then, the next 32-bit instruction code is stored in the temporary storage buffer 5 (step S309) and output to the object file (step S31).
3).

【0043】図5(a)は、一例としてソースコードが
32ビット長の命令コードA,16ビット長の命令コー
ドB,および16ビット長の命令コードCにこの順番で
コード変換された場合の、リトルエンディアン用の各命
令コードの一時保管バッファ5への格納状態、およびオ
ブジェクトファイルへの出力状態を示す説明図である。
図5(b)は、一例としてソースコードが16ビット長
の命令コードB,32ビット長の命令コードAにこの順
番でコード変換された場合の、各命令コードの一時保管
バッファ5への格納状態、およびオブジェクトファイル
への出力状態を示す説明図である。
FIG. 5A shows an example in which the source code is converted into a 32-bit instruction code A, a 16-bit instruction code B, and a 16-bit instruction code C in this order. FIG. 4 is an explanatory diagram showing a storage state of each little endian instruction code in a temporary storage buffer 5 and an output state to an object file.
FIG. 5B shows, as an example, the state of storing each instruction code in the temporary storage buffer 5 when the source code is converted into an instruction code B having a length of 16 bits and an instruction code A having a length of 32 bits in this order. FIG. 9 is an explanatory diagram showing a state of output to an object file.

【0044】プロセッサがリトルエンディアンで動作す
る場合にも、プロセッサがオブジェクトファイルからメ
モリ上にロードされた命令コードを0番地、4番地、6
番地の順に実行していくが、図5(a)および(b)か
らわかるように、オブジェクトファイルへの各命令コー
ドの格納配置はリトルエンディアンの場合に命令コード
の実行順に配置されるよう変換されるので、ソースファ
イルの命令の順番と命令の実行順が一致したものとな
る。
Even when the processor operates in little endian, the processor can read the instruction code loaded from the object file into the memory at addresses 0, 4, 6
The addresses are executed in the order of the addresses. As can be seen from FIGS. 5A and 5B, the storage arrangement of each instruction code in the object file is converted so as to be arranged in the execution order of the instruction codes in the case of little endian. Therefore, the order of the instructions in the source file matches the order of execution of the instructions.

【0045】以上説明したようにアセンブラ処理を行う
ことでアセンブリ言語記述の同一ソースファイルを用い
てもプロセッサにおいてどちらのエンディアンにおいて
も同一の処理を実行するオブジェクトファイルを生成す
ることができ、ソフトウェアの生産性を改善することが
できる。
By performing assembler processing as described above, even if the same source file described in assembly language is used, an object file that executes the same processing in both endians can be generated in the processor. Performance can be improved.

【0046】実施の形態2.実施の形態1のバイエンデ
ィアン対応アセンブラは、32ビット境界で16ビット
長命令に続く命令が16ビット長命令であった場合は2
つの命令を繋げて32ビット分を変換した後にオブジェ
クトファイルに出力するものであったが、この実施の形
態2のバイエンディアン対応アセンブラは、16ビット
命令を変換する際に残り半分の16ビットを常にNOP
命令とすることで処理の簡略化を行うものである。
Embodiment 2 The bi-endian-compatible assembler according to the first embodiment is configured such that if an instruction following a 16-bit instruction on a 32-bit boundary is a 16-bit instruction,
In the bi-endian assembler according to the second embodiment, the remaining half of 16 bits is always converted when converting a 16-bit instruction. NOP
Processing is simplified by using instructions.

【0047】図6は、この発明の実施の形態2であるア
センブラの構成を示すブロック図である。図6に示すよ
うに、実施の形態2のバイエンディアン対応アセンブラ
は、ファイル入力部2と、構文解析部3と、コード変換
部4と、コード変換テーブル10と、一時保管バッファ
5と、配置変換部66と、ファイル出力部7とを備えて
いる。ここで、ファイル入力部2と、構文解析部3と、
コード変換部4と、コード変換テーブル10と、一時保
管バッファ5と、ファイル出力部7は、実施の形態1の
アセンブラと同様であるため、説明を省略する。配置変
換部66は、一時保管バッファ5に16ビット長命令コ
ードが保存された場合に、NOP命令を追加して動作す
るエンディアンに応じて16ビット長命令コードとNO
P命令の配置を変換するものである。
FIG. 6 is a block diagram showing a structure of an assembler according to the second embodiment of the present invention. As shown in FIG. 6, the bi-endian compatible assembler according to the second embodiment includes a file input unit 2, a syntax analysis unit 3, a code conversion unit 4, a code conversion table 10, a temporary storage buffer 5, a layout conversion And a file output unit 7. Here, the file input unit 2, the syntax analysis unit 3,
The code conversion unit 4, the code conversion table 10, the temporary storage buffer 5, and the file output unit 7 are the same as those of the assembler of the first embodiment, and thus the description is omitted. When the 16-bit instruction code is stored in the temporary storage buffer 5, the arrangement conversion unit 66 adds the 16-bit instruction code and the NO
This is for converting the arrangement of P instructions.

【0048】つぎに、このように構成された実施の形態
2のバイエンディアン対応アセンブラによるビッグエン
ディアン用の命令コード生成処理手順について説明す
る。図7は、ビッグエンディアン用命令コード生成の処
理手順を示すフローチャートである。
Next, a description will be given of a processing procedure for generating an instruction code for big endian by the bi-endian-compatible assembler according to the second embodiment configured as described above. FIG. 7 is a flowchart illustrating a processing procedure for generating an instruction code for big endian.

【0049】アセンブラ1は、実施の形態1のビッグエ
ンディアン用命令コード生成処理と同様に、一時保管バ
ッファ5の初期化(ステップS601)、ソースファイ
ルから一行読出し(ステップS602)、構文解析(ス
テップS603)、コード変換を行う(ステップS60
4)。そして配置変換部66では、更に以下のリトルエ
ンディアン用の命令コード生成のための配置変換処理を
行う。まず、コード変換された命令コードのサイズをチ
ェックする(ステップS605)。
The assembler 1 initializes the temporary storage buffer 5 (step S601), reads one line from the source file (step S602), and analyzes the syntax (step S603), similarly to the big endian instruction code generation processing of the first embodiment. ) And perform code conversion (step S60)
4). Then, the arrangement conversion section 66 further performs the following arrangement conversion processing for generating an instruction code for little endian. First, the size of the code-converted instruction code is checked (step S605).

【0050】命令コードが32ビット長であった場合に
は、コード変換された命令コードの上位バイトから1バ
イトずつ4バイト分を、一時保管バッファ5にBUF
[0]、BUF[1]、BUF[2]、BUF[3]の
順で格納する(ステップS606)。そして、ファイル
出力部7によって、一時保管バッファ5に格納された命
令コードを、BUF[0]、BUF[1]、BUF
[2]、BUF[3]の順番で、ビッグエンディアンに
対応させてオブジェクトファイルの下位アドレス(即
ち、MSB)から出力する(ステップS610)。
When the instruction code has a 32-bit length, four bytes, one byte at a time, from the upper byte of the code-converted instruction code are stored in the temporary storage buffer 5 in the BUFF.
[0], BUF [1], BUF [2], and BUF [3] are stored in this order (step S606). Then, the instruction code stored in the temporary storage buffer 5 is converted by the file output unit 7 into BUF [0], BUF [1], BUF [1].
[2] and BUF [3] are output in order from the lower address (that is, MSB) of the object file in correspondence with big endian (step S610).

【0051】ステップS605におけるコードサイズの
チェックの結果、変換された命令コードが16ビット長
であった場合は、16ビット長命令コードの上位8ビッ
トを一時保管バッファ5のBUF[0]に、下位8ビッ
トをBUF[1]に保管する(ステップS607)。そ
して、一時保管バッファ5のBUF[2]、BUF
[3]に16ビットの無処理命令(NOP)を追加保存
する(ステップS608)。更に、NOP命令を保存す
るバッファのBUF[2]の最上位ビットに「1」を設
定する(ステップS609)。BUF[2]の最上位ビ
ットは、図13の動作を行うプロセッサが命令コードを
実行するときに、読み込んだ2つの16ビット長の命令
を並列に実行するか否かを判断する際の並列実行ビット
に対応するものである。かかる最上位ビットを「1」に
設定することにより、BUF[0]とBUF[1]に保
存された16ビット長命令とBUF[2]とBUF
[3]に保存されたNOP命令とがプロセッサによって
並列に実行されることになる。
As a result of the code size check in step S605, if the converted instruction code has a 16-bit length, the upper 8 bits of the 16-bit instruction code are stored in BUF [0] of the temporary storage buffer 5, and the lower 8 bits. 8 bits are stored in BUF [1] (step S607). Then, BUF [2], BUF of the temporary storage buffer 5
A 16-bit no-processing instruction (NOP) is additionally stored in [3] (step S608). Further, "1" is set to the most significant bit of BUF [2] of the buffer storing the NOP instruction (step S609). The most significant bit of BUF [2] is used for parallel execution when determining whether or not to execute two read 16-bit instructions in parallel when the processor performing the operation in FIG. 13 executes the instruction code. It corresponds to a bit. By setting the most significant bit to “1”, the 16-bit instruction stored in BUF [0] and BUF [1], BUF [2] and BUF
The NOP instruction stored in [3] is executed in parallel by the processor.

【0052】そして、ファイル出力部7によって、一時
保管バッファ5に格納された命令コードを、ビッグエン
ディアンに対応するため、BUF[0]、BUF
[1]、BUF[2]、BUF[3]の順番で、ビッグ
エンディアンに対応させてオブジェクトファイルの下位
アドレス(即ち、MSB)から出力する(ステップS6
10)。
The file output unit 7 converts the instruction code stored in the temporary storage buffer 5 into BUF [0], BUF
[1], BUF [2], and BUF [3] are output in order from the lower address (that is, MSB) of the object file in correspondence with big endian (step S6).
10).

【0053】つぎに、バイエンディアン対応アセンブラ
によるリトルエンディアン用の命令コード生成処理手順
について説明する。図8は、リトルエンディアン用命令
コード生成の処理手順を示すフローチャートである。
Next, a description will be given of the procedure for generating an instruction code for little endian by a bi-endian compatible assembler. FIG. 8 is a flowchart illustrating a processing procedure for generating a little endian instruction code.

【0054】アセンブラ1は、上述のビッグエンディア
ン用命令コード生成処理と同様に、一時保管バッファ5
の初期化(ステップS701)、ソースファイルから一
行読出し(ステップS702)、構文解析(ステップS
703)、コード変換を行う(ステップS704)。そ
して配置変換部66では、更に以下のリトルエンディア
ン用の命令コード生成のための配置変換処理を行う。
The assembler 1 stores the temporary storage buffer 5 in the same manner as the big endian instruction code generation processing described above.
Initialization (step S701), one line is read from the source file (step S702), and syntax analysis (step S701)
703), and code conversion is performed (step S704). Then, the arrangement conversion section 66 further performs the following arrangement conversion processing for generating an instruction code for little endian.

【0055】まず、コード変換された命令コードのサイ
ズをチェックする(ステップS705)。命令コードが
32ビット長であった場合には、コード変換された命令
コードの下位バイトから1バイトずつ4バイト分を、一
時保管バッファ5にBUF[0]、BUF[1]、BU
F[2]、BUF[3]の順で格納する(ステップS7
06)。そして、ファイル出力部7によって、BUF
[0]、BUF[1]、BUF[2]、BUF[3]の
順番で、リトルエンディアンに対応させてオブジェクト
ファイルの下位アドレス(即ち、LSB)から一時保管
バッファ5に格納された命令コードをオブジェクトファ
イルに出力する(ステップS710)。
First, the size of the code-converted instruction code is checked (step S705). When the instruction code has a 32-bit length, four bytes, one byte at a time, from the lower byte of the code-converted instruction code are stored in the temporary storage buffer 5 in BUF [0], BUF [1], and BUF.
F [2] and BUF [3] are stored in this order (step S7).
06). Then, the BUF is output by the file output unit 7.
[0], BUF [1], BUF [2], and BUF [3] in this order, the instruction code stored in the temporary storage buffer 5 from the lower address (ie, LSB) of the object file corresponding to little endian. Output to an object file (step S710).

【0056】ステップS705におけるコードサイズの
チェックの結果、コード変換された命令コードが16ビ
ット長であった場合は、16ビット長命令コードの上位
8ビットを一時保管バッファ5のBUF[3]に、下位
8ビットをBUF[2]に保管する。(ステップS70
7)。そして、一時保管バッファ5のBUF[1]、B
UF[0]に16ビットの無処理命令(NOP)を追加
保存する(ステップS708)。更に、16ビット長命
令コードを保存するバッファのBUF[2]の最上位ビ
ットに「1」を設定する(ステップS709)。このB
UF[2]の最上位ビットは、ビッグエンディアン用の
処理と同様に、並列実行ビットに対応するものである。
かかる最上位ビットを「1」に設定することにより、B
UF[3]とBUF[2]に保存された16ビット長命
令とBUF[1]とBUF[0]に保存されたNOP命
令とがプロセッサによって並列に実行されることにな
る。
As a result of the code size check in step S705, if the code-converted instruction code has a 16-bit length, the upper 8 bits of the 16-bit instruction code are stored in BUF [3] of the temporary storage buffer 5, Store the lower 8 bits in BUF [2]. (Step S70
7). Then, BUF [1], B of the temporary storage buffer 5
A 16-bit no-processing instruction (NOP) is additionally stored in UF [0] (step S708). Further, "1" is set to the most significant bit of BUF [2] of the buffer storing the 16-bit instruction code (step S709). This B
The most significant bit of UF [2] corresponds to the parallel execution bit, as in the processing for big endian.
By setting the most significant bit to “1”, B
The 16-bit instruction stored in UF [3] and BUF [2] and the NOP instruction stored in BUF [1] and BUF [0] are executed in parallel by the processor.

【0057】そして、ファイル出力部7によって、一時
保管バッファ5に格納された命令コードを、BUF
[0]、BUF[1]、BUF[2]、BUF[3]の
順番で、リトルエンディアンに対応させてオブジェクト
ファイルの下位アドレス(即ち、LSB)から出力する
(ステップS710)。
Then, the instruction code stored in the temporary storage buffer 5 is converted by the file output unit 7 into a BUFF.
[0], BUF [1], BUF [2], and BUF [3] are output from the lower address (that is, LSB) of the object file in correspondence with little endian (step S710).

【0058】このように、実施の形態2のアセンブラで
は、全ての16ビット長命令を32ビットの境界に配置
するようにしているので、リトルエンディアン動作時に
おいて16ビット長命令がアドレスに逆行した実行動作
となることを無視することができ、また逆アセンブルで
メモリイメージとニーモニックの対応表示を行った場合
にはコーディングした手順がそのまま出力されるため検
証には都合がよくソフトウェア開発の効率化を行うこと
ができる。また、並列実行ビットに対応するビットを
「1」に設定しているので、16ビット長命令と16ビ
ット長のNOP命令とを並列実行させることができ、N
OP命令を追加したことによるプロセッサの実行時間の
増加を少なくすることができる。
As described above, in the assembler according to the second embodiment, all the 16-bit instructions are arranged on the 32-bit boundary. The operation can be ignored, and when displaying the correspondence between the memory image and the mnemonic by disassembling, the coded procedure is output as it is, which is convenient for verification and improves software development efficiency. be able to. Also, since the bit corresponding to the parallel execution bit is set to “1”, the 16-bit instruction and the 16-bit NOP instruction can be executed in parallel.
An increase in the execution time of the processor due to the addition of the OP instruction can be reduced.

【0059】実施の形態3.実施の形態1および実施の
形態2のバイエンディアン対応アセンブラは、ビッグエ
ンディアンとリトルエンディアンの動作モードにおいて
同一のソースファイルを用いることができる利点がある
が、リトルエンディアンで動作したときのプロセッサで
は命令実行におけるアドレスの逆行現象は避けられな
い。そこで、実施の形態3のバイエンディアン対応アセ
ンブラでは、16ビット長命令の全ての組み合わせにつ
いて複合命令のニーモニックを定義し、この複合命令で
記述されたソースファイルを命令コードに変換すること
によりアドレスの逆行を完全に防止するものである。
Embodiment 3 The bi-endian-compatible assemblers of the first and second embodiments have the advantage that the same source file can be used in the big-endian and little-endian operation modes. The inversion phenomenon of the address in unavoidable. Therefore, in the bi-endian assembler of the third embodiment, the mnemonics of compound instructions are defined for all combinations of 16-bit instructions, and the source file described by the compound instructions is converted into instruction codes to reverse the addresses. Is completely prevented.

【0060】図9は、実施の形態3のアセンブラの構成
を示すブロック図である。実施の形態3のアセンブラ1
は、図9に示すように、ファイル入力部2と、構文解析
部3と、コード変換部904と、コード変換テーブル9
10と、ファイル出力部7とを備えている。ここで、フ
ァイル入力部2と、構文解析部3と、ファイル出力部7
は、従来のアセンブラと同様の構成であるため説明を省
略する。
FIG. 9 is a block diagram showing the structure of the assembler according to the third embodiment. Assembler 1 of Embodiment 3
As shown in FIG. 9, the file input unit 2, the syntax analysis unit 3, the code conversion unit 904, and the code conversion table 9
10 and a file output unit 7. Here, the file input unit 2, the syntax analysis unit 3, and the file output unit 7
Has the same configuration as that of the conventional assembler, and thus the description is omitted.

【0061】図10は、実施の形態3のアセンブラで使
用される複合命令の定義例を示すブロック図である。
「複合命令」とは、2つの16ビット長の命令を組み合
わせた命令である。図10において、左列および中央列
のブロックは既存の16ビット長命令のニーモニック表
記8であり、右列のブロックは既存の16ビット長命令
を2つ組み合わせて2命令分の処理内容を表すニーモニ
ック表記9である。図10に示すように、複合命令のニ
ーモニック表記9は、2つの16ビット長命令のすべて
の組み合わせについて定義されている。
FIG. 10 is a block diagram showing a definition example of a compound instruction used in the assembler according to the third embodiment.
A “composite instruction” is an instruction that combines two 16-bit instructions. In FIG. 10, the blocks in the left column and the center column are mnemonics 8 of the existing 16-bit instructions, and the blocks in the right column are mnemonics representing the processing content of two instructions by combining two existing 16-bit instructions. Notation 9 As shown in FIG. 10, the mnemonic notation 9 of the compound instruction is defined for all combinations of two 16-bit length instructions.

【0062】実施の形態3のアセンブラは、このような
複合命令で記述されたソースファイルから命令コード
(機械語)を生成するものであり、このためコード変換
部904は、ソースファイルから読み込んだ複合命令
を、コード変換テーブル910を参照して、対応する複
合命令の命令コード(機械語)に変換するようになって
いる。コード変換テーブル910は、図10の定義例に
示した複合命令のニーモニック表記9と複合命令の命令
コードとを、前述した図14に示す形式でように対応づ
けたものである。
The assembler according to the third embodiment generates an instruction code (machine language) from a source file described with such a composite instruction. Therefore, the code conversion unit 904 reads the composite code read from the source file. The instruction is converted to an instruction code (machine language) of a corresponding composite instruction with reference to the code conversion table 910. The code conversion table 910 associates the mnemonic notation 9 of the compound instruction shown in the definition example of FIG. 10 with the instruction code of the compound instruction in the format shown in FIG. 14 described above.

【0063】図11は、実施の形態3のアセンブラによ
るアセンブラ処理手順を示すフローチャートである。図
11に示すように実施の形態3のアセンブラでは、まず
バッファを初期化する(ステップS1101)。そし
て、ファイル入力部2によって、複合命令で記述された
ソースファイルから複合命令を一行読み込み(ステップ
S1102)、読み込んだ複合命令を構文解析部3によ
って解析する(ステップS1103)。つぎに、コード
変換部904によって、コード変換テーブル910を参
照して複合命令のニーモニックを32ビット長の命令コ
ード(機械語)に変換し(ステップS1104)、変換
された機械語をバッファへ保存する(ステップS110
5)。バッファに保存された機械語は、ファイル出力部
7によって、エンディアンに従ってオブジェクトファイ
ルにを生成する(ステップS1106)。このようなス
テップS1102からステップS1106までの処理
を、ソースファイルに記述されているすべての行の複合
命令について繰り返し行う。
FIG. 11 is a flowchart showing an assembler processing procedure by the assembler according to the third embodiment. As shown in FIG. 11, in the assembler according to the third embodiment, first, a buffer is initialized (step S1101). Then, one line of the compound instruction is read from the source file described by the compound instruction by the file input unit 2 (step S1102), and the read compound instruction is analyzed by the syntax analysis unit 3 (step S1103). Next, the code conversion unit 904 converts the mnemonic of the compound instruction into a 32-bit instruction code (machine language) with reference to the code conversion table 910 (step S1104), and stores the converted machine language in a buffer. (Step S110
5). The machine language stored in the buffer is generated into an object file by the file output unit 7 in accordance with the endian (Step S1106). The processing from step S1102 to step S1106 is repeatedly performed for the composite instructions of all the lines described in the source file.

【0064】このように実施の形態3のアセンブラで
は、図10に示すような複合命令を定義して、この複合
命令のニーモニック表記と命令コードとを対応づけるコ
ード変換テーブル910を使用してコード変換部904
により命令コードを生成しているので、生成される命令
コードは全て32ビット長となる。このため、プロセッ
サのリトルエンディアン動作における命令の逆転実行を
確実になくすことができ、また生成される命令コードの
コード量の最適化を図ることが可能となる。
As described above, in the assembler according to the third embodiment, a compound instruction as shown in FIG. 10 is defined, and code conversion is performed using the code conversion table 910 for associating the mnemonic notation of the compound instruction with the instruction code. Part 904
, The generated instruction codes are all 32 bits long. For this reason, the reverse execution of the instruction in the little endian operation of the processor can be reliably eliminated, and the code amount of the generated instruction code can be optimized.

【0065】[0065]

【発明の効果】以上説明したように、この発明によれ
ば、プロセッサがビッグエンディアンとリトルエンディ
アンのどちらのエンディアンで動作する場合でも、アセ
ンブリ言語記述の同一ソースファイルを用いて同一の処
理を実行するオブジェクトファイルを生成することがで
き、ソフトウェアの生産性を改善することができるとい
う効果を奏する。
As described above, according to the present invention, the same processing is executed using the same source file of the assembly language description regardless of whether the processor operates in either big endian or little endian. It is possible to generate an object file, and it is possible to improve the productivity of software.

【0066】つぎの発明によれば、全ての16ビット長
命令を32ビットの境界に配置して、リトルエンディア
ン動作時において16ビット長命令がアドレスに逆行し
た実行動作となることを無視することができるという効
果を奏する。また、逆アセンブルでメモリイメージとニ
ーモニックの対応表示を行った場合にはコーディングし
た手順がそのまま出力されるため、検証には都合がよく
ソフトウェア開発の効率化を図れるという効果を奏す
る。
According to the next invention, all the 16-bit instructions are arranged on the 32-bit boundary, and it is possible to ignore the fact that the 16-bit instructions have an execution operation backward to the address during little endian operation. It has the effect of being able to. Further, when the correspondence between the memory image and the mnemonic is displayed in the disassembly, the coded procedure is output as it is, so that there is an effect that the verification is convenient and the efficiency of software development can be improved.

【0067】つぎの発明によれば、プロセッサのリトル
エンディアン動作時における命令の逆転実行を確実にな
くすことができ、また、コード量の最適化を図れるとい
う効果を奏する。
According to the next invention, the reverse execution of the instruction during the little endian operation of the processor can be reliably eliminated, and the effects of optimizing the code amount can be achieved.

【0068】つぎの発明によれば、プロセッサがビッグ
エンディアンとリトルエンディアンのどちらのエンディ
アンで動作する場合でも、アセンブリ言語記述の同一ソ
ースファイルを用いて同一の処理を実行するオブジェク
トファイルを生成することができ、ソフトウェアの生産
性を改善することができるという効果を奏する。
According to the next invention, even when the processor operates in either big endian or little endian, it is possible to generate an object file that executes the same processing by using the same source file of the assembly language description. It is possible to improve the productivity of software.

【0069】つぎの発明によれば、全ての16ビット長
命令を32ビットの境界に配置して、リトルエンディア
ン動作時において16ビット長命令がアドレスに逆行し
た実行動作となることを無視することができるという効
果を奏する。また、逆アセンブルでメモリイメージとニ
ーモニックの対応表示を行った場合にはコーディングし
た手順がそのまま出力されるため、検証には都合がよく
ソフトウェア開発の効率化を図れるという効果を奏す
る。
According to the next invention, all the 16-bit instructions are arranged on the 32-bit boundary, and it is possible to ignore the fact that the 16-bit instructions have an execution operation backward to the address during little endian operation. It has the effect of being able to. Further, when the correspondence between the memory image and the mnemonic is displayed in the disassembly, the coded procedure is output as it is, so that there is an effect that the verification is convenient and the efficiency of software development can be improved.

【0070】つぎの発明によれば、プロセッサのリトル
エンディアン動作時における命令の逆転実行を確実にな
くすことができ、また、コード量の最適化を図れるとい
う効果を奏する。
According to the next invention, there is an effect that the reverse execution of the instruction during the little endian operation of the processor can be reliably eliminated, and the amount of code can be optimized.

【0071】つぎの発明によれば、上記の発明のいずれ
か一つの動作をコンピュータによって実行することがで
きるという効果を奏する。
According to the next invention, there is an effect that any one of the above-mentioned inventions can be executed by a computer.

【図面の簡単な説明】[Brief description of the drawings]

【図1】 この発明の実施の形態1および実施の形態2
のアセンブラの構成を示すブロック図である。
FIG. 1 is a view illustrating a first embodiment and a second embodiment of the present invention;
FIG. 2 is a block diagram illustrating a configuration of an assembler.

【図2】 図1に示した実施の形態1のアセンブラによ
るビッグエンディアン用命令コード生成処理手順を示す
フローチャートである。
FIG. 2 is a flowchart illustrating a procedure of a big-endian instruction code generation process performed by the assembler according to the first embodiment illustrated in FIG. 1;

【図3】 図1に示した実施の形態1のアセンブラによ
るリトルエンディアン用命令コード生成処理手順を示す
フローチャートである。
FIG. 3 is a flowchart showing a little-endian instruction code generation processing procedure by the assembler of the first embodiment shown in FIG. 1;

【図4】 図4(a)は、図1に示した実施の形態1の
アセンブラにおいて、ビッグエンディアン用命令コード
生成時の32ビット長の命令コードA,16ビット長の
命令コードB,および16ビット長の命令コードCの一
時保管バッファへの格納状態、およびオブジェクトファ
イルへの出力状態を示す説明図である。図4(b)は、
図1に示した実施の形態1のアセンブラにおいて、ビッ
グエンディアン用命令コード生成時の16ビット長の命
令コードB,32ビット長の命令コードAの一時保管バ
ッファへの格納状態、およびオブジェクトファイルへの
出力状態を示す説明図である。
FIG. 4 (a) shows a 32-bit instruction code A, a 16-bit instruction code B, and a 16-bit instruction code A when the big-endian instruction code is generated in the assembler of the first embodiment shown in FIG. FIG. 7 is an explanatory diagram showing a state of storing a bit-length instruction code C in a temporary storage buffer and a state of output to an object file. FIG. 4 (b)
In the assembler according to the first embodiment shown in FIG. 1, when the big endian instruction code is generated, the 16-bit instruction code B and the 32-bit instruction code A are stored in the temporary storage buffer, and are stored in the object file. FIG. 4 is an explanatory diagram showing an output state.

【図5】 図5(a)は、図1に示した実施の形態1の
アセンブラにおいて、リトルエンディアン用命令コード
生成時の32ビット長の命令コードA,16ビット長の
命令コードB,および16ビット長の命令コードCの一
時保管バッファへの格納状態、およびオブジェクトファ
イルへの出力状態を示す説明図である。図5(b)は、
図1に示した実施の形態1のアセンブラにおいて、リト
ルエンディアン用命令コード生成時の16ビット長の命
令コードB,32ビット長の命令コードAの一時保管バ
ッファへの格納状態、およびオブジェクトファイルへの
出力状態を示す説明図である。
FIG. 5 (a) shows a 32-bit instruction code A, a 16-bit instruction code B, and a 16-bit instruction code A in generating the little endian instruction code in the assembler of the first embodiment shown in FIG. FIG. 7 is an explanatory diagram showing a state of storing a bit-length instruction code C in a temporary storage buffer and a state of output to an object file. FIG. 5 (b)
In the assembler according to the first embodiment shown in FIG. 1, when the little endian instruction code is generated, the 16-bit instruction code B and the 32-bit instruction code A are stored in the temporary storage buffer, and the FIG. 4 is an explanatory diagram showing an output state.

【図6】 この発明の実施の形態2のアセンブラの構成
を示すブロック図である。
FIG. 6 is a block diagram showing a configuration of an assembler according to a second embodiment of the present invention.

【図7】 図6に示したアセンブラによるビッグエンデ
ィアン用命令コード生成処理手順を示すフローチャート
である。
7 is a flowchart illustrating a procedure of a big-endian instruction code generation process performed by the assembler illustrated in FIG. 6;

【図8】 図6に示した実施の形態2のアセンブラによ
るリトルエンディアン用命令コード生成処理手順を示す
フローチャートである。
FIG. 8 is a flowchart showing a little-endian instruction code generation processing procedure by the assembler of the second embodiment shown in FIG. 6;

【図9】 この発明の実施の形態3のアセンブラの構成
を示すブロック図である。
FIG. 9 is a block diagram showing a configuration of an assembler according to a third embodiment of the present invention.

【図10】 図9に示した実施の形態3のアセンブラに
おいて使用される複合命令の定義例を示すブロック図で
ある。
FIG. 10 is a block diagram showing a definition example of a compound instruction used in the assembler of the third embodiment shown in FIG. 9;

【図11】 図9に示した実施の形態3のアセンブラに
よるアセンブラ処理手順のフローチャートである。
FIG. 11 is a flowchart of an assembler processing procedure by the assembler according to the third embodiment shown in FIG. 9;

【図12】 図1、図6および図9に示したアセンブラ
を適用するプロセッサの命令の種類を示す図である。
FIG. 12 is a diagram showing types of instructions of a processor to which the assembler shown in FIGS. 1, 6, and 9 is applied;

【図13】 図1、図6および図9に示したアセンブラ
を適用するプロセッサの命令実行手順を示すフローチャ
ートである。
FIG. 13 is a flowchart showing an instruction execution procedure of a processor to which the assembler shown in FIGS. 1, 6, and 9 is applied;

【図14】 図1および図6に示したアセンブラのコー
ド変換部で参照するコード変換テーブルの説明図であ
る。
FIG. 14 is an explanatory diagram of a code conversion table referred to by a code conversion unit of the assembler shown in FIGS. 1 and 6;

【図15】 機械語に変換した16進数コードのメモリ
配置を示す図である。
FIG. 15 is a diagram showing a memory arrangement of a hexadecimal code converted into a machine language.

【図16】 ビッグエンディアンにおける機械語のメモ
リ配置を示す説明図である。
FIG. 16 is an explanatory diagram showing a memory arrangement of a machine language in big endian.

【図17】 リトルエンディアンにおける機械語のメモ
リ配置を示す説明図である。
FIG. 17 is an explanatory diagram showing a memory arrangement of a machine language in little endian.

【図18】 従来のアセンブラの構成を示すブロック図
である。
FIG. 18 is a block diagram illustrating a configuration of a conventional assembler.

【図19】 従来のアセンブラにおけるアセンブラ処理
手順のフローチャートである。
FIG. 19 is a flowchart of an assembler processing procedure in a conventional assembler.

【符号の説明】[Explanation of symbols]

1 アセンブラ、2 ファイル入力部、3 構文解析
部、4 コード変換部、5 一時保管バッファ、6 配
置変換部、7 ファイル出力部、8 ニーモニック表
記、9 複合命令のニーモニック表記、10 コード変
換テーブル、11アセンブラ、12 ファイル入力部、
13 構文解析部、14 コード変換部、17 ファイ
ル出力部、18 ニーモニック、19 機械語、20
ニーモニック、21 機械語(命令コード)、22 ア
ドレス、23 命令コードの配置(ビッグエンディア
ン)、24 命令コードの配置(リトルエンディア
ン)、66配置変換部、904 コード変換部、910
コード変換テーブル。
1 assembler, 2 file input section, 3 syntax analysis section, 4 code conversion section, 5 temporary storage buffer, 6 layout conversion section, 7 file output section, 8 mnemonic notation, 9 mnemonic notation of compound instruction, 10 code conversion table, 11 Assembler, 12 file input section,
13 syntax analyzer, 14 code converter, 17 file output unit, 18 mnemonic, 19 machine language, 20
Mnemonics, 21 machine language (instruction code), 22 addresses, 23 instruction code arrangement (big endian), 24 instruction code arrangement (little endian), 66 arrangement conversion unit, 904 code conversion unit, 910
Code conversion table.

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】 16ビット長命令と32ビット長命令か
らなる命令セットを有するとともに異なるエンディアン
で動作する時に2個の16ビット長命令コードの実行順
序が入れ替わるプロセッサに対応した命令コードを生成
するアセンブラ処理装置において、 ソースファイルからコード変換された16ビット長命令
コードを一時的に格納する記憶手段と、 前記記憶手段に32ビット境界で配置された2個の16
ビット長命令コードを、動作対象のエンディアンに応じ
て入れ替える配置変換手段と、 入れ替えられた2個の16ビット長命令コードを、オブ
ジェクトファイルへ出力するファイル出力手段と、を備
えたことを特徴とするアセンブラ処理装置。
An assembler that has an instruction set consisting of a 16-bit instruction and a 32-bit instruction and generates an instruction code corresponding to a processor in which the execution order of two 16-bit instruction codes is switched when operating in different endians. A storage device for temporarily storing a 16-bit instruction code code-converted from a source file; two 16-bit instruction codes arranged on a 32-bit boundary in the storage device;
An arrangement conversion means for exchanging bit-length instruction codes in accordance with an endian to be operated, and a file output means for outputting the two exchanged 16-bit instruction codes to an object file. Assembler processing unit.
【請求項2】 前記配置変換手段は、16ビット長命令
コードが前記記憶手段に格納されたときに、更に16ビ
ット長のNOP命令コードを前記記憶手段に追加するも
のであることを特徴とする請求項1に記載のアセンブラ
処理装置。
2. The arrangement conversion means according to claim 1, wherein when a 16-bit instruction code is stored in said storage means, a 16-bit NOP instruction code is further added to said storage means. The assembler processing device according to claim 1.
【請求項3】 16ビット長命令と32ビット長命令か
らなる命令セットを有するとともに異なるエンディアン
で動作する時に2個の16ビット長命令コードの実行順
序が入れ替わるプロセッサに対応した命令コードを生成
するアセンブラ処理装置において、 2個の16ビット長命令を組み合わせて1個の32ビッ
ト長命令として定義した複合命令のニーモニックと、前
記複合命令の命令コードとを対応づけたコード変換テー
ブルと、 ソースファイルから読み出した前記複合命令を、前記コ
ード変換テーブルを参照して前記複合命令に対応する命
令コードに変換するコード変換手段と、 を備えたことを特徴とするアセンブラ処理装置。
3. An assembler having an instruction set consisting of a 16-bit instruction and a 32-bit instruction and generating an instruction code corresponding to a processor in which the execution order of two 16-bit instruction codes is switched when operating in different endians. A code conversion table in which a mnemonic of a compound instruction defined by combining two 16-bit instructions as one 32-bit length instruction and an instruction code of the compound instruction are read from a source file. Code conversion means for converting the compound instruction into an instruction code corresponding to the compound instruction with reference to the code conversion table.
【請求項4】 16ビット長命令と32ビット長命令か
らなる命令セットを有するとともに異なるエンディアン
で動作する時に2個の16ビット長命令コードの実行順
序が入れ替わるプロセッサに対応した命令コードを生成
するアセンブラ処理方法において、 ソースファイルからコード変換された16ビット長命令
コードを、記憶手段に一時的に格納する記憶ステップ
と、 前記記憶手段に32ビット境界で配置された2個の16
ビット長命令コードを、動作対象のエンディアンに応じ
て入れ替える配置変換ステップと、 入れ替えられた2個の16ビット長命令コードを、オブ
ジェクトファイルへ出力するファイル出力ステップと、 を含むことを特徴とするアセンブラ処理方法。
4. An assembler having an instruction set including a 16-bit instruction and a 32-bit instruction and generating an instruction code corresponding to a processor in which the execution order of two 16-bit instruction codes is switched when operating in different endians. In the processing method, a storage step of temporarily storing a 16-bit instruction code code-converted from a source file in a storage means;
An assembler characterized by comprising: an arrangement conversion step of exchanging bit-length instruction codes according to an endian of an operation target; and a file output step of outputting the exchanged two 16-bit instruction codes to an object file. Processing method.
【請求項5】 前記配置変換ステップは、16ビット長
命令コードが前記記憶手段に格納されたときに、更に1
6ビット長のNOP命令コードを前記記憶手段に追加す
るものであることを特徴とする請求項4に記載のアセン
ブラ処理方法。
5. The arrangement conversion step further comprises the step of: when a 16-bit instruction code is stored in the storage means,
5. The assembler processing method according to claim 4, wherein a 6-bit NOP instruction code is added to said storage means.
【請求項6】 16ビット長命令と32ビット長命令か
らなる命令セットを有するとともに異なるエンディアン
で動作する時に2個の16ビット長命令コードの実行順
序が入れ替わるプロセッサに対応した命令コードを生成
するアセンブラ処理方法において、 2個の16ビット長命令を組み合わせて1個の32ビッ
ト長命令として定義した複合命令のニーモニックと前記
複合命令の命令コードとを対応づけたコード変換テーブ
ルを参照して、ソースファイルから読み出した前記複合
命令を前記複合命令に対応する命令コードに変換するコ
ード変換ステップを含むことを特徴とするアセンブラ処
理方法。
6. An assembler that has an instruction set including a 16-bit instruction and a 32-bit instruction and generates an instruction code corresponding to a processor in which the execution order of two 16-bit instruction codes is switched when operating in different endian. In the processing method, a source file is referred to by referring to a code conversion table that associates a mnemonic of a compound instruction defined as one 32-bit instruction with a combination of two 16-bit instructions and an instruction code of the compound instruction. A code conversion step of converting the compound instruction read out of the program into an instruction code corresponding to the compound instruction.
【請求項7】 請求項4〜6のいずれか一つに記載され
たアセンブラ処理方法をコンピュータに実行させるプロ
グラム。
7. A program for causing a computer to execute the assembler processing method according to claim 4.
JP2001156968A 2001-05-25 2001-05-25 Device and method for processing assembler, and program for making computer execute the same method Pending JP2002351672A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001156968A JP2002351672A (en) 2001-05-25 2001-05-25 Device and method for processing assembler, and program for making computer execute the same method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001156968A JP2002351672A (en) 2001-05-25 2001-05-25 Device and method for processing assembler, and program for making computer execute the same method

Publications (1)

Publication Number Publication Date
JP2002351672A true JP2002351672A (en) 2002-12-06

Family

ID=19000902

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001156968A Pending JP2002351672A (en) 2001-05-25 2001-05-25 Device and method for processing assembler, and program for making computer execute the same method

Country Status (1)

Country Link
JP (1) JP2002351672A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7587557B2 (en) 2003-03-19 2009-09-08 Panasonic Corporation Data sharing apparatus and processor for sharing data between processors of different endianness

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7587557B2 (en) 2003-03-19 2009-09-08 Panasonic Corporation Data sharing apparatus and processor for sharing data between processors of different endianness

Similar Documents

Publication Publication Date Title
US7917733B2 (en) Instruction code compression using instruction codes with reuse flags
US6360312B1 (en) Processor for making more efficient use of idling components and program conversion apparatus for the same
JP2004227579A (en) Method and system for converting xml code into binary code
JP3203401B2 (en) Data processing device
JP5869125B2 (en) Method and apparatus for storage of entropy-encoded instruction sequences and conversion to executable form
US20040098709A1 (en) Method, apparatus, and computer program for generating SIMD instruction sequence
US5964861A (en) Method for writing a program to control processors using any instructions selected from original instructions and defining the instructions used as a new instruction set
US6189086B1 (en) Data processing apparatus
JP3983482B2 (en) PC relative branching with high-speed displacement
JPH09231071A (en) Computer system
US20070139424A1 (en) DSP System With Multi-Tier Accelerator Architecture and Method for Operating The Same
JP2002351672A (en) Device and method for processing assembler, and program for making computer execute the same method
JP5168143B2 (en) Processor and instruction control method
JPH11338732A (en) Programmable controller supporting device and recording medium
US7484077B2 (en) Skipping unnecessary instruction by multiplex selector using next instruction offset stride signal generated from instructions comparison results
US20050015574A1 (en) Processor and method capable of executing instruction sets with different lengths
JPS63113634A (en) Relative address calculation system for program counter
JPH09330219A (en) Instruction decoder switching processor and translator
US20060015704A1 (en) Operation apparatus and instruction code executing method
JP2000112754A (en) Data processor
JPH11224199A (en) Translation device, information processor and recording medium
JPH11163736A (en) Processor
JP2764833B2 (en) Compact debug information method
JP3515018B2 (en) Pipeline data processor
KR19990076324A (en) Microprocessor using built-in short instructions