Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP2797777B2 - Language processor - Google Patents
[go: Go Back, main page]

JP2797777B2 - Language processor - Google Patents

Language processor

Info

Publication number
JP2797777B2
JP2797777B2 JP27285691A JP27285691A JP2797777B2 JP 2797777 B2 JP2797777 B2 JP 2797777B2 JP 27285691 A JP27285691 A JP 27285691A JP 27285691 A JP27285691 A JP 27285691A JP 2797777 B2 JP2797777 B2 JP 2797777B2
Authority
JP
Japan
Prior art keywords
line number
branch
instruction
source line
branch destination
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
JP27285691A
Other languages
Japanese (ja)
Other versions
JPH05108371A (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 JP27285691A priority Critical patent/JP2797777B2/en
Publication of JPH05108371A publication Critical patent/JPH05108371A/en
Application granted granted Critical
Publication of JP2797777B2 publication Critical patent/JP2797777B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、言語処理装置に利用さ
れ、特に、アセンブラに関し、分岐命令のオペランドに
記述された分岐先をもとに、分岐命令に対応するオブジ
ェクトを生成するアセンブラの分岐命令処理方式に関す
る。
BACKGROUND OF THE INVENTION The present invention is utilized in the language processing MakotoSo location, in particular, relates to the assembler, based on the described branch destination in the operand of a branch instruction, an assembler to produce an object corresponding to a branch instruction And a branch instruction processing method.

【0002】[0002]

【従来の技術】従来のアセンブラにおいて、ソースプロ
グラムファイルに記述する分岐命令は、そのオペランド
に分岐先のアドレスを指定することにより、オブジェク
トが生成される。
2. Description of the Related Art In a conventional assembler, a branch instruction described in a source program file generates an object by designating an address of a branch destination in its operand.

【0003】実際には、図5の分岐命令501および5
02に示すように、分岐先アドレスとして定数またはレ
ーベルなどのシンボルを用いた式を記述する。ここで、
分岐命令501はアドレス10番地への分岐を示し、分
岐命令502はレーベル1のアドレスへの分岐を示す。
これによりアセンブラは、絶対分岐ならばその分岐先ア
ドレスをそのままオブジェクトに埋め込み、相対分岐な
らば現在のアドレスと分岐先アドレスとの差分を算出し
て相対距離を埋め込みオブジェクトを生成する。
In practice, the branch instructions 501 and 5 in FIG.
As shown at 02, an expression using a symbol such as a constant or a label as a branch destination address is described. here,
The branch instruction 501 indicates a branch to the address 10, and the branch instruction 502 indicates a branch to the label 1 address.
As a result, the assembler embeds the branch destination address in the object as it is for an absolute branch, and calculates the difference between the current address and the branch destination address for a relative branch to generate an object with the relative distance embedded therein.

【0004】しかし、ソースプログラムファイルに記述
する分岐命令のなかには、分岐先がその分岐命令自身と
数ラインしか離れていない場合も多く考えられる。
However, among the branch instructions described in the source program file, there are many cases where the branch destination is only a few lines away from the branch instruction itself.

【0005】例として、「Aレジスタの内容が0であれ
、ある数命令を実行する」内容を記述したソースプロ
グラムを図6に示す。比較命令601でAレジスタの内
容と実データ0を比較し、分岐命令602でゼロフラグ
が0であればレーベル「??1」に分岐する。次に命令
群603で「ある数命令」を記述し、その直後にレーベ
ル「??1」の定義604を行う。このように、分岐命
令602で記述する分岐先は命令群603の直後である
ことが明確であるのに、レーベルを1つ定義して、そこ
への分岐命令を記述しなければならない。
[0005] For example, "If the content of the A register is 0,
If shows a source program describing the "what you want to do a certain number instruction in FIG. A comparison instruction 601 compares the contents of the A register with actual data 0, and if a zero flag is 0 in a branch instruction 602, branch to the label "?? 1". Next, "a certain number of instructions" is described in the instruction group 603, and immediately after that, the definition "604" of the label "?? 1" is performed. As described above, although it is clear that the branch destination described by the branch instruction 602 is immediately after the instruction group 603, one label must be defined and the branch instruction to the label must be described.

【0006】もし、レーベル「??1」の定義604を
せずにソースプログラムを記述したい場合で、かつアセ
ンブラの機能として現在のアドレスを示すマークが存在
する場合は次の通りである。仮に、現在のアドレスを示
すマークが「$」だったとすると、分岐命令605のオ
ペランドの分岐先記述「$+20」のように、分岐命令
605の先頭アドレスと分岐先である命令群606の
「次の命令」607の先頭アドレスとの差分を計算し、
現在のアドレス「$」と前記差分「20」の和として分
岐先アドレスを記述しなければならない。このとき、分
岐命令605の先頭アドレスと分岐先アドレスとの差分
は、分岐命令605自身のオブジェクトと命令群606
(BNZ命令のオブジェクトも含めて20バイトとす
る)のオブジェクトのサイズを手計算して記述するか、
あるいは、1度アセンブラを行ってオブジェクトのサイ
ズを調べた後に正しい差分を記述してソースプログラム
を完成させるかの2方法に限定される。
If it is desired to describe a source program without defining the label "?? 1" 604 and a mark indicating the current address exists as an assembler function, the following is performed. If the mark indicating the current address is “$”, the start address of the branch instruction 605 and “next” of the instruction group 606 that is the branch destination, as in the branch destination description “$ + 20” of the operand of the branch instruction 605, will be described. Of the instruction "607"
The branch destination address must be described as the sum of the current address “$” and the difference “20”. At this time, the difference between the start address of the branch instruction 605 and the branch destination address is determined by the object of the branch instruction 605 itself and the instruction group 606.
(20 bytes including the object of the BNZ instruction)
Alternatively, the method is limited to the two methods of performing assembling once to check the size of the object and then describing a correct difference to complete the source program.

【0007】[0007]

【発明が解決しようとする課題】前述した従来の言語処
理装置におけるアセンブラの分岐命令のオペランド記述
方法および処理方法では、特に、分岐先がその分岐命令
自身と数ラインしか離れていない場合に関して、次のよ
うな課題が発生する。
SUMMARY OF THE INVENTION The aforementioned conventional language processor
The operand describes methods and processes of a branch instruction in assembler in MakotoSo location, particularly with respect to the case where the branch destination is not away only the branch instruction itself and a few lines, the following problems may occur.

【0008】まず、第一にシンボル数の制限を圧迫する
原因となる点である。
[0008] First, it is a point that causes a restriction on the number of symbols.

【0009】最近はソフトウェアの機能が高機能化し、
プログラム規模が拡大してきており、それにともないシ
ンボルの使用量も増加する傾向がある。しかし、アセン
ブラが処理可能なシンボル数には制限がある。このよう
な環境のなかで、分岐先が数ラインしか離れていない分
岐命令を記述するときにも、局所的にしか使用しないレ
ーベルを分岐先アドレスとして定義し、分岐命令で参照
しなければプログラムできない。つまり、1分岐命令に
対して必ず1個のレーベルを使用しなければならないの
である。
Recently, software functions have become more sophisticated,
As the program scale is expanding, the usage of symbols tends to increase accordingly. However, the number of symbols that can be processed by the assembler is limited. In such an environment, even when writing a branch instruction whose branch destination is only a few lines away, a label that is only used locally is defined as a branch destination address, and it can not be programmed unless referenced by the branch instruction . That is, one label must be used for one branch instruction.

【0010】第二に、第一の問題を回避しようとしてシ
ンボルを使用せずに分岐命令のオペランドを記述しよう
とした場合に発生する課題として次に示す二つが挙げら
れる。
Second, the following two problems arise when trying to describe the operand of a branch instruction without using symbols in order to avoid the first problem.

【0011】一つは、分岐先アドレスを手計算により算
出することによるプログラムの信頼性の低下である。シ
ンボルを使用せずに分岐命令を記述するときには、アブ
ソリュートなアドレスを算出するか、相対距離を算出し
なければならない。これは、人間が分岐先までの命令長
を加算していくもので、計算の誤りがあれば、即プログ
ラムの誤りにつながる。また、このプログラムの誤り
は、アセンブル時に発見することはできず、生成された
オブジェクトを実行することにより初めて発見されるこ
とになり、障害発見を遅延させる原因となる。
One is that the reliability of the program is reduced by calculating the branch destination address manually. When describing a branch instruction without using a symbol, an absolute address or a relative distance must be calculated. In this method, a human adds the instruction length up to the branch destination, and if there is a calculation error, it immediately leads to a program error. Further, the error of this program cannot be found at the time of assembling, and is found only when the generated object is executed, which causes a delay in finding a failure.

【0012】もう一つは、プログラム作成時間が多くか
かるという点である。これは前記手計算によるアドレス
の算出をしたり、一度アセンブルをかけて分岐先アドレ
スをアセンブラに計算させた後、その値をプログラムに
書き直すといった作業が発生することによるものであ
る。特に、分岐元と分岐先の間にある命令群の中に、ア
センブラが自動的に最適化を行う分岐命令が存在する場
合は、アセンブルするたびに繰り返し分岐先アドレスの
確認が必要となる。なぜならば、最適化により生成され
る分岐命令のオブジェクトサイズがアセンブラに依存す
るためである。従って、一度の手計算で分岐先アドレス
を決めることはできず、ソースプログラムを少し修正し
ただけで、その度に再アセンブルと分岐先アドレスの確
認が必要となり、作成時間の増大につながってしまう。
Another is that it takes a lot of time to create a program. This is due to the need to calculate the address by the above-mentioned manual calculation, or to assemble once to have the assembler calculate the branch destination address, and then rewrite the value into a program. In particular, when a branch instruction for which the assembler automatically optimizes exists in a group of instructions between the branch source and the branch destination, it is necessary to repeatedly check the branch destination address every time assembling. This is because the object size of the branch instruction generated by the optimization depends on the assembler. Therefore, the branch destination address cannot be determined by a single manual calculation, and a slight modification of the source program requires reassembly and confirmation of the branch destination address each time, leading to an increase in the creation time.

【0013】本発明の目的は、分岐先がその分岐命令自
身と数ラインしか離れていない分岐命令のオペランド
に、分岐先のレーベルや定数を記述するのではなく、分
岐先との相対ソースライン数を記述して、オブジェクト
を生成することにより、不要なシンボルの使用を低減
し、かつプログラムの信頼性を高めるとともにプログラ
ム作成時間を削減することを可能とする、アセンブラの
分岐命令処理方式を有する言語処理装置を提供すること
である。
An object of the present invention is not to describe the label or constant of the branch destination in the operand of the branch instruction whose branch destination is only a few lines away from the branch instruction itself, but to set the relative source line number to the branch destination. Language having an assembler branch instruction processing method that reduces the use of unnecessary symbols by generating an it is to provide a treatment MakotoSo location.

【0014】[0014]

【課題を解決するための手段】本発明は、機械命令や擬
似命令が記述されたソースプログラムを入力し対応する
オブジェクトを生成するアセンブラ処理部を有する言語
処理装置において、前記アセンブラ処理部は、分岐命令
の分岐先として分岐元からの相対ソースライン番号を記
述したオペランドを解析する手段と、オブジェクトを生
成した際に各命令の先頭アドレスとソースライン番号と
を含むライン番号情報を登録し参照する手段と、前記ソ
ースライン番号と前記ライン番号情報とから分岐先であ
る該当ソースラインの先頭アドレスを検索する手段と、
検索した先頭アドレスをもとに前記分岐命令に対応する
オブジェクトを生成する手段とを含むことを特徴とす
る。
SUMMARY OF THE INVENTION The present invention provides a language processing apparatus having a luer assembler processing unit to generate a corresponding object type the source program machine or pseudo-instruction is described, wherein the assembler processing unit Means for analyzing an operand describing a relative source line number from a branch source as a branch destination of a branch instruction, and registering and referring to line number information including a head address and a source line number of each instruction when an object is generated Means for searching for a head address of a corresponding source line that is a branch destination from the source line number and the line number information,
Means for generating an object corresponding to the branch instruction based on the searched start address.

【0015】[0015]

【作用】オブジェクトとを生成した際に各命令の先頭ア
ドレスとソースライン番号とをライン番号情報として登
録しておき、相対ソースライン番号が記述された分岐命
令をオペランドを解析する手段で認識したら、先頭アド
レスを検索する手段において、前記の登録されたライン
番号情報から分岐先アドレスを検索し、オブジェクトを
生成する。
When the object is generated, the start address of each instruction and the source line number are registered as line number information, and when the branch instruction describing the relative source line number is recognized by the operand analyzing means, In the means for searching for a head address, a branch destination address is searched from the registered line number information to generate an object.

【0016】従って、不要なシンボルの使用を低減し、
かつプログラムの信頼性を高めるとともにプログラム作
成時間を削減することが可能となる。
Accordingly, the use of unnecessary symbols is reduced,
In addition, it is possible to improve the reliability of the program and to reduce the program creation time.

【0017】[0017]

【実施例】以下、本発明の実施例について図面を参照し
て説明する。
Embodiments of the present invention will be described below with reference to the drawings.

【0018】図1は本発明の一実施例の要部を示すブロ
ック構成図である。
FIG. 1 is a block diagram showing a main part of an embodiment of the present invention.

【0019】本実施例は、機械命令や擬似命令が記述さ
れたソースプログラムをソースプログラムファイル10
1から入力し対応するオブジェクトを生成しオブジェク
トファイル103に出力す力部104、セグメン
ト処理部107および出力部110を含むアセンブラ処
理部102を有する言語処理装置において、本発明の特
徴とするところの、アセンブラ処理部102は、分岐命
令の分岐先として分岐元からの相対ソースライン番号を
記述したオペランドを解析する手段としての相対ソース
ライン記述解析部111を含む字句解析部105と、オ
ブジェクトを生成した際に各命令の先頭アドレスとソー
スライン番号とを含むライン番号情報を登録し参照する
手段としてのライン番号情報登録・参照処理部109
と、前記ソースライン番号と前記ライン番号情報とから
分岐先である該当ソースラインの先頭アドレスを検索す
る手段としての該当ソースライン先頭アドレス検索部1
08と、検索した先頭アドレスをもとに前記分岐命令に
対応するオブジェクトを生成する手段としての機械命令
オブジェクト生成部106とを含んでいる。
In this embodiment, a source program in which machine instructions and pseudo-instructions are described is stored in a source program file 10.
You output to an object file 103 to generate an object input from one correspondence, in the language processing apparatus having an assembler processing unit 102 including an input section 104, the segment processing unit 107 and output unit 110, and features of the present invention However, the assembler processing unit 102 includes a lexical analysis unit 105 including a relative source line description analysis unit 111 as means for analyzing an operand describing a relative source line number from a branch source as a branch destination of a branch instruction, A line number information registration / reference processing unit 109 as means for registering and referencing line number information including a head address of each instruction and a source line number when generated.
A corresponding source line head address search unit 1 as means for searching for a head address of a corresponding source line as a branch destination from the source line number and the line number information
08, and a machine instruction object generation unit 106 as means for generating an object corresponding to the branch instruction based on the searched start address.

【0020】次に、本実施例によるアセンブラ処理手順
の大要を説明する。処理手順は、大きく二回のパスに分
けられる。
[0020] Next, a compendium of assembler processing procedure according to the present embodiment. The processing procedure is roughly divided into two passes.

【0021】第一回目のパスでは、ソースプログラムフ
ァイル101を入力部104で入力し、入力した字句を
字句解析部105で解析する。ここで、どの機械語命令
が記述され、そのオペランドは何かを判断した後、機械
語命令オブジェクト生成部106でその機械語命令に対
応するオブジェクトのサイズを現在のアドレスに加算す
る。同時に、その機械語命令が記述されたソースライン
番号と先頭アドレスの情報をライン番号情報登録・参照
処理部109に登録する。字句解析部105でプログラ
ムのまとまりの開始を示すセグメント定義を認識したと
きは、セグメント処理部107でアドレスのクリアなど
のセグメント処理を行うと同時に、ソースライン番号を
0としたラインナンバ情報をライン番号情報登録・参照
処理部109に登録する。以上を入力する字句がなくな
るまで繰り返す。入力する字句がなくなったならば、ソ
ースライン番号を0としたライン番号情報をライン番号
情報登録・参照処理部109に登録する。
In the first pass, the source program file 101 is input by the input unit 104, and the input lexical analysis is performed by the lexical analysis unit 105. Here, after determining which machine language instruction is described and what is its operand, the machine language instruction object generation unit 106 adds the size of the object corresponding to the machine language instruction to the current address. At the same time, information of the source line number and the start address in which the machine language instruction is described is registered in the line number information registration / reference processing unit 109. When the lexical analysis unit 105 recognizes the segment definition indicating the start of the unit of the program, the segment processing unit 107 performs segment processing such as clearing of the address, and simultaneously, converts the line number information with the source line number to 0 into the line number. The information is registered in the information registration / reference processing unit 109. Repeat until there are no more words to enter. If there are no more words to be input, the line number information with the source line number set to 0 is registered in the line number information registration / reference processing unit 109.

【0022】第二回目のパスでは、再度、ソースプログ
ラムファイル101を、入力部104で入力し、入力し
た字句を字句解析部105で解析する。ここまでは第一
回目のパスと同じ処理である。次に、どの機械語命令が
記述され、オペランドは何かを判断した後、機械語命令
オブジェクト生成部106はその機械語命令に対応する
オブジェクトを生成すると同時に、第一回目に登録した
ライン番号情報のなかで現在の機械語命令に対応してい
る情報の現在位置を保持しておく。以上を入力する字句
がなくなるまで繰り返す。この間に、字句解析部105
において、相対ソースライン記述解析部111により分
岐命令のオペランドに相対ソースライン記述を認識した
場合は、該当ソースライン先頭アドレス検索部108
で、ライン番号情報の現在位置をもとに、第一回目のパ
スで既に登録されているソースライン番号と先頭アドレ
スの中から該当するソースラインつまり分岐先の先頭ア
ドレスを検索する。その後は通常の機械語と同じく、機
械語命令オブジェクト生成部106で、検索した分岐先
先頭アドレスをもとにオブジェクトを生成する。入力す
る字句がなくなった後、生成されたオブジェクトを出力
部110からオブジェクトファイル103に出力する。
In the second pass, the source program file 101 is input again by the input unit 104, and the input lexical analysis is performed by the lexical analysis unit 105. The processing up to this point is the same as that of the first pass. Next, after determining which machine language instruction is described and what the operand is, the machine language instruction object generation unit 106 generates an object corresponding to the machine language instruction and, at the same time, generates the line number information registered for the first time. Among them, the current position of information corresponding to the current machine language instruction is held. Repeat until there are no more words to enter. During this time, the lexical analyzer 105
When the relative source line description analysis unit 111 recognizes the relative source line description as the operand of the branch instruction, the corresponding source line head address search unit 108
Then, based on the current position of the line number information, the corresponding source line, that is, the start address of the branch destination is searched from the source line number and the start address already registered in the first pass. Thereafter, as in the case of a normal machine language, the machine language instruction object generation unit 106 generates an object based on the searched branch destination head address. After there are no more words to be input, the generated object is output from the output unit 110 to the object file 103.

【0023】ライン番号情報登録・参照処理部109で
登録または参照するライン番号情報201は図2に示す
通り、ソースライン番号202および先頭アドレス20
3を含んでいる。ライン番号情報201の最終データ2
04は、第一回目のパスの最後に登録するデータであ
り、必ずソースライン番号が0である。また、現在位置
205は第二回目のパスでオブジェクト生成とともに更
新されるライン番号情報201の現在位置を示す。
The line number information 201 registered or referred to by the line number information registration / reference processing unit 109 is, as shown in FIG.
Contains three. Last data 2 of line number information 201
04 is data to be registered at the end of the first pass, and the source line number is always 0. The current position 205 indicates the current position of the line number information 201 updated along with the object generation in the second pass.

【0024】該当ソースライン先頭アドレス検索部10
8の詳細な処理の流れを図3で説明する。
The corresponding source line head address search unit 10
8 will be described with reference to FIG.

【0025】まず、字句解析部105の一部である相対
ソースライン記述解析部111で解析した分岐先相対ソ
ースライン番号を入力し(ステップS301)、図2で
示した現在位置205が指すライン番号情報のソースラ
イン番号と分岐先相対ソースライン番号の和を分岐先ソ
ースライン番号として保持する(ステップ302)。な
お、該当ソースライン先頭アドレス検索部108の処理
を行っているときの現在位置205は、その分岐命令行
に対応するライン番号情報を指している。
First, the branch source relative source line number analyzed by the relative source line description analysis unit 111 which is a part of the lexical analysis unit 105 is input (step S301), and the line number indicated by the current position 205 shown in FIG. The sum of the information source line number and the branch destination relative source line number is held as the branch destination source line number (step 302). Note that the current position 205 when the processing of the source line head address search unit 108 is being performed indicates the line number information corresponding to the branch instruction line.

【0026】次に、相対ソースライン番号がプラス方向
かマイナス方向かによってインクリメント・デクリメン
トカウンタに+1または−1をセットし(ステップ30
3、304、305)、また現在位置を分岐先ライン番
号情報位置として保持しておく(ステップ306)。こ
こで、相対ソースライン番号が0か否かを調べ(ステッ
プ307)、0であれば、ステップ306で保持した分
岐先ラインナンバ情報位置が指すラインナンバ情報の先
頭アドレスが求めていた分岐先アドレスとなり(ステッ
プ311)、検索が終了する。
Next, +1 or -1 is set in the increment / decrement counter depending on whether the relative source line number is in the plus direction or the minus direction (step 30).
3, 304, 305), and the current position is held as the branch destination line number information position (step 306). Here, it is checked whether or not the relative source line number is 0 (step 307). If the relative source line number is 0, the branch destination address at which the head address of the line number information indicated by the branch destination line number information position held in step 306 is found (Step 311), and the search ends.

