JPH0594311A - Machine language translation program - Google Patents

Machine language translation program

Info

Publication number
JPH0594311A
JPH0594311A JP25612091A JP25612091A JPH0594311A JP H0594311 A JPH0594311 A JP H0594311A JP 25612091 A JP25612091 A JP 25612091A JP 25612091 A JP25612091 A JP 25612091A JP H0594311 A JPH0594311 A JP H0594311A
Authority
JP
Japan
Prior art keywords
instruction
function
call instruction
call
callx
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
JP25612091A
Other languages
Japanese (ja)
Inventor
Hideji Nimata
秀治 二俣
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.)
NEC IC Microcomputer Systems Co Ltd
Original Assignee
NEC IC Microcomputer Systems Co Ltd
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 NEC IC Microcomputer Systems Co Ltd filed Critical NEC IC Microcomputer Systems Co Ltd
Priority to JP25612091A priority Critical patent/JPH0594311A/en
Publication of JPH0594311A publication Critical patent/JPH0594311A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To minimize an object size in a machine language translation program having the function calling instruction of a different instruction length. CONSTITUTION:In the source analyzing processing (step 100) at a path 1, a source program is converted to an intermediate code, in a CALLX instruction (function calling instruction) use frequency table preparing processing (step 200), the function name and the use frequency called by a CALLX instruction are registered into a CALLX instruction use frequency table 210. Next, the function calling instruction optimizing processing (step 220) by the CALLX instruction is performed, the optimizing processing (step 102) of a branching instruction, etc., is performed, and the object preparing processing (step 103) at a path 2 is performed through a step 104 up to the completion of a file.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は機械語翻訳プログラムに
関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a machine language translation program.

【0002】[0002]

【従来の技術】従来、関数を直接呼出す命令と、有限な
特定領域に予め記憶されている有限な個数の関数の先頭
アドレスを参照して、間接的に関数を呼出す命令を有す
るプロセッサ用の機械語翻訳プログラムにおいて、ソー
ス・プログラムを記述する際に、命令コードが最小にな
るように命令を選択するのは、ソース・プログラム記述
者自身の判断において行われているのが一般である。
2. Description of the Related Art Conventionally, a machine for a processor having an instruction for directly calling a function and an instruction for indirectly calling a function by referring to a head address of a finite number of functions stored in advance in a finite specific area. In a word translation program, when writing a source program, it is generally made by the source program writer himself to select the instruction so that the instruction code is minimized.

【0003】以下、従来の2パス方式による機械語翻訳
プログラムの処理については図4を参照して説明し、ま
た関数呼出し命令を使用したソース・プログラムの一記
述例については図5を参照して説明する。
Hereinafter, the processing of a conventional machine language translation program according to the two-pass method will be described with reference to FIG. 4, and an example of description of a source program using a function call instruction will be described with reference to FIG. explain.

【0004】図4において、従来の2バス方式による機
械語翻訳プログラムにおいては、パス1においてソース
解析処理が行われ(ステップ100)、次いで、当該ソ
ース解析処理がファイルの終端まで行われたか否かが判
断されて(ステップ101)、ファイルの終端までのソ
ース解析処理が行われていない場合には、再度ステップ
100に戻って、パス1におけるソース解析処理が行わ
れる。またステップ101において、前記ソース解析処
理がフィイルの終端まで行われている場合には、次の処
理ステップに進み、分岐命令等の最適化処理が行われて
(ステップ102)、パス2においてオブジェクト生成
処理が実行される(ステップ103)。次いで、前記オ
ブジェクト生成処理がファイルの終端まで行われたか否
かが判断されて(ステップ104)、当該オブジェクト
生成処理がファイルの終端まで行われていない場合に
は、再度ステップ103に戻り、パス2におけるオブジ
ェクト生成処理が実行される。またステップ104にお
いて、前記オブジェクト生成処理がファイルの終端まで
行われている場合には、この2バス方式による機械語翻
訳プログラムにおける一連の処理は終了となる。
In FIG. 4, in the conventional 2-bus machine language translation program, the source analysis process is performed in pass 1 (step 100), and then the source analysis process is performed up to the end of the file. Is determined (step 101), and if the source analysis process up to the end of the file has not been performed, the process returns to step 100 again and the source analysis process in pass 1 is performed. In step 101, if the source analysis processing is performed up to the end of the file, the process proceeds to the next processing step, optimization processing such as a branch instruction is performed (step 102), and an object is generated in pass 2. The process is executed (step 103). Next, it is judged whether or not the object generation processing has been performed up to the end of the file (step 104). If the object generation processing has not been performed up to the end of the file, the procedure returns to step 103 again, and the path 2 The object generation process in is executed. In step 104, when the object generation process is performed up to the end of the file, the series of processes in the machine language translation program by the 2-bus method ends.

