JPH01177128A - Assembler system - Google Patents

Assembler system

Info

Publication number
JPH01177128A
JPH01177128A JP33499587A JP33499587A JPH01177128A JP H01177128 A JPH01177128 A JP H01177128A JP 33499587 A JP33499587 A JP 33499587A JP 33499587 A JP33499587 A JP 33499587A JP H01177128 A JPH01177128 A JP H01177128A
Authority
JP
Japan
Prior art keywords
symbol
module
public
assembler
symbol table
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
JP33499587A
Other languages
Japanese (ja)
Inventor
Harumi Mizuse
水瀬 晴美
Kazuhide Kawada
河田 和秀
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 JP33499587A priority Critical patent/JPH01177128A/en
Priority to US07/286,118 priority patent/US5182807A/en
Priority to EP88121247A priority patent/EP0321000A3/en
Publication of JPH01177128A publication Critical patent/JPH01177128A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To decrease the linking jobs of an post-process and to increase the assembling speed by decreasing the number of pending symbols to be processed in the post-process. CONSTITUTION:An assembler of each module extracts a character string and its value of a local symbol defined in a module as well as a character string of a public symbol defined in another module that is referred to in the relevant module and stores these extracted character strings and values into a symbol table 57a set in a main memory 57. Then the character string and its value of a public symbol defined in the relevant module are extracted and stored in a public symbol table 56b set in an auxiliary memory 56. At the same time, the value of the public symbol whose character string only is stored in the table 56b is searched out of the table 56b for substitution. As a result, the number of pending symbols can be decreased and a high-speed assembling job is attained.

Description

【発明の詳細な説明】 [産業上の利用分野] 本発明は、マイクロコンピュータのプログラム記述言語
であるアセンブリ童話により記述されたソースプログラ
ムを機械語に変換するアセンブラ方式に関し、特に複数
のモジュールに分割され、これらモジュール間でシンボ
ルの参照が行われるプログラムのアセンブラ方式に関す
る。
[Detailed Description of the Invention] [Field of Industrial Application] The present invention relates to an assembler method for converting a source program written in assembly fairy tale, which is a programming language for microcomputers, into machine language, and in particular, the present invention relates to an assembler method for converting a source program written in assembly fairy tale, which is a program description language for microcomputers, into machine language. This book concerns the assembler system for programs in which symbols are referenced between these modules.

[従来の技術] 一般に、アセンブラとはアセンブリ言語で記述されたソ
ースプログラムをマイクロコンピュータが直接実行でき
るように機械語に変換するためのプログラムである。ア
センブラの動作環境は、例えば第7図に示すように、ソ
ースプログラムとアセンブラ・プログラムとを記述する
とともに、出力結果をファイルとして記憶するための磁
気ディスク等からなる補助記憶装置50 (D I S
K)と、この補助記憶袋W50からロードされたソース
・プログラムをアセンブル処理する中央処理装置51 
(CPU)と、上記アセンブル処理に使用される主記憶
装置52(MM)と、前記中央処理装置51の実行を制
御するオペレーション・システム53(O3)と、この
オペレーション・システム53にコマンドを入力したり
、処理結果を出力するためのキーボード54及びデイス
プレィ55とから構成される。
[Prior Art] Generally, an assembler is a program for converting a source program written in assembly language into machine language so that it can be directly executed by a microcomputer. The operating environment of the assembler is, for example, as shown in FIG.
K) and a central processing unit 51 that assembles the source program loaded from this auxiliary memory bag W50.
(CPU), a main memory device 52 (MM) used for the assembling process, an operation system 53 (O3) that controls the execution of the central processing unit 51, and a system for inputting commands to the operation system 53. It also includes a keyboard 54 and a display 55 for outputting processing results.

アセンブラの実行はキーボード54からオペレーション
・システム53にコマンドを入力することにより開始さ
れる。まず、補助記憶装置50から主記憶装置52にア
センブラ・プログラムがロードされ、このプログラムが
中央処理装置51により実行される。アセンブラ・プロ
グラムの命令の実行に従って、補助記憶装置50からソ
ース・プログラムが主記憶装置52に順次読出され、機
械語へと変換される。出力された機械語はオブジェクト
・ファイルとして補助記憶装置50に記憶される。
Execution of the assembler is initiated by entering commands into the operating system 53 from the keyboard 54. First, an assembler program is loaded from the auxiliary storage device 50 to the main storage device 52, and this program is executed by the central processing unit 51. According to execution of the instructions of the assembler program, the source program is sequentially read from the auxiliary storage device 50 to the main storage device 52 and converted into machine language. The output machine language is stored in the auxiliary storage device 50 as an object file.

ところで、従来よりアセンブラの方式として所謂リロケ
ータブル・アセンブラと、所謂アブソリュート・アセン
ブラの2つの方式が知られている。
By the way, two assembler systems are conventionally known: a so-called relocatable assembler and a so-called absolute assembler.

以下、この2つの方式について説明する。These two methods will be explained below.