【0027】相対ソースライン番号が0でなければ、次
に分岐先ライン番号情報位置をインクリメント・デクリ
メントカウンタ分進め(ステップ308)、分岐先ライ
ンナンバ情報位置が指すライン番号情報のソースライン
番号が0か否かを調べ(ステップ309)、0でなけれ
ば分岐先ライン番号情報位置が指すライン番号情報のソ
ースライン番号がステップ302で保持した分岐先ソー
スライン番号に等しいかを調べる(ステップ310)。
等しければ分岐先ライン番号情報位置が指すライン番号
情報の先頭アドレスが求めていた分岐先アドレスとなり
(ステップ311)、検索が終了する。
If the relative source line number is not 0, then the branch destination line number information position is advanced by an increment / decrement counter (step 308), and the source line number of the line number information indicated by the branch destination line number information position is 0. It is determined whether or not the source line number of the line number information indicated by the branch destination line number information position is equal to the branch destination source line number held in step 302 (step 310).
If they are equal, the head address of the line number information indicated by the branch destination line number information position becomes the obtained branch destination address (step 311), and the search ends.

【0028】もし、ステップ310で分岐先ラインナン
バ情報が指すソースライン番号と分岐先ライン番号が異
なるならば、ステップ308に戻り、分岐先ライン番号
情報位置をインクリメントまたはデクリメントしてステ
ップ309および310の処理を繰り返す。ステップ3
09で分岐先ラインナンバ情報位置が指すライン番号情
報のソースライン番号が0である場合は、ソースプログ
ラムに記述された分岐命令のオペランドの相対ソースラ
イン番号が、プログラムのまとまりであるセグメントを
越えて指定されていた、あるいは指定された相対ソース
ライン番号にオブジェクトを発生するような命令が記述
されていなかったことにより、この分岐命令の記述は不
正だったとしてエラーを発生し(ステップ312)、検
索を終了する。分岐先として指定されたソースライン番
号がセグメントを越える、つまり別なセグメントに属し
ていると不正とする理由は、セグメントごとにアドレス
管理がなされているため、特に、配置位置が決定してい
ないリロケータブルなセグメントであると、分岐先が不
定になってしまうためである。
If the source line number indicated by the branch destination line number information and the branch destination line number are different at step 310, the process returns to step 308, where the position of the branch destination line number information is incremented or decremented. Repeat the process. Step 3
If the source line number of the line number information indicated by the branch destination line number information position is 0 at 09, the relative source line number of the operand of the branch instruction described in the source program exceeds the segment which is a unit of the program. Since an instruction that causes an object to be specified or specified at the specified relative source line number is not described, an error is generated because the description of the branch instruction is invalid (step 312), and the search is performed. To end. The reason why the source line number specified as the branch destination exceeds the segment, that is, if it belongs to another segment, is invalid because the address management is performed for each segment, especially the relocatable where the arrangement position is not determined This is because if the segment is a simple segment, the branch destination becomes indefinite.