【0005】この場合、直接関数を呼出す命令をCAL
L命令(命令長は3バイト)とし、特定領域に記憶され
ている関数の先頭アドレス(アドレスを表現するコード
長は2バイト)を参照して、間接的に関数を呼出す命令
をCALLT命令(命令コード長は1バイト)とする
と、同関数の使用頻度が多い程、CALL命令よりCA
LLT命令を使用する方がオブジェクト生成処理(スッ
プ103)において生成する命令長が短くなる。
In this case, the instruction for directly calling the function is CAL.
The L instruction (instruction length is 3 bytes) is referred to, and the instruction that indirectly calls the function is referred to by referring to the start address of the function (the code length expressing the address is 2 bytes) stored in the specific area. If the code length is 1 byte), the more frequently this function is used, the more CA
When the LLT instruction is used, the instruction length generated in the object generation processing (sup 103) becomes shorter.

【0006】図5に示される関数呼出し命令を使用した
ソース・プログラムの一記述例においては、関数SUB
1およびSUB4の使用回数は1度であるため、CAL
L命令を使用した関数呼出し400を行い、関数SUB
2および関数SUB3の使用回数は2度であるため、C
ALLT命令を使用した関数呼出し401を行って、関
数SUB2および関数SUB3の先頭アドレスを、特定
領域に記述する(402)ことにより、命令コード長の
最小化が図られている。
In one example of the description of the source program using the function call instruction shown in FIG. 5, the function SUB
1 and SUB4 are used once, so CAL
The function call 400 using the L instruction is executed, and the function SUB
2 and the function SUB3 are used twice, so C
The function call 401 using the ALLT instruction is performed, and the start addresses of the functions SUB2 and SUB3 are described in the specific area (402) to minimize the instruction code length.

【0007】[0007]

【発明が解決しようとする課題】上述した従来の機械語
翻訳プログラムにおいては、異なる命令長の関数呼出し
命令に対応する最適化処理方法がなく、ソース・プログ
ラムに記述されている関数呼出し命令を、単純に対応す
る機械語に翻訳するのみであったため、命令コード長が
最小になるようにソース・プログラムを記述する場合に
は、ソース・プログラム記述者自身で、同関数の使用頻
度の多い順に、間接的に関数を呼出す命令を使用する必
要がある。また、更に、ソース・プログラムの変更に際
しても、同関数の使用頻度が変化した場合には、その変
化に対応して、再度同関数の使用頻度の多い順に、間節
的に関数を呼出す命令を使用するようにソース・プログ
ラムを修正する必要があるという欠点がある。
In the above-mentioned conventional machine language translation program, there is no optimization processing method corresponding to the function call instruction of different instruction length, and the function call instruction described in the source program is Since it was simply translated into the corresponding machine language, when writing the source program so that the instruction code length was minimized, the source program writer himself, in the order of frequent use of the function, It is necessary to use an instruction that indirectly calls a function. In addition, even when the source program is changed, if the frequency of use of the function changes, in response to the change, instructions for calling the function in the order of high frequency of use of the function are interleaved again. The disadvantage is that the source program needs to be modified to use it.

