JPH05257703A - Assembler device - Google Patents

Assembler device

Info

Publication number
JPH05257703A
JPH05257703A JP16296692A JP16296692A JPH05257703A JP H05257703 A JPH05257703 A JP H05257703A JP 16296692 A JP16296692 A JP 16296692A JP 16296692 A JP16296692 A JP 16296692A JP H05257703 A JPH05257703 A JP H05257703A
Authority
JP
Japan
Prior art keywords
branch instruction
variable
processing
branch
address
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
JP16296692A
Other languages
Japanese (ja)
Inventor
Yoichi Hirasawa
陽一 平澤
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
Publication of JPH05257703A publication Critical patent/JPH05257703A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To reduce the number of times for passing an optimizing processing and to shorten processing time by alternately executing optimization in the order from a smaller address and optimization in the order from a larger address. CONSTITUTION:The analysis of rows is executed by a source analysis processing 100 for preparing a bidirectional table, and the information of a branching instruction is set to a bidirectional branching instruction information table 104. On the other hand, after an input file is finished, a bidirectional optimizing processing 102 for optimizing the branching instruction is performed by a file end discrimination processing 101. Every time the branching instruction appears in a source program file, tables linked by a bidirectional chain having the information of the branching instruction is prepared and stored in a memory. Then, the optimization in the ascending order of addresses and the optimization in the descending order are performed and when any branching instruction to be affected by the number of opposite side bytes each other is present thereon, the instruction having the least number of bytes is generated in the third optimize processing so as to reduce the number of times for passing the optimizing processing up to from once to three time.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、分岐命令の位置するア
ドレスと分岐先のアドレスまでの相対アドレスとに対し
て飛び先範囲の異なる分岐命令を持つアセンブラに利用
する。特に、最適な分岐命令を選択する処理を行うアセ
ンブラに関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention is used in an assembler having branch instructions having different jump destination ranges with respect to the address where the branch instruction is located and the relative address up to the branch destination address. In particular, it relates to an assembler that performs a process of selecting an optimum branch instruction.

【0002】[0002]

【従来の技術】従来例方式は、分岐命令のアドレスが小
さい分岐命令の順に最適化処理を行っていた。図2は従
来技術のアセンブラ処理方式の一例の流れ図である。図
9は従来技術の分岐命令情報テーブル作成処理の一例の
流れ図である。図10および図11は従来技術の最適化
処理方式の一例の流れ図である。前方参照(前方参照と
は、ソースプログラム中で分岐命令の位置がソースプロ
グラムの先頭側に位置することに対して分岐先が終わり
側に位置する関係をいう。)のときは分岐命令から分岐
命令の飛び先までのバイト数が127バイト以下であれ
ば2バイト分の分岐命令を生成し、128バイト以上で
あれば3バイト分の分岐命令を生成する。後方参照(後
方参照とは、分岐先の方が分岐命令よりもソースプログ
ラム中で先頭側に位置する関係をいう。)のときは分岐
命令から分岐命令の飛び先までのバイト数の絶対値12
8バイト以下であれば2バイト分の分岐命令を生成す
る。絶対値129バイト以上であれば3バイト分の分岐
命令を生成するアセンブラで、図2に示すように、パス
1ソース解析処理105で行の解析結果が分岐命令であ
ると、図9の処理で図2の分岐命令の情報を分岐命令情
報テーブル107に設定する。
2. Description of the Related Art In the conventional method, optimization processing is performed in the order of branch instructions having smaller addresses. FIG. 2 is a flowchart of an example of a conventional assembler processing method. FIG. 9 is a flow chart of an example of a conventional branch instruction information table creating process. 10 and 11 are flowcharts of an example of the conventional optimization processing method. In the case of forward reference (forward reference refers to a relationship in which the position of the branch instruction is located at the head side of the source program and the branch destination is located at the end side in the source program), from the branch instruction to the branch instruction If the number of bytes to the jump destination is 127 bytes or less, a 2-byte branch instruction is generated, and if it is 128 bytes or more, a 3-byte branch instruction is generated. In the case of a back reference (a back reference refers to a relationship in which the branch destination is located on the head side in the source program rather than the branch instruction), the absolute value of the number of bytes from the branch instruction to the jump destination of the branch instruction is 12
If it is 8 bytes or less, a 2-byte branch instruction is generated. If the absolute value is 129 bytes or more, an assembler that generates branch instructions for 3 bytes, and if the path analysis result of the path 1 source analysis processing 105 is a branch instruction as shown in FIG. Information on the branch instruction of FIG. 2 is set in the branch instruction information table 107.

【0003】図7(a)は図2の分岐命令情報テーブル
のテーブルのつながりを示した図である。図7(b)は
図2の分岐命令情報テーブルを詳細に説明した図であ
る。分岐命令情報テーブル107は、図7(b)の次の
テーブルを指すチェインポインタ440と、分岐命令の
アドレス442と、シンボルテーブルを指すチェインポ
インタ443と、コード増加量444とで構成される。
FIG. 7 (a) is a diagram showing the connection of the branch instruction information table of FIG. FIG. 7B is a diagram illustrating the branch instruction information table of FIG. 2 in detail. The branch instruction information table 107 includes a chain pointer 440 that points to the next table in FIG. 7B, a branch instruction address 442, a chain pointer 443 that points to the symbol table, and a code increment 444.

【0004】図9に示す分岐命令のアドレスセット処理
200で、分岐命令の次のアドレスを現在処理している
図2の分岐命令情報テーブル107にある変数addに
代入する。図9に示すシンボルテーブルのアドレスセッ
ト処理201で、シンボルテーブルのアドレスを現在処
理している図2の分岐命令情報テーブル107にある変
数sympに代入する。コード増加量セット処理202
で、2バイト分の分岐命令を生成するか3バイト分の分
岐命令を生成するか未確定であることを示すコード増加
量の初期値として「1」を現在処理している図2の分岐
命令情報テーブル107にある変数codeに代入す
る。次のテーブルのアドレスセット処理203で、次の
分岐命令情報テーブルを作成し、作成した次の分岐命令
情報テーブルのアドレスを変数nextに代入する。現
在のテーブルのアドレスセット処理205で、現在処理
中の分岐命令情報テーブルのアドレスを図7(a)の最
後の分岐命令情報テーブルの末尾を指すチェインポイン
タ401を代入する。
In the address setting process 200 of the branch instruction shown in FIG. 9, the address next to the branch instruction is substituted into the variable add in the branch instruction information table 107 of FIG. In the address setting process 201 of the symbol table shown in FIG. 9, the address of the symbol table is assigned to the variable symp in the branch instruction information table 107 of FIG. Code increase amount setting processing 202
2 which is currently processing "1" as the initial value of the code increase amount indicating that it is uncertain whether to generate a 2-byte branch instruction or a 3-byte branch instruction. Substitute for the variable code in the information table 107. In the address setting process 203 of the next table, the next branch instruction information table is created, and the address of the created next branch instruction information table is assigned to the variable next. In the address setting process 205 of the current table, the chain pointer 401 pointing to the end of the last branch instruction information table in FIG. 7A is substituted for the address of the branch instruction information table currently being processed.

【0005】図2に示すパス1ソース解析処理105を
ファイルの最後まで行い、終了後に分岐命令の最適化を
する最適化処理106を行う。最適化処理106では、
図10に示す先頭アドレス代入処理301で図7(a)
で示される分岐命令情報テーブルの先頭を指すチェイン
ポインタ400を変数cpに代入し、図10のフラグ初
期化処理305で分岐命令が2バイト分または3バイト
分に確定したことを表す変数flagに初期値として
「0」を代入する。増加量判別処理306により変数c
pの指す分岐命令情報テーブル107の分岐命令が2バ
イト分の分岐命令かまたは3バイト分の分岐命令に確定
しているか否かを判別し、確定していれば図11の分岐
命令情報テーブル判別処理320へ進む。確定していな
ければ図10の分岐命令までの増加量算出処理307に
よりファイルの先頭から変数cpの指す分岐命令情報テ
ーブルの分岐命令までに図2の最適化処理106の対象
となる分岐命令がいくつあるかを算出し、算出した分岐
命令の数を変数Aに代入する。
The path 1 source analysis process 105 shown in FIG. 2 is performed until the end of the file, and after the completion, an optimization process 106 for optimizing a branch instruction is performed. In the optimization process 106,
In the head address substitution processing 301 shown in FIG.
The chain pointer 400 pointing to the beginning of the branch instruction information table shown by is substituted into the variable cp, and the variable flag indicating that the branch instruction is fixed to 2 bytes or 3 bytes in the flag initialization processing 305 of FIG. 10 is initialized. Substitute "0" as the value. The variable c is determined by the increase amount determination process 306.
It is determined whether or not the branch instruction of the branch instruction information table 107 pointed to by p is determined to be a 2-byte branch instruction or a 3-byte branch instruction, and if determined, the branch instruction information table determination of FIG. Go to process 320. If not determined, how many branch instructions are to be the target of the optimization processing 106 of FIG. 2 from the beginning of the file to the branch instruction of the branch instruction information table pointed to by the variable cp by the increase amount calculation processing 307 up to the branch instruction of FIG. It is calculated whether or not there is, and the calculated number of branch instructions is substituted into the variable A.

【0006】図10の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの分岐命令の飛び先までに図2の最適化処理
106の対象となる分岐命令がいくつあるか算出し、算
出した分岐命令の数を変数Bに代入する。図10の相対
アドレス代入処理309により変数cpの指す分岐命令
情報テーブルの分岐命令の飛び先のアドレスから変数c
pの指す分岐命令情報テーブルの分岐命令のアドレスを
減算し、変数mrlに代入する。そして、シンボル参照
判別処理310により変数cpの指す分岐命令情報テー
ブルの分岐命令が前方参照であるか後方参照であるかを
判別する。
Increasing amount calculation processing 30 up to the jump destination in FIG.
8, the number of branch instructions to be subjected to the optimization processing 106 in FIG. 2 is calculated from the head of the file to the jump destination of the branch instruction in the branch instruction information table pointed to by the variable cp, and the calculated number of branch instructions is set as a variable. Substitute in B. By the relative address substitution process 309 of FIG. 10, the variable c is changed from the jump destination address of the branch instruction of the branch instruction information table pointed to by the variable cp.
The address of the branch instruction in the branch instruction information table pointed to by p is subtracted, and is substituted into the variable mrl. Then, the symbol reference determination processing 310 determines whether the branch instruction in the branch instruction information table pointed to by the variable cp is forward reference or backward reference.

【0007】変数mrlが「0」以下であれば後方参照
であり、「1」以上であれば前方参照である。シンボル
参照判別処理310の結果が前方参照の場合は、相対値
を変数minrにセット処理311により変数mrlを
変数minrに代入し、コード増加量と相対値を変数m
axrにセット処理312とにより変数mrlを変数m
inrに代入し、コード増加量と相対値を変数maxr
にセット処理312とにより変数mrlと変数Bとを加
算し、加算した結果から変数Aを減算した結果を変数m
axrに代入する。また後方参照の場合は、相対値を変
数maxrにセット処理313により変数mrlを変数
maxrに代入し、コード増加量と相対値を変数min
rにセット処理314とにより変数mrlと変数Bとを
加算し、加算した結果から変数Aを減算した結果を変数
minrに代入する。
If the variable mrl is "0" or less, it is a backward reference, and if it is "1" or more, it is a forward reference. When the result of the symbol reference determination processing 310 is forward reference, the relative value is set to the variable minr and the processing 311 substitutes the variable mrl into the variable minr to set the code increase amount and the relative value to the variable m.
By setting processing 312 to axr, the variable mrl is set to the variable m.
Substitute inr, and increase the code and the relative value with the variable maxr
Is added to the variable mrl and the variable B by the set process 312, and the result of subtracting the variable A from the added result is the variable m.
Substitute in axr. In the case of back reference, the relative value is set to the variable maxr and the variable mrl is substituted for the variable maxr by the setting process 313, and the code increase amount and the relative value are set to the variable min.
The variable mrl and the variable B are added to r by the set processing 314, and the result of subtracting the variable A from the added result is substituted for the variable minr.

【0008】次に、図11の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行い、3バイト分
の分岐命令を生成する必要がある場合は、分岐命令のア
ドレス補正処理317により現在処理している分岐命令
情報テーブルの次の分岐命令情報テーブルから変数bt
mが指す分岐命令情報テーブルに格納されている分岐命
令のアドレスに「1」加算する。フラグセット処理31
8で分岐命令が2バイト分または3バイト分のいずれか
に確定したことを表す変数flagに「1」を代入す
る。2バイト分の分岐命令を生成することに確定した場
合も同様に変数flagに「1」を代入する。
Next, a 2-byte branch instruction output determination process 315 and a 3-byte branch instruction output determination process 3 of FIG.
16 determines whether to generate a 2-byte branch instruction or a 3-byte branch instruction, and if a 3-byte branch instruction needs to be generated, a branch instruction address correction process 317 is performed. Variable bt from the branch instruction information table next to the branch instruction information table currently being processed by
"1" is added to the address of the branch instruction stored in the branch instruction information table pointed to by m. Flag setting process 31
In step 8, "1" is assigned to a variable flag indicating that the branch instruction is determined to be either 2 bytes or 3 bytes. Similarly, when it is decided to generate a 2-byte branch instruction, "1" is similarly substituted into the variable flag.

【0009】さらに、コード増加量セット処理319に
より変数cpの指す分岐命令情報テーブルの分岐命令が
2バイト分または3バイト分に確定したことを表す変数
codeに「0」を代入する。変数cpの指す分岐命令
情報テーブルの分岐命令と変数cpの指す分岐命令情報
テーブルの分岐命令の飛び先との間に2バイト分の分岐
命令になるかまたは3バイト分の分岐命令になるか不確
定な分岐命令がありかつ不確定な分岐命令がすべて2バ
イト分の分岐命令となったとき、または変数cpの指す
分岐命令情報テーブルの分岐命令が2バイト分の分岐命
令になる場合また不確定な分岐命令がすべて3バイト分
の分岐命令となったときは、変数cpの指す分岐命令情
報テーブルの分岐命令が3バイト分の分岐命令になる場
合には分岐命令情報テーブル判別処理320へ進む。
Further, "0" is substituted into the variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes by the code increase amount setting process 319. Whether a branch instruction of 2 bytes or a branch instruction of 3 bytes occurs between the branch instruction of the branch instruction information table pointed to by the variable cp and the jump destination of the branch instruction of the branch instruction information table pointed to by the variable cp. When there is a definite branch instruction and all of the undecided branch instructions are 2-byte branch instructions, or when the branch instruction of the branch instruction information table pointed to by the variable cp is a 2-byte branch instruction. If all the branch instructions are the branch instructions for 3 bytes, and if the branch instructions in the branch instruction information table pointed to by the variable cp are the branch instructions for 3 bytes, the process proceeds to the branch instruction information table determination processing 320.

【0010】分岐命令情報テーブル判別処理320で
は、変数cpの指す分岐命令情報テーブルの次の分岐命
令情報テーブルがあるか否かを判別し、ある場合にはポ
インタインクリメント処理321により変数cpに分岐
命令情報テーブルのサイズ分を加算し、変数cpが次の
分岐命令情報テーブルを指すようにして図10の増加量
判別処理306へ進む。次の分岐命令情報テーブルがな
い場合は、図11のフラグ判別処理322により分岐命
令が2バイト分または3バイト分に確定したことを表す
変数flagが「0」であるか否かを判別し、「1」で
あればまだ最適化できる可能性があるので図10の先頭
アドレス代入処理301に戻る。変数flagが「0」
の場合は図11のシンボルテーブル補正処理323へ進
み、シンボルテーブルの補正処理を行う。
In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp, and if there is, a pointer increment processing 321 branches the variable cp to the branch instruction information table. The size of the information table is added, the variable cp points to the next branch instruction information table, and the process proceeds to the increment determination process 306 of FIG. If there is no next branch instruction information table, it is determined by the flag determination processing 322 of FIG. 11 whether or not the variable flag indicating that the branch instruction has been determined to be 2 bytes or 3 bytes is “0”, If it is "1", there is a possibility that the optimization can still be performed, so the process returns to the head address substitution processing 301 in FIG. The variable flag is "0"
In the case of, the process proceeds to the symbol table correction process 323 of FIG. 11, and the symbol table correction process is performed.

【0011】次に、分岐命令の最適化処理を図8で示す
ファイルを入力した場合について説明する。このときに
図7(a)に示す分岐命令情報テーブルを作成する。た
だし、図8で、分岐命令が2バイト分の分岐命令である
場合の分岐命令から分岐命令の飛び先までのバイト数
(飛び先のアドレス−分岐命令のアドレス)は、Dへ分
岐する分岐命令(以下、第一分岐命令という)510か
ら飛び先D(以下、第一飛び先という)520まで12
7バイト、Cへ分岐する分岐命令(以下、第二分岐命令
という)511から飛び先C(以下、第二飛び先とい
う)521まで127バイト、Bへ分岐する分岐命令
(以下、第三分岐命令という)512から飛び先B(以
下、第三飛び先という)522まで127バイト、Aへ
分岐する分岐命令(以下、第四分岐命令という)513
から飛び先A(以下、第四飛び先という)523まで1
20バイト、Hへ分岐する分岐命令(以下、第五分岐命
令という)514から飛び先H(以下、第五飛び先とい
う)524まで−128バイト、Gへ分岐する分岐命令
(以下、第六分岐命令という)515から飛び先G(以
下、第六飛び先という)525まで−128バイト、F
へ分岐する分岐命令(以下、第七分岐命令という)51
6から飛び先F(以下、第七飛び先という)526まで
−128バイト、Eへ分岐する分岐命令(以下、第八分
岐命令という)517から飛び先E(以下、第八飛び先
という)527まで−128バイト、Jへ分岐する分岐
命令(以下、第九分岐命令という)518から飛び先J
(以下、第九飛び先という)528まで127バイト、
Iへ分岐する分岐命令(以下、第十分岐命令という)5
19から飛び先I(以下、第十飛び先という)529ま
で−128バイトとする。
Next, the optimization processing of the branch instruction will be described for the case where the file shown in FIG. 8 is input. At this time, the branch instruction information table shown in FIG. 7A is created. However, in FIG. 8, when the branch instruction is a 2-byte branch instruction, the number of bytes from the branch instruction to the jump destination of the branch instruction (jump destination address-branch instruction address) is the branch instruction branching to D. 12 (hereinafter, referred to as first branch instruction) 510 to jump destination D (hereinafter, referred to as first jump destination) 520 12
7 bytes, branch instruction branching to C (hereinafter referred to as second branch instruction) 511 to jump destination C (hereinafter referred to as second jump destination) 521 127 bytes, branch instruction branching to B (hereinafter referred to as third branch instruction) 512) to jump destination B (hereinafter, referred to as third jump destination) 522, 127 bytes, branch instruction for branching to A (hereinafter, referred to as fourth branch instruction) 513
To destination A (hereinafter referred to as the fourth destination) 523 to 1
20 bytes, a branch instruction for branching to H (hereinafter referred to as the fifth branch instruction) 514 to a jump destination H (hereinafter, referred to as the fifth jump destination) 524 is -128 bytes, a branch instruction for branching to G (hereinafter, the sixth branch instruction). From instruction 515 to destination G (hereinafter referred to as the sixth destination) 525, -128 bytes, F
Branch instruction for branching to (hereinafter referred to as the seventh branch instruction) 51
6 to jump destination F (hereinafter, referred to as the seventh jump destination) 526, -128 bytes, a branch instruction (hereinafter, referred to as the eighth branch instruction) 517 that branches to E, and jump destination E (hereinafter, referred to as the eighth jump destination) 527. Up to -128 bytes, branch instruction to branch to J (hereinafter referred to as the ninth branch instruction) 518 to jump to J
(Hereafter referred to as the ninth destination) 127 bytes up to 528,
Branch instruction for branching to I (hereinafter referred to as the tenth branch instruction) 5
From 19 to 529 (hereinafter referred to as the tenth destination) 529 is -128 bytes.

【0012】図8のソースプログラムファイルを入力
し、図2のパス1ソース解析処理105で行の解析をし
た結果として図8の第一分岐命令510が出現すると、
図9の処理で、分岐命令の情報を図2の分岐命令情報テ
ーブル107に設定する。図9の分岐命令のアドレスセ
ット処理200で、図8の第一分岐命令510の次のア
ドレスを図7(a)の第一分岐命令510の分岐命令情
報テーブル430が持つ変数addに代入する。図9の
シンボルテーブルのアドレスセット処理201で、図8
の第一飛び先520のシンボルテーブルのアドレスを図
7(a)の第一分岐命令の分岐命令情報テーブル430
が持つ変数sympに代入する。
When the first branch instruction 510 of FIG. 8 appears as a result of inputting the source program file of FIG. 8 and analyzing the line in the path 1 source analysis processing 105 of FIG.
In the process of FIG. 9, the branch instruction information is set in the branch instruction information table 107 of FIG. In the address setting process 200 of the branch instruction of FIG. 9, the address next to the first branch instruction 510 of FIG. 8 is substituted into the variable add held in the branch instruction information table 430 of the first branch instruction 510 of FIG. 7A. In the address set processing 201 of the symbol table of FIG.
The address of the symbol table of the first jump destination 520 of the branch instruction information table 430 of the first branch instruction of FIG.
To the variable symp held by.