リロケータブル・アセンブラは、メモリの任意の番地に
再配置可能(リロケータブル)な機械語を出力するアセ
ンブラ方式で、プログラムの修正が容易であるという利
点がある。この方式では、第8図に示すようにソース・
プログラム61を、機能等により複数のモジュール1,
2.3に分割し、これらモジュール1,2.3を入力ス
テップ62で第7図のキーボード54等から夫々個別に
入力して補助記憶装置50内に夫々ソース・モジュール
・ファイル63として記憶させる。リロケータブル・ア
センブラ64は、これらソース・モジュール・ファイル
63を別々にアセンブルし、機械語のオブジェクト・プ
ログラムをリロケータブル・オブジェクト・ファイル6
5の形式で出力する。リロケータブル・アセンブラ64
は夫々各ソース・モジュール・ファイル63を全く独立
に機械語に変換するため、出力されるすロケータプル・
オブジェクト・ファイル65内の機械語プログラムの各
命令に割り当てられるメモリ番地は、モジュール毎に独
立に決定し得るように相対番地となっている。このリロ
ケータブル・オブジェクト・ファイル65の機械語プロ
グラムをコンピユーが実行できる形式にするためには、
更にリンカ66によりリンク作業を行い、リロケータブ
ル・オブジェクト・ファイル65中の相対番地をメモリ
上の絶対番地に変更する必要がある。リンカ66により
絶対番地に付は替えられた機械語プログラムは、ロード
・モジュール・ファイル67として記憶される。
A relocatable assembler is an assembler method that outputs machine language that can be relocated to any address in memory, and has the advantage that programs can be easily modified. In this method, the source
The program 61 is divided into multiple modules 1,
In an input step 62, these modules 1, 2.3 are input individually from the keyboard 54 in FIG. The relocatable assembler 64 separately assembles these source module files 63 and converts the machine language object program into a relocatable object file 6.
Output in format 5. Relocatable assembler 64
converts each source module file 63 into machine language completely independently, so the output locator
The memory address assigned to each instruction of the machine language program in the object file 65 is a relative address so that it can be determined independently for each module. In order to make the machine language program of this relocatable object file 65 into a format that can be executed by a computer,
Furthermore, it is necessary to perform a linking operation using the linker 66 and change the relative address in the relocatable object file 65 to an absolute address in the memory. The machine language program reassigned to the absolute address by the linker 66 is stored as a load module file 67.

このリロケータブル・アセンブラ方式では、プログラム
がモジュール1,2.3の編成順を意識する必要がない
、即ち、モジュールの順序はリンク時にのみ指定されれ
ば良い、このことは、例えばあるモジュールを修正した
時に、もし他のモジュールのりロケータプル・オブジェ
クト・ファイルが既に存在しているならば、修正したモ
ジュールのみをアセンブルすれば良く、その後、他のり
ロケータプル・オブジェクトと今回アセンブルしたりロ
ケータプル・オブジェクトとを単にリンクするだけで修
正を加えたロード・モジュールが生成されることを意味
する。この特徴は、大きいプログラムで少しだけ修正を
加える必要がある場合に、アセンブルすべきソース・モ
ジュールが少なくて済むため、アセンブル時間が短縮さ
れるという利点がある。しかしながら、リロケータブル
・アセンブラ方式では各モジュールのアセンブルを単独
に行うために、例えば、あるモジュール内で参照するシ
ンボルが別のモジュールで定義されているような場合に
やや複雑な管理が必要になる。
With this relocatable assembler method, there is no need for the program to be aware of the order in which modules 1, 2, and 3 are organized; in other words, the order of the modules only needs to be specified at the time of linking. Sometimes, if other module or locator object files already exist, you only need to assemble the modified module, and then simply link the currently assembled or locator object with the other module or locator object files. This means that a modified load module will be generated just by doing this. This feature has the advantage of reducing assembly time when a large program requires minor modifications, since fewer source modules need to be assembled. However, since the relocatable assembler method assembles each module independently, somewhat complicated management is required, for example, when a symbol referenced in one module is defined in another module.

即ち、アセンブリ言語には、任意のデータまたはアドレ
スに名前を付ける擬似命令がある。ソース・プログラム
中でその擬似命令によりあるデータ又はアドレスの値が
割りふられた名前を記述すると、アセンブル時にその名
前が対応する値に変換される。この名前を一般にシンボ
ルと呼び、シンボルをソース・プログラム中に記述する
ことをシンボルの参照と呼ぶ、シンボル参照が行われる
ときは、シンボルに割りふられた値をシンボルが記述さ
れた位置に代入する必要があるので、予めシンボルの文
字列と値とを対照させたシンボルテーブルを主記憶装置
52内の一部に作成しておく必要がある。
That is, assembly language has pseudo-instructions that name arbitrary data or addresses. When a name to which a certain data or address value is assigned by the pseudo-instruction is written in the source program, the name is converted to the corresponding value during assembly. This name is generally called a symbol, and writing a symbol in a source program is called symbol reference. When a symbol is referenced, the value assigned to the symbol is assigned to the position where the symbol is written. Since this is necessary, it is necessary to create a symbol table in a part of the main storage device 52 in advance in which the character strings and values of symbols are compared.

このため、アセンブラは、通常2パスアセンブラ方式に
なっており、ソース・プログラムは2回に分けて解析さ
れる。つまり、−度目の解析フェイズであるパス1でソ
ース・プログラム中のシンボルが定義されている箇所が
抽出され、シンボルとそれに割り当てられた値とを対応
づけたシンボルテーブルが主記憶装置内に作成される。
For this reason, the assembler usually uses a two-pass assembler method, and the source program is analyzed in two parts. In other words, in pass 1, which is the -th analysis phase, locations in the source program where symbols are defined are extracted, and a symbol table is created in the main memory that associates symbols with their assigned values. Ru.

そして、二度目の解析フェイズであるパス2でシンボル
の参照箇所にシンボルテーブルから探索した値を埋めて
いく。
Then, in pass 2, which is the second analysis phase, the value searched from the symbol table is filled in the symbol reference location.