【0029】具体的なソースプログラムの記述例を図4
に示す。例えば、相対ソースライン番号の記述を「相対
ソース・ライン番号」にサフィックスLを付加すると規
定すれば、分岐命令401のオペランドのように「4
L」と記述すると4行先の次の命令402への分岐命令
としてオブジェクトを生成する。
FIG. 4 shows a description example of a specific source program.
Shown in For example, if the description of the relative source line number is defined to add the suffix L to the “relative source line number”, “4” as in the operand of the branch instruction 401
If "L" is described, an object is generated as a branch instruction to the next instruction 402 four lines ahead.

【0030】以上の処理により、分岐命令のオペランド
に記述された分岐先相対ソースライン番号を、各行のラ
イン番号情報を登録または参照することにより、自動的
に分岐先アドレスを求め、正しいオブジェクトを生成す
ることが可能となる。
With the above processing, the branch destination address is automatically obtained by registering or referencing the line number information of each line with the branch destination relative source line number described in the operand of the branch instruction, and a correct object is generated. It is possible to do.

【0031】なお、本実施例で使用したソースライン番
号と先頭アドレスからなるライン番号情報は、プログラ
ムのデバッグ情報としても有効なデータであることか
ら、データ共有を行うことにより、アセンブラ本体に不
要な負荷をかけることなく実現が可能となる。
Since the line number information composed of the source line number and the head address used in the present embodiment is also effective as debug information of a program, by performing data sharing, it becomes unnecessary for the assembler body. This can be realized without applying a load.