【0013】図9のコード増加量セット処理202で、
2バイト分の分岐命令を生成するか3バイト分の分岐命
令を生成するか未確定であることを示す「1」をコード
増加量の初期値として図7(a)の第一分岐命令の分岐
命令情報テーブル430が持つ変数codeに代入す
る。図9の次のテーブルのアドレスセット処理203
で、次の分岐命令情報テーブルを作成し、作成した次の
分岐命令情報テーブルのアドレスを図7(a)の第一分
岐命令の分岐命令情報テーブル430が持つ変数nex
tに代入する。図9のアドレスセット処理205で、図
7(a)の第一分岐命令の分岐命令情報テーブル430
のアドレスを最後の分岐命令情報テーブルを指す変数b
tmに代入する。これで図7(a)の第一分岐命令の分
岐命令情報テーブル430が作成される。以下同じよう
に図8の第二分岐命令511、第三分岐命令512、第
四分岐命令513、第五分岐命令514、第六分岐命令
515、第七分岐命令516、第八分岐命令517、第
九分岐命令518および第十分岐命令519について行
い、各々の分岐命令情報テーブルを作成する。終了後に
分岐命令の最適化をする図2の最適化処理106を行
う。
In the code increment setting process 202 of FIG. 9,
The branch of the first branch instruction of FIG. 7A is set with “1” indicating that it is uncertain whether to generate a branch instruction of 2 bytes or a branch instruction of 3 bytes, as an initial value of the code increase amount. It is assigned to the variable code of the instruction information table 430. Address set processing 203 of the next table in FIG.
Then, the next branch instruction information table is created, and the address of the created next branch instruction information table is stored in the variable next in the branch instruction information table 430 of the first branch instruction of FIG. 7A.
Substitute in t. In the address set processing 205 of FIG. 9, the branch instruction information table 430 of the first branch instruction of FIG.
Variable b that points to the address of the last branch instruction information table
Substitute for tm. With this, the branch instruction information table 430 of the first branch instruction of FIG. 7A is created. Similarly, the second branch instruction 511, the third branch instruction 512, the fourth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516, the eighth branch instruction 517, and the The nine-branch instruction 518 and the tenth branch instruction 519 are performed, and each branch instruction information table is created. After completion, the optimization process 106 of FIG. 2 for optimizing the branch instruction is performed.

【0014】図2の最適化処理106では、図10の先
頭アドレス代入処理301で、分岐命令情報テーブルの
先頭を指す図7(a)の先頭を指すチェインポインタ4
00を変数cpに代入し、図10のフラグ初期化処理3
05で、分岐命令が2バイト分または3バイト分に確定
したことを表す変数flagに初期値として「0」を代
入する。増加量判別処理306により変数cpの指す分
岐命令情報テーブルの図8の第一分岐命令510が2バ
イト分の分岐命令かまたは3バイト分の分岐命令に確定
しているか否かを判別する。この場合は確定していない
ので、図10の分岐命令までの増加量算出処理307に
よりファイルの先頭から変数cpの指す分岐命令情報テ
ーブルの図8の第一分岐命令510までに図2の最適化
処理106の対象となる分岐命令がいくつ存在するか算
出し、算出した分岐命令の数を変数Aに代入する。この
場合は自分自身の図8の第一分岐命令510のみなの
で、「1」を変数Aに代入する。
In the optimization processing 106 of FIG. 2, the chain pointer 4 pointing to the head of FIG. 7A pointing to the head of the branch instruction information table in the head address substitution processing 301 of FIG.
00 is assigned to the variable cp, and flag initialization processing 3 in FIG.
At 05, "0" is assigned as an initial value to a variable flag indicating that the branch instruction is fixed to 2 bytes or 3 bytes. The increment determination process 306 determines whether the first branch instruction 510 in FIG. 8 in the branch instruction information table pointed to by the variable cp is a 2-byte branch instruction or a 3-byte branch instruction. In this case, since it is not decided, the optimization of FIG. 2 is performed from the head of the file to the first branch instruction 510 of FIG. The number of branch instructions to be processed 106 is calculated, and the calculated number of branch instructions is assigned to the variable A. In this case, since only the first branch instruction 510 of its own in FIG. 8 is set, “1” is assigned to the variable A.

【0015】図10の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図8の第一分岐命令510の飛び先である
図8の第一飛び先520までに図2の最適化処理106
の対象となる分岐命令がいくつ存在するか算出し、算出
した分岐命令の数を変数Bに代入する。この場合は図8
の第一分岐命令510、第二分岐命令511、第三分岐
命令512および第四分岐命令513の4個なので、
「4」を変数Bに代入する。図10の相対アドレス代入
処理309により変数cpの指す分岐命令情報テーブル
の図8の第一分岐命令510の飛び先である第一飛び先
520のアドレスから変数cpの指す分岐命令情報テー
ブルの第一分岐命令510のアドレスを減算し、変数m
rlに代入する。この場合は127バイトなので、「1
27」を変数mrlに代入する。
Increasing amount calculation processing 30 up to the jump destination in FIG.
8 from the head of the file to the first jump destination 520 of FIG. 8 which is the jump destination of the first branch instruction 510 of FIG. 8 in the branch instruction information table pointed to by the variable cp.
The number of branch instructions to be processed is calculated, and the calculated number of branch instructions is assigned to the variable B. In this case,
The first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fourth branch instruction 513 of
Substitute “4” into variable B. By the relative address assignment process 309 of FIG. 10, the first of the branch instruction information table pointed to by the variable cp from the address of the first jump destination 520 which is the jump destination of the first branch instruction 510 of FIG. The address of the branch instruction 510 is subtracted, and the variable m
Substitute for rl. In this case, 127 bytes, so "1
27 ”is substituted into the variable mrl.

【0016】そして、図10のシンボル参照判別処理3
10により変数cpの指す分岐命令情報テーブルの図8
の第一分岐命令510が前方参照であるか後方参照であ
るかを判別する。この場合は前方参照なので、図10の
相対値を変数minrにセット処理311により変数m
rlを変数minrに代入し、コード増加量と相対値を
変数maxrにセット処理312により変数mrlと変
数Bを加算し、加算した結果から変数Aを減算した結果
を変数maxrに代入する。この場合は変数minrに
「127」が代入され、変数maxrに「130」が代
入される。
Then, the symbol reference determination process 3 of FIG.
8 of the branch instruction information table pointed to by the variable cp by 10
It is determined whether the first branch instruction 510 of is a forward reference or a backward reference. In this case, since it is a forward reference, the relative value of FIG.
rl is substituted into the variable minr, the code increase amount and the relative value are set into the variable maxr, the variable mrl and the variable B are added by the setting processing 312, and the result of subtracting the variable A from the added result is substituted into the variable maxr. In this case, "127" is assigned to the variable minr and "130" is assigned to the variable maxr.

【0017】次に、図11の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合に
変数maxrが「130」であるので、2バイト分の分
岐命令出力判別処理315の条件が成り立たず、3バイ
ト分の分岐命令出力判別処理316へ進む。変数max
rが「130」、変数minrが「127」であるので
3バイト分の分岐命令出力判別処理316の条件は成り
立ち、2バイト分の分岐命令を生成するか3バイト分の
分岐命令を生成するかが確定しないので分岐命令情報テ
ーブル判別処理320へ進む。
Next, the 2-byte branch instruction output discrimination processing 315 and the 3-byte branch instruction output discrimination processing 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since the variable maxr is "130", the condition of the 2-byte branch instruction output determination process 315 is not satisfied, and the process proceeds to the 3-byte branch instruction output determination process 316. Variable max
Since r is “130” and the variable minr is “127”, the condition of the branch instruction output determination process 316 for 3 bytes is satisfied and whether a branch instruction for 2 bytes or a branch instruction for 3 bytes is generated. Is not determined, the process proceeds to the branch instruction information table discrimination processing 320.

【0018】分岐命令情報テーブル判別処理320で
は、変数cpの指す分岐命令情報テーブルの次の分岐命
令情報テーブルが存在するか否かを判別する。この場合
は次の分岐命令情報テーブルが存在するのでポインタイ
ンクリメント処理321へ進み、変数cpに分岐命令情
報テーブルのサイズ分を加算し、変数cpが次の分岐命
令情報テーブルを指すようにして図10の増加量判別処
理306へ進み、図8の第二分岐命令511および第三
分岐命令512に対して第一分岐命令510と同様の処
理を行う。
In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to pointer increment processing 321 and the size of the branch instruction information table is added to the variable cp so that the variable cp points to the next branch instruction information table. 8 and performs the same processing as the first branch instruction 510 on the second branch instruction 511 and the third branch instruction 512 of FIG.

【0019】第二分岐命令511および第三分岐命令5
12も第一分岐命令510と同様に2バイト分の分岐命
令を生成するか3バイト分の分岐命令を生成するか確定
しない。次に第四分岐命令513の処理を行う。図10
の増加量判別処理306により変数cpの指す分岐命令
情報テーブルの図8の第四分岐命令513が2バイト分
の分岐命令かまたは3バイト分の分岐命令に確定してい
るかを判別する。この場合は確定していないので、図1
0の分岐命令までの増加量算出処理307によりファイ
ルの先頭から変数cpの指す分岐命令情報テーブルの図
8の第四分岐命令513までに図2の最適化処理106
の対象となる分岐命令がいくつ存在するか算出し、算出
した分岐命令の数を変数Aに代入する。この場合は図8
の第一分岐命令510、第二分岐命令511、第三分岐
命令512および第四分岐命令513の4個なので、
「4」を変数Aに代入する。
Second branch instruction 511 and third branch instruction 5
Similarly to the first branch instruction 510, 12 also does not decide whether to generate a 2-byte branch instruction or a 3-byte branch instruction. Next, the fourth branch instruction 513 is processed. Figure 10
It is determined whether the fourth branch instruction 513 in FIG. 8 in the branch instruction information table pointed to by the variable cp is a 2-byte branch instruction or a 3-byte branch instruction. In this case, since it has not been confirmed,
By the increase amount calculation processing 307 up to the branch instruction of 0, the optimization processing 106 of FIG. 2 is performed from the beginning of the file to the fourth branch instruction 513 of FIG.
The number of branch instructions to be processed is calculated, and the calculated number of branch instructions is assigned to the variable A. In this case,
The first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fourth branch instruction 513 of
Substitute "4" for variable A.

【0020】図10の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図8の第四分岐命令513の飛び先である
第四飛び先523までに図2の最適化処理106の対象
となる分岐命令がいくつ存在するか算出し、算出した分
岐命令の数を変数Bに代入する。この場合は図8の第一
分岐命令510、第二分岐命令511、第三分岐命令5
12および第四分岐命令513の4個なので、「4」を
変数Bに代入する。図10の相対アドレス代入処理30
9により変数cpの指す分岐命令情報テーブルの図8の
第四分岐命令513の飛び先である第四飛び先523の
アドレスから変数cpの指す分岐命令情報テーブルの第
四分岐命令513のアドレスを減算し、変数mrlに代
入する。この場合は120バイトなので、「120」を
変数mrlに代入し、図10のシンボル参照判別処理3
10により変数cpの指す分岐命令情報テーブルの図8
の第四分岐命令513が前方参照であるか後方参照であ
るかを判別する。この場合は前方参照なので、図10の
算出量セット処理311により変数mrlを変数min
rに代入し、コード増加量と相対値を変数maxrにセ
ット処理312により変数mrlと変数Bとを加算し、
加算した結果から変数Aを減算した結果を変数maxr
に代入する。この場合は変数minrに「120」が代
入され、変数maxrに「120」が代入される。
Increase amount calculation processing 30 up to the jump destination in FIG.
8 shows how many branch instructions to be subjected to the optimization processing 106 of FIG. 2 from the head of the file to the fourth jump destination 523 which is the jump destination of the fourth branch instruction 513 of FIG. 8 from the branch instruction information table pointed to by the variable cp. It is calculated whether it exists, and the calculated number of branch instructions is substituted into the variable B. In this case, the first branch instruction 510, the second branch instruction 511, and the third branch instruction 5 of FIG.
Since there are four of 12 and the fourth branch instruction 513, “4” is assigned to the variable B. Relative address substitution process 30 of FIG.
9. The address of the fourth branch instruction 513 of the branch instruction information table pointed to by the variable cp is subtracted from the address of the fourth jump destination 523 of the fourth branch instruction 513 of FIG. And assign it to the variable mrl. In this case, since it is 120 bytes, "120" is assigned to the variable mrl, and the symbol reference determination process 3 in FIG.
8 of the branch instruction information table pointed to by the variable cp by 10
It is determined whether the fourth branch instruction 513 is a forward reference or a backward reference. In this case, since it is a forward reference, the variable mrl is changed to the variable min by the calculation amount setting process 311 in FIG.
Substituting in r, the code increase amount and the relative value are set in the variable maxr, and the variable mrl and the variable B are added by the processing 312.
The result of subtracting the variable A from the result of addition is the variable maxr
To. In this case, "120" is assigned to the variable minr and "120" is assigned to the variable maxr.

【0021】次に、図11の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合は
変数minrと変数maxrとが共に「120」である
ので、2バイト分の分岐命令出力判別処理315の条件
が成り立ち、フラグセット処理318へ進む。フラグセ
ット処理318では図8の第四分岐命令513が2バイ
ト分の分岐命令を生成することに確定したので、2バイ
ト分または3バイト分に確定したことを表す変数fla
gに「1」を代入する。
Next, the 2-byte branch instruction output discrimination processing 315 and the 3-byte branch instruction output discrimination processing 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since both the variable minr and the variable maxr are “120”, the condition of the branch instruction output determination process 315 for 2 bytes is satisfied, and the process proceeds to the flag set process 318. In the flag setting process 318, since it is decided that the fourth branch instruction 513 of FIG. 8 generates a branch instruction for 2 bytes, a variable fla indicating that it is decided for 2 bytes or 3 bytes.
Substitute “1” for g.

【0022】さらに、図11のコード増加量セット処理
319により変数cpの指す分岐命令情報テーブルの分
岐命令が2バイト分または3バイト分に確定したことを
表す変数codeに「0」を代入し、分岐命令情報テー
ブル判別処理320へ進む。分岐命令情報テーブル判別
処理320では、変数cpの指す分岐命令情報テーブル
の次の分岐命令情報テーブルが存在するか否かを判別す
る。この場合は次の分岐命令情報テーブルが存在するの
で、ポインタインクリメント処理321へ進み、変数c
pに分岐命令情報テーブルのサイズ分を加算し、変数c
pが次の分岐命令情報テーブルを指すようにして図10
の増加量判別処理306へ進む。
Further, "0" is assigned to the variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes by the code increment setting process 319 of FIG. The process proceeds to the branch instruction information table discrimination processing 320. In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to the pointer increment processing 321 and the variable c
The size of the branch instruction information table is added to p, and the variable c
10 so that p points to the next branch instruction information table.
Then, the process proceeds to the increase amount determination processing 306.

【0023】増加量判別処理306により変数cpの指
す分岐命令情報テーブルの図8の第五分岐命令514が
2バイト分の分岐命令または3バイト分の分岐命令のい
ずれに確定しているかを判別する。この場合は確定して
いないので、図10の分岐命令までの増加量算出処理3
07によりファイルの先頭から変数cpの指す分岐命令
情報テーブルの図8の第五分岐命令514までに図2の
最適化処理106の対象となる分岐命令がいくつ存在す
るかを算出し、算出した分岐命令の数を変数Aに代入す
る。この場合は図8の第一分岐命令510、第二分岐命
令511、第三分岐命令512および第五分岐命令51
4の4個なので、「4」を変数Aに代入する。
In the increase amount determination processing 306, it is determined whether the fifth branch instruction 514 of FIG. 8 in the branch instruction information table pointed to by the variable cp is determined to be a 2-byte branch instruction or a 3-byte branch instruction. .. In this case, since it has not been decided, the increase amount calculation process 3 up to the branch instruction in FIG.
The number of branch instructions to be subjected to the optimization process 106 of FIG. 2 is calculated from 07 from the head of the file to the fifth branch instruction 514 of FIG. 8 of the branch instruction information table pointed to by the variable cp, and the calculated branch Substitute the number of instructions into variable A. In this case, the first branch instruction 510, the second branch instruction 511, the third branch instruction 512 and the fifth branch instruction 51 of FIG.
Since there are four of them, "4" is assigned to the variable A.

【0024】図10の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図8の第五分岐命令514の飛び先である
第五飛び先524までに図2の最適化処理106の対象
となる分岐命令がいくつ存在するかを算出し、算出した
分岐命令の数を変数Bに代入する。この場合は図8の第
一分岐命令510、第二分岐命令511、第三分岐命令
512および第五分岐命令514の4個なので、「4」
を変数Bに代入する。
Increasing amount calculation processing 30 up to the jump destination in FIG.
8 shows how many branch instructions to be subjected to the optimization process 106 of FIG. It is calculated whether or not there is, and the calculated number of branch instructions is substituted into the variable B. In this case, since the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fifth branch instruction 514 in FIG.
Is substituted into the variable B.

【0025】図10の相対アドレス代入処理309によ
り変数cpの指す分岐命令情報テーブルの図8の第五分
岐命令514の飛び先である第五飛び先524のアドレ
スから変数cpの指す分岐命令情報テーブルの第五分岐
命令514のアドレスを減算し、変数mrlに代入す
る。この場合は−128バイトなので、「−128」を
変数mrlに代入する。
The branch instruction information table pointed to by the variable cp from the address of the fifth jump destination 524 which is the jump destination of the fifth branch instruction 514 shown in FIG. The address of the fifth branch instruction 514 is subtracted and is substituted into the variable mrl. In this case, since it is -128 bytes, "-128" is assigned to the variable mrl.

【0026】そして、図10のシンボル参照判別処理3
10により変数cpの指す分岐命令情報テーブルの図8
の分岐命令514が前方参照であるか後方参照であるか
を判別する。この場合は後方参照なので、図10の相対
値を変数maxrにセット処理313により変数mrl
を変数maxrに代入し、コード増加量と相対値とを変
数minrにセット処理314により変数mrlと変数
Bとを加算し、加算した結果から変数Aを減算した結果
を変数minrに代入する。この場合は変数minrに
「−128」が代入され、変数maxrに「−128」
が代入される。
Then, the symbol reference determination process 3 of FIG.
8 of the branch instruction information table pointed to by the variable cp by 10
It is determined whether the branch instruction 514 of (1) is a forward reference or a backward reference. In this case, since it is a backward reference, the relative value of FIG.
Is assigned to the variable maxr, the code increase amount and the relative value are set to the variable minr, the variable mrl and the variable B are added by the setting process 314, and the result of subtracting the variable A from the added result is assigned to the variable minr. In this case, "-128" is assigned to the variable minr, and "-128" is assigned to the variable maxr.
Is substituted.

【0027】次に、図11の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合は
変数maxrと変数minrとが共に「−128」であ
るので、2バイト分の分岐命令出力判別処理315の条
件が成り立ち、2バイト分の分岐命令を生成することに
確定し、フラグセット処理318へ進む。フラグセット
処理318では図8の第五分岐命令514が2バイト分
の分岐命令を生成することに確定したので、2バイト分
または3バイト分に確定したことを表す変数flagに
「1」を代入する。
Next, a 2-byte branch instruction output determination process 315 and a 3-byte branch instruction output determination process 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since the variables maxr and minr are both "-128", the condition of the 2-byte branch instruction output determination processing 315 is satisfied, and it is decided that the 2-byte branch instruction is generated, and the flag is set. Go to processing 318. In the flag setting process 318, since it is determined that the fifth branch instruction 514 of FIG. 8 generates a branch instruction of 2 bytes, "1" is assigned to the variable flag indicating that it is determined to be 2 bytes or 3 bytes. To do.

【0028】さらに、図11のコード増加量セット処理
319により変数cpの指す分岐命令情報テーブルの分
岐命令が2バイト分または3バイト分に確定したことを
表す変数codeに「0」を代入し、分岐命令情報テー
ブル判別処理320へ進む。分岐命令情報テーブル判別
処理320では、変数cpの指す分岐命令情報テーブル
の次の分岐命令情報テーブルが存在するか否かを判別す
る。この場合は次の分岐命令情報テーブルが存在するの
で、ポインタインクリメント処理321へ進み、変数c
pに分岐命令情報テーブルのサイズ分を加算し、変数c
pが次の分岐命令情報テーブルを指すようにして図10
の増加量判別処理306へ進み、図8の第六分岐命令5
15、第七分岐命令516および第八分岐命令517に
対して第五分岐命令514と同様の処理を行う。第六分
岐命令515と第六飛び先525との間に図2の最適化
処理106の対象となる分岐命令が存在せずかつ第六飛
び先525のアドレスから第六分岐命令515のアドレ
スを減算した値が「−128」以上であるので、第六分
岐命令は2バイト分の分岐命令を生成することに確定す
る。
Further, "0" is assigned to the variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes by the code increase amount setting processing 319 of FIG. The process proceeds to the branch instruction information table discrimination processing 320. In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to the pointer increment processing 321 and the variable c
The size of the branch instruction information table is added to p, and the variable c
10 so that p points to the next branch instruction information table.
Of the sixth branch instruction 5 of FIG.
15, the seventh branch instruction 516 and the eighth branch instruction 517 are processed in the same manner as the fifth branch instruction 514. The sixth branch instruction 515 and the sixth jump destination 525 do not have a branch instruction to be subjected to the optimization processing 106 of FIG. 2 and the address of the sixth branch instruction 515 is subtracted from the address of the sixth jump destination 525. Since the value obtained is "-128" or more, the sixth branch instruction is determined to generate a 2-byte branch instruction.

【0029】第七分岐命令516および第八分岐命令5
17も第六分岐命令と同様に2バイト分の分岐命令を生
成することに確定する。
Seventh branch instruction 516 and eighth branch instruction 5
Similarly to the sixth branch instruction, 17 is also determined to generate a 2-byte branch instruction.

【0030】次に第九分岐命令518の処理および第十
分岐命令519を行う。第九分岐命令518と第九飛び
先528との間に図2の最適化処理106の対象となる
第十分岐命令519が存在しかつ第十分岐命令519が
2バイト分の分岐命令に確定した場合は、第九分岐命令
518も2バイト分の分岐命令に確定し、第十分岐命令
519が3バイト分の分岐命令に確定した場合は第九分
岐命令518も3バイト分の分岐命令に確定するので、
第十分岐命令519が確定しないと第九分岐命令518
は確定しない。第十分岐命令519も同様に第九分岐命
令518が確定しないと2バイト分の分岐命令を生成す
るか3バイト分の分岐命令を生成するかが確定しない。
Next, the processing of the ninth branch instruction 518 and the tenth branch instruction 519 are performed. Between the ninth branch instruction 518 and the ninth jump destination 528 is the tenth branch instruction 519 that is the target of the optimization processing 106 of FIG. 2 and the tenth branch instruction 519 is determined to be a 2-byte branch instruction. If the ninth branch instruction 518 is determined to be a 2-byte branch instruction, and if the tenth branch instruction 519 is determined to be a 3-byte branch instruction, the ninth branch instruction 518 is also determined to be a 3-byte branch instruction. So
If the tenth branch instruction 519 is not determined, the ninth branch instruction 518
Is not confirmed. Similarly, for the tenth branch instruction 519, if the ninth branch instruction 518 is not determined, it is not determined whether to generate a 2-byte branch instruction or a 3-byte branch instruction.

