JP2610890B2 - Assembler branch instruction generation method - Google Patents

Assembler branch instruction generation method

Info

Publication number
JP2610890B2
JP2610890B2 JP62227418A JP22741887A JP2610890B2 JP 2610890 B2 JP2610890 B2 JP 2610890B2 JP 62227418 A JP62227418 A JP 62227418A JP 22741887 A JP22741887 A JP 22741887A JP 2610890 B2 JP2610890 B2 JP 2610890B2
Authority
JP
Japan
Prior art keywords
branch instruction
address
symbol
branch
assembler
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.)
Expired - Lifetime
Application number
JP62227418A
Other languages
Japanese (ja)
Other versions
JPS6468836A (en
Inventor
三喜雄 尾形
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 Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP62227418A priority Critical patent/JP2610890B2/en
Publication of JPS6468836A publication Critical patent/JPS6468836A/en
Application granted granted Critical
Publication of JP2610890B2 publication Critical patent/JP2610890B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明はアセンブラの分岐命令生成方式に関し、特に
長さが異なる二つ以上のオブジェクトコードを持つ分岐
命令を有するコンピュータに使用されるアセンブラの分
岐命令生成方式に関する。
Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a branch instruction generation method of an assembler, and more particularly to a branch of an assembler used in a computer having a branch instruction having two or more object codes having different lengths. The present invention relates to an instruction generation method.

〔従来の技術〕[Conventional technology]

分岐する範囲によりアドレス部の長さが異なる二つ以
上のオブジェクトコードを持つ分岐命令を有するコンピ
ュータにおける第1の従来のアセンブラの分岐命令生成
方式は、長さが異なる複数のオブジェクトコードごと
に、それぞれ個別のアセンブリ言語の分岐命令を用意
し、使用者が適したアセンブリ言語の分岐命令を選択し
て使用する方式を用いている。
A first conventional assembler branch instruction generation method in a computer having a branch instruction having two or more object codes having different address portions depending on the range of branching has a plurality of object codes having different lengths. A method is used in which individual assembly language branch instructions are prepared, and a user selects and uses an appropriate assembly language branch instruction.

しかし、使用者は、最初ソースプログラムを記述する
ときに、どの長さの分岐命令が適しているか判断できな
い場合、安全のために長い分岐命令を選択して使用する
こととなる。
However, when a user cannot determine which length of a branch instruction is suitable when writing a source program for the first time, the user selects and uses a long branch instruction for safety.

このため、アセンブラは、ソースプログラムの中に記
述している分岐命令がより短い分岐命令で記述可能であ
った場合、その旨のメッセージを出力し、使用者に記述
の変更を促している。
For this reason, when the branch instruction described in the source program can be described by a shorter branch instruction, the assembler outputs a message to that effect to urge the user to change the description.

また、第2の従来のアセンブラの分岐命令生成方式
は、最初ソースプログラムを記述するときに、アセンブ
リ言語の分岐命令を疑似命令で記述し、アセンブラがア
センブル時に、この疑似命令を適当なオブジェクトコー
ドに生成する方式であるが、疑似命令の分岐先がその疑
似命令の後に出て来る場所を指す場合、アセンブラが疑
似命令の分岐先をアセンブル時に確定できないので、最
長の分岐命令を選ぶこととなり、適した長さのオブジェ
クトコードを生成することができなかった。
In the second conventional branch instruction generation method of assembler, when a source program is first described, a branch instruction of an assembly language is described by a pseudo instruction, and when the assembler assembles, the pseudo instruction is converted into an appropriate object code. If the branch destination of a quasi-instruction points after the quasi-instruction, the assembler cannot determine the quasi-instruction's branch destination when assembling, so the longest branch instruction is selected. Could not generate the object code of the specified length.

〔発明が解決しようとする問題点〕[Problems to be solved by the invention]

上述した従来のアセンブラの分岐命令生成方式は、い
ずれの場合も、使用者がどの長さが適しているか判断で
きない場合や分岐先が分岐命令の後に出て来る場所を指
す場合など、適した長さのオブジェクトコードの分岐命
令を生成することができない場合がある。
In any case, the conventional assembler branch instruction generation method described above uses an appropriate length, such as when the user cannot determine which length is appropriate or when the branch destination points to a place that comes out after the branch instruction. May not be able to generate a branch instruction for the object code.

このため、適した長さの分岐命令にするために、使用
者が後でソースプログラムを変更しなければならないと
いう問題点がある。
For this reason, there is a problem that the user must later change the source program in order to obtain a branch instruction having an appropriate length.

また、一度、使用者がソースプログラムを変更したと
きに、多くのオブジェクトコードが短くなることによ
り、長い分岐命令でしか分岐できなかったものが、さら
に、より短い分岐命令で分岐可能になり、最適なオブジ
ェクトコードにするために、複数回に渡って、ソースプ
ログラムを変更しなければならなくなるという問題点が
ある。
In addition, once the user changes the source program, many object codes are shortened, so that what could only be branched with a long branch instruction can now be branched with a shorter branch instruction. There is a problem that the source program must be changed several times in order to make the object code simple.

さらに、プログラムのデバッグ段階では、ソースプロ
グラムに命令を追加したり、削除したりして修正するた
めに、使用できる分岐命令が変ってしまうので、デバッ
グが終了した段階でなければ、何度でもソースプログラ
ムを変更しなければならないという欠点がある。
Furthermore, in the program debugging stage, the branch instructions that can be used are changed because instructions are added to or deleted from the source program to modify the source program. The disadvantage is that the program has to be changed.

本発明の目的は、長さが異なる二つ以上のオブジェク
トコードを持つ分岐命令を有するコンピュータで、適し
た長さの分岐命令を自動的に生成することができるアセ
ンブラの分岐命令生成方式を提供することにある。
An object of the present invention is to provide a branch instruction generation method of an assembler that can automatically generate a branch instruction of an appropriate length in a computer having a branch instruction having two or more object codes having different lengths. It is in.

〔問題点を解決するための手段〕[Means for solving the problem]

本発明のアセンブラの分岐命令生成方式は、分岐する
範囲によりアドレス部の長さが異なる二つ以上のオブジ
ェクトコードを持つ分岐命令を有するコンピュータに使
用されるアセンブラの分岐命令生成方式において、 (A)ソースプログラムを入力して分岐命令が出現する
ごとに、その分岐命令に関して適した長さのアドレス部
を有するオブジェクトコードを選定して定め、定められ
ないときには、短い分岐命令に仮に定めて、その分岐命
令に関して算定した仮番地およびその分岐命令の長さの
変動範囲をそれぞれ記憶し、分岐命令のアドレス部に使
用されるシンボルが出現するごとに、そのシンボルに関
して算定した仮番地を記憶する選定作業表を作成するア
センブラの第1パス手順、 (B)前記選定作業表に記憶されたすべての分岐命令の
仮番地およびそれらの変動範囲と、分岐命令の分岐先を
示すすべてのシンボルの仮番地とを参照して、それぞれ
の分岐命令とそのアドレス部に使用されたシンボルとの
最小相対番地と最大相対番地とを算定し、前記最小相対
番地および前記最大相対番地の値から判断することによ
りそれぞれの分岐命令に関して適した長さのアドレス部
を有するオブジェクトコードを選定して定め、これらの
選定結果により前記選定作業表に記憶された分岐命令お
よびシンボルそれぞれの仮番地をそれぞれの最終番地に
更新し、シンボルの最終番地をシンボルテーブルに登録
する分岐命令選定手順、 (C)前記シンボルテーブルの登録内容を参照すること
により、適した長さのオブジェクトコードを持つ分岐命
令を含むオブジェクトプログラムを生成して出力するア
センブラの第2パス手順、 を備えて構成されている。
The assembler branch instruction generation method according to the present invention is the assembler branch instruction generation method used in a computer having a branch instruction having two or more object codes whose address portions have different lengths depending on the range of branching. Each time a source program is input and a branch instruction appears, an object code having an address portion of an appropriate length for the branch instruction is selected and determined. A selection work table that stores a temporary address calculated for an instruction and a variation range of the length of the branch instruction, and stores a temporary address calculated for the symbol each time a symbol used in the address part of the branch instruction appears. (B) all the branch instructions stored in the selection work table Address and the range of their fluctuation, and the temporary addresses of all the symbols indicating the branch destination of the branch instruction, and refer to the minimum relative address and the maximum relative address of each branch instruction and the symbol used in its address part. Address, and by judging from the values of the minimum relative address and the maximum relative address, an object code having an address portion of a suitable length for each branch instruction is selected and determined. A branch instruction selection procedure for updating the branch address and the temporary address of each symbol stored in the selection work table to the final address, and registering the final address of the symbol in the symbol table; (C) Refer to the registered contents of the symbol table To generate an object program including a branch instruction having an object code of a suitable length. Second pass procedure forces assembler is configured to include a.

〔実施例〕〔Example〕

次に本発明の実施例について図面を参照して説明す
る。
Next, embodiments of the present invention will be described with reference to the drawings.

第1図は本発明のアセンブラの分岐命令生成方式の一
実施例を示す流れ図である。
FIG. 1 is a flowchart showing one embodiment of a branch instruction generation method of an assembler of the present invention.

以下において、本実施例のアセンブラの分岐命令生成
方式が、アドレス部の長さで分岐する範囲が異なる1バ
イト分岐命令,2バイト分岐命令および3バイト分岐命令
の3種類のオブジェクトコードを持つ分岐命令を有する
コンピュータで使用される場合について説明する。
In the following, the branch instruction generation method of the assembler of the present embodiment is based on a branch instruction having three types of object codes of a 1-byte branch instruction, a 2-byte branch instruction, and a 3-byte branch instruction having different branch ranges depending on the length of the address part A case in which the computer is used in a computer having the following will be described.

第1図において、アセンブラの第1パス手順1は、ソ
ースプログラムのアセンブル時における1回目のソース
プログラム入力処理手順を示している。
In FIG. 1, a first pass procedure 1 of the assembler indicates a first source program input processing procedure at the time of assembling a source program.

第2図は入力してアセンブルされるソースプログラム
の一例を示す情報説明図である。
FIG. 2 is an information explanatory diagram showing an example of a source program to be input and assembled.

まず、文字解析手順1−1で、第1図および第2図の
ソースプログラムaをステートメントごとに入力して、
文字単位に処理し、シンボル,予約語,数値,特殊文字
などのトークンと呼ばれる中間コードへ変換する。
First, in the character analysis procedure 1-1, the source program a of FIGS. 1 and 2 is input for each statement,
Processing is performed on a character-by-character basis, and is converted into an intermediate code called a token such as a symbol, a reserved word, a numerical value, or a special character.

次に、構文解析手順1−2で、そのトークンを受取
り、そのステートメントの構文を解析して処理する。
Next, in the syntax analysis step 1-2, the token is received, and the syntax of the statement is analyzed and processed.

このとき、上記の3種類を選択する必要がある分岐命
令で、分岐先が未だ確定できない分岐命令が出現すれ
ば、それ以後のシンボルを選定作業表bに記憶するため
に、作業フラグをオンに設定する。
At this time, if a branch instruction whose branch destination cannot be determined yet appears among the branch instructions for which the above three types need to be selected, the work flag is turned on to store the subsequent symbols in the selection work table b. Set.

第2図の例では、ソースプログラムaのステートメン
トのBR EXITで、作業フラグがオンに設定され、アセン
ブラの第1パス手順1が終了するまで保持される。
In the example of FIG. 2, the work flag is set to ON by BR EXIT of the statement of the source program a, and the work flag is held until the first pass procedure 1 of the assembler is completed.

次に、ステップ1−3で、未確定情報を含むかどうか
を判断し、上記の3種類を選択する必要があり分岐先が
未だ確定できない分岐命令および上記の作業フラグがオ
ンのときの格納番地が未だ確定していないシンボルにつ
いては、未確定情報を含むので、選定作業表作成手順1
−4へ移行し、その他についてはシンボル登録手順1−
5に移行する。
Next, in step 1-3, it is determined whether or not the undetermined information is included, and the above three types need to be selected. The branch instruction whose branch destination cannot be determined yet and the storage address when the work flag is on are set. For symbols that have not been determined yet, since unconfirmed information is included, the selection work table creation procedure 1
-4, and for others, symbol registration procedure 1-
Move to 5.

選定作業表作成手順1−4で、分岐命令は、長さを最
小のものに仮に定めて、その分岐命令に関して算定した
仮番地およびその分岐命令の長さの変動範囲をそれぞれ
選定作業表bに記憶し、シンボルは、そのシンボルに関
して算定した仮番地を選定作業表bに記憶して、ステッ
プ1−6に移る。
In the selection work table preparation procedure 1-4, the branch instruction is temporarily set to the minimum length, and the temporary address calculated for the branch instruction and the variation range of the length of the branch instruction are respectively set in the selection work table b. For the symbol, the temporary address calculated for the symbol is stored in the selection work table b, and the process proceeds to step 1-6.

第3図は選定作業表に記憶される情報の一例を示す情
報説明図である。
FIG. 3 is an information explanatory view showing an example of information stored in a selection work table.

第3図において、分岐命令は、選定作業表bの分岐命
令表b−1に、長さを最小のものに仮に定めて算定した
仮番地である分岐命令の仮先頭番地の値(この値を以下
に記号Aで示す)およびその分岐命令の長さの変動範囲
である最大増加バイト数の値(この値を以下に記号Bで
示す)を記憶し、シンボルは、選定作業表bのシンボル
表b−2に、算定した仮番地であるシンボルの仮先頭番
地の値(この値を以下に記号Eで示す)を記憶する。
In FIG. 3, the branch instruction is a branch instruction table b-1 of the selection work table b in which the value of the temporary start address of the branch instruction which is the temporary address calculated by temporarily determining the length to be the minimum (this value is (Hereinafter denoted by symbol A) and the value of the maximum increment byte number (this value is denoted by symbol B below) which is the range of variation of the length of the branch instruction, and the symbol is the symbol table of the selection work table b. In b-2, the value of the calculated temporary address of the symbol, which is the temporary address, is stored (this value is indicated by symbol E below).

一方、シンボル登録手順1−5では、シンボルを、そ
のシンボルに関して算定した確定番地とともに、シンボ
ルテーブルcに登録して、ステップ1−6に移る。
On the other hand, in the symbol registration procedure 1-5, the symbol is registered in the symbol table c together with the determined address calculated for the symbol, and the process proceeds to step 1-6.

次に、ステップ1−6で、ソースプログラムaの最後
のステートメントまで終了したかどうかを判断し、未だ
終了していなければ、文字解析手順1−1にもどって次
のステートメントの処理に移り、終了していれば、分岐
命令選定手順2に移行する。
Next, in step 1-6, it is determined whether or not the processing has been completed up to the last statement of the source program a. If the processing has not been completed yet, the process returns to the character analysis procedure 1-1 and proceeds to the processing of the next statement. If so, the process proceeds to branch instruction selection procedure 2.

分岐命令選定手順2では、まず、未確定情報確定化手
順2−1で、分岐先が未だ確定してない分岐命令および
格納番地が未だ確定してないシンボルについて、選定作
業表bの情報を使用して、未確定情報の確定化動作を行
う。
In the branch instruction selection procedure 2, first, in the undetermined information finalization procedure 2-1, the information of the selection work table b is used for a branch instruction whose branch destination is not yet determined and a symbol whose storage address is not yet determined. Then, the operation of finalizing the undetermined information is performed.

第3図において、選定作業表bに記憶されたすべての
分岐命令に関する仮番地であるAおびその変動範囲であ
るBと、それらの分岐命令の分岐先を示すすべてのシン
ボルに関する仮番地であるEとを参照して、それぞれの
分岐命令とそのアドレス部に使用されたシンボルとの間
の最小相対番地の値(この値を以下に記号Cで示す)と
最大相対番地の値(この値を以下に記号Dで示す)とを
算定し、CおよびDから判断することによりそれぞれの
分岐命令に関して適した長さのアドレス部を有するオブ
ジェクトコードを選定して定め、これらの選定結果によ
り選定作業表bに記憶された分岐命令の仮番地であるA
およびシンボルの仮番地であるEをそれぞれの最終番地
に更新する。
In FIG. 3, A is a temporary address for all branch instructions stored in the selection operation table b and B is its variation range, and E is a temporary address for all symbols indicating the branch destinations of those branch instructions. And the value of the minimum relative address between the respective branch instructions and the symbol used for the address part (this value is indicated by symbol C below) and the value of the maximum relative address (this value is , And an object code having an address portion having an appropriate length for each branch instruction is selected and determined by judging from C and D, and a selection work table b is determined based on the selection results. A, which is the temporary address of the branch instruction stored in
And the temporary address E of the symbol is updated to the final address.

第4図はこの未確定情報確定化手順2−1の詳細を示
す流れ図である。
FIG. 4 is a flowchart showing details of the unconfirmed information finalizing procedure 2-1.

第4図において、まず、ステップS1で、分岐命令表b
−1の最初の行の分岐命令BR EXITの最小相対番地Cお
よび最大相対番地Dの値を計算する。
In FIG. 4, first, in step S1, a branch instruction table b
Calculate the values of the minimum relative address C and the maximum relative address D of the branch instruction BR EXIT in the first row of -1.

最小相対番地Cの値は、分岐命令BR EXITのAが0100
で、シンボル表b−2のシンボルEXITのEが0150のた
め、その差0050となる。
The value of the minimum relative address C is 0100 for A of the branch instruction BR EXIT.
Since E of the symbol EXIT in the symbol table b-2 is 0150, the difference is 0050.

最大相対番地Dの値は、第2図に示すように、分岐命
令BR EXITとシンボルEXITとの間に、未確定の分岐命令B
R LABELおよびBR LOOPがあり、分岐命令表b−1に示す
ように、これらの最大増加バイト数Bがそれぞれ2であ
るので、これらを最小相対番地Cの値に加えた0054とな
る。
The value of the maximum relative address D is, as shown in FIG. 2, between the branch instruction BR EXIT and the symbol EXIT, the undetermined branch instruction B
There are R LABEL and BR LOOP, and as shown in the branch instruction table b-1, the maximum number of bytes B of each of them is 2, so that 0054 is obtained by adding these to the value of the minimum relative address C.

次に、ステップS2で、Dが、1バイト分岐命令で分岐
できる最大値(この値を以下に記号I1で示す)以下であ
るかどうかを判断する。
Next, in step S2, D is the maximum value that can be branched in 1-byte branch instruction (indicated by symbol I 1 this value below) to determine if a whether or less.

D≦I1であれば、その分岐命令は、1バイト分岐命令
になるので、ステップS3で、対象のBを0に更新する。
If D ≦ I 1, the branch instruction, since the 1-byte branch instruction, at step S3, to update the target B to 0.

D≦I1でなければ、次に、ステップS4で、Dが、2バ
イト分岐命令で分岐できる最大値(この値を以下に記号
I2で示す)以下で、しかもC≦I1≦Dであるかどうかを
判断する。
Otherwise D ≦ I 1, then, in step S4, D is the maximum value that can be split by 2 bytes branch instruction (Symbol this value below
In at shown) below I 2, yet it is determined whether the C ≦ I 1 ≦ D.

C≦I1≦D≦I2であれば、その分岐命令は、1バイト
分岐命令か2バイト分岐命令かになるので、ステップS5
で、対象のBが2のときはそのBを1に更新する。
If C ≦ I 1 ≦ D ≦ I 2 , the branch instruction is a one-byte branch instruction or a two-byte branch instruction.
If the target B is 2, the B is updated to 1.

C≦I1≦D≦I2でなければ、次に、ステップS6で、I1
≦C≦D≦I2であるかどうかを判断する。I1≦C≦D≦
I2であれば、その分岐命令は、2バイト分岐命令になる
ので、ステップS7で、対象のBが2のときはそのBを0
として、その分岐命令から後の番地にあるすべての分岐
命令のAおよびその分岐命令から後の番地にあるすべて
のシンボルのEのそれぞれに1を加える。
If C ≦ I 1 ≦ D ≦ I 2 , then in step S 6, I 1
It is determined whether or not ≦ C ≦ D ≦ I 2 . I 1 ≦ C ≦ D ≦
If I 2, the branch instruction, since the 2-byte branch instruction, in step S7, when the subject of B is 2 and the B 0
Is added to each of A of all branch instructions at addresses subsequent to the branch instruction and E of all symbols at addresses subsequent to the branch instruction.

I1≦C≦D≦I2でなければ、次に、ステップS8で、I1
≦C≦I2≦Dであるかどうかを判断する。I1≦C≦I2
Dであれば、その分岐命令は、2バイト分岐命令か3バ
イト分岐命令かになるので、ステップS9で、対象のBが
2のときはそのBを1として、その分岐命令から後の番
地にあるすべての分岐命令のAおよびその分岐命令から
後の番地にあるすべてのシンボルのEのそれぞれに1を
加える。
If it is not I 1 ≦ C ≦ D ≦ I 2 , then in step S8, I 1
It is determined whether or not ≦ C ≦ I 2 ≦ D. I 1 ≦ C ≦ I 2
If it is D, the branch instruction is a two-byte branch instruction or a three-byte branch instruction. In step S9, if the target B is 2, the B is set to 1 and the address after the branch instruction is set to 1. One is added to each of A of all branch instructions and E of all symbols at addresses subsequent to the branch instruction.

I1≦C≦I2≦Dでなければ、次に、ステップS9で、I2
≦Cであるかどうかを判断する。
If I 1 ≦ C ≦ I 2 ≦ D, then in step S9, I 2
It is determined whether or not ≦ C.

I2≦Cであれば、その分岐命令は、3バイト分岐命令
になるので、ステップS10で、その分岐命令から後の番
地にあるすべての分岐命令のAおよびその分岐命令から
後の番地にあるすべてのシンボルのEのそれぞれにその
分岐命令のBを加えて更新するとともに、その分岐命令
のBは0とする。
If I 2 ≦ C, the branch instruction is a 3-byte branch instruction. Therefore, in step S10, all the branch instructions A at the address after the branch instruction and the addresses after the branch instruction are present. The E of all the symbols is updated by adding the B of the branch instruction, and the B of the branch instruction is set to 0.

次に、ステップS11で、最後の行まで終了したかどう
かを判断する。未だ途中の行であれば、ステップS12
で、次の行に対する動作に移り、ステップS1にもどって
同じ動作を繰返す。
Next, in step S11, it is determined whether the processing has been completed up to the last line. If the line is still in the middle, step S12
Then, the operation shifts to the operation for the next line, and returns to step S1 to repeat the same operation.

ステップS11で、最後の行まで終了した場合は、ステ
ップS13に移り、最大増加バイト数のBがすべて0にな
ったかどうかを判定する。Bがすべて0であれば、この
未確定情報確定化手順2−1を終了し、第1図で次のシ
ンボル登録手順2−2に移行する。
If it is determined in step S11 that the process has been completed up to the last line, the process proceeds to step S13, and it is determined whether or not all of the maximum incremented bytes B have become zero. If B is all 0, the undetermined information finalizing procedure 2-1 ends, and the process proceeds to the next symbol registration procedure 2-2 in FIG.

ステップS13で、Bに0でないものがあれば、ステッ
プS14に移る。
If it is determined in step S13 that B is not 0, the process proceeds to step S14.

ステップS14では、上記の各行に対する一巡の動作
で、選定作業表bを更新していたかどうかを判断する。
選定作業表bを更新していれば、ステップS15で、さら
に、もう一巡の動作を行うため、最初の行にもどって、
ステップS1から同じ動作を繰返す。
In step S14, it is determined whether or not the selection work table b has been updated in one cycle of each row described above.
If the selection work table b has been updated, in step S15, the operation returns to the first line to perform another round of operation.
The same operation is repeated from step S1.

ステップS14で、選定作業表bを更新していなけれ
ば、この未確定情報確定化手順2−1を終了し、第1図
で次のシンボル登録手順2−2に移行する。
If it is determined in step S14 that the selection work table b has not been updated, the undecided information finalizing procedure 2-1 ends, and the process proceeds to the next symbol registration procedure 2-2 in FIG.

シンボル登録手順2−2では、未確定情報確定化手順
2−1で確定したシンボルの最終番地をシンボルテーブ
ルcに登録し、アセンブラの第2パス手順3に移行す
る。
In the symbol registration procedure 2-2, the final address of the symbol determined in the undetermined information determination procedure 2-1 is registered in the symbol table c, and the process proceeds to the second pass procedure 3 of the assembler.

アセンブラの第2パス手順3は、ソースプログラムの
アセンブル時における2回目のソースプログラム入力処
理手順を示している。
The second pass procedure 3 of the assembler indicates a second source program input processing procedure at the time of assembling the source program.

まず、文字解析手順3−1で、ソースプログラムaを
ステートメントごとに入力して、文字単位に処理し、シ
ンボル,予約語,数値,特殊文字などのトークンと呼ば
れる中間コードへ変換する。
First, in the character analysis procedure 3-1, the source program a is input for each statement, processed in units of characters, and converted into intermediate codes called tokens such as symbols, reserved words, numerical values, and special characters.

次に、構文解析手順3−2で、そのトークンを受取
り、そのステートメントの構文を解析し処理する。
Next, in a syntax analysis procedure 3-2, the token is received, and the syntax of the statement is analyzed and processed.

次に、オブジェクト生成手順3−3で、シンボルテー
ブルcの登録内容を参照することにより、適した長さの
オブジェクトコードを持つ分岐命令を含むオブジェクト
プログラムdを生成して出力する。
Next, in the object generation procedure 3-3, an object program d including a branch instruction having an object code of an appropriate length is generated and output by referring to the registered contents of the symbol table c.

次に、ステップ3−4で、ソースプログラムaの最後
のステートメントまで終了したかどうかを判断し、未だ
終了していなければ、文字解析手順3−1にもどって、
次のステートメントの処理に移り、終了していればアセ
ンブル処理を終了する。
Next, in step 3-4, it is determined whether or not the processing has been completed up to the last statement of the source program a. If the processing has not been completed yet, the process returns to the character analysis procedure 3-1.
Move to the processing of the next statement, and if completed, end the assembling processing.

〔発明の効果〕〔The invention's effect〕

以上説明したように、本発明のアセンブラの分岐命令
生成方式は、長さが異なる二つ以上のオブジェクトコー
ドを持つ分岐命令を有するコンピュータで、選定作業表
を使用して処理し、適した長さの分岐命令を自動的に生
成することができるという効果を有している。また、本
発明のアセンブラの分岐命令生成方式は、分岐命令の長
さを定められないときには、短い分岐命令に仮に定め
て、分岐命令の選定作業表を作成し、分岐命令の選定作
業を能率良く実施しているので、長い分岐命令に仮に定
めて分岐命令の選定作業を行う場合に比べて分岐命令の
選定を速やかに行えるという利点を有している。
As described above, the branch instruction generation method of the assembler of the present invention is a computer having a branch instruction having two or more object codes having different lengths. Is automatically generated. Further, when the length of a branch instruction cannot be determined, the assembler branch instruction generation method according to the present invention tentatively determines the length of the branch instruction, creates a branch instruction selection work table, and efficiently selects the branch instruction. Since the present invention is implemented, there is an advantage that the branch instruction can be selected more quickly than when a branch instruction is selected and the branch instruction is selected.

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

第1図は本発明のアセンブラの分岐命令生成方式の一実
施例を示す流れ図、第2図はソースプログラムの一例を
示す情報説明図、第3図は選定作業表に記憶される情報
の一例を示す情報説明図、第4図は未確定情報確定化手
順の詳細を示す流れ図である。 1……アセンブラの第1パス手順、1−1……文字解析
処理手順、1−2……構文解析処理手順、1−4……選
定作業表作成手順、1−5……シンボル登録手順、2…
…分岐命令選定手順、2−1……未確定情報確定化手
順、2−2……シンボル登録手順、3……アセンブラの
第2パス手順、3−1……文字解析処理手順、3−2…
…構文解析処理手順、3−3……オブジェクト生成手
順、a……ソースプログラム、b……選定作業表、b−
1……分岐命令表、b−2……シンボル表、c……シン
ボルテーブル、d……オブジェクトプログラム。
FIG. 1 is a flowchart showing an embodiment of a branch instruction generation method of an assembler according to the present invention, FIG. 2 is an explanatory diagram showing an example of a source program, and FIG. 3 is an example of information stored in a selection work table. FIG. 4 is a flowchart showing the details of the unconfirmed information finalizing procedure. 1... First pass procedure of assembler 1-1... Character analysis processing procedure 1-2... Syntax analysis processing procedure 1-4... Selection work table creation procedure 1-5. 2 ...
… Branch instruction selection procedure 2-1… undefined information finalization procedure 2-2… symbol registration procedure 3… second assembler pass procedure 3-1 …… character analysis processing procedure 3-2 …
... Syntax analysis procedure, 3-3 ... Object generation procedure, a ... Source program, b ... Selection work table, b-
1 ... branch instruction table, b-2 ... symbol table, c ... symbol table, d ... object program.

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】分岐する範囲によりアドレス部の長さが異
なる二つ以上のオブジェクトコードを持つ分岐命令を有
するコンピュータに使用されるアセンブラの分岐命令生
成方式において、 (A)ソースプログラムを入力して分岐命令が出現する
ごとに、その分岐命令に関して適した長さのアドレス部
を有するオブジェクトコードを選定して定め、定められ
ないときには、短い分岐命令に仮に定めて、その分岐命
令に関して算定した仮番地およびその分岐命令の長さの
変動範囲をそれぞれ記憶し、分岐命令のアドレス部に使
用されるシンボルが出現するごとに、そのシンボルに関
して算定した仮番地を記憶する選定作業表を作成するア
センブラの第1パス手順、 (B)前記選定作業表に記憶されたすべての分岐命令の
仮番地およびそれらの変動範囲と、分岐命令の分岐先を
示すすべてのシンボルの仮番地とを参照して、それぞれ
の分岐命令とそのアドレス部に使用されたシンボルとの
最小相対番地と最大相対番地とを算定し、前記最小相対
番地および前記最大相対番地の値から判断することによ
りそれぞれの分岐命令に関して適した長さのアドレス部
を有するオブジェクトコードを選定して定め、これらの
選定結果により前記選定作業表に記憶された分岐命令お
よびシンボルそれぞれの仮番地をそれぞれの最終番地に
更新し、シンボルの最終番地をシンボルテーブルに登録
する分岐命令選定手順、 (C)前記シンボルテーブルの登録内容を参照すること
により、適した長さのオブジェクトコードを持つ分岐命
令を含むオブジェクトプログラムを生成して出力するア
センブラの第2パス手順、 を備えることを特徴とするアセンブラの分岐命令生成方
式。
1. An assembler branch instruction generation system used in a computer having a branch instruction having two or more object codes whose address portions have different lengths depending on the range of branching: (A) inputting a source program Every time a branch instruction appears, an object code having an address part of an appropriate length for the branch instruction is selected and determined. If not determined, a temporary address is temporarily determined for a short branch instruction and calculated for the branch instruction. And a selection work table for storing a temporary address calculated for the symbol each time a symbol used in the address part of the branch instruction appears, and a variable range of the length of the branch instruction. (B) temporary addresses of all branch instructions stored in the selection work table and their variations , Calculating the minimum relative address and the maximum relative address of each branch instruction and the symbol used in the address portion thereof by referring to the temporary addresses of all the symbols indicating the branch destination of the branch instruction, By judging from the values of the minimum relative address and the maximum relative address, an object code having an address portion of an appropriate length for each branch instruction is selected and determined, and based on these selection results, the object code is stored in the selection work table. A branch instruction selecting procedure for updating the temporary address of each of the branch instruction and the symbol to the final address and registering the final address of the symbol in the symbol table, and (C) referring to the registered contents of the symbol table to obtain an appropriate length. Pass of the assembler that generates and outputs an object program including a branch instruction having the object code Branch instruction generation method of the assembler, characterized in that it comprises successively, a.
JP62227418A 1987-09-09 1987-09-09 Assembler branch instruction generation method Expired - Lifetime JP2610890B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP62227418A JP2610890B2 (en) 1987-09-09 1987-09-09 Assembler branch instruction generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP62227418A JP2610890B2 (en) 1987-09-09 1987-09-09 Assembler branch instruction generation method

Publications (2)

Publication Number Publication Date
JPS6468836A JPS6468836A (en) 1989-03-14
JP2610890B2 true JP2610890B2 (en) 1997-05-14

Family

ID=16860531

Family Applications (1)

Application Number Title Priority Date Filing Date
JP62227418A Expired - Lifetime JP2610890B2 (en) 1987-09-09 1987-09-09 Assembler branch instruction generation method

Country Status (1)

Country Link
JP (1) JP2610890B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3231619B2 (en) * 1996-04-25 2001-11-26 エヌイーシーマイクロシステム株式会社 Assembling method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS584371B2 (en) * 1975-04-04 1983-01-26 株式会社日立製作所 Relative address determination method for object instruction generation
JPS58172758A (en) * 1982-04-05 1983-10-11 Omron Tateisi Electronics Co Varying method for jump instruction

Also Published As

Publication number Publication date
JPS6468836A (en) 1989-03-14

Similar Documents

Publication Publication Date Title
US5471626A (en) Variable stage entry/exit instruction pipeline
US6611956B1 (en) Instruction string optimization with estimation of basic block dependence relations where the first step is to remove self-dependent branching
US20040154009A1 (en) Structuring program code
JP2610890B2 (en) Assembler branch instruction generation method
US5276821A (en) Operation assignment method and apparatus therefor
Bansal et al. Minimal pathset and minimal cutsets using search technique
US5313632A (en) Method for processing data in a distributed processing system
Schneider Syntax-directed description of incremental compilers
US20050071312A1 (en) System and method for conversion from graphical business process representations to structural text-based business process representations
JP3036900B2 (en) Assembler processing unit
JPH0440554A (en) Character data processor
JPH0644264B2 (en) Word memory system
Bansal et al. Improved implementation of search technique to find spanning trees
JPH05257703A (en) Assembler device
JPS62293434A (en) Branch destination forecasting controlling system
Mössenböck Data Structures in Coco/R
JPH08272650A (en) Retest path selection system
JPH0651993A (en) Assembler
JPH02216515A (en) System for treating coexisting field
JPH025135A (en) Message schedule system
JPH10149279A (en) Source program shaping device
JPH01305431A (en) Error message insertion system
JPH1115836A (en) Table for searching character string, generation method therefor and character string searching method
JPH04112329A (en) Frame searching system
JPH0343832A (en) Label retrieving system

Legal Events

Date Code Title Description
EXPY Cancellation because of completion of term
FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080227

Year of fee payment: 11