【0032】[0032]

【発明の効果】以上説明したように、本発明は、分岐命
令のオペランドに分岐先として分岐元からの相対ソース
ライン番号を記述したソースプログラムを入力し、各行
のソースライン番号と先頭アドレス情報からなるライン
番号情報を登録または参照することにより、アセンブラ
内部で自動的に分岐先アドレスを検索し、正しいオブジ
ェクトを生成するので、不要なレーベル定義をせずに分
岐命令を記述することによって使用シンボル数の低減が
図れるとともに、分岐先アドレスを人手によらず計算す
るために、プログラム自身の信頼性を高めることができ
る効果がある。
As described above, according to the present invention, the source program in which the relative source line number from the branch source is described as the branch destination is input to the operand of the branch instruction, and the source line number of each line and the head address information are used. By registering or referencing the line number information, the assembler automatically searches the branch destination address and generates the correct object, so the number of symbols used can be described by writing a branch instruction without unnecessary label definition. In addition, since the branch destination address is calculated without manual operation, the reliability of the program itself can be improved.

【0033】また、分岐先アドレスにレーベルを定義し
た場合と比較すると、レーベルは全登録シンボルを検索
してアドレスを取り出さなければならないのに対し、本
発明の処理方式によるセグメント内のラインナンバ情報
の検索で済むことから、アセンブラ自身の処理時間の向
上を図ることができる効果がある。
Compared with the case where a label is defined for a branch destination address, the label must retrieve all registered symbols to fetch the address, whereas the label of the line number information in the segment according to the processing method of the present invention. Since the search is completed, the processing time of the assembler itself can be improved.

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