【0031】第十分岐命令519まで処理が終了すると
フラグ判別処理322へ進む。フラグ判別処理322で
は、2バイト分の分岐命令を生成するか3バイト分の分
岐命令を生成するかが確定すると、「1」にセットされ
る変数flagが「1」であるか否かを判別する。変数
flagが「1」の場合は、2バイト分の分岐命令を生
成するか3バイト分の分岐命令を生成するかが確定した
分岐命令があるということであり、2バイト分の分岐命
令を生成するか3バイト分の分岐命令を生成するかが確
定した分岐命令が、いままで2バイト分の分岐命令を生
成するか3バイト分の分岐命令を生成するかが未確定で
あったために、2バイト分の分岐命令を生成するか3バ
イト分の分岐命令を生成するか確定できなかった分岐命
令が2バイト分の分岐命令を生成するか、3バイト分の
分岐命令を生成するか確定できる可能性があるので、先
頭アドレス代入処理301へ進む。これで1回目の図2
の最適化処理106が終了する。
When the processing up to the tenth branch instruction 519 is completed, the flow proceeds to flag determination processing 322. In the flag determination processing 322, when it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes, it is determined whether the variable flag set to "1" is "1". To do. If the variable flag is "1", it means that there is a branch instruction that determines whether a 2-byte branch instruction or a 3-byte branch instruction is generated, and a 2-byte branch instruction is generated. Whether a branch instruction for 2 bytes or a branch instruction for 3 bytes has been determined so far. Whether a branch instruction for bytes or a branch instruction for 3 bytes could not be determined can be determined for a branch instruction that generates a branch instruction for 2 bytes or a branch instruction for 3 bytes. Therefore, the process proceeds to the head address substitution processing 301. This is the first time Figure 2
The optimization process 106 of ends.

【0032】2バイト分の分岐命令を生成することに確
定した分岐命令は、図8の第四分岐命令513、第五分
岐命令514、第六分岐命令515、第七分岐命令51
6および第八分岐命令517の5個である。次に2回目
の図2の最適化処理106を行う。図8の第三分岐命令
512と第三飛び先522との間に図2の最適化処理1
06の対象となる分岐命令が存在せずかつ第三飛び先5
22のアドレスから第三分岐命令512のアドレスを減
算して値が「127」以下であるので、第三分岐命令は
2バイト分の分岐命令を生成することに確定する。3回
目の図2の最適化処理106を行うと、図8の第二分岐
命令511と第二飛び先521との間に図2の最適化処
理106の対象となる分岐命令が存在せずかつ第二飛び
先521のアドレスから第二分岐命令511のアドレス
を減算した値が「127」以下であるので、第二分岐命
令は2バイト分の分岐命令を生成することに確定する。
The branch instructions decided to generate a 2-byte branch instruction are the fourth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, and the seventh branch instruction 51 in FIG.
6 and the eighth branch instruction 517. Next, the second optimization processing 106 of FIG. 2 is performed. Between the third branch instruction 512 and the third jump destination 522 of FIG. 8, the optimization process 1 of FIG.
No target branch instruction of 06 exists and the third jump destination 5
Since the value of "22" or less is obtained by subtracting the address of the third branch instruction 512 from the address of 22, the third branch instruction is determined to generate a 2-byte branch instruction. When the third optimization process 106 of FIG. 2 is performed, there is no branch instruction to be the optimization process 106 of FIG. 2 between the second branch instruction 511 and the second jump destination 521 of FIG. Since the value obtained by subtracting the address of the second branch instruction 511 from the address of the second jump destination 521 is "127" or less, the second branch instruction is determined to generate a branch instruction of 2 bytes.

【0033】4回目の図2の最適化処理106を行う
と、図8の第一分岐命令510と第一飛び先520との
間に図2の最適化処理106の対象となる分岐命令が存
在せずかつ第一飛び先520のアドレスから第一分岐命
令510のアドレスを減算した値が「127」以下であ
るので、第一分岐命令510は2バイト分の分岐命令を
生成することに確定する。
When the optimization process 106 of FIG. 2 is performed a fourth time, there is a branch instruction to be the optimization process 106 of FIG. 2 between the first branch instruction 510 and the first jump destination 520 of FIG. Since the value obtained by subtracting the address of the first branch instruction 510 from the address of the first jump destination 520 is "127" or less, the first branch instruction 510 is determined to generate a 2-byte branch instruction. ..

【0034】5回目の図2の最適化処理106では、図
10の増加量判別処理306により変数cpの指す分岐
命令情報テーブルの図8の第一分岐命令510が2バイ
ト分の分岐命令かまたは3バイト分の分岐命令に確定し
ているかを判別する。この場合は確定しているので、図
11の分岐命令情報テーブル判別処理320へ進む。分
岐命令情報テーブル判別処理320では、変数cpの指
す分岐命令情報テーブルの次の分岐命令情報テーブルが
存在するか否かを判別する。この場合は図8の第一分岐
命令510が最後の分岐命令でないので、図11のポイ
ンタインクリメント処理321へ進んで変数cpに分岐
命令情報テーブルのサイズ分を加算し、変数cpが次の
分岐命令情報テーブルを指すようにして図10の増加量
判別処理306へ進む。
In the fifth optimization processing 106 of FIG. 2, the first branch instruction 510 of FIG. 8 in the branch instruction information table pointed to by the variable cp is the branch instruction of 2 bytes or not by the increase amount determination processing 306 of FIG. It is determined whether the branch instruction for 3 bytes is fixed. In this case, since it has been decided, the process proceeds to the branch instruction information table discrimination processing 320 of FIG. In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the first branch instruction 510 of FIG. 8 is not the last branch instruction, the procedure proceeds to the pointer increment processing 321 of FIG. 11, and the variable cp is added with the size of the branch instruction information table, and the variable cp is the next branch instruction. The process proceeds to the increase amount determination processing 306 of FIG. 10 by pointing to the information table.

【0035】図8の第二分岐命令511、第三分岐命令
512、第四分岐命令513、第五分岐命令514、第
六分岐命令515、第七分岐命令516および第八分岐
命令517も第一分岐命令510と同様に2バイト分の
分岐命令かまたは3バイト分の分岐命令に確定している
ので第一分岐命令510と同じ処理を繰り返す。
The second branch instruction 511, the third branch instruction 512, the fourth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516 and the eighth branch instruction 517 of FIG. Similar to the branch instruction 510, since the branch instruction for 2 bytes or the branch instruction for 3 bytes is determined, the same processing as the first branch instruction 510 is repeated.

【0036】次に、第十分岐命令519が2バイト分の
分岐命令または3バイト分の分岐命令のいずれかに確定
しなければ、第九分岐命令518が2バイト分の分岐命
令かまたは3バイト分の分岐命令かに確定できない。同
様に第九分岐命令518が2バイト分の分岐命令または
3バイト分の分岐命令のいずれかに確定しなければ第十
分岐命令519が2バイト分の分岐命令かまたは3バイ
ト分の分岐命令かに確定できない。5回目の図2の最適
化処理106では2バイト分の分岐命令または3バイト
分の分岐命令のいずれかに確定した分岐命令がないの
で、変数flagは「0」である。図11のフラグ判別
処理322により変数flagが「0」なのでシンボル
テーブル補正処理323へ進む。シンボルテーブル補正
処理323はシンボルテーブルを作成したときに2バイ
ト分の分岐命令を生成すると仮定してシンボル値を決定
していたので、3バイト分の分岐命令を生成することに
確定した分岐命令がある場合は、3バイト分の分岐命令
を生成する数分シンボルのアドレス値に加算する処理を
行う。以上5回目で図2の最適化処理106を終了す
る。
Next, if the tenth branch instruction 519 is not determined to be either a 2-byte branch instruction or a 3-byte branch instruction, the ninth branch instruction 518 is a 2-byte branch instruction or a 3-byte branch instruction. It is not possible to determine whether it is a minute branch instruction. Similarly, if the ninth branch instruction 518 is not determined to be a 2-byte branch instruction or a 3-byte branch instruction, then the 10th branch instruction 519 is a 2-byte branch instruction or a 3-byte branch instruction. I can't confirm. In the optimization process 106 of FIG. 2 for the fifth time, the variable flag is “0” because there is no confirmed branch instruction in either the 2-byte branch instruction or the 3-byte branch instruction. Since the variable flag is "0" by the flag determination processing 322 of FIG. 11, the processing proceeds to the symbol table correction processing 323. Since the symbol table correction processing 323 has determined the symbol value on the assumption that a 2-byte branch instruction is generated when the symbol table is created, the branch instruction determined to generate a 3-byte branch instruction is If there is, a process of adding to the address value of the symbol for the number of times the branch instruction for 3 bytes is generated is performed. The optimization process 106 of FIG. 2 is completed at the fifth time.

【0037】もう一つの従来例方式は、分岐命令のアド
レスが小さい分岐命令の順に最適化処理を行っていた。
図13は従来技術のアセンブラ処理方式の一例の流れ図
である。図22は従来技術の分岐命令情報テーブル作成
処理の一例の流れ図である。図23および図24は従来
技術の最適化処理方式の一例の流れ図である。
In another conventional method, the optimization processing is performed in the order of the branch instruction having the smallest branch instruction address.
FIG. 13 is a flowchart of an example of a conventional assembler processing method. FIG. 22 is a flow chart of an example of a conventional branch instruction information table creating process. 23 and 24 are flowcharts of an example of a conventional optimization processing method.

【0038】前方参照のときは分岐命令から分岐命令の
飛び先までのバイト数が127バイト以下であれば2バ
イト分の分岐命令を生成し、128バイト以上であれば
3バイト分の分岐命令を生成し、後方参照のときは分岐
命令から分岐命令の飛び先までのバイト数の絶対値12
8バイト以下であれば2バイト分の分岐命令を生成し、
絶対値129バイト以上であれば3バイト分の分岐命令
を生成するアセンブラで、図13に示すように、パス1
ソース解析処理105で行の解析結果が分岐命令である
と、図22の処理で図13の分岐命令の情報を分岐命令
情報テーブル107に設定する。図20(a)は図13
の分岐命令情報テーブルのテーブルの繋がりを示した図
である。図20(b)は図13の分岐命令情報テーブル
を詳細に説明した図である。
In the case of forward reference, if the number of bytes from the branch instruction to the jump destination of the branch instruction is 127 bytes or less, a 2-byte branch instruction is generated, and if it is 128 bytes or more, a 3-byte branch instruction is generated. Absolute value of the number of bytes from the branch instruction to the jump destination of the branch instruction 12
If it is 8 bytes or less, a branch instruction for 2 bytes is generated,
If the absolute value is 129 bytes or more, it is an assembler that generates a branch instruction for 3 bytes.
If the line analysis result in the source analysis processing 105 is a branch instruction, the information of the branch instruction of FIG. 13 is set in the branch instruction information table 107 in the processing of FIG. FIG. 20 (a) is shown in FIG.
5 is a diagram showing the connection of tables of the branch instruction information table of FIG. FIG. 20B is a diagram illustrating the branch instruction information table of FIG. 13 in detail.

【0039】分岐命令情報テーブル107は、図20
(b)の次のテーブルを指すチェインポインタ440
と、分岐命令のアドレス442と、シンボルテーブルを
指すチェインポインタ443と、コード増加量444と
で構成される。図22に示す分岐命令のアドレスセット
処理200で、分岐命令の次のアドレスを現在処理して
いる図13の分岐命令情報テーブル107にある変数a
ddに代入する。図22に示すシンボルテーブルのアド
レスセット処理201で、シンボルテーブルのアドレス
を現在処理している図2の分岐命令情報テーブル107
にある変数sympに代入する。
The branch instruction information table 107 is shown in FIG.
Chain pointer 440 that points to the table next to (b)
, A branch instruction address 442, a chain pointer 443 pointing to the symbol table, and a code increment 444. In the address setting process 200 of the branch instruction shown in FIG. 22, the variable a in the branch instruction information table 107 of FIG. 13 which is currently processing the next address of the branch instruction.
Substitute in dd. In the symbol table address set processing 201 shown in FIG. 22, the branch instruction information table 107 of FIG.
To the variable symp at.

【0040】コード増加量セット処理202で、2バイ
ト分の分岐命令を生成するか3バイト分の分岐命令を生
成するか未確定であることを示すコード増加量の初期値
として「1」を現在処理している図13の分岐命令情報
テーブル107にある変数codeに代入する。次のテ
ーブルのアドレスセット処理203で、次の分岐命令情
報テーブルを作成し、作成した次の分岐命令情報テーブ
ルのアドレスを変数nextに代入する。現在のテーブ
ルのアドレスセット処理205で、現在処理中の分岐命
令情報テーブルのアドレスを図20(a)の分岐命令情
報テーブルの末尾を指すチェインポインタ401に代入
する。
In the code increment setting process 202, "1" is currently set as the initial value of the code increment indicating that it is uncertain whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. It is assigned to the variable code in the branch instruction information table 107 of FIG. 13 being processed. In the address setting process 203 of the next table, the next branch instruction information table is created, and the address of the created next branch instruction information table is assigned to the variable next. In the address setting process 205 of the current table, the address of the branch instruction information table currently being processed is assigned to the chain pointer 401 pointing to the end of the branch instruction information table of FIG.

【0041】図13に示すパス1ソース解析処理105
をファイルの最後まで行い、終了後に分岐命令の最適化
をする最適化処理106を行う。最適化処理106で
は、図23に示す先頭アドレス代入処理301で図20
(a)で示される分岐命令情報テーブルの先頭を指すチ
ェインポインタ400を変数cpに代入し、図23のフ
ラグ初期化処理305で分岐命令が2バイト分または3
バイト分に確定したことを表す変数flagに初期値と
して「0」を代入する。
Path 1 source analysis processing 105 shown in FIG.
Is executed to the end of the file, and after the completion, the optimization process 106 for optimizing the branch instruction is executed. In the optimization process 106, the start address substitution process 301 shown in FIG.
The chain pointer 400 that points to the beginning of the branch instruction information table shown in (a) is assigned to the variable cp, and the branch instruction corresponds to 2 bytes or 3 in the flag initialization processing 305 of FIG.
As the initial value, "0" is substituted into the variable flag indicating that it has been determined in bytes.

【0042】増加量判別処理306により変数cpの指
す分岐命令情報テーブル107の分岐命令が2バイト分
の分岐命令かまたは3バイト分の分岐命令に確定してい
るか否かを判別し、確定していれば図24の分岐命令情
報テーブル判別処理320へ進む。確定していなければ
図23の分岐命令までの増加量算出処理307によりフ
ァイルの先頭から変数cpの指す分岐命令情報テーブル
の分岐命令までに図13の最適化処理106の対象とな
る分岐命令がいくつあるかを算出し、算出した分岐命令
の数を変数Aに代入する。図23の飛び先までの増加量
算出処理308によりファイルの先頭から変数cpの指
す分岐命令情報テーブルの分岐命令の飛び先までに図1
3の最適化処理106の対象となる分岐命令がいくつあ
るか算出し、算出した分岐命令の数を変数Bに代入す
る。
The increase amount determination processing 306 determines whether the branch instruction of the branch instruction information table 107 indicated by the variable cp is a 2-byte branch instruction or a 3-byte branch instruction, and is determined. If so, the process proceeds to the branch instruction information table determination processing 320 of FIG. If not determined, how many branch instructions are subject to the optimization processing 106 in FIG. 13 from the head of the file to the branch instruction in the branch instruction information table pointed to by the variable cp by the increase amount calculation processing 307 up to the branch instruction in FIG. It is calculated whether or not there is, and the calculated number of branch instructions is substituted into the variable A. From the beginning of the file to the jump destination of the branch instruction in the branch instruction information table pointed to by the variable cp by the increase amount calculation processing 308 to the jump destination in FIG.
The number of branch instructions to be the target of the optimization processing 106 of 3 is calculated, and the calculated number of branch instructions is substituted into the variable B.

【0043】図23の相対アドレス代入処理309によ
り変数cpの指す分岐命令情報テーブルの分岐命令の飛
び先のアドレスから変数cpの指す分岐命令情報テーブ
ルの分岐命令のアドレスを減算し、変数mrlに代入す
る。そして、シンボル参照判別処理310により変数c
pの指す分岐命令情報テーブルの分岐命令が前方参照で
あるか後方参照であるかを判別する。変数mrlが
「0」以下であれば後方参照であり、「1」以上であれ
ば前方参照である。シンボル参照判別処理310の結果
が前方参照の場合は、相対値を変数minrにセット処
理311により変数mrlを変数minrに代入し、コ
ード増加量と相対値を変数maxrにセット処理312
とにより変数mrlを変数minrに代入し、コード増
加量と相対値を変数maxrにセット処理312とによ
り変数mrlと変数Bとを加算し、加算した結果から変
数Aを減算した結果を変数maxrに代入する。
By the relative address assignment processing 309 of FIG. 23, the address of the branch instruction of the branch instruction information table pointed to by the variable cp is subtracted from the address of the branch instruction jump destination of the branch instruction information table pointed to by the variable cp, and assigned to the variable mrl. To do. Then, the variable c is determined by the symbol reference determination processing 310.
It is determined whether the branch instruction in the branch instruction information table pointed to by p is forward reference or backward reference. If the variable mrl is "0" or less, it is backward reference, and if it is "1" or more, it is forward reference. When the result of the symbol reference determination processing 310 is forward reference, the relative value is set in the variable minr, the variable mrl is substituted in the variable minr by the processing 311, and the code increase amount and the relative value are set in the variable maxr 312.
The variable mrl is substituted into the variable minr by and the variable mrl and the variable B are added to the variable maxr by the setting process 312, and the result of subtracting the variable A from the addition result is set to the variable maxr. substitute.

【0044】また後方参照の場合は、相対値を変数ma
xrにセット処理313により変数mrlを変数max
rに代入し、コード増加量と相対値を変数minrにセ
ット処理314とにより変数mrlと変数Bとを加算
し、加算した結果から変数Aを減算した結果を変数mi
nrに代入する。
In the case of back reference, the relative value is set to the variable ma.
The variable mrl is set to the variable max by the setting process 313 in which xr is set.
Substituting for r, the code increase amount and the relative value are set to the variable minr by the setting process 314, the variable mrl and the variable B are added, and the result of subtracting the variable A from the added result is the variable mi.
Substitute in nr.

【0045】次に、図24の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行い、3バイト分
の分岐命令を生成する必要がある場合は、分岐命令のア
ドレス補正処理317により現在処理している分岐命令
情報テーブルの次の分岐命令情報テーブルから変数bt
mが指す分岐命令情報テーブルに格納されている分岐命
令のアドレスに「1」加算する。フラグセット処理31
8で分岐命令が2バイト分または3バイト分のいずれか
に確定したことを表す変数flagに「1」を代入す
る。2バイト分の分岐命令を生成することに確定した場
合も同様に変数flagに「1」を代入する。さらに、
コード増加量セット処理319により変数cpの指す分
岐命令情報テーブルの分岐命令が2バイト分または3バ
イト分に確定したことを表す変数codeに「0」を代
入する。
Next, the 2-byte branch instruction output discrimination processing 315 and the 3-byte branch instruction output discrimination processing 3 of FIG.
16 determines whether to generate a 2-byte branch instruction or a 3-byte branch instruction, and if a 3-byte branch instruction needs to be generated, a branch instruction address correction process 317 is performed. Variable bt from the branch instruction information table next to the branch instruction information table currently being processed by
"1" is added to the address of the branch instruction stored in the branch instruction information table pointed to by m. Flag setting process 31
In step 8, "1" is assigned to a variable flag indicating that the branch instruction is determined to be either 2 bytes or 3 bytes. Similarly, when it is decided to generate a 2-byte branch instruction, "1" is similarly substituted into the variable flag. further,
By the code increase amount setting process 319, "0" is assigned to the variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes.

【0046】変数cpの指す分岐命令情報テーブルの分
岐命令と変数cpの指す分岐命令情報テーブルの分岐命
令の飛び先との間に2バイト分の分岐命令になるかまた
は3バイト分の分岐命令になるか不確定な分岐命令があ
りかつ不確定な分岐命令がすべて2バイト分の分岐命令
となったとき、または変数cpの指す分岐命令情報テー
ブルの分岐命令が2バイト分の分岐命令になる場合また
不確定な分岐命令がすべて3バイト分の分岐命令となっ
たときは、変数cpの指す分岐命令情報テーブルの分岐
命令が3バイト分の分岐命令になる場合には分岐命令情
報テーブル判別処理320へ進む。分岐命令情報テーブ
ル判別処理320では、変数cpの指す分岐命令情報テ
ーブルの次の分岐命令情報テーブルがあるか否かを判別
し、ある場合にはポインタインクリメント処理321に
より変数cpに分岐命令情報テーブルのサイズ分を加算
し、変数cpが次の分岐命令情報テーブルを指すように
して図23の増加量判別処理306へ進む。
A branch instruction of 2 bytes or a branch instruction of 3 bytes is provided between the branch instruction of the branch instruction information table pointed to by the variable cp and the jump destination of the branch instruction of the branch instruction information table pointed to by the variable cp. Or there are uncertain branch instructions and all uncertain branch instructions have become 2-byte branch instructions, or when the branch instruction in the branch instruction information table pointed to by the variable cp becomes 2-byte branch instructions. Further, when all the undefined branch instructions become branch instructions of 3 bytes, when the branch instruction of the branch instruction information table pointed to by the variable cp becomes a branch instruction of 3 bytes, the branch instruction information table discrimination processing 320 Go to. In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. If there is, the pointer increment processing 321 sets the variable cp to the branch instruction information table. The size is added, the variable cp points to the next branch instruction information table, and the process proceeds to the increase amount determination processing 306 in FIG.