【0008】[0008]

【課題を解決するための手段】本発明の機械語翻訳プロ
グラムは、関数を呼出す第1の呼出し命令と、有限な特
定領域に予め記憶されている有限個数の関数の先頭アド
レスとを参照して、間接的に前記関数を呼出すことによ
り、前記第1の呼出し命令の命令長より短かい命令長の
第2の呼出し命令を有するプロセッサ用の機械語翻訳プ
ログラムにおいて、前記関数を呼出す仮想的な第3の呼
出し命令を定義し、機械語翻訳処理中に、当該第3の呼
出し命令が使用される度ごとに呼出される関数名ならび
に当該関数の使用回数を登録するテーブルと、前記テー
ブルに前記関数名ならびに当該関数の使用回数を登録す
る第1の処理手順と、使用頻度の多い関数の順位に対応
して、前記プロセッサにおいて適用可能な範囲内の前記
第2の呼出し命令の個数値に至るまで、前記第3の呼出
し命令を前記第2の呼出し命令に変換するとともに、変
換することのできない残りの第3の呼出し命令を、前記
第1の呼出し命令に変換する第2の処理手順と、を少な
くとも有することを特徴としている。
A machine language translation program of the present invention refers to a first calling instruction for calling a function and a leading address of a finite number of functions stored in advance in a finite specific area. In a machine language translation program for a processor having a second call instruction having an instruction length shorter than the instruction length of the first call instruction by indirectly calling the function, a virtual first call function is provided. 3 is defined, and a table for registering the name of a function to be called each time the third calling instruction is used and the number of times the function is used during the machine language translation process; and the function in the table. A first processing procedure for registering a name and the number of times the function is used, and the second call instruction within a range applicable to the processor corresponding to the rank of the function that is frequently used. A second call instruction for converting the third call instruction to the second call instruction and the remaining third call instruction that cannot be converted to the first call instruction until reaching the numerical value. And at least a processing procedure.

【0009】[0009]

【実施例】次に、本発明について図面を参照して説明す
る。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be described with reference to the drawings.

【0010】図1は本発明の一実施例の要部を示す構成
図であり、図2は、本実施例における関数呼出し命令の
最適化処理部の動作を示す流れ図である。また、図3
(a)および(b)に示されるのは、それぞれ、本発明
におけるソース・プログラムの記述例、および関数呼出
し命令の最適化処理後の中間コードに対応するソース・
プログラム例である。
FIG. 1 is a block diagram showing the essential parts of an embodiment of the present invention, and FIG. 2 is a flow chart showing the operation of an optimization processing unit for function call instructions in this embodiment. Also, FIG.
(A) and (b) respectively show a description example of the source program in the present invention and a source code corresponding to the intermediate code after the optimization processing of the function call instruction.
This is an example program.

【0011】今、直接関数を呼出す命令をCALL命令
(命令コード長は3バイト)とし、有限な特定領域に予
め記憶されている有限な個数の関数の先頭アドレス(ア
ドレスを表わすコード長は2バイト)を参照して、間接
的に関数を呼出すことにより第1の命令の命令長より短
かい命令長の第2の呼出し命令をCALLT命令(命令
コード長は1バイト)とし、機械語翻訳処理中に命令コ
ード長が最小になるように、前記CALL命令またはC
ALLT命令に変換するために定義された関数呼出し命
令をCALLX命令、前記特定領域をCALLTテーブ
ルと呼ぶこととする。
Now, a CALL instruction (instruction code length is 3 bytes) is used as an instruction for directly calling a function, and a finite number of function start addresses stored in advance in a finite specific area (the code length representing the address is 2 bytes). ), A second call instruction having an instruction length shorter than the instruction length of the first instruction is made a CALLT instruction (instruction code length is 1 byte) by indirectly calling a function, and a machine language translation process is in progress. The CALL instruction or C to minimize the instruction code length.
The function call instruction defined for conversion into an ALLT instruction will be called a CALLX instruction, and the specific area will be called a CALLT table.