リロケータブル・アセンブラにおいても、シンボルの定
義と参照とが1つのモジュール内だけで行われるのであ
れば、上記のアセンブル方式で事足りるが、シンボルの
定義と参照とが異なるモジュール間で行われる場合には
、特殊な管理が必要になる。一般に、前者をローカル・
シンボル、後者をパブリック・シンボルと呼ぶ、いま、
あるモジュールで、他のモジュールで定義されたパブリ
ック・シンボルを参照しているとすると、アセンブルの
パス1で作成されたシンボルテーブルにはそのパブリッ
ク・シンボルは登録されないので、アセンブルのパス2
において、その値を参照することができない。このため
、未解決のままりロケータプル・オブジェクト・ファイ
ル65に出力される。即ち、例えば第9図(a)に示す
ソース・プログラム70のように、モジュール71,7
2゜73の夫々相対番地10,50.80に定義されて
いるシンボルSYMA、SYMB、SYMCは、各外部
モジュールでBR命令により参照されているが、モジュ
ール71,72.73は個別にアセンブルされるため、
モジュール71の“BRSMMC”、モジュール72の
“B RS Y M A ”、モジュール73の“BR
SYMB”命令のオペランドは夫々数値に変換されず、
未解決のまま各リロケータブル・オブジェクト・ファイ
ル65に出力される。従って、これらのリロケータブル
・オブジェクト・ファイル65の相対的に割り付けられ
たメモリ番地を、第9図(b 、)に示すように、絶対
的な番地0−590に変換し、各モジュールのアセンブ
ル時には未解決であったシンボルのSYMA、SYMB
、SYMCに値を割り付け、ロード・モジュール・ファ
イル74として出力するという処理は第8図のリンカ6
6によって行われる。
Even in relocatable assemblers, if symbols are defined and referenced only within one module, the above assembly method is sufficient, but if symbols are defined and referenced between different modules, Special management is required. Generally, the former is
Symbols, the latter are called public symbols, now,
If a module references a public symbol defined in another module, that public symbol will not be registered in the symbol table created in pass 1 of assembling, so pass 2 of assembling will
, its value cannot be referenced. Therefore, it is output to the locator object file 65 without being resolved. That is, for example, as in the source program 70 shown in FIG. 9(a), modules 71, 7
Symbols SYMA, SYMB, and SYMC defined at relative addresses 10, 50.80, respectively, of 2.73 are referenced by the BR instruction in each external module, but modules 71, 72.73 are assembled individually. For,
“BRSMMC” of module 71, “BRS Y M A” of module 72, “BR” of module 73
SYMB” instruction operands are not converted to numerical values,
The data is output to each relocatable object file 65 unresolved. Therefore, the relatively allocated memory addresses of these relocatable object files 65 are converted into absolute addresses 0-590, as shown in FIG. Symbols SYMA and SYMB that were resolved
, SYMC and outputting it as the load module file 74 is performed by the linker 6 in FIG.
6.

一方、このリロケータブル・アセンブラに対し、アブソ
リュート・アセンブラでは、命令やデータに割り振られ
るメモリ番地は、絶対番地である。
On the other hand, in contrast to the relocatable assembler, in the absolute assembler, the memory addresses allocated to instructions and data are absolute addresses.

即ち、第10図に示すように、ソースプログラム81を
入力ステップ82で第7図のキーボード54から入力し
て得られたソース・ファイル83は、アセンブラ84に
よりオブジェクト・ファイル85に変換されるが、この
オブジェクト・ファイル85はロード・モジュール・フ
ァイルとして直接コンピュータにロードして実行するこ
とが可能である。また、アブソリュート・アセンブラで
のシンボルの管理は主記憶装置52内のシンボル・テー
ブルのみで行われる。シンボルの参照時はシンボル・テ
ーブル内を探索してシンボルに対応する値を抽出しシン
ボル記述位置に抽出した値を代入するという方式をとっ
ている。
That is, as shown in FIG. 10, a source file 83 obtained by inputting a source program 81 from the keyboard 54 in FIG. 7 in an input step 82 is converted into an object file 85 by an assembler 84. This object file 85 can be directly loaded into a computer and executed as a load module file. Further, symbol management in the absolute assembler is performed only by the symbol table in the main storage device 52. When referencing a symbol, a method is used in which the symbol table is searched, a value corresponding to the symbol is extracted, and the extracted value is assigned to the symbol description position.

アブソリュート・アセンブラ方式では、ソース・モジュ
ールとロード・モジュールであるオブジェクトモジュー
ルとが一つずつであるため、ソロケータプル・アセンブ
ラのようなシンボルの外部モジュール参照を行う必要が
なくなるので、アセンブルに未解決のシンボル等は存在
しない、また、メモリも絶対番地が割り振られるために
、リロケータブル・アセンブラでのリンク処理はアブソ
リュート・アセンブラでは不必要となる。
In the absolute assembler method, there is one source module and one object module, which is the load module, so there is no need to refer to an external module for symbols as in the sorlocator assembler, so there are no unresolved symbols in the assembler. etc. do not exist, and since absolute addresses are allocated to memory, the link processing in the relocatable assembler is unnecessary in the absolute assembler.

[発明が解決しようとする問題点] 上述した従来のりロケータプル・アセンブラでは、シン
ボル・テーブルがソース・プログラムを構成している各
モジュールのアセンブル時に個々に作成されるので、一
つのシンボル・テーブルが小さくシンボルのサーチ時間
が短縮され、アセンブル時間も短くなる。しかし、アセ
ンブル終了後に未解決なシンボルの参照をリンク処理に
よって解決しなければならないため、パブリック・シン
ボルの数が多い場合はリンク処理に時間がかかるという
欠点がある。
[Problems to be Solved by the Invention] In the conventional locator assembler described above, symbol tables are created individually when assembling each module that makes up a source program, so one symbol table is small. Symbol search time is shortened and assembly time is also shortened. However, since unresolved symbol references must be resolved by link processing after assembly is completed, there is a drawback that link processing takes time when there are a large number of public symbols.

一方、一つのソース・プログラムに対して一つのシンボ
ル・テーブルしか作成されないアブソリュート・アセン
ブラ方式では、ソース・プログラムが拡張されるにつれ
てシンボル・テーブルも大きくなるために、シンボルを
サーチする処理に多くの時間を費やし、アセンブル・ス
ピードが遅くなるという欠点がある。
On the other hand, in the absolute assembler method, where only one symbol table is created for one source program, the symbol table grows as the source program expands, so it takes a lot of time to search for symbols. The disadvantage is that it consumes a lot of time and the assembly speed is slow.

本発明はかかる問題点に鑑みてなされたものであって、
シンボルのサーチ時間及びリンク処理時間の短縮を図る
ことができ、高速アセンブルが可能のアセンブラ方式を
提供することを目的とする。
The present invention has been made in view of such problems, and includes:
It is an object of the present invention to provide an assembler system that can shorten symbol search time and link processing time, and can perform high-speed assembly.