【0047】次の分岐命令情報テーブルがない場合は、
図24のフラグ判別処理322により分岐命令が2バイ
ト分または3バイト分に確定したことを表す変数fla
gが「0」であるか否かを判別し、「1」であればまだ
最適化できる可能性があるので図23の先頭アドレス代
入処理301に戻る。変数flagが「0」の場合は図
24のシンボルテーブル補正処理323へ進み、シンボ
ルテーブルの補正処理を行う。
If there is no next branch instruction information table,
A variable fla indicating that the branch instruction has been fixed to 2 bytes or 3 bytes by the flag determination processing 322 of FIG.
It is determined whether or not g is "0", and if it is "1", there is a possibility that optimization can still be performed, so the process returns to the head address substitution processing 301 of FIG. When the variable flag is "0", the process proceeds to the symbol table correction process 323 of FIG. 24, and the symbol table correction process is performed.

【0048】次に、分岐命令の最適化処理を図21で示
すファイルを入力した場合について説明する。このとき
に図20(a)に示す分岐命令情報テーブルを作成す
る。ただし、図21で、分岐命令が2バイト分の分岐命
令である場合の分岐命令から分岐命令の飛び先までのバ
イト数(飛び先のアドレス−分岐命令のアドレス)は、
第一分岐命令510から第一飛び先520まで127バ
イト、第二分岐命令511から第二飛び先521まで1
27バイト、第三分岐命令512から第三飛び先522
まで127バイト、第四分岐命令513から第四飛び先
523まで120バイト、第五分岐命令514から第五
飛び先524まで−128バイト、第六分岐命令515
から第六飛び先525まで−128バイト、第七分岐命
令516から第七飛び先526まで−128バイト、第
八分岐命令517から第八飛び先527まで−128バ
イト、第九分岐命令518から第九飛び先528まで1
27バイト、第十分岐命令519から第十飛び先529
まで−128バイトとする。
Next, the optimization processing of the branch instruction will be described for the case where the file shown in FIG. 21 is input. At this time, the branch instruction information table shown in FIG. 20A is created. However, in FIG. 21, when the branch instruction is a 2-byte branch instruction, the number of bytes from the branch instruction to the jump destination of the branch instruction (jump destination address-branch instruction address) is
127 bytes from the first branch instruction 510 to the first jump destination 520, 1 from the second branch instruction 511 to the second jump destination 521
27 bytes, third branch instruction 512 to third jump destination 522
Up to 127 bytes, 120 bytes from the fourth branch instruction 513 to the fourth jump destination 523, -128 bytes from the fifth branch instruction 514 to the fifth jump destination 524, the sixth branch instruction 515
To the sixth jump destination 525 -128 bytes, the seventh branch instruction 516 to the seventh jump destination 526 -128 bytes, the eighth branch instruction 517 to the eighth jump destination 527 -128 bytes, the ninth branch instruction 518 to the 9 up to 528 1
27 bytes, 10th branch instruction 519 to 1029th destination 529
Up to -128 bytes.

【0049】図21のソースプログラムファイルを入力
し、図13のパス1ソース解析処理105で行の解析を
した結果として図21の第一分岐命令510が出現する
と、図22の処理で、分岐命令の情報を図13の分岐命
令情報テーブル107に設定する。図22の分岐命令の
アドレスセット処理200で、図21の第一分岐命令5
10の次のアドレスを図20(a)の第一分岐命令51
0の分岐命令情報テーブル430が持つ変数addに代
入する。図22のシンボルテーブルのアドレスセット処
理201で、図21の第一飛び先520のシンボルテー
ブルのアドレスを図20(a)の第一分岐命令の分岐命
令情報テーブル430が持つ変数sympに代入する。
図22のコード増加量セット処理202で、2バイト分
の分岐命令を生成するか3バイト分の分岐命令を生成す
るか未確定であることを示す「1」をコード増加量の初
期値として、図20(a)の第一分岐命令の分岐命令情
報テーブル430が持つ変数codeに代入する。図2
2の次のテーブルのアドレスセット処理203で、次の
分岐命令情報テーブルを作成し、作成した次の分岐命令
情報テーブルのアドレスを図20(a)の第一分岐命令
の分岐命令情報テーブル430が持つ変数nextに代
入する。
When the source program file of FIG. 21 is input and the first branch instruction 510 of FIG. 21 appears as a result of line analysis in the path 1 source analysis processing 105 of FIG. 13, a branch instruction is executed in the processing of FIG. Information is set in the branch instruction information table 107 of FIG. In the address setting process 200 of the branch instruction of FIG. 22, the first branch instruction 5 of FIG.
The address next to 10 is set to the first branch instruction 51 in FIG.
It is assigned to the variable add of the branch instruction information table 430 of 0. In the address setting process 201 of the symbol table of FIG. 22, the address of the symbol table of the first jump destination 520 of FIG. 21 is assigned to the variable symp of the branch instruction information table 430 of the first branch instruction of FIG.
In the code increase amount setting process 202 of FIG. 22, "1" indicating whether to generate a 2-byte branch instruction or a 3-byte branch instruction is undetermined is set as the initial value of the code increase amount, and It is substituted into the variable code held in the branch instruction information table 430 of the first branch instruction in FIG. Figure 2
The address of the next branch instruction information table created in the address setting process 203 of the table next to No. 2 is the branch instruction information table 430 of the first branch instruction of FIG. Substitute for the variable next.

【0050】図22のアドレスセット処理205で、図
20(a)の第一分岐命令の分岐命令情報テーブル43
0のアドレスを最後の分岐命令情報テーブルを指す変数
btmに代入する。これで図20(a)の第一分岐命令
の分岐命令情報テーブル430が作成される。以下同じ
ように図21の第二分岐命令511、第三分岐命令51
2、第四分岐命令513、第五分岐命令514、第六分
岐命令515、第七分岐命令516、第八分岐命令51
7、第九分岐命令518および第十分岐命令519につ
いて行い、各々の分岐命令情報テーブルを作成する。終
了後に分岐命令の最適化をする図13の最適化処理10
6を行う。
In the address setting process 205 of FIG. 22, the branch instruction information table 43 of the first branch instruction of FIG.
The address of 0 is assigned to the variable btm that points to the last branch instruction information table. With this, the branch instruction information table 430 of the first branch instruction of FIG. 20A is created. Similarly, the second branch instruction 511 and the third branch instruction 51 of FIG.
2, fourth branch instruction 513, fifth branch instruction 514, sixth branch instruction 515, seventh branch instruction 516, eighth branch instruction 51
7, the ninth branch instruction 518 and the tenth branch instruction 519 are performed, and each branch instruction information table is created. Optimization process 10 of FIG. 13 for optimizing the branch instruction after completion.
Do 6.

【0051】図13の最適化処理106では、図23の
先頭アドレス代入処理301で、分岐命令情報テーブル
の先頭を指す図20(a)の先頭を指すチェインポイン
タ400を変数cpに代入し、図23のフラグ初期化処
理305で、分岐命令が2バイト分または3バイト分に
確定したことを表す変数flagに初期値として「0」
を代入する。増加量判別処理306により、変数cpの
指す分岐命令情報テーブルの図21の第一分岐命令51
0が2バイト分の分岐命令かまたは3バイト分の分岐命
令に確定しているか否かを判別する。この場合は確定し
ていないので、図23の分岐命令までの増加量算出処理
307により、ファイルの先頭から変数cpの指す分岐
命令情報テーブルの図21の第一分岐命令510までに
図13の最適化処理106の対象となる分岐命令がいく
つ存在するか算出し、算出した分岐命令の数を変数Aに
代入する。この場合は自分自身の図21の第一分岐命令
510のみなので、「1」を変数Aに代入する。
In the optimization process 106 of FIG. 13, the chain pointer 400 that points to the beginning of the branch instruction information table in FIG. 20A is assigned to the variable cp in the beginning address assignment process 301 of FIG. In the flag initialization processing 305 of 23, the variable “flag” indicating that the branch instruction is fixed to 2 bytes or 3 bytes is set to “0” as an initial value.
Is substituted. By the increase amount determination processing 306, the first branch instruction 51 of FIG. 21 in the branch instruction information table pointed to by the variable cp.
It is determined whether 0 is a 2-byte branch instruction or a 3-byte branch instruction. In this case, since it has not been decided, by the increase amount calculation processing 307 up to the branch instruction of FIG. 23, the optimum of FIG. The number of branch instructions that are subject to the conversion process 106 is calculated, and the calculated number of branch instructions is substituted into the variable A. In this case, since it is only the first branch instruction 510 of its own in FIG. 21, "1" is assigned to the variable A.

【0052】図23の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図21の第一分岐命令510の飛び先であ
る図21の第一飛び先520までに図13の最適化処理
106の対象となる分岐命令がいくつ存在するか算出
し、算出した分岐命令の数を変数Bに代入する。この場
合は図21の第一分岐命令510、第二分岐命令51
1、第三分岐命令512および第四分岐命令513の4
個なので、「4」を変数Bに代入する。図23の相対ア
ドレス代入処理309により変数cpの指す分岐命令情
報テーブルの図21の第一分岐命令510の飛び先であ
る第一飛び先520のアドレスから変数cpの指す分岐
命令情報テーブルの第一分岐命令510のアドレスを減
算し、変数mrlに代入する。この場合は127バイト
なので、「127」を変数mrlに代入する。
Increase amount calculation processing 30 up to the jump destination in FIG.
8. From the beginning of the file to the first jump destination 520 of FIG. 21, which is the jump destination of the first branch instruction 510 of FIG. 21, in the branch instruction information table pointed to by the variable cp, which is the target of the optimization process 106 of FIG. The number of instructions existing is calculated, and the calculated number of branch instructions is substituted into the variable B. In this case, the first branch instruction 510 and the second branch instruction 51 of FIG.
1, 4 of the third branch instruction 512 and the fourth branch instruction 513
Since it is a piece, "4" is substituted into the variable B. By the relative address substitution processing 309 of FIG. 23, the first of the branch instruction information table pointed to by the variable cp from the address of the first jump destination 520 which is the destination of the first branch instruction 510 of FIG. The address of the branch instruction 510 is subtracted and substituted into the variable mrl. In this case, since it is 127 bytes, "127" is substituted for the variable mrl.

【0053】そして、図23のシンボル参照判別処理3
10により変数cpの指す分岐命令情報テーブルの図2
1の第一分岐命令510が前方参照であるか後方参照で
あるかを判別する。この場合は前方参照なので、図23
の相対値を変数minrにセット処理311により変数
mrlを変数minrに代入し、コード増加量と相対値
を変数maxrにセット処理312により変数mrlと
変数Bを加算し、加算した結果から変数Aを減算した結
果を変数maxrに代入する。この場合は変数minr
に「127」が代入され、変数maxrに「130」が
代入される。
Then, the symbol reference discrimination processing 3 of FIG.
2 of the branch instruction information table pointed to by the variable cp by 10
It is determined whether the first branch instruction 510 of 1 is a forward reference or a backward reference. In this case, since it is a forward reference, FIG.
The relative value of is set to the variable minr by the setting process 311 and the variable mrl is substituted into the variable minr. The code increase amount and the relative value are set to the variable maxr by the setting process 312. The result of the subtraction is substituted into the variable maxr. In this case, the variable minr
“127” is substituted into, and “130” is substituted into the variable maxr.

【0054】次に、図24の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合に
変数maxrが「130」であるので、2バイト分の分
岐命令出力判別処理315の条件が成り立たず、3バイ
ト分の分岐命令出力判別処理316へ進む。
Next, the 2-byte branch instruction output determination processing 315 and the 3-byte branch instruction output determination processing 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since the variable maxr is "130", the condition of the 2-byte branch instruction output determination process 315 is not satisfied, and the process proceeds to the 3-byte branch instruction output determination process 316.

【0055】変数maxrが「130」、変数minr
が「127」であるので3バイト分の分岐命令出力判別
処理316の条件は成り立ち、2バイト分の分岐命令を
生成するか3バイト分の分岐命令を生成するかが確定し
ないので分岐命令情報テーブル判別処理320へ進む。
分岐命令情報テーブル判別処理320では、変数cpの
指す分岐命令情報テーブルの次の分岐命令情報テーブル
が存在するか否かを判別する。この場合は次の分岐命令
情報テーブルが存在するのでポインタインクリメント処
理321へ進み、変数cpに分岐命令情報テーブルのサ
イズ分を加算し、変数cpが次の分岐命令情報テーブル
を指すようにして図23の増加量判別処理306へ進
み、図21の第二分岐命令511および第三分岐命令5
12に対して第一分岐命令510と同様の処理を行う。
The variable maxr is "130" and the variable minr
Is 127, the condition of the branch instruction output determination process 316 for 3 bytes is satisfied, and it is not determined whether the branch instruction for 2 bytes or the branch instruction for 3 bytes is generated. Proceed to the discrimination processing 320.
In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to the pointer increment processing 321, and the size of the branch instruction information table is added to the variable cp so that the variable cp points to the next branch instruction information table. 21 and the third branch instruction 5 of FIG. 21.
The same processing as that of the first branch instruction 510 is performed for 12.

【0056】第二分岐命令511および第三分岐命令5
12も第一分岐命令510と同様に2バイト分の分岐命
令を生成するか3バイト分の分岐命令を生成するかが確
定しない。次に第四分岐命令513の処理を行う。図2
3の増加量判別処理306により変数cpの指す分岐命
令情報テーブルの図21の第四分岐命令513が2バイ
ト分の分岐命令かまたは3バイト分の分岐命令に確定し
ているか否かを判別する。この場合は確定していないの
で、図23の分岐命令までの増加量算出処理307によ
りファイルの先頭から変数cpの指す分岐命令情報テー
ブルの図21の第四分岐命令513までに図13の最適
化処理106の対象となる分岐命令がいくつ存在するか
を算出し、算出した分岐命令の数を変数Aに代入する。
この場合は図8の第一分岐命令510、第二分岐命令5
11、第三分岐命令512および第四分岐命令513の
4個なので、「4」を変数Aに代入する。
Second branch instruction 511 and third branch instruction 5
Similarly to the first branch instruction 510, 12 also does not determine whether to generate a 2-byte branch instruction or a 3-byte branch instruction. Next, the fourth branch instruction 513 is processed. Figure 2
By the increase amount determination processing 306 of 3, it is determined whether the fourth branch instruction 513 in FIG. 21 of the branch instruction information table pointed to by the variable cp is a 2-byte branch instruction or a 3-byte branch instruction. . In this case, since it has not been decided, the optimization of FIG. 13 is performed from the head of the file to the fourth branch instruction 513 of FIG. 21 in the branch instruction information table pointed to by the variable cp by the increase amount calculation processing 307 up to the branch instruction of FIG. The number of branch instructions to be processed 106 is calculated, and the calculated number of branch instructions is assigned to the variable A.
In this case, the first branch instruction 510 and the second branch instruction 5 in FIG.
Since there are four, 11, the third branch instruction 512 and the fourth branch instruction 513, “4” is assigned to the variable A.

【0057】図23の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図21の第四分岐命令513の飛び先であ
る第四飛び先523までに図13の最適化処理106の
対象となる分岐命令がいくつ存在するかを算出し、算出
した分岐命令の数を変数Bに代入する。この場合は図2
1の第一分岐命令510、第二分岐命令511、第三分
岐命令512および第四分岐命令513の4個なので、
「4」を変数Bに代入する。
Increase amount calculation processing 30 up to the jump destination in FIG.
The number of branch instructions to be subjected to the optimization process 106 in FIG. 13 is determined from the head of the file to the fourth jump destination 523 in the branch instruction information table pointed to by the variable cp, which is the jump destination of the fourth branch instruction 513 in FIG. It is calculated whether or not there is, and the calculated number of branch instructions is substituted into the variable B. In this case,
Since the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fourth branch instruction 513 of 1 are four,
Substitute “4” into variable B.

【0058】図23の相対アドレス代入処理309によ
り変数cpの指す分岐命令情報テーブルの図21の第四
分岐命令513の飛び先である第四飛び先523のアド
レスから変数cpの指す分岐命令情報テーブルの第四分
岐命令513のアドレスを減算し、変数mrlに代入す
る。この場合は120バイトなので、「120」を変数
mrlに代入し、図23のシンボル参照判別処理310
により変数cpの指す分岐命令情報テーブルの図21の
第四分岐命令513が前方参照であるか後方参照である
かを判別する。この場合は前方参照なので、図23の算
出量セット処理311により変数mrlを変数minr
に代入し、コード増加量と相対値を変数maxrにセッ
ト処理312により変数mrlと変数Bを加算し、加算
した結果から変数Aを減算した結果を変数maxrに代
入する。この場合は変数minrに「120」が代入さ
れ、変数maxrに「120」が代入される。
The branch instruction information table pointed to by the variable cp from the address of the fourth jump destination 523 which is the jump destination of the fourth branch instruction 513 in FIG. 21 in the branch instruction information table pointed to by the variable cp by the relative address assignment processing 309 in FIG. The address of the fourth branch instruction 513 is subtracted and substituted into the variable mrl. In this case, since it is 120 bytes, "120" is assigned to the variable mrl, and the symbol reference determination processing 310 of FIG.
It is determined whether the fourth branch instruction 513 of FIG. 21 in the branch instruction information table pointed to by the variable cp is forward reference or backward reference. In this case, since it is a forward reference, the variable mrl is changed to the variable minr by the calculation amount setting process 311 of FIG.
, The code increase amount and the relative value are set to the variable maxr by the setting process 312, the variable mrl and the variable B are added, and the result of subtracting the variable A from the added result is substituted for the variable maxr. In this case, "120" is assigned to the variable minr and "120" is assigned to the variable maxr.

【0059】次に、図24の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合は
変数minrと変数maxrが共に「120」であるの
で、2バイト分の分岐命令出力判別処理315の条件が
成り立ち、フラグセット処理318へ進む。フラグセッ
ト処理318では図21の第四分岐命令513が2バイ
ト分の分岐命令を生成することに確定したので、2バイ
ト分または3バイト分に確定したことを表す変数fla
gに「1」を代入する。さらに、図24のコード増加量
セット処理319により変数cpの指す分岐命令情報テ
ーブルの分岐命令が2バイト分または3バイト分に確定
したことを表す変数codeに「0」を代入し、分岐命
令情報テーブル判別処理320へ進む。
Next, the 2-byte branch instruction output determination process 315 and the 3-byte branch instruction output determination process 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since the variables minr and maxr are both “120”, the condition of the branch instruction output determination process 315 for 2 bytes is satisfied, and the process proceeds to the flag setting process 318. In the flag setting process 318, it is decided that the fourth branch instruction 513 of FIG. 21 generates a branch instruction of 2 bytes, and therefore, a variable fla indicating that it is decided to be 2 bytes or 3 bytes.
Substitute “1” for g. Further, "0" is assigned to the variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes by the code increase amount setting processing 319 of FIG. The process proceeds to the table determination process 320.

【0060】分岐命令情報テーブル判別処理320で
は、変数cpの指す分岐命令情報テーブルの次の分岐命
令情報テーブルが存在するか否かを判別する。この場合
は次の分岐命令情報テーブルが存在するので、ポインタ
インクリメント処理321へ進み、変数cpに分岐命令
情報テーブルのサイズ分を加算し、変数cpが次の分岐
命令情報テーブルを指すようにして図23の増加量判別
処理306へ進む。
In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to the pointer increment processing 321, the variable cp is added with the size of the branch instruction information table, and the variable cp points to the next branch instruction information table. 23, the process proceeds to the increase amount determination process 306.

【0061】増加量判別処理306により変数cpの指
す分岐命令情報テーブルの図21の第五分岐命令514
が2バイト分の分岐命令または3バイト分の分岐命令の
いずれに確定しているかを判別する。この場合は確定し
ていないので、図23の分岐命令までの増加量算出処理
307によりファイルの先頭から変数cpの指す分岐命
令情報テーブルの図21の第五分岐命令514までに図
13の最適化処理106の対象となる分岐命令がいくつ
存在するかを算出し、算出した分岐命令の数を変数Aに
代入する。この場合は図21の第一分岐命令510、第
二分岐命令命令511、第三分岐命令512および第五
分岐命令514の4個なので、「4」を変数Aに代入す
る。
The fifth branch instruction 514 of FIG. 21 in the branch instruction information table pointed to by the variable cp by the increase amount determination processing 306.
Is determined to be a 2-byte branch instruction or a 3-byte branch instruction. In this case, since it has not been decided, the optimization of FIG. 13 is performed from the head of the file to the fifth branch instruction 514 of FIG. The number of branch instructions to be processed 106 is calculated, and the calculated number of branch instructions is assigned to the variable A. In this case, there are four first branch instruction 510, second branch instruction 511, third branch instruction 512, and fifth branch instruction 514 in FIG. 21, so “4” is assigned to variable A.

【0062】図23の飛び先までの増加量算出処理30
8によりファイルの先頭から変数cpの指す分岐命令情
報テーブルの図21の第五分岐命令514の飛び先であ
る第五飛び先524までに図13の最適化処理106の
対象となる分岐命令がいくつ存在するかを算出し、算出
した分岐命令の数を変数Bに代入する。この場合は図2
1の第一分岐命令510、第二分岐命令511、第三分
岐命令512および第五分岐命令514の4個なので、
「4」を変数Bに代入する。
Increase amount calculation processing 30 up to the jump destination in FIG.
The number of branch instructions subject to the optimization process 106 of FIG. 13 from the head of the file to the fifth jump destination 524 which is the jump destination of the fifth branch instruction 514 of FIG. It is calculated whether or not there is, and the calculated number of branch instructions is substituted into the variable B. In this case,
Since the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fifth branch instruction 514 of 1 are four,
Substitute “4” into variable B.