【0012】従来技術に対応して、パス1におけるソー
ス解析処理(ステップ100)の後に、新たにCALL
X命令使用回数テーブル作成処理(ステップ200)
と、分岐命令等の最適化処理(ステップ102)の前
に、CALLX命令の最適化処理(ステップ220)
と、CALLX命令により呼出す関数名および同関数を
呼出すCALLX命令の使用回数を登録するCALLX
命令使用回数テーブル210が追加されている。
Corresponding to the conventional technique, a CALL is newly added after the source analysis process (step 100) in pass 1.
X command usage count table creation process (step 200)
And the optimization process of the CALLX instruction (step 220) before the optimization process of the branch instruction (step 102).
And the name of the function called by the CALLX instruction and the number of times the CALLX instruction is used to call the function are registered.
The instruction usage count table 210 is added.

【0013】パス1におけるソース解析処理(ステップ
100)において、ソース・プログラムが中間コードに
変換される。この時、CALLX命令使用回数テーブル
作成処理(ステップ200)において、CALLX命令
により呼出された関数ごとに、関数名と使用回数がCA
LLX命令使用回数テーブル210に登録される。この
動作はファイルの終端に至るまで続行される。
In the source analysis process in pass 1 (step 100), the source program is converted into intermediate code. At this time, in the CALLX instruction use count table creation process (step 200), the function name and the use count are CA for each function called by the CALLX instruction.
It is registered in the LLX instruction usage count table 210. This operation continues until the end of the file.

【0014】次に、関数呼出し命令最適化処理(ステッ
プ220)が行われるが、この処理動作については、図
2を参照して説明する。
Next, the function call instruction optimizing process (step 220) is performed. The process operation will be described with reference to FIG.

【0015】先ず、上記の処理手順を介して作成された
CALLX命令使用回数テーブル210を、使用回数の
降順に並べ替えてソート処理し(ステップ221)、C
ALLX命令使用回数テーブル210の先頭から、保存
された関数名の関数の先頭アドレスを、CALLTテー
ブルに記憶できる限りCALLX命令をCALLT命令
に変換し(ステップ222)、残りのCALLX命令を
CALL命令に変換する(ステップ223)。そして、
変換されたCALLT命令に対応するCALLTテーブ
ルを作成する(ステップ224)。
First, the CALLX instruction usage count table 210 created through the above processing procedure is sorted and sorted in descending order of the usage count (step 221).
From the beginning of the ALLX instruction usage count table 210, the beginning address of the function with the saved function name is converted into a CALLT instruction as long as it can be stored in the CALLT table (step 222), and the remaining CALLX instructions are converted into CALL instructions. (Step 223). And
A CALLT table corresponding to the converted CALLT instruction is created (step 224).

【0016】次いで、図1に戻り、従来の処理方法と同
様に、分岐命令等の最適化処理が行われて(ステップ1
02)、パス2におけるオブジェクト生成処理が実行さ
れ(ステップ103)、ステップ104による判断処理
を介して、このパス2におけるオブジェクト生成処理が
ファイルの終了するまで実行される。
Next, returning to FIG. 1, optimization processing of branch instructions and the like is performed as in the conventional processing method (step 1).
02), the object generation process in pass 2 is executed (step 103), and the object generation process in pass 2 is executed until the end of the file through the determination process in step 104.