[問題点を解決するための手段] 本発明は、分割モジュール型で、少なくとも1つのモジ
ュールにパブリック・シンボルの参照命令を含むソース
・プログラムを予め指定された編成順序で各モジュール
毎にアセンブルしてオブジェクト・ファイルを生成する
アセンブラ方式であって、前記モジュール毎のアセンブ
ラが、次の2つの手順を備えたことを特徴としている。
[Means for Solving the Problems] The present invention is a divided module type source program in which at least one module includes a public symbol reference instruction, and the source program is assembled into each module in a prespecified organization order. This is an assembler method for generating object files, and is characterized in that the assembler for each module includes the following two procedures.

第1の手順は、処理中のモジュール内に定義されたロー
カル・シンボルの文字列及び値と、当該モジュール内で
参照され他のモジュール内に定義されたパブリック・シ
ンボルの文字列とを抽出し、シンボル・テーブルに格納
する手順である。
The first step is to extract the character strings and values of local symbols defined in the module being processed, and the character strings of public symbols referenced within the module and defined in other modules, This is the procedure for storing in the symbol table.

第2の手順は、当該モジュール内に定義されたパブリッ
ク・シンボルの文字列及び値を抽出し、これらをパブリ
ック・シンボル・テーブルに格納するとともに、前記シ
ンボル・テーブルに文字列のみが格納された前記パブリ
ック・シンボルの値を前記パブリック・シンボル・テー
ブルから探索して代入する。
The second step is to extract the character strings and values of public symbols defined in the module and store them in the public symbol table. A value of a public symbol is searched from the public symbol table and assigned.

なお、前記シンボル・テーブルは、主記憶装置内にモジ
ュール毎に形成される。また、前記パブリック・シンボ
ル・テーブルは、補助記憶装置内に全モジュールに共通
のものとして形成される。
Note that the symbol table is formed for each module in the main memory. Further, the public symbol table is formed in the auxiliary storage device as one common to all modules.

[作用] 本発明によれば、ソース・プログラムを分割モジュール
化しているので、各モジュールでのシンボル・テーブル
を小型にでき、シンボルのサーチ時間を短縮することが
できる。
[Operation] According to the present invention, since the source program is divided into modules, the symbol table in each module can be made smaller, and the symbol search time can be shortened.

また、本発明ではモジュール分割されたソース・プログ
ラムをアセンブルする際に、そのモジュールの編成順序
を予め指定し、アセンブル時に各モジュールで定義され
たパブリック・シンボルの文字列と、それに割り当てら
れた値を対応付けたパブリック・シンボル・テーブルを
補助記憶装置内に作成することにより、1つのモジュー
ルのアセンブルが終了してシンボル・テーブルが破壊さ
れても、パブリック・シンボル・テーブルは破壊されず
に残る。このため、あるモジュールで参照されているパ
ブリック・シンボルがそれより先に編成されたモジュー
ルでシンボル定義している場合、リロケータブル・アセ
ンブラのように、そのシンボルを未解決のままオブジェ
クトファイルに出力するのではなく、上記の補助記憶装
置のパブリック・シンボル・テーブルに記憶されている
シンボルの値をアセンブル時に参照してオブジェクト・
ファイルに出力することができる。つまり、後処理に回
す未解決のシンボルの数を減らすことができる。
Furthermore, in the present invention, when assembling a source program divided into modules, the organization order of the modules is specified in advance, and the character strings of public symbols defined in each module and the values assigned to them are specified at the time of assembly. By creating the associated public symbol table in the auxiliary storage device, even if the symbol table is destroyed when the assembly of one module is completed, the public symbol table remains undestroyed. For this reason, if a public symbol referenced in a module is defined in a module organized earlier, it is not possible to output that symbol unresolved to an object file, as in a relocatable assembler. Instead, the values of the symbols stored in the public symbol table in the auxiliary storage described above are referenced during assembly to create objects.
It can be output to a file. In other words, the number of unresolved symbols sent to post-processing can be reduced.

また、本発明では、モジュールの編成順序を指定し、パ
ブリック・シンボル・テーブルの探索を行うことにより
、アセンブル時に機械語命令の絶対番地を割り付けるこ
とができる。
Furthermore, in the present invention, absolute addresses of machine language instructions can be assigned at the time of assembly by specifying the order of module organization and searching the public symbol table.

従って、後処理のリンカの作業を大幅に軽減し、アセン
ブル・スピードを速めることができる。
Therefore, the post-processing work of the linker can be greatly reduced and the assembly speed can be increased.

[実施例] 次に、本発明の実施例について添付の図面を参照して詳
細に説明する。
[Example] Next, an example of the present invention will be described in detail with reference to the accompanying drawings.

第1図に、本発明の実施例に係るアセンブル方式の動作
環境を示す。第7図のシステムと異なる点は、主として
補助記憶装置56の内容である。
FIG. 1 shows an operating environment for an assembly method according to an embodiment of the present invention. The main difference from the system shown in FIG. 7 is the contents of the auxiliary storage device 56.

補助記憶装置56は、ソース・プログラム及び改良型の
アセンブラ・プログラムの他に、モジュールの編成順序
を指定するモジュール編成順序テーブル56aと、ソー
ス・プログラムで定義されたパブリック・シンボルを記
憶するパブリック・シンボル・テーブル56bとを備え
ている。また、主記憶装置57には、モジュール毎に書
替えられるシンボル・テーブル57aが形成される。
In addition to the source program and the improved assembler program, the auxiliary storage device 56 stores a module organization order table 56a that specifies the organization order of modules, and a public symbol store that stores public symbols defined in the source program. - A table 56b is provided. Furthermore, a symbol table 57a is formed in the main storage device 57, which is rewritten for each module.