【0063】図23の相対アドレス代入処理309によ
り変数cpの指す分岐命令情報テーブルの図21の第五
分岐命令514の飛び先である第五飛び先524のアド
レスから変数cpの指す分岐命令情報テーブルの第五分
岐命令514のアドレスを減算し、変数mrlに代入す
る。この場合は−128バイトなので、「−128」を
変数mrlに代入する。そして、図23のシンボル参照
判別処理310により変数cpの指す分岐命令情報テー
ブルの図21の分岐命令514が前方参照であるか後方
参照であるかを判別する。この場合は後方参照なので、
図23の相対値を変数maxrにセット処理313によ
り変数mrlを変数maxrに代入し、コード増加量と
相対値とを変数minrにセット処理314により変数
mrlと変数Bとを加算し、加算した結果から変数Aを
減算した結果を変数minrに代入する。この場合は変
数minrに「−128」が代入され、変数maxrに
「−128」が代入される。
The branch instruction information table pointed to by the variable cp from the address of the fifth jump destination 524, which is the jump destination of the fifth branch instruction 514 shown in FIG. 21, in the branch instruction information table pointed to by the variable cp by the relative address substitution processing 309 shown in FIG. The address of the fifth branch instruction 514 is subtracted and is substituted into the variable mrl. In this case, since it is -128 bytes, "-128" is assigned to the variable mrl. Then, the symbol reference determination processing 310 of FIG. 23 determines whether the branch instruction 514 of FIG. 21 in the branch instruction information table pointed to by the variable cp is a forward reference or a backward reference. In this case it's a back reference, so
The result of adding the relative value in FIG. 23 to the variable maxr by substituting the variable mrl into the variable maxr by the setting processing 313, adding the code increase amount and the relative value to the variable minr by the setting processing 314, and adding the variable mrl and the variable B. The result of subtracting the variable A from is substituted into the variable minr. In this case, "-128" is assigned to the variable minr, and "-128" is assigned to the variable maxr.

【0064】次に、図24の2バイト分の分岐命令出力
判別処理315と3バイト分の分岐命令出力判別処理3
16とにより2バイト分の分岐命令を生成するか3バイ
ト分の分岐命令を生成するかの判別を行う。この場合は
変数maxrと変数minrとが共に「−128」であ
るので、2バイト分の分岐命令出力判別処理315の条
件が成り立ち、2バイト分の分岐命令を生成することに
確定し、フラグセット処理318へ進む。
Next, the 2-byte branch instruction output determination processing 315 and the 3-byte branch instruction output determination processing 3 of FIG.
With 16, it is determined whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes. In this case, since the variables maxr and minr are both "-128", the condition of the 2-byte branch instruction output determination processing 315 is satisfied, and it is decided that the 2-byte branch instruction is generated, and the flag is set. Go to processing 318.

【0065】フラグセット処理318では図21の第五
分岐命令514が2バイト分の分岐命令を生成すること
に確定したので、2バイト分または3バイト分に確定し
たことを表す変数flagに「1」を代入する。さら
に、図24のコード増加量セット処理319により変数
cpの指す分岐命令情報テーブルの分岐命令が2バイト
分または3バイト分に確定したことを表す変数code
に「0」を代入し、分岐命令情報テーブル判別処理32
0へ進む。分岐命令情報テーブル判別処理320では、
変数cpの指す分岐命令情報テーブルの次の分岐命令情
報テーブルが存在するか否かを判別する。この場合は次
の分岐命令情報テーブルが存在するので、ポインタイン
クリメント処理321へ進み、変数cpに分岐命令情報
テーブルのサイズ分を加算し、変数cpが次の分岐命令
情報テーブルを指すようにして図23の増加量判別処理
306へ進み、図21の第六分岐命令515および第七
分岐命令516に対して第五分岐命令514と同様の処
理を行う。
In the flag setting process 318, it is decided that the fifth branch instruction 514 of FIG. 21 generates a branch instruction for 2 bytes, so that the variable flag indicating that it is decided for 2 bytes or 3 bytes is "1". Is substituted. Furthermore, a variable code indicating that the branch instruction of the branch instruction information table pointed to by the variable cp is fixed to 2 bytes or 3 bytes by the code increase amount setting process 319 of FIG.
Substitute “0” for the branch instruction information table determination process 32.
Go to 0. In the branch instruction information table discrimination processing 320,
It is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to pointer increment processing 321 and the size of the branch instruction information table is added to the variable cp so that the variable cp points to the next branch instruction information table. 23, the same processing as that of the fifth branch instruction 514 is performed on the sixth branch instruction 515 and the seventh branch instruction 516 of FIG.

【0066】第六分岐命令515と第六飛び先525と
の間に図13の最適化処理106の対象となる分岐命令
が存在せずかつ第六飛び先525のアドレスから第六分
岐命令515のアドレスを減算した値が「−128」以
上であるので、第六分岐命令は2バイト分の分岐命令を
生成することに確定する。第七分岐命令516と第八分
岐命令517とも第六分岐命令と同様に2バイト分の分
岐命令を生成することに確定する。次に第九分岐命令5
18の処理および第十分岐命令519を行う。第九分岐
命令518と第九飛び先528との間に図2の最適化処
理106の対象となる第十分岐命令519が存在しかつ
第十分岐命令519が共に2バイト分の分岐命令に確定
した場合は、第九分岐命令518も2バイト分の分岐命
令に確定し、第十分岐命令519が3バイト分の分岐命
令に確定した場合は第九分岐命令518も3バイト分の
分岐命令に確定するので、第十分岐命令519が確定し
ないと第九分岐命令518は確定しない。
There is no branch instruction which is the target of the optimization processing 106 of FIG. Since the value obtained by subtracting the address is "-128" or more, the sixth branch instruction is determined to generate a branch instruction for 2 bytes. Both the seventh branch instruction 516 and the eighth branch instruction 517 are determined to generate a branch instruction of 2 bytes, like the sixth branch instruction. Next, the ninth branch instruction 5
18 processing and the tenth branch instruction 519 are performed. The tenth branch instruction 519 to be the target of the optimization processing 106 in FIG. 2 exists between the ninth branch instruction 518 and the ninth jump destination 528, and both the tenth branch instruction 519 are determined as branch instructions of 2 bytes. If so, the ninth branch instruction 518 is also determined to be a 2-byte branch instruction, and if the tenth branch instruction 519 is determined to be a 3-byte branch instruction, the ninth branch instruction 518 is also determined to be a 3-byte branch instruction. Since it is decided, the ninth branch instruction 518 is not decided unless the tenth branch instruction 519 is decided.

【0067】第十分岐命令519も同様に第九分岐命令
518が確定しないと2バイト分の分岐命令を生成する
か3バイト分の分岐命令を生成するかが確定しない。第
十分岐命令519まで処理が終了するとフラグ判別処理
322へ進む。フラグ判別処理322では、2バイト分
の分岐命令を生成するか3バイト分の分岐命令を生成す
るかが確定すると、「1」にセットされる変数flag
が「1」であるか否かを判別する。
Similarly for the tenth branch instruction 519, if the ninth branch instruction 518 is not determined, it is not determined whether a 2-byte branch instruction or a 3-byte branch instruction is generated. When the processing up to the tenth branch instruction 519 is completed, the processing proceeds to the flag determination processing 322. In the flag determination processing 322, when it is determined whether a branch instruction for 2 bytes or a branch instruction for 3 bytes is determined, the variable flag set to "1".
Is determined to be "1".

【0068】変数flagが「1」の場合は、2バイト
分の分岐命令を生成するか3バイト分の分岐命令を生成
するかが確定した分岐命令があるということであり、2
バイト分の分岐命令を生成するか3バイト分の分岐命令
を生成するかが確定した分岐命令がいままで、2バイト
分の分岐命令を生成するか3バイト分の分岐命令を生成
するかが未確定であったために、2バイト分の分岐命令
を生成するか3バイト分の分岐命令を生成するか確定で
きなかった分岐命令が、2バイト分の分岐命令を生成す
るか3バイト分の分岐命令を生成するか確定できる可能
性があるので、先頭アドレス代入処理301へ進む。こ
れで1回目の図13の最適化処理106が終了する。
When the variable flag is "1", it means that there is a branch instruction in which it is decided whether to generate a branch instruction for 2 bytes or a branch instruction for 3 bytes.
It has not been determined whether a branch instruction for 2 bytes or a branch instruction for 3 bytes will be generated until the branch instruction for which it is decided whether to generate a branch instruction for bytes or a branch instruction for 3 bytes. A branch instruction that cannot be determined whether to generate a 2-byte branch instruction or a 3-byte branch instruction because it is definite will generate a 2-byte branch instruction or a 3-byte branch instruction. Since there is a possibility that it is possible to determine whether to generate, the process proceeds to the head address substitution processing 301. This completes the first optimization process 106 in FIG.

【0069】2バイト分の分岐命令を生成することに確
定した分岐命令は、図21の第四分岐命令513、第五
分岐命令514、第六分岐命令515および第七分岐命
令516および第八分岐命令517の5個である。次に
2回目の図13の最適化処理106を行う。図21の第
三分岐命令512と第三飛び先522との間に図13の
最適化処理106の対象となる分岐命令が存在せずかつ
第三飛び先522のアドレスから第三分岐命令512の
アドレスを減算して値が「127」以下であるので、第
三分岐命令512は2バイト分の分岐命令を生成するこ
とに確定する。
The branch instructions decided to generate a 2-byte branch instruction are the fourth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516, and the eighth branch instruction of FIG. There are five instructions 517. Next, the second optimization processing 106 of FIG. 13 is performed. The third branch instruction 512 and the third jump destination 522 in FIG. 21 have no branch instruction to be the target of the optimization processing 106 in FIG. Since the address is subtracted and the value is "127" or less, the third branch instruction 512 is determined to generate a branch instruction for 2 bytes.

【0070】3回目の図2の最適化処理106を行う
と、図21の第二分岐命令511と第二飛び先521と
の間に図13の最適化処理106の対象となる分岐命令
が存在せずかつ第二飛び先521のアドレスから第二分
岐命令511のアドレスを減算した値が「127」以下
であるので、第二分岐命令は2バイト分の分岐命令を生
成することに確定する。4回目の図13の最適化処理1
06を行うと、図21の第一分岐命令510と第一飛び
先520との間に図2の最適化処理106の対象となる
分岐命令が存在せずかつ第一飛び先520のアドレスか
ら第一分岐命令510のアドレスを減算した値が「12
7」以下であるので、第一分岐命令510は2バイト分
の分岐命令を生成することに確定する。
When the optimization process 106 of FIG. 2 is performed a third time, there is a branch instruction to be the optimization process 106 of FIG. 13 between the second branch instruction 511 and the second jump destination 521 of FIG. Since the value obtained by subtracting the address of the second branch instruction 511 from the address of the second jump destination 521 is "127" or less, the second branch instruction is determined to generate a branch instruction of 2 bytes. Fourth optimization process 1 in FIG.
When 06 is executed, there is no branch instruction to be the target of the optimization processing 106 of FIG. 2 between the first branch instruction 510 and the first jump destination 520 of FIG. The value obtained by subtracting the address of the one-branch instruction 510 is "12.
7 ”or less, the first branch instruction 510 is determined to generate a 2-byte branch instruction.

【0071】5回目の図13の最適化処理106では、
図23の増加量判別処理306により変数cpの指す分
岐命令情報テーブルの図21の第一分岐命令510が2
バイト分の分岐命令かまたは3バイト分の分岐命令に確
定しているかを判別する。この場合は確定しているの
で、図24の分岐命令情報テーブル判別処理320へ進
む。分岐命令情報テーブル判別処理320では、変数c
pの指す分岐命令情報テーブルの次の分岐命令情報テー
ブルが存在するか否かを判別する。この場合は図21の
第一分岐命令510が最後の分岐命令でないので、図2
4のポインタインクリメント処理321へ進んで変数c
pに分岐命令情報テーブルのサイズ分を加算し、変数c
pが次の分岐命令情報テーブルを指すようにして図23
の増加量判別処理306へ進む。
In the fifth optimization processing 106 of FIG. 13,
The first branch instruction 510 of FIG. 21 in the branch instruction information table pointed to by the variable cp is 2 by the increase amount determination processing 306 of FIG.
It is determined whether a branch instruction for bytes or a branch instruction for 3 bytes is confirmed. In this case, since it has been decided, the process proceeds to the branch instruction information table discrimination processing 320 of FIG. In the branch instruction information table determination processing 320, the variable c
It is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by p. In this case, since the first branch instruction 510 of FIG. 21 is not the last branch instruction,
4 pointer increment processing 321 and proceed to variable c
The size of the branch instruction information table is added to p, and the variable c
23 so that p points to the next branch instruction information table.
Then, the process proceeds to the increase amount determination processing 306.

【0072】図21の第二分岐命令511、第三分岐命
令512、第四分岐命令513、第五分岐命令514、
第六分岐命令515、第七分岐命令516および第八分
岐命令517も第一分岐命令510と同様に2バイト分
の分岐命令かまたは3バイト分の分岐命令に確定してい
るので第一分岐命令510と同じ処理を繰り返す。次
に、第九分岐命令518は第十分岐命令519が2バイ
ト分の分岐命令に確定しなければ、2バイト分の分岐命
令かまたは3バイト分の分岐命令かに確定できない。同
様に第十分岐命令519も第九分岐命令518が2バイ
ト分の分岐命令かまたは3バイト分の分岐命令に確定し
なければ第十分岐命令519も2バイト分の分岐命令か
または3バイト分の分岐命令に確定できない。
The second branch instruction 511, the third branch instruction 512, the fourth branch instruction 513, the fifth branch instruction 514 of FIG.
Similarly to the first branch instruction 510, the sixth branch instruction 515, the seventh branch instruction 516, and the eighth branch instruction 517 are also defined as the 2-byte branch instruction or the 3-byte branch instruction, so the first branch instruction The same processing as 510 is repeated. Next, the ninth branch instruction 518 cannot be determined as a 2-byte branch instruction or a 3-byte branch instruction unless the 10th branch instruction 519 is determined as a 2-byte branch instruction. Similarly, if the ninth branch instruction 518 is not determined to be a 2-byte branch instruction or a 3-byte branch instruction, the tenth branch instruction 519 is also a 2-byte branch instruction or a 3-byte branch instruction. Cannot be determined to the branch instruction of.

【0073】5回目の図13の最適化処理106では2
バイト分の分岐命令または3バイト分の分岐命令のいず
れかに確定した分岐命令がないので、変数flagは
「0」である。図24のフラグ判別処理322により変
数flagが「0」なのでシンボルテーブル補正処理3
23へ進む。シンボルテーブル補正処理323はシンボ
ルテーブルを作成したときに2バイト分の分岐命令を生
成すると仮定してシンボル値を決定していたので、3バ
イト分の分岐命令を生成することに確定した分岐命令が
ある場合は、3バイト分の分岐命令を生成する数分シン
ボルのアドレス値に加算する処理を行う。以上5回目で
図13の最適化処理106を終了する。
In the fifth optimization processing 106 of FIG. 13, 2 is obtained.
The variable flag is “0” because there is no definite branch instruction for either the byte branch instruction or the 3-byte branch instruction. Since the variable flag is “0” by the flag determination processing 322 of FIG. 24, the symbol table correction processing 3
Proceed to 23. Since the symbol table correction processing 323 has determined the symbol value on the assumption that a 2-byte branch instruction is generated when the symbol table is created, the branch instruction determined to generate a 3-byte branch instruction is If there is, a process of adding to the address value of the symbol for the number of times the branch instruction for 3 bytes is generated is performed. The optimization process 106 of FIG. 13 is completed at the fifth time.

【0074】[0074]

【発明が解決しようとする課題】このように、従来のア
センブラの分岐命令の最適化処理方式では、分岐命令の
アドレスが小さい順に処理を行っているので、前方参照
している分岐命令が4個連続していてかつ交差している
分岐命令が1個ある場合は、分岐命令の最適化処理を5
回行わなくてはならず、分岐命令の最適化処理に時間が
かかる欠点があった。
As described above, in the conventional assembler branch instruction optimization processing method, processing is performed in ascending order of the address of the branch instruction. If there is one branch instruction that is continuous and intersects, the branch instruction optimization process
Since it has to be performed once, it takes a long time to optimize the branch instruction.

【0075】本発明は、このような欠点を除去するもの
で、最適化処理のパス回数を削減する手段をもつアセン
ブラ装置を提供することを目的とする。
The present invention eliminates such drawbacks, and an object of the present invention is to provide an assembler device having means for reducing the number of passes of optimization processing.

【0076】[0076]

【課題を解決するための手段】請求項1に対応する発明
は、分岐先までの相対アドレスの大小にかかわらず同じ
記述形式で分岐命令が記述されたソースプログラムファ
イルを入力する入力手段と、上記分岐命令がソースプロ
グラムファイルに出現する毎に上記分岐命令について次
のテーブルへのポインタと分岐命令のアドレスとシンボ
ルテーブルを指すポインタとコード増加量の情報とをも
つテーブルを記憶するメモリと、アドレスの小さい順に
上記テーブルをチェインでつなぐ第一テーブル連繋手段
と、上記第一テーブル連繋手段でつながれたテーブルを
参照して上記分岐命令のアドレスの小さい順に処理を行
い、分岐命令を最も短いオブジェクトコードに対応させ
たオブジェクトモジュールファイルを作成するオブジェ
クトモジュールファイル作成手段とを備えたアセンブラ
装置において、上記テーブルに前のテーブルへのポイン
タを付加してアドレスの大きい順にテーブルをチェイン
でつなぐ第二テーブル連繋手段と、上記オブジェクトモ
ジュールファイル作成手段は、上記第二テーブル連繋手
段で繋がれたテーブルを参照して分岐命令のアドレスの
大きい順に行う処理を上記分岐命令のアドレスの小さい
順に行う処理と交互に実行する手段と、この手段での処
理実行後に残された分岐命令を処理する手段とを備えた
ことを特徴とする。
The invention according to claim 1 is an input means for inputting a source program file in which a branch instruction is described in the same description format regardless of the size of the relative address up to the branch destination, and the above-mentioned. Each time a branch instruction appears in the source program file, a memory for storing a table having a pointer to the next table, a branch instruction address, a pointer to the symbol table, and code increment information for the branch instruction, and an address The first table connection means for connecting the tables in the ascending order and the table connected by the first table connection means are processed in the ascending order of the addresses of the branch instructions, and the branch instructions correspond to the shortest object code. The object module file that creates the object module file In the assembler device including a file creating means, a pointer to the previous table is added to the table and the tables are connected in a chain in descending order of the address. A means for alternately performing the processing of performing the branch instruction in the descending order of address with reference to the tables connected by the two-table connecting means and the processing of performing the branch instruction in the descending order of the address of the branch instruction, and remaining after the processing by this means is executed. And a means for processing the branch instruction.

【0077】請求項2に対応する発明は、分岐先までの
相対アドレスの大小にかかわらず同じ記述形式で分岐命
令が記述されたソースプログラムファイルを入力する入
力手段と、上記分岐命令がソースプログラムファイルに
出現する毎に上記分岐命令について次のテーブルへのポ
インタと分岐命令のアドレスとシンボルテーブルを指す
ポインタとコード増加量の情報とをもつテーブルを記憶
するメモリと、アドレスの小さい順に上記テーブルをチ
ェインでつなぐ第一テーブル連繋手段と、上記第一テー
ブル連繋手段でつながれたテーブルを参照して上記分岐
命令のアドレスの小さい順に処理を行い、分岐命令を最
も短いオブジェクトコードに対応させたオブジェクトモ
ジュールファイルを作成するオブジェクトモジュールフ
ァイル作成手段とを備えたアセンブラ装置において、上
記テーブルに前のテーブルへのポインタを付加してアド
レスの大きい順にテーブルをチェインでつなぐ第二テー
ブル連繋手段と、上記オブジェクトモジュールファイル
作成手段は、上記第二テーブル連繋手段で繋がれたテー
ブルを参照して分岐命令のアドレスの大きい順に行う第
一手段と、上記分岐命令のアドレスの小さい順に行う第
二手段と、この第一手段で処理を行うときに分岐命令の
飛び先が交差する分岐命令群に対して互いに相手のオブ
ジェクトコードサイズに依存する分岐命令群を最適なオ
ブジェクトコードに決定する手段とを備えたことを特徴
とする。
According to the second aspect of the present invention, input means for inputting a source program file in which a branch instruction is described in the same description format regardless of the relative address up to the branch destination, and the branch instruction are source program files. Every time it appears in the branch instruction, a memory for storing a table having a pointer to the next table for the branch instruction, the address of the branch instruction, a pointer pointing to the symbol table, and code increment information, and the table is chained in ascending order of address. By referring to the table connected by the first table connection means and the first table connection means, the processing is performed in ascending order of the address of the branch instruction, and the object module file in which the branch instruction is associated with the shortest object code is created. Object module file creation means to create and In the provided assembler device, a second table linking means for adding a pointer to the previous table to the table and chaining the tables in descending order of address, and the object module file creating means are the second table linking means. First means for referring to the linked table in the descending order of the address of the branch instruction, second means for decreasing the address of the branch instruction, and jump destination of the branch instruction when processing is performed by the first means. And a means for determining a branch instruction group that depends on the object code size of the other party as an optimum object code for the branch instruction group that intersects with each other.

【0078】[0078]

【作用】請求項1に対応する本発明では、分岐命令がソ
ースプログラムファイルに出現する毎に分岐命令の情報
をもった双方向のチェインでつないだテーブルを作成し
てメモリに記憶し、次にこのテーブルを基にアドレスの
昇順からの最適化と降順からの最適化とを行い、交差し
ている分岐命令で互いに相手側のバイト数に影響される
分岐命令が存在する場合には三回目の最適化処理で最も
短いバイト数の命令を生成する。これにより、従来技術
では、連続した前方参照の分岐命令の個数+1回の最適
化処理のパス回数を要したが、本発明では、最適化処理
のパス回数を1回から3回に削減できる。
According to the present invention corresponding to claim 1, each time a branch instruction appears in the source program file, a table linked by a bidirectional chain having information on the branch instruction is created and stored in the memory. Based on this table, optimization is performed from the ascending order of addresses and from the descending order of addresses, and if there are branch instructions that intersect each other and are affected by the number of bytes on the other side, the third time Generates the instruction with the shortest number of bytes in the optimization process. As a result, in the conventional technique, the number of consecutive forward-referenced branch instructions plus the number of passes of the optimization process is required, but in the present invention, the number of passes of the optimization process can be reduced from one to three.