【0017】この場合に、図3(a)に示されるソース
・プログラム例において、全ての関数呼出しをCALL
X命令により行った場合には、CALLX命令最適化処
理(ステップ220)が行われた後においては、図3
(b)の中間コードに対応するソース・プログラムの例
に示されるように、関数SUB1の呼出し命令は、CA
LLT命令に変換され(300)、関数SUB2の呼出
し命令は、CALL命令に変換される(ステップ30
1)。また、関数SUB1に対するCALLTテーブル
が作成される(302)。
In this case, in the source program example shown in FIG. 3A, all the function calls are CALL.
When the X instruction is used, after the CALLX instruction optimizing process (step 220) is performed,
As shown in the example of the source program corresponding to the intermediate code in (b), the call instruction of the function SUB1 is CA
It is converted into an LLT instruction (300), and the call instruction of the function SUB2 is converted into a CALL instruction (step 30).
1). Also, a CALLT table for the function SUB1 is created (302).

【0018】[0018]

【発明の効果】以上説明したように、本発明は、異なる
命令コード長の関数呼出し命令により最適化処理を行う
ことにより、ソース・プログラム記述者の介入なしに、
機械語翻訳プログラムの生成するオブジェクト・サイズ
の最適化を図ることができるという効果がある。
As described above, according to the present invention, the optimization processing is performed by the function call instruction having the different instruction code length, so that the intervention of the source program writer can be avoided.
There is an effect that the object size generated by the machine language translation program can be optimized.

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

【図1】本発明の一実施例の処理手順を示す流れ図であ
る。
FIG. 1 is a flowchart showing a processing procedure of an embodiment of the present invention.

【図2】本実施例における部分処理手順を示す流れ図で
ある。
FIG. 2 is a flowchart showing a partial processing procedure in the present embodiment.

【図3】本実施例におけるソース・プログラムの記述例
を示す図である。
FIG. 3 is a diagram showing a description example of a source program in the present embodiment.

【図4】従来例における処理手順を示す流れ図である。FIG. 4 is a flowchart showing a processing procedure in a conventional example.

【図5】従来例におけるソース・プログラムの記述例を
示す図である。
FIG. 5 is a diagram showing a description example of a source program in a conventional example.

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

100 パス1におけるソース解析 101 ファイル終端判定 102 分岐命令等の最適化 103 オブジェクト生成 104 ファイル終端判定 200 CALLX命令使用回数テーブル作成 210 CALLX命令使用回数テーブル 220 CALLX命令最適化 221 CALLX命令使用回数テーブルのソート 222 CALLX命令をCALLT命令に変換 223 残CALLX命令をCALL命令に変換 224 CALLTテーブル作成 300 CALL命令を使用した関数呼出し 301 CALLT命令を使用した関数呼出し 302 特定領域に記憶する関数先頭アドレス 400 CALLT命令に変換された関数呼出し 401 CALL命令に変換された関数呼出し 402 作成されたFALLTテーブル 100 Source analysis in pass 1 101 File end judgment 102 Optimization of branch instructions 103 Object generation 104 File end judgment 200 CALLX instruction usage count table 210 CALLX instruction usage count table 220 CALLX instruction optimization 221 CALLX instruction usage count sort 222 Converts CALLX command to CALLT command 223 Converts remaining CALLX command to CALL command 224 Creates CALLT table 300 Calls function using CALL command 301 Calls function using CALLT command 302 Stores start address of function 400 to CALLT command Converted function call 401 Function call converted to CALL instruction 402 Created FALLT table

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 関数を呼出す第1の呼出し命令と、有限
な特定領域に予め記憶されている有限個数の関数の先頭
アドレスとを参照して、間接的に前記関数を呼出すこと
により、前記第1の呼出し命令の命令長より短かい命令
長の第2の呼出し命令を有するプロセッサ用の機械語翻
訳プログラムにおいて、 前記関数を呼出す仮想的な第3の呼出し命令を定義し、
機械語翻訳処理中に、当該第3の呼出し命令が使用され
る度ごとに呼出される関数名ならびに当該関数の使用回
数を登録するテーブルと、 前記テーブルに前記関数名ならびに当該関数の使用回数
を登録する第1の処理手順と、 使用頻度の多い関数の順位に対応して、前記プロセッサ
において適用可能な範囲内の前記第2の呼出し命令の個
数値に至るまで、前記第3の呼出し命令を前記第2の呼
出し命令に変換するとともに、変換することのできない
残りの第3の呼出し命令を、前記第1の呼出し命令に変
換する第2の処理手順と、 を少なくとも有することを特徴とする機械語翻訳プログ
ラム。
1. A first call instruction for calling a function and a head address of a finite number of functions stored in advance in a finite specific area are referred to, thereby indirectly calling the function, In a machine language translation program for a processor having a second call instruction having an instruction length shorter than that of one call instruction, a virtual third call instruction for calling the function is defined,
During the machine language translation process, a table for registering a function name called each time the third call instruction is used and the number of times the function is used, and the table showing the function name and the number of times the function is used Corresponding to the first processing procedure to be registered and the rank of the function that is frequently used, the third call instruction is executed until the number value of the second call instruction within the applicable range in the processor is reached. A second processing procedure for converting the second call instruction into the second call instruction and converting the remaining third call instruction that cannot be converted into the first call instruction. Language translation program.
JP25612091A 1991-10-03 1991-10-03 Machine language translation program Pending JPH0594311A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP25612091A JPH0594311A (en) 1991-10-03 1991-10-03 Machine language translation program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP25612091A JPH0594311A (en) 1991-10-03 1991-10-03 Machine language translation program