【図1】本発明の一実施例の要部を示すブロック構成
図。
FIG. 1 is a block diagram showing a main part of an embodiment of the present invention.

【図2】そのライン番号情報の一例を示す説明図。FIG. 2 is an explanatory diagram showing an example of the line number information.

【図3】その該当ソースライン先頭アドレス検索処理部
の処理手順を示す流れ図。
FIG. 3 is a flowchart showing a processing procedure of a corresponding source line head address search processing unit.

【図4】その具体的な分岐命令記述例を示す説明図。FIG. 4 is an explanatory diagram showing a specific example of branch instruction description.

【図5】従来の分岐命令記述例を示す説明図。FIG. 5 is an explanatory diagram showing an example of a conventional branch instruction description.

【図6】従来の分岐命令記述例を示す説明図。FIG. 6 is an explanatory diagram showing an example of a conventional branch instruction description.

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

101 ソースプログラムファイル 102 アセンブラ処理部 103 オブジェクトファイル 104 入力部 105 字句解析部 106 機械語命令オブジェクト生成部 107 セグメント処理部 108 該当ソースライン先頭アドレス検索部 109 ライン番号情報登録・参照部 110 出力部 111 相対ソースライン記述解析部 201 ライン番号情報 202 ソースライン番号 203 先頭アドレス 204 最終データ 205 現在位置 301〜312 ステップ 401、402、501、502、602、605
分岐命令 601 比較命令 603、606 命令群 604 レーベル定義 607 「次の命令」
101 Source program file 102 Assembler processing unit 103 Object file 104 Input unit 105 Lexical analysis unit 106 Machine language instruction object generation unit 107 Segment processing unit 108 Relevant source line head address search unit 109 Line number information registration / reference unit 110 Output unit 111 Relative Source line description analysis unit 201 Line number information 202 Source line number 203 Start address 204 Final data 205 Current position 301 to 312 Step 401, 402, 501, 502, 602, 605
Branch instruction 601 Comparison instruction 603,606 Instruction group 604 Label definition 607 "Next instruction"

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 機械命令や擬似命令が記述されたソース
プログラムを入力し対応するオブジェクトを生成するア
センブラ処理部を有する言語処理装置において、 前記アセンブラ処理部は、分岐命令の分岐先として分岐
元からの相対ソースライン番号を記述したオペランドを
解析する手段と、オブジェクトを生成した際に各命令の
先頭アドレスとソースライン番号とを含むライン番号情
報を登録し参照する手段と、前記ソースライン番号と前
記ライン番号情報とから分岐先である該当ソースライン
の先頭アドレスを検索する手段と、検索した先頭アドレ
スをもとに前記分岐命令に対応するオブジェクトを生成
する手段とを含むことを特徴とする言語処理装置。
1. A language processing apparatus having a machine or pseudo-instruction enters a source program written corresponding luer <br/> assembler processing unit to generate an object, the assembler processing unit, the branch instruction Means for analyzing an operand describing a relative source line number from a branch source as a branch destination; means for registering and referring to line number information including a head address of each instruction and a source line number when an object is generated; Means for searching the source line number and the line number information for a head address of a corresponding source line which is a branch destination; and means for generating an object corresponding to the branch instruction based on the searched head address. A language processing device characterized by the following.
JP27285691A 1991-10-21 1991-10-21 Language processor Expired - Lifetime JP2797777B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP27285691A JP2797777B2 (en) 1991-10-21 1991-10-21 Language processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP27285691A JP2797777B2 (en) 1991-10-21 1991-10-21 Language processor