【0079】請求項2に対応する発明では、分岐命令が
ソースプログラムファイルに出現する毎に分岐命令の情
報を出現アドレスに対して双方向のチェインで繋いだテ
ーブルを作成してメモリに記憶し、次にこのテーブルを
基にアドレスの昇順からの最適化と降順からの最適化と
を行い、アドレスの降順から最適化を行う際に交差して
互いに干渉している分岐命令群に対して分岐命令群単位
に最適化処理を行う。これにより、従来技術では、連続
した前方参照の分岐命令の個数+1回の最適化処理のパ
ス回数を要したが、本発明では、1回から2回のパス回
数で終了するので、処理時間の短縮が図れる。
In the invention according to claim 2, each time a branch instruction appears in the source program file, a table in which the information of the branch instruction is connected to the appearance address by a bidirectional chain is created and stored in the memory. Next, based on this table, optimization is performed from the ascending order of addresses and from the descending order of addresses, and when the optimization is performed from the descending order of addresses, the branch instructions are crossed and interfere with each other. Optimization processing is performed for each group. As a result, in the conventional technique, the number of consecutive forward-referenced branch instructions + the number of passes of the optimization process is required. However, in the present invention, since the process is completed in one to two passes, the processing time is reduced. Can be shortened.

【0080】[0080]

【実施例】まず、請求項1に対応する発明の一実施例に
ついて図面を参照して説明する。図1は、この発明のア
センブラ処理方式の一実施例の流れ図である。図3は、
この発明の分岐命令情報テーブル作成処理の一実施例の
流れ図である。図4および図5は、この発明の最適化処
理方式の一実施例の流れ図である。図5は、従来例で説
明した図11に対して破線でくくられた部分がこの発明
の実現のために追加された処理である。図6(a)はこ
の発明で作成される分岐命令情報テーブルの一実施例で
ある。図8は、ソースプログラムファイルの一例であ
る。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS First, an embodiment of the invention corresponding to claim 1 will be described with reference to the drawings. FIG. 1 is a flow chart of an embodiment of the assembler processing system of the present invention. Figure 3
5 is a flowchart of an embodiment of a branch instruction information table creating process of the present invention. 4 and 5 are flow charts of an embodiment of the optimization processing system of the present invention. FIG. 5 shows a process in which a part surrounded by a broken line is added to realize the present invention with respect to FIG. 11 described in the conventional example. FIG. 6A shows an embodiment of the branch instruction information table created by the present invention. FIG. 8 is an example of a source program file.

【0081】従来の技術で説明したアセンブラに図8の
ソースプログラムファイルを入力し、図1のパス1双方
向のテーブルを作成するソース解析処理100で行の解
析をした結果として図8の第一分岐命令510が出現す
ると図3の処理で分岐命令の情報を図1の双方向の分岐
命令情報テーブル104に設定する。双方向の分岐命令
情報テーブル104は、図6(a)の次のテーブルを指
すチェインポインタ440と、前のテーブルを指すチェ
インポインタ441と、分岐命令のアドレス442と、
シンボルテーブルを指すチェインポインタ443と、コ
ード増加量444とで構成される。
The source program file of FIG. 8 is input to the assembler described in the prior art, and the line analysis is performed by the source analysis processing 100 for creating the bidirectional path 1 table of FIG. When the branch instruction 510 appears, the information of the branch instruction is set in the bidirectional branch instruction information table 104 of FIG. 1 by the processing of FIG. The bidirectional branch instruction information table 104 includes a chain pointer 440 that points to the next table in FIG. 6A, a chain pointer 441 that points to the previous table, and a branch instruction address 442.
It is composed of a chain pointer 443 which points to the symbol table and a code increment 444.

【0082】図3の分岐命令のアドレスセット処理20
0で、図8の第一分岐命令510の次のアドレスを図6
(a)の第一分岐命令の分岐命令情報テーブル430が
持つ変数addに代入する。図3のシンボルテーブルの
アドレスセット処理201で、図8の第一飛び先520
のシンボルテーブルのアドレスを図6(a)の第一分岐
命令の分岐命令情報テーブル430が持つ変数symp
に代入する。図3のコード増加量セット処理202で2
バイト分の分岐命令を生成するか3バイト分の分岐命令
を生成するかが未確定であることを示す「1」をコード
増加量の初期値として図6(a)の第一分岐命令の分岐
命令情報テーブル430が持つ変数codeに代入す
る。
Address set processing 20 of the branch instruction of FIG.
0, the next address of the first branch instruction 510 of FIG.
The variable is added to the variable add held in the branch instruction information table 430 of the first branch instruction in (a). In the address setting process 201 of the symbol table of FIG. 3, the first jump destination 520 of FIG.
Of the address of the symbol table of FIG. 6 is stored in the branch instruction information table 430 of the first branch instruction of FIG.
To. 2 in the code increment setting process 202 of FIG.
The branch of the first branch instruction in FIG. 6A is set to “1” indicating that it is uncertain whether to generate a branch instruction for bytes or a branch instruction for 3 bytes, as an initial value of the code increment amount. It is assigned to the variable code of the instruction information table 430.

【0083】図3の次のテーブルのアドレスセット処理
203で、次の分岐命令情報テーブルを作成し、作成し
た次の分岐命令情報テーブルのアドレスを図6(a)の
第一分岐命令の分岐命令情報テーブル430が持つ変数
nextに代入する。図3の前のテーブルのアドレスセ
ット処理204で、図6(a)の第一分岐命令の分岐命
令情報テーブル430のアドレスを次の分岐命令情報テ
ーブルが持つ変数backに代入する。図3のアドレス
セット処理205で、図6(a)の第一分岐命令の分岐
命令情報テーブル430のアドレスを末尾を指すチェイ
ンポインタ401に代入する。これで第一分岐命令の分
岐命令情報テーブル430が作成される。
In the address setting process 203 of the next table of FIG. 3, the next branch instruction information table is created, and the address of the created next branch instruction information table is set to the branch instruction of the first branch instruction of FIG. 6A. The variable next is held in the information table 430. In the address setting process 204 of the table before FIG. 3, the address of the branch instruction information table 430 of the first branch instruction of FIG. 6A is substituted for the variable back held in the next branch instruction information table. In the address setting process 205 of FIG. 3, the address of the branch instruction information table 430 of the first branch instruction of FIG. 6A is assigned to the chain pointer 401 pointing to the end. With this, the branch instruction information table 430 of the first branch instruction is created.

【0084】以下同じように図8の第二分岐命令51
1、第三分岐命令512、第四分岐命令513、第五分
岐命令514、第六分岐命令515、第七分岐命令51
6、第八分岐命令517、第九分岐命令518および第
十分岐命令519について行い、図6(a)の各々の分
岐命令情報テーブルが作成される。図1のファイル終了
判別処理101で入力ファイルが終了後に、分岐命令の
最適化をする図1の双方向の最適化処理102を行う。
Similarly, the second branch instruction 51 of FIG.
1, third branch instruction 512, fourth branch instruction 513, fifth branch instruction 514, sixth branch instruction 515, seventh branch instruction 51
6, the eighth branch instruction 517, the ninth branch instruction 518, and the tenth branch instruction 519 are performed, and each branch instruction information table of FIG. 6A is created. After the end of the input file in the file end determination processing 101 of FIG. 1, the bidirectional optimization processing 102 of FIG. 1 for optimizing the branch instruction is performed.

【0085】次に、図4を流れ図に従って最適化処理を
説明する。図1の双方向の最適化処理102では、図4
のループ判別処理300によりアドレスの小さい順から
最適化を行うかアドレスの大きい順に最適化を行うかを
表す変数iが「0」または「2」のいずれかを判別す
る。変数iは初期値を「0」としているので、この場合
条件が成り立ち、先頭アドレス代入処理301へ進む。
先頭アドレス代入処理301で、分岐命令情報テーブル
の先頭を指す図6(a)の先頭を指すチェインポインタ
400を変数cpに代入し、図4のループ変数「1」加
算処理302でアドレスの小さい順から最適化を行うか
アドレスの大きい順に最適化を行うかを表す変数iに
「1」を加え、フラグ初期化処理305で分岐命令が2
バイト分または3バイト分に確定したことを表す変数f
lagに初期値として「0」を代入する。
Next, the optimization process will be described with reference to the flowchart of FIG. In the bidirectional optimization process 102 of FIG.
By the loop discrimination processing 300, it is discriminated whether the variable i indicating whether optimization is performed from the smallest address or the largest address is "0" or "2". Since the initial value of the variable i is “0”, the condition is satisfied in this case, and the process proceeds to the head address substitution processing 301.
In the start address substitution processing 301, the chain pointer 400 that points to the head of the branch instruction information table that points to the head of FIG. 1 is added to the variable i indicating whether optimization is performed or optimization is performed in the order of increasing addresses, and the branch instruction is 2 in the flag initialization processing 305.
A variable f that indicates that it has been confirmed to be bytes or 3 bytes
Substitute "0" as an initial value for lag.

【0086】増加量判別処理306以降の処理は従来の
技術と同様であるので、1回目の図1の双方向の最適化
処理102が終了した時点で2バイト分の分岐命令を生
成することに確定した分岐命令は、第四分岐命令51
3、第五分岐命令514、第六分岐命令515、第七分
岐命令516および第八分岐命令517の5個である。
Since the processing after the increase amount determination processing 306 is the same as that of the conventional technique, a 2-byte branch instruction is generated when the first bidirectional optimization processing 102 of FIG. The determined branch instruction is the fourth branch instruction 51.
The fifth branch instruction 514, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516, and the eighth branch instruction 517.

【0087】次に2回目の図1の双方向の最適化処理1
02を行う。双方向の最適化処理102では、図4のル
ープ判別処理300によりアドレスの小さい順から最適
化を行うかアドレスの大きい順に最適化を行うかを表す
変数iが「0」または「2」のいずれかを判別する。こ
の場合は変数iは「1」なので条件が成り立たず、末尾
アドレス代入処理303へ進む。
Next, the second bidirectional optimization process 1 of FIG.
Do 02. In the bidirectional optimization process 102, the variable i indicating whether the optimization is performed from the smallest address or the largest address by the loop determination process 300 of FIG. 4 is either “0” or “2”. Determine whether. In this case, since the variable i is "1", the condition is not satisfied, and the process proceeds to the end address substitution processing 303.

【0088】末尾アドレス代入処理303で、分岐命令
情報テーブルの最後を指す図6(a)の先頭を指すチェ
インポインタ400を変数cpに代入し、図4のループ
変数代入処理304で、アドレスの小さい順から最適化
を行うかアドレスの大きい順に最適化を行うかを表す変
数iに「2」を代入し、フラグ初期化処理305で、分
岐命令が2バイト分または3バイト分のいずれかに確定
したことを表す変数flagに初期値として「0」を代
入する。増加量判別処理306により変数cpの指す分
岐命令情報テーブルの図8の第十分岐命令519が2バ
イト分の分岐命令または3バイト分の分岐命令のいずれ
かに確定しているか否かを判別する。この場合は確定し
ていないので、図4の分岐命令までの増加量算出処理3
07によりファイルの先頭から変数cpの指す分岐命令
情報テーブルの図8の第十分岐命令519までに図1の
双方向の最適化処理102の対象となる分岐命令がいく
つ存在するかを算出し、変数Aに代入する。この場合は
図8の第一分岐命令510、第二分岐命令511、第三
分岐命令512、第四分岐命令513、第五分岐命令5
14、第六分岐命令515、第七分岐命令516、第八
分岐命令517および第九分岐命令518の9個なの
で、「9」を変数Aに代入する。
In the end address substitution processing 303, the chain pointer 400 indicating the end of the branch instruction information table indicating the beginning of FIG. 6A is substituted into the variable cp, and in the loop variable substitution processing 304 of FIG. Substituting "2" into a variable i indicating whether optimization is performed in order or optimization is performed in descending order of addresses, and in the flag initialization processing 305, the branch instruction is determined to be either 2 bytes or 3 bytes. "0" is assigned as an initial value to the variable flag indicating that the action has been performed. In the increment determination process 306, it is determined whether the tenth branch instruction 519 in FIG. 8 in the branch instruction information table pointed to by the variable cp is determined to be a 2-byte branch instruction or a 3-byte branch instruction. . In this case, since it is not decided, the increase amount calculation process 3 up to the branch instruction in FIG.
From 07, the number of branch instructions to be subjected to the bidirectional optimization processing 102 of FIG. 1 is calculated from the head of the file to the tenth branch instruction 519 of FIG. 8 in the branch instruction information table pointed to by the variable cp. Substitute in variable A. In this case, the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, the fourth branch instruction 513, and the fifth branch instruction 5 of FIG.
Since there are nineteen, the sixth branch instruction 515, the seventh branch instruction 516, the eighth branch instruction 517, and the ninth branch instruction 518, “9” is assigned to the variable A.

【0089】図4の飛び先までの増加量算出処理308
によりファイルの先頭から変数cpの指す分岐命令情報
テーブルの図8の第十分岐命令519の飛び先である第
十飛び先529までに図1の双方向の最適化処理102
の対象となる分岐命令がいくつ存在するか算出し、変数
Bに代入する。この場合は図8の第一分岐命令510、
第二分岐命令511、第三分岐命令512、第四分岐命
令513、第五分岐命令514、第六分岐命令515、
第七分岐命令516および第八分岐命令517の8個な
ので、「8」を変数Bに代入する。
Increase amount calculation processing 308 to the jump destination in FIG.
1 from the head of the file to the tenth jump destination 529 which is the jump destination of the tenth branch instruction 519 of FIG. 8 in the branch instruction information table pointed to by the variable cp.
The number of branch instructions to be processed is calculated, and the calculated branch instruction is substituted into the variable B. In this case, the first branch instruction 510 of FIG.
Second branch instruction 511, third branch instruction 512, fourth branch instruction 513, fifth branch instruction 514, sixth branch instruction 515,
Since there are eight seventh branch instructions 516 and eight branch instructions 517, “8” is assigned to the variable B.

【0090】図4の相対アドレス代入処理309により
変数cpの指す分岐命令情報テーブルの図8の第十分岐
命令519の飛び先である第十飛び先529のアドレス
から変数cpの指す分岐命令情報テーブルの第十分岐命
令519のアドレスを減算し、変数mrlに代入する。
この場合は「−128」バイトなので、「−128」を
変数mrlに代入する。そして、図4のシンボル参照判
別処理310により変数cpの指す分岐命令情報テーブ
ルの図8の第十分岐命令519が前方参照であるか後方
参照であるかを判別する。この場合は後方参照なので、
図4の相対値を変数maxrにセット処理313により
変数mrlを変数maxrに代入し、コード増加量と相
対値とを変数minrにセット処理314により変数m
rlと変数Bとを加算し、加算した結果から変数Aを減
算した結果を変数minrに代入する。この場合は変数
minrに「−129」が代入され、変数maxrに
「−128」が代入される。次に、図5の2バイト分の
分岐命令出力判別処理315と3バイト分の分岐命令出
力判別処理316とにより2バイト分の分岐命令を生成
するか3バイト分の分岐命令を生成するかの判別を行
う。この場合は変数minrが「−129」であるの
で、2バイト分の分岐命令出力判別処理315の条件が
成り立たず、3バイト分の分岐命令出力判別処理316
へ進む。
The branch instruction information table pointed to by the variable cp from the address of the tenth jump destination 529 which is the jump destination of the tenth branch instruction 519 of FIG. 8 in the branch instruction information table pointed to by the variable cp by the relative address substitution processing 309 of FIG. The address of the tenth branch instruction 519 is subtracted and substituted into the variable mrl.
In this case, since "-128" bytes, "-128" is assigned to the variable mrl. Then, the symbol reference determination process 310 of FIG. 4 determines whether the tenth branch instruction 519 of FIG. 8 in the branch instruction information table pointed to by the variable cp is a forward reference or a backward reference. In this case it's a back reference, so
The relative value in FIG. 4 is set in the variable maxr by the setting process 313, the variable mrl is substituted in the variable maxr, and the code increase amount and the relative value are set in the variable minr by the setting process 314.
rl and the variable B are added, and the result of subtracting the variable A from the added result is substituted for the variable minr. In this case, "-129" is assigned to the variable minr and "-128" is assigned to the variable maxr. Next, whether a 2-byte branch instruction or a 3-byte branch instruction is generated by the 2-byte branch instruction output determination processing 315 and the 3-byte branch instruction output determination processing 316 of FIG. Make a decision. In this case, since the variable minr is “−129”, the condition of the 2-byte branch instruction output determination process 315 is not satisfied, and the 3-byte branch instruction output determination process 316 is performed.
Go to.

【0091】変数maxrが「−129」であるので3
バイト分の分岐命令出力判別処理316の条件は成り立
ち、2バイト分の分岐命令を生成するか3バイト分の分
岐命令を生成するかが確定しないので、最適化回数判定
処理330へ進む。変数iが「2」であるので判定は偽
となり、分岐命令情報テーブル判別処理320へ進む。
分岐命令情報テーブル判別処理320では、変数cpの
指す分岐命令情報テーブルの次の分岐命令情報テーブル
が存在するか否かを判別する。この場合は次の分岐命令
情報テーブルが存在するので、ポインタインクリメント
処理321へ進んで変数cpに分岐命令情報テーブルの
サイズ分を加算し、次の分岐命令情報テーブルを指すよ
うにして図4の増加量判別処理306へ進み、図8の第
九分岐命令518に対して第十分岐命令519と同様の
処理を行う。
Since the variable maxr is "-129", 3
The condition of the branch instruction output determination processing 316 for bytes is satisfied and it is not determined whether the branch instruction for 2 bytes or the branch instruction for 3 bytes is generated. Therefore, the process proceeds to the optimization number determination processing 330. Since the variable i is “2”, the determination is false, and the process proceeds to the branch instruction information table determination processing 320.
In the branch instruction information table determination processing 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the process proceeds to the pointer increment processing 321 to add the size of the branch instruction information table to the variable cp and point to the next branch instruction information table to increase the number in FIG. Proceeding to the amount determination processing 306, the same processing as the tenth branch instruction 519 is performed on the ninth branch instruction 518 of FIG.

【0092】第九分岐命令518も同様に第十分岐命令
519が確定しないと2バイト分の分岐命令を生成する
か3バイト分の分岐命令を生成するかが確定しない。
Similarly, for the ninth branch instruction 518, if the tenth branch instruction 519 is not determined, it is not determined whether the 2-byte branch instruction or the 3-byte branch instruction is generated.

【0093】次に第三分岐命令512の処理を行う。第
三分岐命令512と第三飛び先522との間に図2の最
適化処理106の対象となる分岐命令が存在せずかつ第
三飛び先522のアドレスから第三分岐命令512のア
ドレスを減算した値が「127」以下であるので、第三
分岐命令512は2バイト分の分岐命令を生成すること
に確定する。第二分岐命令511と第二飛び先521と
の間に図2の最適化処理106の対象となる分岐命令が
存在せずかつ第二飛び先521のアドレスから第二分岐
命令511のアドレスを減算した値が「127」以下で
あるので、第二分岐命令511は2バイト分の分岐命令
を生成することに確定する。
Next, the third branch instruction 512 is processed. The branch instruction that is the target of the optimization process 106 in FIG. 2 does not exist between the third branch instruction 512 and the third jump destination 522, and the address of the third branch instruction 512 is subtracted from the address of the third jump destination 522. Since the value obtained is less than or equal to "127", the third branch instruction 512 is determined to generate a 2-byte branch instruction. 2 does not exist between the second branch instruction 511 and the second jump destination 521, and the address of the second branch instruction 511 is subtracted from the address of the second jump destination 521. Since the value obtained is "127" or less, it is determined that the second branch instruction 511 generates a 2-byte branch instruction.

【0094】第一分岐命令510と第一飛び先520と
の間に図2の最適化処理106の対象となる分岐命令が
存在せずかつ第一飛び先520のアドレスから第一分岐
命令510のアドレスを減算した値が「127」以下で
あるので、第一分岐命令510は2バイト分の分岐命令
を生成することに確定する。これで2回目の図1の双方
向の最適化処理102が終了する。2バイト分の分岐命
令を生成することに確定した分岐命令は、図8の第一分
岐命令510、第二分岐命令511、第三分岐命令51
2、第四分岐命令513、第五分岐命令514、第六分
岐命令515、第七分岐命令516および第八分岐命令
517の8個である。次に3回目の図1の双方向の最適
化処理102を行う。3回目の最適化処理102は、変
数iが「3」になり、変数cpはファイルの先頭から分
岐命令情報テーブルを示す。ここまでにバイト数が確定
していないのは双方向の分岐命令であり、かつ互いが干
渉しあっているために確定できないものである。
There is no branch instruction which is the target of the optimization processing 106 of FIG. Since the value obtained by subtracting the address is "127" or less, the first branch instruction 510 is determined to generate a branch instruction for 2 bytes. This completes the second bidirectional optimization process 102 of FIG. The branch instruction determined to generate a 2-byte branch instruction is the first branch instruction 510, the second branch instruction 511, and the third branch instruction 51 of FIG.
Two are the second, fourth branch instruction 513, fifth branch instruction 514, sixth branch instruction 515, seventh branch instruction 516, and eighth branch instruction 517. Next, the third bidirectional optimization process 102 of FIG. 1 is performed. In the third optimization process 102, the variable i becomes “3”, and the variable cp indicates the branch instruction information table from the head of the file. It is a bidirectional branch instruction that the number of bytes has not been determined so far, and cannot be determined because they interfere with each other.

【0095】本実施例では第九分岐命令518と第十分
岐命令519とが互いに干渉しているために確定できて
いない。第九分岐命令518は最適化回数判定処理33
0で変数iが「3」で真と判定されるので、次の交差し
ている分岐命令判定処理331に進む。変数mrlは
「127」であり真であるので2バイト分の分岐命令と
確定し、フラグセット処理318へ進む。
In the present embodiment, the ninth branch instruction 518 and the tenth branch instruction 519 interfere with each other and cannot be determined. The ninth branch instruction 518 is the optimization number determination processing 33.
When the variable i is 0, it is determined to be true when the variable i is "3". Since the variable mrl is “127” and is true, it is decided that the branch instruction is for 2 bytes, and the process proceeds to the flag setting process 318.