Publications (1)

Publication Number Publication Date
JPH0594311A true JPH0594311A (en) 1993-04-16

Family

ID=17288179

Family Applications (1)

Application Number Title Priority Date Filing Date
JP25612091A Pending JPH0594311A (en) 1991-10-03 1991-10-03 Machine language translation program

Country Status (1)

Country Link
JP (1) JPH0594311A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6002404A (en) * 1996-07-09 1999-12-14 Minolta Co., Ltd. Image editing device for processing image data
US6163882A (en) * 1997-04-03 2000-12-19 Nec Corporation Language processing apparatus for converting source program into object program
US6809742B1 (en) 1996-07-29 2004-10-26 Minolta Co., Ltd. Image editing device permitting user to register desired patterns

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6002404A (en) * 1996-07-09 1999-12-14 Minolta Co., Ltd. Image editing device for processing image data
US6809742B1 (en) 1996-07-29 2004-10-26 Minolta Co., Ltd. Image editing device permitting user to register desired patterns
US6163882A (en) * 1997-04-03 2000-12-19 Nec Corporation Language processing apparatus for converting source program into object program

Similar Documents

Publication Publication Date Title
US6052530A (en) Dynamic translation system and method for optimally translating computer code
JP3237693B2 (en) Language processing apparatus and language processing method
JPH0594311A (en) Machine language translation program
JP3267550B2 (en) Degrade check device
JPH07210397A (en) Program conversion method and program execution method using the same
JPH05165650A (en) Machine language translation device
JPH0371342A (en) Reserved word deciding system
JPH036624A (en) Processing system for translation list output corresponding to plural code systems
JP2543678B2 (en) Data generation method
JPH05151000A (en) Generation processing system for optimum internal call instruction
JPH06119263A (en) Processing function calling system
JP3007356B2 (en) Compiling device
JPH05197561A (en) Compilation system
JPH05100720A (en) Managing device for program
JPH11184680A (en) File editing method, method and device for developing program using the same, and storage medium
JPS6115251A (en) Virtual memory control system
JPH09258961A (en) Method for analyzing program environment definition information
JPH0535385A (en) Key code converter
JPH0244434A (en) Pseudo symbolic debugging system in non-symbolic debugger
JPH0320825A (en) Program editor
JPH0232425A (en) Constant optimizing system
JPH02199540A (en) Automatic formation system for calling sentence
JPH01310452A (en) Address output system
JPH0713771A (en) Language processing program
JPH02108131A (en) Dynamic table control system

Legal Events

Date Code Title Description
A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20000829