Publications (2)

Publication Number Publication Date
JPH05108371A JPH05108371A (en) 1993-04-30
JP2797777B2 true JP2797777B2 (en) 1998-09-17

Family

ID=17519729

Family Applications (1)

Application Number Title Priority Date Filing Date
JP27285691A Expired - Lifetime JP2797777B2 (en) 1991-10-21 1991-10-21 Language processor

Country Status (1)

Country Link
JP (1) JP2797777B2 (en)

Also Published As

Publication number Publication date
JPH05108371A (en) 1993-04-30

Similar Documents

Publication Publication Date Title
JPH06314203A (en) Method and device for optimizing compiler
JPH0769834B2 (en) Method and apparatus for compiling source program
US6065035A (en) Method and system for procedure boundary detection
JP2797777B2 (en) Language processor
US7065758B2 (en) Optimize code for a family of related functions
JPH08194611A (en) A device that analyzes the range of influence of program modification
JP3063297B2 (en) Language processing program creation device
JP3327662B2 (en) Program translation device and program translation method
JPH05224944A (en) Alignment matching method
JPH1196018A (en) COMPILING DEVICE AND METHOD, AND COMPUTER-READABLE RECORDING MEDIUM RECORDING COMPILING EXECUTION PROGRAM
JP3082767B2 (en) Translation list output control device
JPH05197561A (en) Compilation system
JP3000878B2 (en) Assembler processing method
JP2001067234A (en) Compiler and processor
JPH10214194A (en) Class definition import method
JP3332723B2 (en) Machine language conversion system with division support function
JP2000132405A (en) Inline expansion processing apparatus and method
JP3231578B2 (en) Modifier for job control language
JPH06208470A (en) Target code optimization device
JPH1195995A (en) Data flow analysis device, data flow analysis method, and recording medium recording computer program therefor
JPH0651993A (en) Assembler
JP2004139369A (en) Analysis method for pointer pointing constant address domain
JPH05100829A (en) Compiling unit management system
JPH0695889A (en) Program correction system
JPH05216683A (en) Non-language dependent filing procedure automatic generation method