【0096】次に第十分岐命令519は第九分岐命令5
18が2バイト分の分岐命令と確定され、変数mrlは
「−128」、変数maxrは「−128」、変数mi
nrは「−128」になり、2バイト分の分岐命令出力
判別処理315で真になり、2バイト分の分岐命令と確
定される。分岐命令情報テーブル判別処理320では、
次の情報テーブルが無いので最適化終了処理判定332
へ進む。最適化終了処理判定332では、変数iが
「3」であるので、変数flagの判定をスキップして
シンボルテーブル補正処理323へ進んで最適化処理が
終了する。したがって3回の最適化処理により終了する
ことができる。
Next, the tenth branch instruction 519 is the ninth branch instruction 5
18 is determined to be a 2-byte branch instruction, the variable mrl is "-128", the variable maxr is "-128", and the variable mi.
nr becomes "-128", which becomes true in the 2-byte branch instruction output determination processing 315, and is determined as a 2-byte branch instruction. In the branch instruction information table discrimination processing 320,
Since there is no next information table, the optimization end processing determination 332
Go to. In the optimization end processing determination 332, since the variable i is “3”, the determination of the variable flag is skipped, the process proceeds to the symbol table correction processing 323, and the optimization processing ends. Therefore, the optimization process can be completed three times.

【0097】次に、請求項2に対応する発明の一実施例
について図面を参照して説明する。図12は、本発明の
アセンブラ処理方式の一実施例の流れ図である。図14
は、本発明の分岐命令目情報テーブル作成処理の一実施
例の流れ図である。図15、図16、図17および図1
8は、本発明の最適化処理方式の一実施例の流れ図であ
る。図16は、従来例で説明した図24に対して破線で
くくられた部分が本発明の実現のために追加された処理
である。図17および図18は、交差している互いに干
渉しあう分岐命令群の最適化処理の流れ図である。図1
9(a)は本発明で作成される分岐命令情報テーブルの
一実施例である。図21は、ソースプログラムファイル
の一例である。
Next, an embodiment of the invention corresponding to claim 2 will be described with reference to the drawings. FIG. 12 is a flow chart of an embodiment of the assembler processing method of the present invention. 14
6 is a flowchart of an embodiment of a branch instruction information table creating process of the present invention. 15, 16, 17, and 1
8 is a flow chart of an embodiment of the optimization processing method of the present invention. FIG. 16 shows a process in which a portion surrounded by a broken line is added to realize the present invention with respect to FIG. 24 described in the conventional example. FIG. 17 and FIG. 18 are flowcharts of optimization processing of branch instruction groups that intersect each other and interfere with each other. Figure 1
9 (a) is an embodiment of the branch instruction information table created by the present invention. FIG. 21 is an example of a source program file.

【0098】従来の技術で説明したアセンブラに図21
のソースプログラムファイルを入力し、図12のパス1
双方向のテーブルを作成するソース解析処理100で行
の解析をした結果として図21の第一分岐命令510が
出現すると図14の処理で分岐命令の情報を図12の双
方向の分岐命令情報テーブル104に設定する。双方向
の分岐命令情報テーブル104は、図19(a)の次の
テーブルを指すチェインポインタ440と、前のテーブ
ルを指すチェインポインタ441と、分岐命令のアドレ
ス442と、シンボルテーブルを指すチェインポインタ
443と、コード増加量444とで構成される。
FIG. 21 shows the assembler described in the prior art.
Enter the source program file of
When the first branch instruction 510 of FIG. 21 appears as a result of the line analysis in the source analysis processing 100 for creating a bidirectional table, the information of the branch instruction is processed in the processing of FIG. 14 and the bidirectional branch instruction information table of FIG. Set to 104. The bidirectional branch instruction information table 104 includes a chain pointer 440 that points to the next table in FIG. 19A, a chain pointer 441 that points to the previous table, a branch instruction address 442, and a chain pointer 443 that points to the symbol table. And a code increase amount 444.

【0099】図14の分岐命令のアドレスセット処理2
00で、図21の第一分岐命令510の次のアドレスを
図19(a)の第一分岐命令の分岐命令情報テーブル4
30が持つ変数addに代入する。図14のシンボルテ
ーブルのアドレスセット処理201で、図21の第一飛
び先520のシンボルテーブルのアドレスを図19
(a)の第一分岐命令の分岐命令情報テーブル430が
持つ変数sympに代入する。図14のコード増加量セ
ット処理202で2バイト分の分岐命令を生成するか3
バイト分の分岐命令を生成するかが未確定であることを
示す「1」をコード増加量の初期値として図19(a)
の第一分岐命令の分岐命令情報テーブル430が持つ変
数codeに代入する。図14の次のテーブルのアドレ
スセット処理203で、次の分岐命令情報テーブルを作
成し、作成した次の分岐命令情報テーブルのアドレスを
図19(a)の第一分岐命令の分岐命令情報テーブル4
30が持つ変数nextに代入する。
Address set processing 2 of the branch instruction of FIG.
00, the next address of the first branch instruction 510 of FIG. 21 is set to the branch instruction information table 4 of the first branch instruction of FIG.
Substitute for the variable add of 30. In the address setting process 201 of the symbol table of FIG. 14, the address of the symbol table of the first jump destination 520 of FIG.
The variable is assigned to the variable symp of the branch instruction information table 430 of the first branch instruction of (a). Whether to generate a 2-byte branch instruction in the code increment setting process 202 of FIG.
FIG. 19A shows an initial value of the code increase amount, which is "1" indicating that it is uncertain whether to generate a branch instruction for bytes.
The first branch instruction is assigned to the variable code in the branch instruction information table 430. In the address setting process 203 of the next table in FIG. 14, the next branch instruction information table is created, and the address of the created next branch instruction information table is set to the branch instruction information table 4 of the first branch instruction in FIG. 19A.
Substitute in the variable next of 30.

【0100】図14の前のテーブルのアドレスセット処
理204で、図19(a)の第一分岐命令の分岐命令情
報テーブル430のアドレスを次の分岐命令情報テーブ
ルが持つ変数backに代入する。図14のアドレスセ
ット処理205で、図19(a)の第一分岐命令の分岐
命令情報テーブル430のアドレスを末尾を指すチェイ
ンポインタ401に代入する。これで第一分岐命令の分
岐命令情報テーブル430が作成される。以下同じよう
に図21の第二分岐命令511、第三分岐命令512、
第四分岐命令513、第五分岐命令514、第六分岐命
令515、第七分岐命令516、第八分岐命令517、
第九分岐命令518および第十分岐命令519について
行い、図19(a)の各々の分岐命令情報テーブルが作
成される。図12のファイル終了判別処理101で入力
ファイルが終了後に、分岐命令の最適化をする図12の
双方向の最適化処理102を行う。
In the address setting process 204 of the previous table of FIG. 14, the address of the branch instruction information table 430 of the first branch instruction of FIG. 19A is substituted into the variable back held in the next branch instruction information table. In the address setting processing 205 of FIG. 14, the address of the branch instruction information table 430 of the first branch instruction of FIG. 19A is assigned to the chain pointer 401 pointing to the end. With this, the branch instruction information table 430 of the first branch instruction is created. Similarly, the second branch instruction 511 and the third branch instruction 512 of FIG.
A fourth branch instruction 513, a fifth branch instruction 514, a sixth branch instruction 515, a seventh branch instruction 516, an eighth branch instruction 517,
The ninth branch instruction 518 and the tenth branch instruction 519 are performed, and each branch instruction information table of FIG. 19A is created. After the input file is completed in the file end determination processing 101 in FIG. 12, the bidirectional optimization processing 102 in FIG. 12 for optimizing the branch instruction is performed.

【0101】次に、図15を流れ図に従って最適化処理
を説明する。図12の双方向の最適化処理102では、
図15のループ判別処理300によりアドレスの小さい
順から最適化を行うかアドレスの大きい順に最適化を行
うかを表す変数iが「0」か否かを判別する。変数iは
初期値を「0」としているので、この場合は条件が成り
立ち、先頭アドレス代入処理301へ進む。先頭アドレ
ス代入処理301で、分岐命令情報テーブルの先頭を指
す図19(a)の先頭を指すチェインポインタ400を
変数cpに代入し、図15のループ変数「1」加算処理
302でアドレスの小さい順から最適化を行うかアドレ
スの大きい順に最適化を行うかを表す変数iに「1」を
加算し、フラグ初期化処理305で分岐命令が2バイト
分または3バイト分に確定したことを表す変数flag
に初期値として「0」を代入する。増加量判別処理30
6以降の処理は従来の技術と同様であるので、1回目の
図12の双方向の最適化処理102が終了した時点で2
バイト分の分岐命令を生成することに確定した分岐命令
は、第四分岐命令513、第五分岐命令514、第六分
岐命令515、第七分岐命令516および第八分岐命令
517の5個である。次に2回目の図1の双方向の最適
化処理102を行う。
Next, the optimization processing will be described with reference to the flowchart of FIG. In the bidirectional optimization process 102 of FIG. 12,
By the loop discrimination processing 300 of FIG. 15, it is determined whether or not the variable i indicating whether optimization is performed from the smallest address or the largest address is “0”. Since the initial value of the variable i is “0”, the condition is satisfied in this case, and the process proceeds to the head address substitution processing 301. In the head address substitution processing 301, the chain pointer 400 that points to the head of the branch instruction information table that points to the head of FIG. 19A is assigned to the variable cp, and the loop variable “1” addition processing 302 of FIG. Is added to the variable i indicating whether optimization is performed or the optimization is performed in descending order of address, and a variable indicating that the branch instruction is fixed to 2 bytes or 3 bytes in the flag initialization processing 305. flag
Substitute "0" as the initial value for. Increase amount determination process 30
Since the processing from step 6 onward is the same as that of the conventional technique, 2 at the time when the first bidirectional optimization processing 102 of FIG. 12 is completed.
The five branch instructions determined to generate the branch instructions for bytes are the fifth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516, and the eighth branch instruction 517. . Next, the second bidirectional optimization process 102 of FIG. 1 is performed.

【0102】双方向の最適化処理102では、図15の
ループ判別処理300によりアドレスの小さい順から最
適化を行うかアドレスの大きい順に最適化を行うかを表
す変数iが「0」か否かを判別する。この場合は変数i
は「1」なので条件が成り立たず、末尾アドレス代入処
理303へ進む。末尾アドレス代入処理303で、分岐
命令情報テーブルの最後を指す図19(a)の先頭を指
すチェインポインタ400を変数cpに代入し、図15
のループ変数「1」代入処理302で、アドレスの小さ
い順から最適化を行うかアドレスの大きい順に最適化を
行うかを表す変数iに「1」を加え、フラグ初期化処理
305で、分岐命令が2バイト分または3バイト分のい
ずれかに確定したことを表す変数flagに初期値とし
て「0」を代入する。増加量判別処理306により変数
cpの指す分岐命令情報テーブルの図21の第十分岐命
令519が2バイト分の分岐命令または3バイト分の分
岐命令のいずれかに確定しているか否かを判別する。こ
の場合は確定していないので、図15の分岐命令までの
増加量算出処理307によりファイルの先頭から変数c
pの指す分岐命令情報テーブルの図21の第十分岐命令
519までに図12の双方向の最適化処理102の対象
となる分岐命令がいくつ存在するかを算出し、変数Aに
代入する。この場合は図21の第一分岐命令510、第
二分岐命令511、第三分岐命令512、第四分岐命令
513、第五分岐命令514、第六分岐命令515、第
七分岐命令516、第八分岐命令517および第九分岐
命令518の9個なので、「9」を変数Aに代入する。
In the bidirectional optimization process 102, whether or not the variable i indicating whether the optimization is performed from the smallest address or the largest address by the loop discrimination process 300 of FIG. 15 is "0". To determine. In this case the variable i
Since “1” is “1”, the condition is not satisfied, and the process proceeds to the end address substitution process 303. In the end address substitution processing 303, the chain pointer 400 indicating the beginning of FIG. 19A indicating the end of the branch instruction information table is assigned to the variable cp, and
In the loop variable “1” substitution process 302 of FIG. 1, “1” is added to the variable i indicating whether optimization is performed from the smallest address or the largest address, and a branch instruction is generated in the flag initialization process 305. "0" is assigned as an initial value to a variable flag indicating that is determined to be either 2 bytes or 3 bytes. In the increment determination process 306, it is determined whether the tenth branch instruction 519 of FIG. 21 in the branch instruction information table pointed to by the variable cp is determined to be a 2-byte branch instruction or a 3-byte branch instruction. . In this case, since it has not been decided, the variable c from the beginning of the file is calculated by the increase amount calculation processing 307 up to the branch instruction in FIG.
21 is calculated by the tenth branch instruction 519 in FIG. 21 in the branch instruction information table pointed to by p, and is substituted into the variable A. In this case, the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, the fourth branch instruction 513, the fifth branch instruction 514, the sixth branch instruction 515, the seventh branch instruction 516 and the eighth branch instruction of FIG. Since there are nine branch instructions 517 and the ninth branch instruction 518, “9” is assigned to the variable A.

【0103】図4の飛び先までの増加量算出処理308
によりファイルの先頭から変数cpの指す分岐命令情報
テーブルの図21の第十分岐命令519の飛び先である
第十飛び先529までに図12の双方向の最適化処理1
02の対象となる分岐命令がいくつ存在するか算出し、
変数Bに代入する。この場合は図21の第一分岐命令5
10、第二分岐命令511、第三分岐命令512、第四
分岐命令513、第五分岐命令514、第六分岐命令5
15、第七分岐命令516および第八分岐命令517の
8個なので、「8」を変数Bに代入する。図15の相対
アドレス代入処理309により変数cpの指す分岐命令
情報テーブルの図21の第十分岐命令519の飛び先で
ある第十飛び先529のアドレスから変数cpの指す分
岐命令情報テーブルの第十分岐命令519のアドレスを
減算し、変数mrlに代入する。この場合は「−12
8」バイトなので、「−128」を変数mrlに代入す
る。
Increase amount calculation processing 308 up to the jump destination in FIG.
12 from the head of the file to the tenth jump destination 529 which is the jump destination of the tenth branch instruction 519 of FIG. 21 in the branch instruction information table pointed to by the variable cp.
Calculate how many branch instructions are subject to 02,
Substitute in variable B. In this case, the first branch instruction 5 in FIG.
10, second branch instruction 511, third branch instruction 512, fourth branch instruction 513, fifth branch instruction 514, sixth branch instruction 5
Since there are eightteen, the seventh branch instruction 516 and the eighth branch instruction 517, “8” is substituted into the variable B. In the branch instruction information table pointed to by the variable cp by the relative address assignment processing 309 of FIG. The address of the branch instruction 519 is subtracted and substituted into the variable mrl. In this case, "-12
Since it is 8 "bytes," -128 "is assigned to the variable mrl.

【0104】そして、図15のシンボル参照判別処理3
10により変数cpの指す分岐命令情報テーブルの図2
1の第十分岐命令519が前方参照であるか後方参照で
あるかを判別する。この場合は後方参照なので、図15
の相対値を変数maxrにセット処理313により変数
mrlを変数maxrに代入し、コード増加量と相対値
とを変数minrにセット処理314により変数mrl
と変数Bとを加算し、加算した結果から変数Aを減算し
た結果を変数minrに代入する。この場合は変数mi
nrに「−129」が代入され、変数maxrに「−1
28」が代入される。次に、図16の2バイト分の分岐
命令出力判別処理315と3バイト分の分岐命令出力判
別処理316とにより2バイト分の分岐命令を生成する
か3バイト分の分岐命令を生成するかの判別を行う。こ
の場合は変数minrが「−129」であるので、2バ
イト分の分岐命令出力判別処理315の条件が成り立た
ず、3バイト分の分岐命令出力判別処理316へ進む。
変数maxrが「−129」であるので3バイト分の分
岐命令出力判別処理316の条件は成り立ち、2バイト
分の分岐命令を生成するか3バイト分の分岐命令を生成
するかが確定しないので、最適化回数判定処理330へ
進む。変数iが「2」であるので判定は真となり、交差
して互いに干渉している分岐命令群の最適化処理331
へ進む。
Then, the symbol reference discrimination processing 3 of FIG.
2 of the branch instruction information table pointed to by the variable cp by 10
It is determined whether the 1st tenth branch instruction 519 is a forward reference or a backward reference. In this case, the reference is backward, so
Is set to the variable maxr by the setting process 313, the variable mrl is substituted into the variable maxr, and the code increase amount and the relative value are set to the variable minr by the setting process 314.
And the variable B are added, and the result of subtracting the variable A from the added result is substituted for the variable minr. In this case, the variable mi
"-129" is assigned to nr, and "-1" is assigned to the variable maxr.
28 ”is substituted. Next, whether the 2-byte branch instruction output determination process 315 and the 3-byte branch instruction output determination process 316 in FIG. 16 generate a 2-byte branch instruction or a 3-byte branch instruction. Make a distinction. In this case, since the variable minr is "-129", the condition of the 2-byte branch instruction output determination process 315 is not satisfied, and the process proceeds to the 3-byte branch instruction output determination process 316.
Since the variable maxr is “−129”, the condition of the branch instruction output determination process 316 for 3 bytes is satisfied and it is not determined whether the branch instruction for 2 bytes or the branch instruction for 3 bytes is generated. The process proceeds to the optimization number determination process 330. Since the variable i is “2”, the determination is true, and the optimization processing 331 of the branch instruction group that intersects and interferes with each other.
Go to.

【0105】この交差して互いに干渉している分岐命令
群の最適化処理331の流れを図17および図18を使
って説明する。図17では分岐命令群の先頭ポインタを
指している変数cpの値を変数stptにセーブし、バ
イト数が未定の交差している分岐命令数を変数undに
代入して順にバイト数が未定の分岐命令の最適化の確認
を行う。図17の判別306から図18の判別316ま
では、図15の判別306から図16の判別316まで
と同じであり、分岐先までのアドレス計算を行ってい
る。図18の処理353と判別354で分岐命令群の終
りか否かを判定している。終りでない場合は処理352
へ戻る。終りの場合は最後の分岐命令が前方参照か後方
参照かを判定する。前方参照の場合は分岐命令群の分岐
命令をすべて2バイト分岐にできるので処理362へ行
く。処理362から判別367までの処理により、分岐
命令群のすべてを2バイト分岐命令として確定する。後
方参照の場合は分岐命令群の継続として処理351へ戻
る。
The flow of the optimizing process 331 of the branch instruction group which intersects and interferes with each other will be described with reference to FIGS. 17 and 18. In FIG. 17, the value of the variable cp that points to the head pointer of the branch instruction group is saved in the variable stpt, the number of intersecting branch instructions whose number of bytes is undecided is assigned to the variable und, and the number of bytes is undecided. Check the optimization of the instruction. The determination 306 of FIG. 17 to the determination 316 of FIG. 18 are the same as the determination 306 of FIG. 15 to the determination 316 of FIG. 16, and the address calculation up to the branch destination is performed. It is determined by the processing 353 and the determination 354 of FIG. 18 whether the end of the branch instruction group is reached. If not finished, process 352
Return to. If it is the end, it is determined whether the last branch instruction is a forward reference or a backward reference. In the case of forward reference, since all branch instructions in the branch instruction group can be branched into 2 bytes, the process goes to step 362. By the processing from the processing 362 to the determination 367, all the branch instruction groups are decided as 2-byte branch instructions. In the case of backward reference, the branch instruction group is continued and the process returns to the processing 351.

【0106】また判別316の判定で分岐命令が3バイ
ト命令であると確定されると、処理317から判別36
8までの処理により分岐命令群のいままで全ての分岐命
令を3バイト命令で確定する処理を行う。本実施例では
図17の処理350で変数cpが指す分岐命令情報テー
ブルポインタを変数stptに代入する。次に処理35
1で分岐命令から分岐先までにある未解決な分岐命令数
を求める処理を行って変数undに代入する。この場合
は図21の分岐命令518が未確定な分岐命令として変
数undには「1」が代入される。処理352で変数c
pに次の分岐命令情報テーブルのポインタをセットす
る。変数cpには図21の分岐命令518の分岐情報テ
ーブル428が入る。
If it is determined in the determination 316 that the branch instruction is the 3-byte instruction, the process 317 to the determination 36.
By the processing up to 8, all branch instructions of the branch instruction group up to now are determined by 3-byte instructions. In this embodiment, the branch instruction information table pointer pointed to by the variable cp is assigned to the variable stpt in the process 350 of FIG. Next process 35
In step 1, the number of unresolved branch instructions from the branch instruction to the branch destination is calculated and assigned to the variable und. In this case, the branch instruction 518 of FIG. 21 is an undetermined branch instruction, and “1” is assigned to the variable und. Variable c in process 352
The pointer of the next branch instruction information table is set to p. The branch information table 428 of the branch instruction 518 in FIG. 21 is stored in the variable cp.

【0107】判別306では変数cpの指す分岐命令が
確定しているかどうかの判定を行う。確定されている場
合は処理352へ戻る。この場合は未確定なので偽とな
り、処理307へ進む。処理307から図18の判別3
16までは図15および図16と同じ処理である。した
がって図18の判別316の判定まで進む。判定は偽に
なるので処理353に進み、変数undを「1」減じ
る。その時点で変数undは「0」になる。次に判別3
54で変数undが「0」か否かの判定を行う。変数u
ndは「0」であるので判定は真となり、判別355へ
進む。判別355では変数cpの指す分岐命令が前方参
照か否かの判定を行う。図21の分岐命令518は前方
参照である。したがって判定は真となり、処理362へ
進む。処理362からの処理は互いに干渉している分岐
命令を2バイト分岐命令に確定する処理である。処理3
62では変数cpの値を変数tcpに代入して変数st
ptの指す分岐情報テーブルまでの未確定分岐命令をす
べて2バイト分岐命令に確定する処理を行う。この場合
は図21の分岐命令518と分岐命令519とが2バイ
ト分岐命令に確定される。
In the judgment 306, it is judged whether or not the branch instruction pointed to by the variable cp is fixed. If it has been confirmed, the process returns to the process 352. In this case, since it is undetermined, it becomes false and the process proceeds to step 307. Determination 3 of processing 307 to FIG.
The process up to 16 is the same as that in FIGS. 15 and 16. Therefore, the process proceeds to the determination of determination 316 in FIG. Since the determination is false, the process proceeds to step 353, and the variable und is decremented by "1". At that time, the variable und becomes “0”. Next discrimination 3
At 54, it is determined whether the variable und is "0". Variable u
Since nd is “0”, the determination is true, and the process proceeds to determination 355. In the determination 355, it is determined whether or not the branch instruction pointed to by the variable cp is a forward reference. The branch instruction 518 in FIG. 21 is a forward reference. Therefore, the determination is true, and the process advances to the process 362. The processing from the processing 362 is processing for determining branch instructions that interfere with each other as a 2-byte branch instruction. Process 3
At 62, the value of the variable cp is substituted for the variable tcp to obtain the variable st.
Processing is performed to fix all undetermined branch instructions up to the branch information table pointed to by pt as 2-byte branch instructions. In this case, the branch instruction 518 and the branch instruction 519 of FIG. 21 are fixed as a 2-byte branch instruction.