アセンブル方式は、分割モジュール毎の2バスアセンブ
ル方式である。パス1においては、ソース・モジュール
からローカル・シンボルを抽出し、その文字列と値をシ
ンボル・テーブル57aに格納すると共に、他のモジュ
ールで定義しであるシンボルを参照することを宣言した
EXTRNffJ似命令により定義されたEXTRN 
(外部)シンボルを抽出し、その文字列を、シンボル・
テーブル57に格納する。パス2においては、ソース・
モジュールからパブリック・シンボルを抽出し、その文
字列と値をパブリック・シンボル・テーブル56bに格
納すると共に、シンボル・テーブル57aに記憶された
未解決のEXTR,Nシンボルとそれに対応する値をパ
ブリック・シンボル・テーブル56bの中から見つけ出
し、シンボル・テーブル57aに出力する。尚、パブリ
ック・シンボル・テーブル56b内からEXTRNシン
ボルの値を探索する時に、モジュール編成順序テーブル
56aの内容を参照し、現在アセンブル中のソース・モ
ジュールより先に編成されたモジュールにおいて抽出さ
れたパブリック・シンボルのみを探索の対象とする。
The assembly method is a two-bus assembly method for each divided module. In pass 1, an EXTRNffJ-like instruction is used that extracts a local symbol from the source module, stores its character string and value in the symbol table 57a, and declares that it refers to a symbol defined in another module. EXTRN defined by
Extract the (external) symbol and convert the string to the symbol
It is stored in table 57. In pass 2, the source
Extracts a public symbol from the module, stores its character string and value in the public symbol table 56b, and stores the unresolved EXTR,N symbols and their corresponding values stored in the symbol table 57a as public symbols. - Find it from the table 56b and output it to the symbol table 57a. When searching for the value of the EXTRN symbol in the public symbol table 56b, the contents of the module organization order table 56a are referred to, and the public symbol extracted in the module organized before the source module currently being assembled is searched for. Only symbols are searched.

次に、第2図及び第3図のフロー図によって、本発明の
動作について詳細に説明する。
Next, the operation of the present invention will be explained in detail with reference to the flowcharts of FIGS. 2 and 3.

第2図は、2パスアセンブラのパス1におけるシンボル
に関連した動作を示すフロー図である。
FIG. 2 is a flow diagram illustrating symbol-related operations in pass 1 of a two-pass assembler.

ステップC1で、ソース・モジュールから一行を取り出
す、ステップC2において、ステップC1で取り出した
一行の中に、名前に任意のデータ又はアドレスの値を定
義するシンボル定義擬似命令が記述されているか否かを
判断する。シンボル定義擬似命令が記述されていたら、
ステップC5でシンボルと割り付けられた値をシンボル
・テーブル57aに記憶し、ステップC1に戻る。シン
ボル定義擬似命令でない場合、そのモジュール外で定義
されたシンボルの参照を行う事をシンボルを明示して宣
言するEXTRN擬似命令か否かをステップC3で判断
し、このEXTRN擬似命令が記述されていたら、ステ
ップC6でシンボル・テーブル57aへシンボルの文字
列とEXTRNシンボルであることを示す文字(例えば
E)を記憶し、ステップC1に戻る。EXTRN擬似命
令でない場合は、ステップC4でシンボル以外の処理を
終え、ステップC1に戻る。
In step C1, one line is extracted from the source module. In step C2, it is determined whether or not a symbol definition pseudo-instruction that defines arbitrary data or address value in the name is written in the one line extracted in step C1. to decide. If a symbol definition directive is written,
At step C5, the symbols and assigned values are stored in the symbol table 57a, and the process returns to step C1. If it is not a symbol definition pseudo-instruction, it is determined in step C3 whether it is an EXTRN pseudo-instruction that explicitly declares the symbol to refer to a symbol defined outside the module, and if this EXTRN pseudo-instruction is written, In step C6, the character string of the symbol and a character (for example, E) indicating that it is an EXTRN symbol are stored in the symbol table 57a, and the process returns to step C1. If it is not an EXTRN pseudo-instruction, processing other than symbols is finished in step C4, and the process returns to step C1.

第3図は、2パスアセンブル方式のパス2におけるシン
ボルに関連する動作を示したフロー図である。パス2で
はソース・プログラムを再度先頭から解釈する。ステッ
プD1でソース・モジュールより一行を取り出す。ステ
ップD2において、ステップD1で取り出した一行の中
にシンボルの・PtJBLI C宣言を行うPUBLI
C擬似命令が記述されていたら、その行に記述されてい
るシンボル文字列をステップD6で第1図で示したよう
にシンボル・テーブル57aから探し、探し出したシン
ボルの文字列と値をステップD5でパブリック・シンボ
ル・テーブル56bへ記憶させ、ステップD1に戻る。
FIG. 3 is a flow diagram showing symbol-related operations in pass 2 of the two-pass assembly method. In pass 2, the source program is interpreted again from the beginning. In step D1, one line is extracted from the source module. In step D2, PUBLI declares the symbol ・PtJBLI C in the line extracted in step D1.
If a C pseudo-instruction is written, the symbol string written in that line is searched for in the symbol table 57a as shown in FIG. 1 in step D6, and the string and value of the found symbol are searched in step D5. It is stored in the public symbol table 56b, and the process returns to step D1.

次に、ステップD2でPUBLIC擬似命令ではないと
判断した場合、ステップD3でその行でシンボル参照が
行われているか否かを判断する。
Next, if it is determined in step D2 that it is not a PUBLIC pseudo-instruction, it is determined in step D3 whether or not a symbol reference is made in that line.