【0108】図18の処理が終了して図16の判別32
0から処理が始まる。判別320では変数cpの指す分
岐命令情報テーブルの次の分岐命令情報テーブルが存在
するか否かを判別する。この場合は次の分岐命令情報テ
ーブルが存在するので処理321へ進み、変数cpに分
岐命令情報テーブルのサイズ分を加算し、次の分岐命令
情報テーブルを指すようにして図15増加量判別処理3
06へ進み、図8の第三分岐命令512に対して第十分
岐命令519と同様の処理を行う。第三分岐命令512
と第三飛び先522の間に図13の最適化処理106の
対象となる分岐命令が存在せず、かつ第三飛び先522
のアドレスから第三分岐命令512のアドレスを減算し
た値が「127」以下であるので、第三分岐命令は2バ
イト分の分岐命令を生成することに確定する。第二分岐
命令511と第二飛び先521の間に図13の最適化処
理106の対象となる分岐命令が存在せず、かつ第二飛
び先521のアドレスから第二分岐命令511のアドレ
スを減算した値が「127」以下であるので、第二分岐
命令511は2バイト分の分岐命令を生成することに確
定する。
After the processing of FIG. 18 is completed, the determination 32 of FIG.
The process starts from 0. In the determination 320, it is determined whether or not there is a branch instruction information table next to the branch instruction information table pointed to by the variable cp. In this case, since the next branch instruction information table exists, the processing proceeds to step 321, the size of the branch instruction information table is added to the variable cp, and the next branch instruction information table is pointed to.
In step 06, the same processing as that of the tenth branch instruction 519 is performed on the third branch instruction 512 of FIG. Third branch instruction 512
Between the third jump destination 522 and the third jump destination 522, there is no branch instruction that is the target of the optimization processing 106 of FIG.
Since the value obtained by subtracting the address of the third branch instruction 512 from the address of is less than "127", the third branch instruction is determined to generate a branch instruction of 2 bytes. The branch instruction that is the target of the optimization processing 106 in FIG. 13 does not exist between the second branch instruction 511 and the second jump destination 521, and the address of the second branch instruction 511 is subtracted from the address of the second jump destination 521. Since the value obtained is "127" or less, it is determined that the second branch instruction 511 generates a 2-byte branch instruction.

【0109】第一分岐命令510と第一飛び先520の
間に図13の最適化処理106の対象となる分岐命令が
存在せず、かつ第一飛び先520のアドレスから第一分
岐命令510のアドレスを減算した値が「127」以下
であるので、第二分岐命令511は2バイト分の分岐命
令を生成することに確定する。これで2回目の図1の双
方向の最適化処理102が終了する。
There is no branch instruction which is the target of the optimization processing 106 of FIG. 13 between the first branch instruction 510 and the first jump destination 520, and the first branch instruction 510 is changed from the address of the first jump destination 520. Since the value obtained by subtracting the address is equal to or smaller than "127", the second branch instruction 511 is determined to generate a 2-byte branch instruction. This completes the second bidirectional optimization process 102 of FIG.

【0110】2バイト分の分岐命令を生成することに確
定した分岐命令は、図21の第一分岐命令510、第二
分岐命令511、第三分岐命令512、第四分岐命令5
13、第五分岐命令514、第六分岐命令515、第七
分岐命令516、第八分岐命令517、第九分岐命令5
18および第十分岐命令519の10個でありすべての
分岐命令の最適化が完了した。最適化終了処理判定33
2では、変数iが「2」であるので、変数flagの判
定をスキップして処理323へ進んで最適化処理が終了
する。したがって2回の最適化処理により終了すること
ができる。
The branch instruction determined to generate a 2-byte branch instruction is the first branch instruction 510, the second branch instruction 511, the third branch instruction 512, and the fourth branch instruction 5 of FIG.
13, fifth branch instruction 514, sixth branch instruction 515, seventh branch instruction 516, eighth branch instruction 517, ninth branch instruction 5
The optimization of all the branch instructions was completed with 10 of the 18th and 10th branch instructions. Optimization end processing determination 33
In 2, since the variable i is “2”, the determination of the variable flag is skipped, the process proceeds to step 323, and the optimization process ends. Therefore, the optimization process can be completed twice.

【0111】[0111]

【発明の効果】本発明は、以上説明したように、アドレ
スの小さい順からの最適化とアドレスの大きい順からの
最適化を交互に行うので、従来の技術では連続した前方
参照の分岐命令の個数分に対する最適化の回数が必要と
されるのに対して、本発明では連続した前方参照の分岐
命令の個数にかかわらず最適化処理が請求項1に対応す
る発明では2回または3回にまた請求項2に対応する発
明では1回または2回に削減できる効果がある。
As described above, according to the present invention, optimization is performed alternately from the smallest address and the largest address. Therefore, in the prior art, continuous forward reference branch instructions are executed. In the present invention, the optimization process is performed twice or three times regardless of the number of consecutive forward-referenced branch instructions, whereas the number of optimizations for the number of optimizations is required. Further, the invention according to claim 2 has an effect that it can be reduced to once or twice.

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

【図1】本発明第一実施例の全体動作を示すフローチャ
ート。
FIG. 1 is a flowchart showing the overall operation of the first embodiment of the present invention.

【図2】従来例の動作を示すフローチャート。FIG. 2 is a flowchart showing the operation of a conventional example.

【図3】本発明第一実施例の分岐命令情報テーブル作成
処理内容を示すフローチャート。
FIG. 3 is a flowchart showing the contents of branch instruction information table creation processing according to the first embodiment of the present invention.

【図4】本発明第一実施例最適化処理のフローチャート
詳細図。
FIG. 4 is a detailed flowchart of the optimization process of the first embodiment of the present invention.

【図5】本発明第一実施例最適化処理のフローチャート
詳細図。
FIG. 5 is a detailed flowchart of the optimization process of the first embodiment of the present invention.

【図6】本発明第一実施例の分岐命令情報テーブルの内
容を示す図。
FIG. 6 is a diagram showing the contents of a branch instruction information table according to the first embodiment of the present invention.

【図7】従来例の分岐命令情報テーブルの内容を示す
図。
FIG. 7 is a diagram showing the contents of a conventional branch instruction information table.

【図8】アセンブラソースプログラムの内容を示す図。FIG. 8 is a diagram showing the contents of an assembler source program.

【図9】従来例の分岐命令情報テーブル作成処理の内容
を示すフローチャート。
FIG. 9 is a flowchart showing the contents of a conventional branch instruction information table creation process.

【図10】従来例の最適化処理の内容を示すフローチャ
ート。
FIG. 10 is a flowchart showing the contents of optimization processing of a conventional example.

【図11】従来例の最適化処理の内容を示すフローチャ
ート。
FIG. 11 is a flowchart showing the contents of an optimization process of a conventional example.

【図12】本発明第二実施例の全体動作を示すフローチ
ャート。
FIG. 12 is a flowchart showing the overall operation of the second embodiment of the present invention.

【図13】従来例の動作を示すフローチャート。FIG. 13 is a flowchart showing the operation of a conventional example.

【図14】本発明第二実施例の分岐命令情報テーブル作
成処理の内容を示すフローチャート。
FIG. 14 is a flowchart showing the contents of a branch instruction information table creation process of the second embodiment of the present invention.

【図15】本発明第二実施例の最適化処理の内容を示す
フローチャート。
FIG. 15 is a flowchart showing the contents of optimization processing according to the second embodiment of the present invention.

【図16】本発明第二実施例の最適化処理の内容を示す
フローチャート。
FIG. 16 is a flowchart showing the contents of optimization processing of the second embodiment of the present invention.

【図17】本発明第二実施例の最適化処理の内容を示す
フローチャート。
FIG. 17 is a flowchart showing the contents of optimization processing of the second embodiment of the present invention.

【図18】本発明第二実施例の最適化処理の内容を示す
フローチャート。
FIG. 18 is a flowchart showing the contents of optimization processing according to the second embodiment of the present invention.

【図19】本発明第二実施例の分岐命令情報テーブルの
内容を示す図。
FIG. 19 is a diagram showing the contents of a branch instruction information table according to the second embodiment of the present invention.

【図20】従来例の分岐命令情報テーブルの内容を示す
図。
FIG. 20 is a diagram showing the contents of a conventional branch instruction information table.

【図21】アセンブラソースプログラムの内容を示す
図。
FIG. 21 is a diagram showing the contents of an assembler source program.

【図22】従来例の分岐命令情報テーブル作成処理の内
容を示すフローチャート。
FIG. 22 is a flowchart showing the contents of conventional branch instruction information table creation processing.

【図23】従来例の最適化処理の内容を示すフローチャ
ート。
FIG. 23 is a flowchart showing the contents of optimization processing of a conventional example.

【図24】従来例の最適化処理の内容を示すフローチャ
ート。
FIG. 24 is a flowchart showing the contents of optimization processing of a conventional example.

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

400 先頭を指すチェインポインタ 401 末尾を指すチェインポインタ 410 第一分岐命令の前のテーブルを指すチェイン
ポインタ 411 第二分岐命令の前のテーブルを指すチェイン
ポインタ 412 第三分岐命令の前のテーブルを指すチェイン
ポインタ 413 第四分岐命令の前のテーブルを指すチェイン
ポインタ 414 第五分岐命令の前のテーブルを指すチェイン
ポインタ 415 第六分岐命令の前のテーブルを指すチェイン
ポインタ 416 第七分岐命令の前のテーブルを指すチェイン
ポインタ 417 第八分岐命令の前のテーブルを指すチェイン
ポインタ 418 第九分岐命令の前のテーブルを指すチェイン
ポインタ 419 第十分岐命令の前のテーブルを指すチェイン
ポインタ 420 第一分岐命令の次のテーブルを指すチェイン
ポインタ 421 第二分岐命令の次のテーブルを指すチェイン
ポインタ 422 第三分岐命令の次のテーブルを指すチェイン
ポインタ 423 第四分岐命令の次のテーブルを指すチェイン
ポインタ 424 第五分岐命令の次のテーブルを指すチェイン
ポインタ 425 第六分岐命令の次のテーブルを指すチェイン
ポインタ 426 第七分岐命令の次のテーブルを指すチェイン
ポインタ 427 第八分岐命令の次のテーブルを指すチェイン
ポインタ 428 第九分岐命令の次のテーブルを指すチェイン
ポインタ 429 第十分岐命令の次のテーブルを指すチェイン
ポインタ 430 第一分岐命令の分岐命令情報テーブル 431 第二分岐命令の分岐命令情報テーブル 432 第三分岐命令の分岐命令情報テーブル 433 第四分岐命令の分岐命令情報テーブル 434 第五分岐命令の分岐命令情報テーブル 435 第六分岐命令の分岐命令情報テーブル 436 第七分岐命令の分岐命令情報テーブル 437 第八分岐命令の分岐命令情報テーブル 438 第九分岐命令の分岐命令情報テーブル 439 第十分岐命令の分岐命令情報テーブル 440 次のテーブルを指すチェインポインタ 441 前のテーブルを指すチェインポインタ 442 分岐命令のアドレス 443 シンボルテーブルを指すチェインポインタ 444 コード増加量 500 ソースプログラムファイル 501 連続した前方参照の分岐命令群 502 連続した後方参照の分岐命令群 503 交差している分岐命令 510 第一分岐命令 511 第二分岐命令 512 第三分岐命令 513 第四分岐命令 514 第五分岐命令 515 第六分岐命令 516 第七分岐命令 517 第八分岐命令 518 第九分岐命令 519 第十分岐命令 520 第一飛び先 521 第二飛び先 522 第三飛び先 523 第四飛び先 524 第五飛び先 525 第六飛び先 526 第七飛び先 527 第八飛び先 528 第九飛び先 529 第十飛び先
400 Chain pointer that points to the beginning 401 Chain pointer that points to the end 410 Chain pointer that points to the table before the first branch instruction 411 Chain pointer that points to the table before the second branch instruction 412 Chain that points to the table before the third branch instruction Pointer 413 Chain pointer that points to the table before the fourth branch instruction 414 Chain pointer that points to the table before the fifth branch instruction 415 Chain pointer that points to the table before the sixth branch instruction 416 Pointer to the table before the seventh branch instruction Chain pointer 417 Chain pointer that points to the table before the eighth branch instruction 418 Chain pointer that points to the table before the ninth branch instruction 419 Chain pointer that points to the table before the tenth branch instruction 420 Next to the first branch instruction Chain pointing to a table Pointer 421 Chain pointer pointing to the next table of the second branch instruction 422 Chain pointer pointing to the table of the third branch instruction 423 Chain pointer 424 Pointing to the table of the fourth branch instruction 424 Next table of the fifth branch instruction Chain pointer to point 425 Chain pointer to point to the table next to the sixth branch instruction 426 Chain pointer to point to the table next to the seventh branch instruction 427 Chain pointer to point to the table next to the eighth branch instruction 428 Next to the ninth branch instruction Chain pointer pointing to a table 429 Chain pointer pointing to a table next to a tenth branch instruction 430 Branch instruction information table 431 of a first branch instruction Branch instruction information table 432 of a second branch instruction Branch instruction information table 433 of a third branch instruction Branch instruction information Bull 434 Branch instruction information table of fifth branch instruction 435 Branch instruction information table of sixth branch instruction 436 Branch instruction information table of seventh branch instruction 437 Branch instruction information table of eighth branch instruction 438 Branch instruction information of ninth branch instruction Table 439 Branch instruction information table for tenth branch instruction 440 Chain pointer pointing to the next table 441 Chain pointer pointing to the previous table 442 Branch instruction address 443 Chain pointer pointing to the symbol table 444 Code increment 500 Source program file 501 Continuous Forward reference branch instruction group 502 Continuous backward reference branch instruction group 503 Crossing branch instruction 510 First branch instruction 511 Second branch instruction 512 Third branch instruction 513 Fourth branch instruction 514 Fifth branch instruction 515 Sixth Branch Instruction 516 7th branch instruction 517 8th branch instruction 518 9th branch instruction 519 10th branch instruction 520 1st jump destination 521 2nd jump destination 522 3rd jump destination 523 4th jump destination 524 5th jump destination 525 6th jump instruction Destination 526 7th destination 527 8th destination 528 9th destination 529 10th destination

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】 分岐先までの相対アドレスの大小にかか
わらず同じ記述形式で分岐命令が記述されたソースプロ
グラムファイルを入力する入力手段と、 上記分岐命令がソースプログラムファイルに出現する毎
に上記分岐命令について次のテーブルへのポインタと分
岐命令のアドレスとシンボルテーブルを指すポインタと
コード増加量の情報とをもつテーブルを記憶するメモリ
と、 アドレスの小さい順に上記テーブルをチェインでつなぐ
第一テーブル連繋手段と、 上記第一テーブル連繋手段でつながれたテーブルを参照
して上記分岐命令のアドレスの小さい順に処理を行い、
分岐命令を最も短いオブジェクトコードに対応させたオ
ブジェクトモジュールファイルを作成するオブジェクト
モジュールファイル作成手段とを備えたアセンブラ装置
において、 上記テーブルに前のテーブルへのポインタを付加してア
ドレスの大きい順にテーブルをチェインでつなぐ第二テ
ーブル連繋手段と、 上記オブジェクトモジュールファイル作成手段は、上記
第二テーブル連繋手段で繋がれたテーブルを参照して分
岐命令のアドレスの大きい順に行う処理を上記分岐命令
のアドレスの小さい順に行う処理と交互に実行する手段
と、この手段での処理実行後に残された分岐命令を処理
する手段とを備えたことを特徴とするアセンブラ装置。
1. Input means for inputting a source program file in which a branch instruction is described in the same description format regardless of the relative address up to the branch destination, and the branching each time the branch instruction appears in the source program file. For the instruction, a memory for storing a table having a pointer to the next table, an address of a branch instruction, a pointer to the symbol table, and code increase amount information, and a first table connecting means for connecting the above tables in a chain in ascending order of address. And referring to the tables connected by the first table connection means, perform processing in the ascending order of the addresses of the branch instructions,
In an assembler device provided with an object module file creating means for creating an object module file in which a branch instruction is associated with the shortest object code, a pointer is added to the previous table in the above table to chain the tables in descending order of address. The second table linking means for connecting with each other and the object module file creating means refer to the tables linked by the second table linking means and perform the processing in the descending order of the address of the branch instruction in ascending order of the address of the branch instruction. An assembler device comprising: a means for executing the processing alternately with the processing to be performed; and a means for processing a branch instruction left after the processing is executed by this means.
【請求項2】 分岐先までの相対アドレスの大小にかか
わらず同じ記述形式で分岐命令が記述されたソースプロ
グラムファイルを入力する入力手段と、 上記分岐命令がソースプログラムファイルに出現する毎
に上記分岐命令について次のテーブルへのポインタと分
岐命令のアドレスとシンボルテーブルを指すポインタと
コード増加量の情報とをもつテーブルを記憶するメモリ
と、 アドレスの小さい順に上記テーブルをチェインでつなぐ
第一テーブル連繋手段と、 上記第一テーブル連繋手段でつながれたテーブルを参照
して上記分岐命令のアドレスの小さい順に処理を行い、
分岐命令を最も短いオブジェクトコードに対応させたオ
ブジェクトモジュールファイルを作成するオブジェクト
モジュールファイル作成手段とを備えたアセンブラ装置
において、 上記テーブルに前のテーブルへのポインタを付加してア
ドレスの大きい順にテーブルをチェインでつなぐ第二テ
ーブル連繋手段と、 上記オブジェクトモジュールファイル作成手段は、上記
第二テーブル連繋手段で繋がれたテーブルを参照して分
岐命令のアドレスの大きい順に行う第一手段と、上記分
岐命令のアドレスの小さい順に行う第二手段と、この第
一手段で処理を行うときに分岐命令の飛び先が交差する
分岐命令群に対して互いに相手のオブジェクトコードサ
イズに依存する分岐命令群を最適なオブジェクトコード
に決定する手段とを備えたことを特徴とするアセンブラ
装置。
2. Input means for inputting a source program file in which a branch instruction is described in the same description format regardless of the relative address up to the branch destination, and the branching each time the branch instruction appears in the source program file. For the instruction, a memory for storing a table having a pointer to the next table, an address of a branch instruction, a pointer to the symbol table, and code increase amount information, and a first table connecting means for connecting the above tables in a chain in ascending order of address. And referring to the tables connected by the first table connection means, perform processing in the ascending order of the addresses of the branch instructions,
In an assembler device provided with an object module file creating means for creating an object module file in which a branch instruction is associated with the shortest object code, a pointer is added to the previous table in the above table to chain the tables in descending order of address. The second table linking means for connecting with each other and the object module file creating means refer to the tables linked by the second table linking means in the order of descending branch instruction addresses, and the branch instruction address. The second object to be executed in the ascending order of the first and second instruction groups which are dependent on each other's object code size with respect to the branch instruction group in which the jump destinations of the branch instructions cross each other when the processing by this first means is performed. And a means for determining That assembler apparatus.
JP16296692A 1991-11-07 1992-06-22 Assembler device Pending JPH05257703A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP3-291536 1991-11-07
JP29153691 1991-11-07

Publications (1)

Publication Number Publication Date
JPH05257703A true JPH05257703A (en) 1993-10-08

Family

ID=17770178

Family Applications (1)

Application Number Title Priority Date Filing Date
JP16296692A Pending JPH05257703A (en) 1991-11-07 1992-06-22 Assembler device

Country Status (1)

Country Link
JP (1) JPH05257703A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08234998A (en) * 1995-02-28 1996-09-13 Nec Corp Assembler processing method
JPH08241196A (en) * 1995-03-05 1996-09-17 Nec Corp Branch instruction processing system
EP0803805A1 (en) * 1996-04-25 1997-10-29 Nec Corporation Assembler

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08234998A (en) * 1995-02-28 1996-09-13 Nec Corp Assembler processing method
JPH08241196A (en) * 1995-03-05 1996-09-17 Nec Corp Branch instruction processing system
EP0803805A1 (en) * 1996-04-25 1997-10-29 Nec Corporation Assembler
US5960203A (en) * 1996-04-25 1999-09-28 Nec Corporation Assembler device and its assembling method for use in a microcomputer or other computer system

Similar Documents

Publication Publication Date Title
US5043880A (en) Data flow processor which combines packets having same identification and destination and synchronizes loop variables for detecting processing loop termination
KR100875401B1 (en) Processor Units and How to Handle Complex Conditions
JP2765423B2 (en) Programmable controller and control method thereof
US4773007A (en) Complier code optimization method for a source program having a first and second array definition and use statements in a loop
US4608660A (en) Data processing system with condition data setting function
JPH05257703A (en) Assembler device
JP3047771B2 (en) Branch instruction processing method and apparatus
US6961846B1 (en) Data processing unit, microprocessor, and method for performing an instruction
JP3036900B2 (en) Assembler processing unit
CN113238746A (en) Hybrid programming control method, device, equipment and storage medium
CN115817381B (en) Throttle mode self-adaptive identification method and device, storage medium and terminal
JP2003223204A (en) Programming method of programmable controller, system thereof and recording medium thereof
JP2768803B2 (en) Parallel processing unit
JPS6266315A (en) Input control system
EP0633525A2 (en) Language processing method
JPH04330526A (en) Relocatable assembler
KR100423742B1 (en) Exclusive control system by sequential function chart
JPH0546404A (en) Branch instruction deletion optimizing system
WO1990007152A1 (en) A modular blackboard-based expert system
JP2515719B2 (en) Equipment group control method
JPH086797A (en) Constant reference optimizing processor
JP3658771B2 (en) Compiler device
JP3012366B2 (en) Remote file access method
JPH0651993A (en) Assembler
JPH03271941A (en) Optimizing system for language processor