シンボルを参照していたら、ステップD7においてシン
ボル・テーブル57aでそのシンボルと同じ文字列を探
す、ステップD8において、探し出したシンボルの項に
Eが記述され、そのシンボルが外部モジュールで定義し
た値を参照していると判断したら、ステップD10で、
同一アセンプル単位のモジュールアセンブル時に作成さ
れたパブリック・シンボル・テーブル56bからそのシ
ンボルと同じ文字列のシンボルを探索し、ステップDl
lでパブリック・シンボルテーブル56bにそのシンボ
ルが記憶されていると判断したら、ステップD9でその
シンボルに割り付けられた値を代入する。また、ステッ
プD11でそのシンボルがパブリック・シンボルテーブ
ル56bに存在しないと判断したら、ステップD12で
未解決シンボルとして保留にしておく。
If a symbol is referenced, the symbol table 57a is searched for the same character string as the symbol in step D7, and in step D8, E is written in the column of the found symbol, and the symbol refers to the value defined in the external module. If it is determined that it is, in step D10,
A symbol having the same character string as that symbol is searched from the public symbol table 56b created when assembling the module in the same assemble unit, and step Dl
If it is determined in step D9 that the symbol is stored in the public symbol table 56b, the value assigned to that symbol is substituted in step D9. Further, if it is determined in step D11 that the symbol does not exist in the public symbol table 56b, it is held as an unresolved symbol in step D12.

更に、ステップD8でシンボル・テーブルのシンボルの
項にEが記述されていない場合は、シンボルに割り当て
られた値を抽出し、そのシンボルに代入する。ステップ
D9又はD12の処理が終了したらステップD1に戻る
。なお、シンボルの参照で、シンボル・テーブルにその
シンボルが記述されていない場合はシンボル未定義エラ
ーを出力する等のステップがあるが、ここでは説明を省
略する。
Furthermore, if E is not written in the symbol field of the symbol table in step D8, the value assigned to the symbol is extracted and substituted into that symbol. When the processing in step D9 or D12 is completed, the process returns to step D1. Note that when a symbol is referenced and the symbol is not described in the symbol table, there are steps such as outputting a symbol undefined error, but the explanation is omitted here.

以上の処理を前述した第9図(a)のソース・プログラ
ムを例にとり、第4図(a)、(b)乃至第6図(a>
、(b)を参照して説明する。
Taking the source program of FIG. 9(a) described above as an example, the above processing is performed as follows.
, (b).

第4図、第5図、第6図は夫々モジュール71゜72.
73についてのシンボル・テーブル及びパブリック・シ
ンボル・テーブルの内容を示し、各図において(a)は
シンボル・テーブル、(b)はパブリック・シンボル・
テーブルの内容を示す。
4, 5, and 6 show the modules 71 and 72, respectively.
The contents of the symbol table and public symbol table for 73 are shown, and in each figure, (a) is the symbol table and (b) is the public symbol table.
Shows the contents of the table.

なお、モジュール編成順序テーブル56aには、モジュ
ール71,72.73の順で編成順序が指定されている
ものとする。
It is assumed that the module organization order table 56a specifies the organization order in the order of modules 71, 72, and 73.

先ず、モジュール71のアセンブルのパス1では、シン
ボル定義擬似命令SYMAが抽出され、その文字列SY
MAと値VALUEAがシンボル・テーブル57aに格
納される0次に、EXTRN擬似命令が抽出され、その
文字列SMMCと、その値が未確定であることを示す文
字′″E”とが格納される[第4図(a)]。
First, in pass 1 of assembly of module 71, symbol definition pseudo-instruction SYMA is extracted, and its character string SY
MA and the value VALUEA are stored in the symbol table 57a. Next, the EXTRN pseudo-instruction is extracted, and its character string SMMC and the character ``E'' indicating that its value is undefined are stored. [Figure 4(a)].

パス2では、PUBLIC擬似命令が抽出され、シンボ
ル・テーブル57aの探索により、その文字列SYMA
と値VALUEAとがパブリック・シンボル・テーブル
56bに格納される[第4図(b)]。更に、シンボル
参照命令BRが抽出され、そのシンボルSMMCはEX
TRNシンボルであるのでパブリック・シンボル・テー
ブル56bを探索するが、この場合には、末だSYMC
が登録されていないので、SYMC値は未確定のまま処
理を終了する。
In pass 2, the PUBLIC pseudo-instruction is extracted, and by searching the symbol table 57a, its character string SYMA
and the value VALUEA are stored in the public symbol table 56b [FIG. 4(b)]. Furthermore, the symbol reference instruction BR is extracted, and its symbol SMMC is EX
Since it is a TRN symbol, the public symbol table 56b is searched, but in this case, the last SYMC
Since the SYMC value is not registered, the process ends with the SYMC value undetermined.

モジュール72のアセンブル処理では、パス1でシンボ
ル定義擬似命令SYMB及びEXTRN擬似命令SYM
Aが夫々抽出され、シンボル・テーブル5゛7bの内容
は、第5図(a)に示すようになる。パス2では、新た
にPUBLI C擬似命令SYMBがパブリック・シン
ボル・テーブル56bに登録される。そして、このパス
2では、シンボル参照命令BRがシンボルSYMAを指
定する。この時、パブリック・シンボル・テーブル56
bには、SYMAの値VALUEAが登録されているの
で[第5図(b)]、シンボル・テーブル57aのSY
MAの値として、上記VALUEAを代入することがで
きる。従って、モジュール72のシンボル・テーブル5
7aではパブリック・シンボルSYMAの値が確定する
In the assembling process of the module 72, in pass 1, the symbol definition pseudo-instruction SYMB and the EXTRN pseudo-instruction SYM are
A is extracted, and the contents of the symbol table 5'7b become as shown in FIG. 5(a). In pass 2, the PUBLI C pseudo-instruction SYMB is newly registered in the public symbol table 56b. In this pass 2, the symbol reference instruction BR specifies the symbol SYMA. At this time, public symbol table 56
Since the value VALUEA of SYMA is registered in SYMA b [FIG. 5(b)], SY of the symbol table 57a
The above VALUEA can be substituted as the value of MA. Therefore, symbol table 5 of module 72
At 7a, the value of the public symbol SYMA is determined.

モジュール73についても同様に、パブリック・シンボ
ル・テーブル56bには、モジュール73で参照してい
るパブリック・シンボルのSYMBの値が既に登録され
ているので、シンボル・テーブル57aのSYMBの値
を確定させることができる[第6図(a)、(b)コ。
Similarly, regarding the module 73, since the value of SYMB of the public symbol referenced by the module 73 is already registered in the public symbol table 56b, the value of SYMB of the symbol table 57a must be determined. can be done [Fig. 6 (a), (b)].

従って、3つのモジュール71,72.73のアセンブ
ルが終了すると、結局、未解決シンボルは、モジュール
71におけるSYMCだけであり、後のリンク処理の負
担を大幅に軽減できる。
Therefore, when the assembly of the three modules 71, 72, and 73 is completed, the only unresolved symbol is SYMC in module 71, and the burden of subsequent link processing can be greatly reduced.

このように、第9図(a)のソース・プログラムにおい
て、モジュール72.73で参照しているシンボルSY
MA、SYMBはアドレスが若いモジュールで定義され
ているため、シンボル・テーブルに記憶された値をSY
MA、SYMBにアセンブル時に代入することができる
In this way, in the source program of FIG. 9(a), the symbol SY referenced in modules 72 and 73
Since MA and SYMB are defined in modules with young addresses, the values stored in the symbol table are
It can be assigned to MA and SYMB during assembly.

なお、上記実施例の説明で、パブリック・シンボルを格
納するのに使用した補助記憶装置とは、所謂ディスク等
のアクセス速度が低速の装置ばかりではなく、半導体メ
モリで構成された所謂RAMディスクやバブル・メモリ
等で構成されたものでもよい。
In the explanation of the above embodiment, the auxiliary storage device used to store public symbols is not only a device with a low access speed such as a so-called disk, but also a so-called RAM disk made of semiconductor memory or a bubble memory device.・It may be composed of memory or the like.

最後に、以上説明した本発明のアセンブラが、特に、所
謂シングル・チップ・マイコンにおいて有効であるとい
うことを説明する。シングル・チップ・マイコンは通常
主記憶装置内のプログラム・メモリ(ROM)とデータ
・メモリ(RAM)のアドレス空間とが異なり、データ
の記憶領域の制約が厳しいという理由からシンボルの定
義はソース・プログラムの最初に行うという慣習がある
Finally, it will be explained that the assembler of the present invention described above is particularly effective in so-called single-chip microcomputers. In single-chip microcontrollers, the program memory (ROM) and data memory (RAM) in the main memory usually have different address spaces, and because the data storage area is severely constrained, symbol definitions are limited to the source program. There is a custom of doing this at the beginning of the

未定義のシンボルはプログラム・メモリ・アドレスを示
すレーベルに集中するが、プログラムの局所性のために
レーベルはローカル・シンボルである場合が圧倒的に多
い。従って、シングル・チップ・マイコンでは、殆どの
パブリック・シンボルが後方のアドレスが若いモジュー
ルに位置し、そのためアセンブル時に殆ど解決されるこ
とになるので、アセンブル終了時の未解決シンボルの数
が極端に減少するのである。従って、本発明のアセンブ
ラ方式は、特に、シングル・チップ・マイコン用のソー
ス・プログラムを機械語に変換するアセンブラに応用す
ると、アセンブルの速度が従来のアセンブラに比して、
著しく向上することが期待される。
Undefined symbols are concentrated in labels that indicate program memory addresses, but because of program locality, labels are overwhelmingly local symbols. Therefore, in single-chip microcontrollers, most public symbols are located in modules with lower rear addresses, and as a result, most of them are resolved during assembly, which dramatically reduces the number of unresolved symbols at the end of assembly. That's what I do. Therefore, when the assembler method of the present invention is applied to an assembler that converts a source program for a single-chip microcontroller into machine language, the assembler method of the present invention has a faster assembling speed than a conventional assembler.
It is expected that this will improve significantly.

[発明の効果] 以上説明したように、本発明に係るアセンブラ方式によ
れば、ソース・プログラムを複数に分割し、モジュール
化した場合に、定義を行ったモジュール内でのみ参照可
能なローカル・シンボルを主記憶装置に記憶させて、更
にそれとは別にシンボルを定義したモジュール以外の外
部モジュールからでも参照しているパブリック・シンボ
ルを主記憶装置内のシンボル・テーブルが破壊されても
残るように、補助記憶装置内の任意のパブリック・シン
ボル・テーブルに記憶させることにより、アセンブル時
の編成順序が前であるモジュールで定義されたパブリッ
ク・シンボルをパブリック・シンボル・テーブルを探索
して参照し、機械語に変換することができる。このため
、アセンブル終了後には、ロードされるメモリ番地は決
定しているがその値が割り付けられていない所謂未解決
シンボルの数を減少させることができる。また、アセン
ブル時のモジュールの編成順序が指定されるためにアセ
ンブル時に機械語命令を絶対番地に割り当てることがで
きる。このため、リンカの作業を大幅に軽減して、アセ
ンブル速度を著しく速くすることができるという多大の
効果を奏する。
[Effects of the Invention] As explained above, according to the assembler method according to the present invention, when a source program is divided into multiple parts and modularized, local symbols that can be referenced only within the module in which they are defined is stored in main memory, and in addition, public symbols that are referenced even from external modules other than the module that defined the symbol are stored in auxiliary memory so that they remain even if the symbol table in main memory is destroyed. By storing public symbols in any public symbol table in the storage device, public symbols defined in modules that are organized earlier in assembly order can be searched and referenced in the public symbol table, and converted into machine language. can be converted. Therefore, after the assembly is completed, it is possible to reduce the number of so-called unresolved symbols whose memory addresses to be loaded have been determined but whose values have not been assigned. Furthermore, since the order of organization of modules at the time of assembly is specified, machine language instructions can be assigned to absolute addresses at the time of assembly. Therefore, the work of the linker can be greatly reduced and the assembly speed can be significantly increased, which is a great advantage.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の実施例に係るアセンブル方式を実行す
るシステムのブロック図、第2図は同実施例のパス1の
動作フロー図、第3図は同実施例のパス2の動作フロー
図、第4図(a)、(b)、第5[](a)、(b)及
び第6図(a)、(b)は夫々モジュール71,72.
73におけるシンボル・テーブル及びパブリック・シン
ボル・テーブルの内容を示す概略図、第7図は従来のア
センブル・システムの概略構成を示すブロック図、第8
図は従来のりロケータプルアセンブラの概略構成を示す
ブロック図、第9図(a)、(b)は第8図に示すアセ
ンブラで作成される夫々ソースプログラム及びロード・
モジュール・ファイルの概略図、第10図は従来のアブ
ソリュート・アセンブラの概略構成を示すブロック図で
ある。 50.56:補助記憶装置、51;中央処理装置、52
.57.主記憶装置、53;オペレーションシステム、
54;キーボード、55;デイスプレィ、56a;モジ
ュール編成順序テーブル、56b;パブリック・シンボ
ル・テーブル、57a;シンボル・テーブル
FIG. 1 is a block diagram of a system that executes an assembly method according to an embodiment of the present invention, FIG. 2 is an operation flow diagram of pass 1 of the embodiment, and FIG. 3 is an operation flow diagram of pass 2 of the embodiment. , FIGS. 4(a), (b), 5[](a), (b), and FIGS. 6(a), (b) are the modules 71, 72., respectively.
7 is a schematic diagram showing the contents of a symbol table and a public symbol table in 73, FIG. 7 is a block diagram showing a schematic configuration of a conventional assemble system, and FIG.
The figure is a block diagram showing the schematic configuration of a conventional glue locator pull assembler, and FIGS.
A schematic diagram of a module file. FIG. 10 is a block diagram showing a schematic configuration of a conventional absolute assembler. 50.56: Auxiliary storage device, 51; Central processing unit, 52
.. 57. Main storage device, 53; operation system,
54; keyboard; 55; display; 56a; module organization order table; 56b; public symbol table; 57a; symbol table

Claims (1)

【特許請求の範囲】[Claims] アセンブリ言語で記述され、複数のモジュールに分割さ
れるとともに、少なくとも1つのモジュールに他のモジ
ュールで定義されたパブリック・シンボルの参照命令を
含むソース・プログラムを、予め指定された編成順序で
上記モジュール毎にアセンブルしてオブジェクト・ファ
イルを生成するアセンブラ方式であつて、前記モジュー
ル毎のアセンブラは、当該モジュール内に定義されたロ
ーカル・シンボルの文字列及び値と、当該モジュール内
で参照され他のモジュール内に定義されたパブリック・
シンボルの文字列とを抽出し、これらを主記憶装置内に
形成されたシンボル・テーブルに格納する第1の手順と
、当該モジュール内に定義されたパブリック・シンボル
の文字列及び値を抽出し、これらを補助記憶装置内に形
成されたパブリック・シンボル・テーブルに格納すると
ともに、前記シンボル・テーブルに文字列のみ格納され
た前記パブリック・シンボルの値を前記パブリック・シ
ンボル・テーブルから探索して代入する第2の手順とを
備えたことを特徴とするアセンブラ方式。
A source program that is written in assembly language and is divided into a plurality of modules, and in which at least one module includes instructions for referencing public symbols defined in other modules, is divided into a plurality of modules in a pre-specified organization order for each of the modules. This is an assembler method that generates an object file by assembling into objects, and the assembler for each module assembles the character strings and values of local symbols defined in the module, and the strings and values of local symbols that are referenced in the module and in other modules. public defined in
a first step of extracting character strings of symbols and storing them in a symbol table formed in main memory; extracting character strings and values of public symbols defined in the module; These are stored in a public symbol table formed in an auxiliary storage device, and the value of the public symbol in which only character strings are stored in the symbol table is searched from the public symbol table and assigned. An assembler method characterized by comprising a second procedure.
JP33499587A 1987-12-18 1987-12-31 Assembler system Pending JPH01177128A (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP33499587A JPH01177128A (en) 1987-12-31 1987-12-31 Assembler system
US07/286,118 US5182807A (en) 1987-12-18 1988-12-19 Assembler system for determining when to compile source code modules
EP88121247A EP0321000A3 (en) 1987-12-18 1988-12-19 Assembler system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP33499587A JPH01177128A (en) 1987-12-31 1987-12-31 Assembler system

Publications (1)

Publication Number Publication Date
JPH01177128A true JPH01177128A (en) 1989-07-13

Family

ID=18283553

Family Applications (1)

Application Number Title Priority Date Filing Date
JP33499587A Pending JPH01177128A (en) 1987-12-18 1987-12-31 Assembler system

Country Status (1)

Country Link
JP (1) JPH01177128A (en)

Similar Documents

Publication Publication Date Title
US9081626B2 (en) Method and apparatus for converting software
WO2007013418A1 (en) System for writing software documentation in natural languages
JPH05197685A (en) System and method for supporting translation of windowed user interface with plurality of languages
JPS6091450A (en) Table type language interpreter
JPS63201834A (en) Generation of object module
JPH09259153A (en) Device and method for generating batch execution control program
WO2023078053A1 (en) Code generation method and apparatus, and computer device and storage medium
JP2004094487A (en) Support system for preparing document
JPH01177128A (en) Assembler system
CN111367937B (en) Data processing method and device
GB2420638A (en) Method of substituting code fragments in Internal Representation
JP2827724B2 (en) Program debug processing method
JPH08179953A (en) Automatic generation method and device for controller program
JP3044953B2 (en) Symbol processing method of language processing system
JPH09114655A (en) Patch generation and operation system in high-level language level
JP2003108369A (en) Autocreation of program that receives request from web and performs outputting of result
JPH07105014A (en) Symbol processing system for language processing system
JP2701781B2 (en) Document editing device
JP2000231494A (en) Software execution system and software executing method
JPH04248624A (en) Program conversion processor
JP2022135700A (en) Rewriting program and method for rewriting
JP2000207226A (en) Code optimizing device, language processor, and code optimization method
JPH05150960A (en) Precompiler
JPH04145536A (en) Address rearrangement processing system for program conversion processing system
JP2720643B2 (en) Program generator generator