JP2011123719A - Language processing system, language processing method and language-processing program - Google Patents

Language processing system, language processing method and language-processing program Download PDF

Info

Publication number
JP2011123719A
JP2011123719A JP2009281554A JP2009281554A JP2011123719A JP 2011123719 A JP2011123719 A JP 2011123719A JP 2009281554 A JP2009281554 A JP 2009281554A JP 2009281554 A JP2009281554 A JP 2009281554A JP 2011123719 A JP2011123719 A JP 2011123719A
Authority
JP
Japan
Prior art keywords
segment
data
information
compiler
object code
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
JP2009281554A
Other languages
Japanese (ja)
Inventor
Akira Egashira
朗 江頭
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.)
Renesas Electronics Corp
Original Assignee
Renesas Electronics 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 Renesas Electronics Corp filed Critical Renesas Electronics Corp
Priority to JP2009281554A priority Critical patent/JP2011123719A/en
Publication of JP2011123719A publication Critical patent/JP2011123719A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

【課題】セグメントレジスタへの設定コードを最小限に抑えて、オブジェクトのコードサイズを削減する。
【解決手段】1回目のコンパイルで従来のコンパイラと同様にオブジェクトコードを生成する。この場合は、セグメントレジスタに値を設定するコードを生成する。このコードを受け取ったリンカが「変数がどのセグメント番号に割り当たるか」という情報(この情報の集合体を「セグメント情報」と呼ぶ)を出力し、その情報を利用して再度コンパイルする。2回目以降のコンパイル時にはセグメント情報から変数のセグメント番号が分かっているので、セグメントレジスタの書き換えが必要かどうか分かる。セグメントレジスタの書き換えが不要だと分かればセグメントレジスタの設定コードを削減することができる。
【選択図】図4
An object of the present invention is to reduce the code size of an object by minimizing the code set in a segment register.
An object code is generated in the first compilation as in a conventional compiler. In this case, a code for setting a value in the segment register is generated. The linker that has received this code outputs the information “to which segment number the variable is assigned” (this set of information is referred to as “segment information”), and uses that information to compile again. Since the segment number of the variable is known from the segment information at the second and subsequent compilations, it can be determined whether the segment register needs to be rewritten. If it is known that rewriting of the segment register is unnecessary, the setting code of the segment register can be reduced.
[Selection] Figure 4

Description

本発明は、ソース入力手段、構文解析手段、オブジェクトコード生成手段を有する言語処理プログラムに関する。   The present invention relates to a language processing program having source input means, syntax analysis means, and object code generation means.

16ビットのマイクロプロセッサは、通常、16ビットで表現できる64キロバイトのアドレス空間を持つ。近年の市場では、64キロバイトを超えるメモリを必要とする場合が増えてきている。しかし、64キロバイトを超えるアドレス空間を扱える24ビットマイクロプロセッサや32ビットマイクロプロセッサは価格が高く、安価な16ビットマイクロプロセッサで64キロバイトを超えるメモリをアクセスできるプロセッサが市場で求められている。   A 16-bit microprocessor usually has a 64-kilobyte address space that can be expressed in 16 bits. In the market in recent years, an increasing number of cases require memory exceeding 64 kilobytes. However, 24-bit microprocessors and 32-bit microprocessors that can handle an address space exceeding 64 kilobytes are expensive, and there is a demand for a processor that can access memory exceeding 64 kilobytes with an inexpensive 16-bit microprocessor.

この市場のニーズ(要求)に答えて、16ビットのマイクロプロセッサで64キロバイトを超えるアドレス空間をアクセス可能とする手法として、セグメントアドレス方式のマイクロプロセッサが存在する。セグメントアドレス方式の16ビットマイクロプロセッサは、16ビットよりも上位のビットを含む上位アドレスを格納するセグメントレジスタを備えることにより、データのビット幅が16ビットでありながら、64キロバイトを超えるアドレス空間を扱うことができる。つまり、アドレス空間を64キロバイトごとに区切り、番号を付けて管理するのがセグメントレジスタであると考えると良い。以降、アドレスを16ビットで区切った上位アドレスを「セグメント番号」と呼ぶ。   In response to the needs (requests) of this market, there is a segment address type microprocessor as a method for making an address space exceeding 64 kilobytes accessible by a 16-bit microprocessor. The segment address 16-bit microprocessor includes a segment register that stores an upper address including bits higher than 16 bits, thereby handling an address space exceeding 64 kilobytes while the data bit width is 16 bits. be able to. In other words, it can be considered that segment registers divide the address space into 64 kilobytes and manage them with numbers. Hereinafter, an upper address obtained by dividing an address by 16 bits is referred to as a “segment number”.

セグメントアドレス方式では、64キロバイトに収まらないデータにアクセスする場合、データのセグメント番号をセグメントレジスタに設定してからデータにアクセスすることになる。このため、オブジェクトコード生成において、オブジェクトコードのサイズが増大してしまうという問題がある。   In the segment address method, when accessing data that does not fit in 64 kilobytes, the data is accessed after setting the segment number of the data in the segment register. For this reason, there is a problem that the size of the object code increases in the object code generation.

関連する技術として、特許文献1(特開平06−337791号公報)に、セグメントアドレス方式に関する説明がある。また、特許文献2(特開平07−121380号公報)では、コードの削減手法として、不要なセグメントレジスタの設定コードを省略することが記載されている。しかし、セグメントレジスタの設定が省略可能かどうかの判断基準となるセグメントレジスタの設定値の取得方法については、記載されていない。   As a related technique, Patent Document 1 (Japanese Patent Laid-Open No. 06-337791) describes a segment address system. Japanese Patent Laid-Open No. 07-121380 discloses that an unnecessary segment register setting code is omitted as a code reduction technique. However, it does not describe how to obtain the set value of the segment register that is a criterion for determining whether the setting of the segment register can be omitted.

図1は、ユーザが記述したソースプログラムファイル1から最終的な出力であるロードモジュールファイル2を生成するコンパイル方式(言語処理方式)を示す。ロードモジュールファイルとは、関数や変数など全てのデータのメモリ配置が確定したオブジェクトコードを意味する。   FIG. 1 shows a compilation method (language processing method) for generating a load module file 2 which is a final output from a source program file 1 described by a user. The load module file means an object code in which the memory arrangement of all data such as functions and variables is fixed.

<従来方式の構成>
図1で示す通り、従来のコンパイル方式は、コンパイラ(compiler)10と、リンカ(linker)20を備える。
<Conventional configuration>
As shown in FIG. 1, the conventional compilation method includes a compiler 10 and a linker 20.

コンパイラ10は、構文解析部11と、コード生成部13と、オブジェクト出力部14を備える。   The compiler 10 includes a syntax analysis unit 11, a code generation unit 13, and an object output unit 14.

構文解析部11は、ソースプログラムファイル1に記述されたプログラミング言語のソースコードを構文解析する。なお、一般的に、構文解析(parser)の前に字句解析(lexer)が行われる。字句解析については記載を省略する。例えば、構文解析部11は、字句解析によってソースプログラムファイル1のプログラム中のトークン(命令語やリテラル)を切り出した後の段階において、そのトークンの属性と文法に記述された構文規則に基づいて、構文木を導出する。   The syntax analysis unit 11 parses the source code of the programming language described in the source program file 1. Generally, lexical analysis (lexer) is performed before syntax analysis (parser). The description of lexical analysis is omitted. For example, the syntax analysis unit 11 at the stage after cutting out a token (an instruction word or a literal) in the program of the source program file 1 by lexical analysis, based on the attribute of the token and the syntax rule described in the grammar, Derive a syntax tree.

コード生成部13は、構文木からオブジェクトコードを生成する。   The code generation unit 13 generates an object code from the syntax tree.

オブジェクト出力部14は、コンパイラ10からオブジェクトコードを出力し、リンカ20に入力する。コンパイラ10からリンカ20に渡すデータは、メモリ配置が決定していないオブジェクトコードであるが、当該データの受け渡し方法については、外部ファイルを介した受け渡しでも、メモリ内での受け渡しでも良い。   The object output unit 14 outputs the object code from the compiler 10 and inputs it to the linker 20. Data passed from the compiler 10 to the linker 20 is an object code whose memory arrangement has not been determined. The data delivery method may be delivery via an external file or delivery in memory.

リンカ20は、オブジェクトコードに必要なライブラリ等を付け加えて実行可能ファイルを生成し、ロードモジュールファイル2として出力する機能を備える。ロードモジュールファイル2は、メインメモリにロードできる実行ファイル形式のモジュールである。   The linker 20 has a function of generating an executable file by adding a necessary library or the like to the object code and outputting it as a load module file 2. The load module file 2 is an executable file format module that can be loaded into the main memory.

<従来方式のデータアクセス処理>
図2を参照して、図1のコード生成部13内部の処理について説明する。
<Conventional data access processing>
With reference to FIG. 2, the processing inside the code generation unit 13 of FIG. 1 will be described.

ここで、「データ」とは、ソースコード中の変数、並びにプロセッサ内での変数の領域を意味する。変数には、マイクロプロセッサのメモリ(ROM、RAM等)上に静的に配置されるものや、ソースコードにおける自動変数のように、RAMのスタック領域に必要に応じて自動的に確保されるものがある。「データアクセス」とは、変数に対してマイクロプロセッサがRead/Write(読み込み/書き込み)することを意味する。   Here, “data” means a variable in the source code and an area of the variable in the processor. Variables are statically allocated on the microprocessor's memory (ROM, RAM, etc.), or automatically allocated as needed in the RAM stack area, such as automatic variables in the source code. There is. “Data access” means that the microprocessor performs Read / Write (read / write) on the variable.

また、「farデータ」とは、従来の64キロバイトのアドレス空間に収まらないデータを意味する。また、従来の64キロバイトのアドレス空間に収まるデータは「nearデータ」と呼んで区別する。個々のデータをnearデータとするかfarデータとするかは、ユーザが決める。なお、nearデータかfarデータかを指定することで意味があるのは、一般的には静的に配置される変数である。   “Far data” means data that does not fit in the conventional 64-kilobyte address space. Also, data that fits in the conventional 64-kilobyte address space is called “near data” to be distinguished. The user decides whether individual data is to be near data or far data. Note that it is generally a variable that is statically allocated to designate near data or far data.

(1)ステップS101
コード生成部13は、データアクセスの際に、アクセス対象のデータ(ソースプログラムファイル1の変数)がfarデータかどうか確認する。ここでは、farデータではない場合、nearデータであるものとする。従来方式において、変数がfarデータかどうかの判定方法については、ソースコード中の変数に対して「_near」や「_far」という修飾子をつけることで、コンパイラ10の構文解析部11が判定する。修飾子を省略した変数をnearデータとするかfarデータとするかは、コンパイラ10の最適化を指示することで、コンパイラ10の構文解析部11が、全てnearデータとして処理するか、全てfarデータとして処理する。なお、「_near」や「_far」という修飾子は、便宜上のものであり、実際には、この例に限定されない。
(1) Step S101
When the data is accessed, the code generation unit 13 checks whether the data to be accessed (variable in the source program file 1) is far data. Here, if it is not far data, it is assumed to be near data. In the conventional method, the method for determining whether or not a variable is far data is determined by the syntax analysis unit 11 of the compiler 10 by attaching modifiers “_near” and “_far” to the variable in the source code. Whether the variable without the qualifier is to be near data or far data is determined by the compiler 10 instructing optimization, so that the parsing unit 11 of the compiler 10 processes all the near data or all the far data. Process as. The modifiers “_near” and “_far” are for convenience and are not actually limited to this example.

(2)ステップS102
コード生成部13は、farデータではない(nearデータである)場合、セグメントレジスタ設定コードは不要とする。例えば、コード生成部13は、nearデータは従来の64キロバイトのアドレス空間に収まるため、セグメントレジスタにセグメント番号を設定することなくデータにアクセスし、オブジェクトコードを生成する。
(2) Step S102
If it is not far data (near data), the code generation unit 13 does not need a segment register setting code. For example, since the near data fits in the conventional 64-kilobyte address space, the code generation unit 13 accesses the data without setting the segment number in the segment register and generates an object code.

(3)ステップS103
コード生成部13は、farデータである場合、セグメントレジスタ設定コードを出力する。例えば、コード生成部13は、farデータは64キロバイトのアドレス空間に収まらないため、セグメント番号として16ビットよりも上位のビットを含む上位アドレスをセグメントレジスタに設定してからデータにアクセスし、オブジェクトコードを生成する。
(3) Step S103
The code generation unit 13 outputs a segment register setting code when it is far data. For example, since the far data does not fit in an address space of 64 kilobytes, the code generation unit 13 sets the upper address including bits higher than 16 bits as the segment number in the segment register and then accesses the data. Is generated.

図3は、ユーザが記述したソースプログラムファイルと、生成されたオブジェクトコード(コンパイラの出力)の例である。   FIG. 3 shows an example of a source program file written by the user and generated object code (compiler output).

図3では、ソースプログラムファイル(101)は、C言語で書かれている。「_far」は、farデータを意味する修飾子である。また、「_near」は、nearデータを意味する修飾子である。   In FIG. 3, the source program file (101) is written in C language. “_Far” is a qualifier that means far data. “_Near” is a qualifier that means near data.

図3のオブジェクトコードについて、先頭が「;」から始まる文字列は、ユーザが記述したソースプログラムをコメントで表示したものであり、プロセッサの動作とは関係がない。「mov」は、データを転送する命令であり、カンマで区切られた右側に記述したものから左側に記述したものにデータを設定することを意味する。DSは、セグメントレジスタを意味する。「#」は、定数であることを意味し、「#1」は、定数1であることを意味する。「high_addr(a)」は、変数aの上位アドレスを意味するが、この値は、コード生成時では、確定しておらず、リンカ(linker)で変数のメモリ配置が行われた時点で確定する。「!_」は、変数の中身であることを意味する。「DS:」は、セグメントレジスタに設定された上位アドレスを付加して64キロバイトを超えるアドレス空間をアクセスすることを意味する。   In the object code of FIG. 3, the character string starting with “;” is a source program written by the user as a comment, and is not related to the operation of the processor. “Mov” is an instruction to transfer data, and means to set data from what is written on the right side to what is written on the left side separated by commas. DS means a segment register. “#” Means a constant, and “# 1” means a constant 1. “High_addr (a)” means the upper address of the variable a, but this value is not fixed at the time of code generation, but is determined when the memory is allocated to the variable by the linker. . “! _” Means the contents of a variable. “DS:” means that an upper address set in the segment register is added to access an address space exceeding 64 kilobytes.

以上を踏まえてソースプログラムとオブジェクトコードを比較すると、farデータである変数aに1を設定する場合、最初に変数aの上位アドレスをセグメントレジスタに設定してから、改めて変数aに1を設定するコードを生成することになる。   Comparing the source program with the object code based on the above, when 1 is set to the variable a which is far data, the upper address of the variable a is first set to the segment register, and then 1 is set to the variable a again. Will generate code.

このとき、コンパイラ(compiler)は、ユーザが記述したソースプログラムを解析してオブジェクトコードを生成するが、最終的に「メモリのどこにデータを配置するか」を決定するのはリンカである。つまり、コンパイラがオブジェクトコードを生成する時点では、farデータにアクセスする際にセグメント番号の値は分からない。   At this time, the compiler analyzes the source program written by the user to generate an object code, but it is the linker that finally decides “where in the memory to place data”. That is, when the compiler generates the object code, the segment number value is not known when accessing the far data.

例えば、図3のソースプログラムでは、farデータの変数aをアクセスした後にfarデータの変数bをアクセスしている。変数aと変数bのセグメント番号が全く同じである場合、セグメントレジスタの値を再設定する必要はない。しかし、コンパイラがコードを生成する時点では、最終的に変数aと変数bのセグメント番号が同じになるかどうかは判断できない。そのため、コンパイラは、毎回セグメントレジスタに値を設定するコードを生成する必要がある。   For example, in the source program of FIG. 3, the variable b of the far data is accessed after the variable a of the far data is accessed. When the segment numbers of the variable a and the variable b are exactly the same, it is not necessary to reset the segment register value. However, when the compiler generates code, it cannot be determined whether or not the segment numbers of the variables a and b are finally the same. Therefore, the compiler needs to generate code that sets a value in the segment register each time.

このセグメントレジスタへの設定コードを最小限に抑えることができれば、オブジェクトコードのサイズを削減することができると考えられる。   If the setting code to the segment register can be minimized, it is considered that the size of the object code can be reduced.

特開平06−337791号公報Japanese Patent Laid-Open No. 06-337791 特開平07−121380号公報Japanese Patent Laid-Open No. 07-121380

本発明の目的は、コンパイラが毎回セグメントレジスタに値を設定するために生成するコードのサイズを最小限に抑えることである。   An object of the present invention is to minimize the size of code generated by the compiler to set a value in the segment register each time.

本発明では、1回目のコンパイルで従来のコンパイラと同様にオブジェクトコードを生成する。この場合は、セグメントレジスタに値を設定するコードを生成する。このコードを受け取ったリンカが「変数がどのセグメント番号に割り当たるか」という情報(以降、この情報の集合体を「セグメント情報」と呼ぶ)を出力し、その情報を利用して再度コンパイルする。2回目以降のコンパイル時には、セグメント情報から変数のセグメント番号が分かっているので、セグメントレジスタの書き換えが必要かどうか分かる。セグメントレジスタの書き換えが不要だと判明する。   In the present invention, the object code is generated in the first compilation in the same manner as the conventional compiler. In this case, a code for setting a value in the segment register is generated. The linker that has received this code outputs the information “to which segment number the variable is assigned” (hereinafter, this collection of information is called “segment information”) and recompiles using this information. At the time of the second and subsequent compilations, since the segment number of the variable is known from the segment information, it can be determined whether the segment register needs to be rewritten. It turns out that it is not necessary to rewrite the segment register.

本発明の言語処理システムは、コンパイラと、リンカとを含む。コンパイラは、ソースプログラムファイルを読み込み、ソースプログラムファイルに基づいて、オブジェクトコードを生成する。リンカは、オブジェクトコードを読み込み、オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成する。更に、コンパイラは、セグメント情報を読み込むセグメント情報設定部と、セグメント情報が存在しない場合、セグメントレジスタに値を設定するオブジェクトコードを生成するコード生成部とを具備する。   The language processing system of the present invention includes a compiler and a linker. The compiler reads the source program file and generates object code based on the source program file. The linker reads the object code, and generates a load module file in which the memory allocation of the function and variable is determined based on the object code, and segment information that is a collection of information indicating which segment number the variable is assigned to To do. The compiler further includes a segment information setting unit that reads segment information, and a code generation unit that generates an object code for setting a value in the segment register when the segment information does not exist.

本発明の言語処理方法では、コンパイラにより、ソースプログラムファイルを読み込み、ソースプログラムファイルに基づいて、オブジェクトコードを生成する。また、リンカにより、オブジェクトコードを読み込み、オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成することと、コンパイラにより、セグメント情報を読み込む。また、セグメント情報が存在しない場合、コンパイラにより、セグメントレジスタに値を設定するオブジェクトコードを生成する。   In the language processing method of the present invention, a source program file is read by a compiler, and object code is generated based on the source program file. In addition, the object code is read by the linker, and the load module file in which the memory allocation of the function and the variable is determined based on the object code, and the segment information which is a collection of information indicating which segment number the variable is assigned to, And segment information is read by the compiler. If segment information does not exist, the compiler generates object code for setting a value in the segment register.

本発明の言語処理用プログラムは、コンパイラとして、ソースプログラムファイルを読み込み、ソースプログラムファイルに基づいて、オブジェクトコードを生成するステップと、リンカとして、オブジェクトコードを読み込み、オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成するステップと、コンパイラとして、セグメント情報を読み込むステップと、セグメント情報が存在しない場合、コンパイラとして、セグメントレジスタに値を設定するオブジェクトコードを生成するステップとを計算機に実行させるためのプログラムである。なお、本発明の言語処理用プログラムは、記憶装置や記憶媒体に格納することが可能である。   The language processing program of the present invention reads a source program file as a compiler, generates an object code based on the source program file, reads an object code as a linker, and functions and variables based on the object code. Generating a load module file with a fixed memory allocation and segment information that is a collection of information indicating which segment number a variable is assigned to, as a compiler, reading segment information, and segment information When the program does not exist, the program causes the computer to execute a step of generating an object code for setting a value in the segment register as a compiler. The language processing program of the present invention can be stored in a storage device or a storage medium.

セグメントレジスタの設定コードを削減することで、オブジェクトコードのサイズを削減することができる。   The size of the object code can be reduced by reducing the setting code of the segment register.

従来のコンパイル方式の構成例を示すブロック図である。It is a block diagram which shows the structural example of the conventional compilation system. 従来のコンパイル方式のデータアクセス処理のフローチャートである。It is a flowchart of the data access process of the conventional compilation system. 従来のコンパイル方式における、データアクセス処理を行うC言語とアセンブラ出力である。They are C language for performing data access processing and assembler output in the conventional compilation method. 本発明の言語処理システムの構成例を示すブロック図である。It is a block diagram which shows the structural example of the language processing system of this invention. 本発明の言語処理システムのデータアクセス処理のフローチャートである。It is a flowchart of the data access process of the language processing system of this invention. 本発明の言語処理システムにおける、データアクセス処理を行うC言語とアセンブラ出力である。It is C language and assembler output which perform a data access process in the language processing system of this invention.

<基本構成>
以下に、本発明の実施形態について添付図面を参照して説明する。
図4で示す通り、本発明の言語処理システムは、コンパイラ(compiler)10と、リンカ(linker)20を備える。
<Basic configuration>
Embodiments of the present invention will be described below with reference to the accompanying drawings.
As shown in FIG. 4, the language processing system of the present invention includes a compiler 10 and a linker 20.

コンパイラ10は、構文解析部11と、セグメント情報設定部12と、コード生成部13と、オブジェクト出力部14を備える。   The compiler 10 includes a syntax analysis unit 11, a segment information setting unit 12, a code generation unit 13, and an object output unit 14.

構文解析部11は、ソースプログラムファイル1に記述されたプログラミング言語のソースコードを構文解析する。なお、一般的に、構文解析(parser)の前に字句解析(lexer)が行われる。字句解析については記載を省略する。例えば、構文解析部11は、字句解析によってソースプログラムファイル1のプログラム中のトークン(命令語やリテラル)を切り出した後の段階において、そのトークンの属性と文法に記述された構文規則に基づいて、構文木を導出する。   The syntax analysis unit 11 parses the source code of the programming language described in the source program file 1. Generally, lexical analysis (lexer) is performed before syntax analysis (parser). The description of lexical analysis is omitted. For example, the syntax analysis unit 11 at the stage after cutting out a token (an instruction word or a literal) in the program of the source program file 1 by lexical analysis, based on the attribute of the token and the syntax rule described in the grammar, Derive a syntax tree.

セグメント情報設定部12は、セグメント情報3を読み込む。セグメント情報3は、「変数がどのセグメント番号に割り当たるか」を示す情報の集合体である。セグメント情報3は、各変数のシンボル情報(変数名)と、nearデータかfarデータか(near/far)を示す情報を持ち、更に、farデータである場合は、セグメント番号を情報として保持する。ここでは、セグメント情報設定部12は、リンカ20からセグメント情報を受け取る。セグメント情報3の受け渡し方法については、外部ファイルを介した受け渡しでも、メモリ内での受け渡しでも良い。   The segment information setting unit 12 reads the segment information 3. The segment information 3 is a collection of information indicating “to which segment number the variable is assigned”. The segment information 3 has symbol information (variable name) of each variable and information indicating whether it is near data or far data (near / far). If it is far data, it holds a segment number as information. Here, the segment information setting unit 12 receives segment information from the linker 20. The segment information 3 may be transferred via an external file or within a memory.

コード生成部13は、構文木からオブジェクトコードを生成する。   The code generation unit 13 generates an object code from the syntax tree.

オブジェクト出力部14は、コンパイラ10からオブジェクトコードを出力し、リンカ20に入力する。コンパイラ10からリンカ20に渡すデータは、メモリ配置が決定していないオブジェクトコードであるが、当該データの受け渡し方法については、外部ファイルを介した受け渡しでも、メモリ内での受け渡しでも良い。   The object output unit 14 outputs the object code from the compiler 10 and inputs it to the linker 20. Data passed from the compiler 10 to the linker 20 is an object code whose memory arrangement has not been determined. The data delivery method may be delivery via an external file or delivery in memory.

リンカ20は、ロードモジュールファイル2と、セグメント情報3を出力する機能を備える。ここでは、リンカ20は、セグメント情報3をセグメント情報設定部12に提供する。   The linker 20 has a function of outputting the load module file 2 and the segment information 3. Here, the linker 20 provides the segment information 3 to the segment information setting unit 12.

本発明の言語処理システムの例として、PC(パソコン)、シンクライアント端末/サーバ、ワークステーション、メインフレーム、スーパーコンピュータ等の計算機を想定している。コンパイラ10とリンカ20は、同一の計算機上に限らず、それぞれ異なる計算機上に存在していても良い。但し、実際には、これらの例に限定されない。   As an example of the language processing system of the present invention, a computer such as a PC (personal computer), a thin client terminal / server, a workstation, a mainframe, a supercomputer is assumed. The compiler 10 and the linker 20 are not limited to the same computer, and may exist on different computers. However, actually, it is not limited to these examples.

構文解析部11、セグメント情報設定部12、コード生成部13、及びオブジェクト出力部14は、プログラムで駆動される処理装置等のハードウェアと、そのハードウェアを駆動して所望の処理を実行させるプログラム等のソフトウェアと、そのソフトウェアや各種データを格納する記憶装置によって実現される。処理装置の例として、CPU(Central Processing Unit)、マイクロプロセッサ(microprocessor)、マイクロコントローラ、或いは、同様の機能を有する半導体集積回路(Integrated Circuit(IC))等が考えられる。記憶装置の例として、RAM(Random Access Memory)、ROM(Read Only Memory)、EEPROM(Electrically Erasable and Programmable Read Only Memory)や、フラッシュメモリ等の半導体記憶装置、HDD(Hard Disk Drive)やSSD(Solid State Drive)等の補助記憶装置、又は、DVD(Digital Versatile Disk)やメモリカード等の記憶媒体(メディア)が考えられる。また、オブジェクト出力部14は、ネットワークを介して通信する必要がある場合、ネットワークインタフェースを含むものとする。ネットワークインタフェースの例として、NIC(Network Interface Card)等のネットワークアダプタや、アンテナ等の通信装置、接続口(コネクタ)等の通信ポート等が考えられる。また、ネットワークの例として、インターネット、LAN(Local Area Network)、無線LAN(Wireless LAN)、WAN(Wide Area Network)、バックボーン(Backbone)、ケーブルテレビ(CATV)回線、固定電話網、携帯電話網、WiMAX(IEEE 802.16a)、3G(3rd Generation)、専用線(lease line)、IrDA(Infrared Data Association)、Bluetooth(登録商標)、シリアル通信回線、データバス等が考えられる。但し、実際には、これらの例に限定されない。   The syntax analysis unit 11, the segment information setting unit 12, the code generation unit 13, and the object output unit 14 are hardware such as a processing device driven by a program, and a program that drives the hardware to execute a desired process And a storage device for storing the software and various data. As an example of the processing apparatus, a CPU (Central Processing Unit), a microprocessor (microprocessor), a microcontroller, or a semiconductor integrated circuit (Integrated Circuit (IC)) having a similar function can be considered. Examples of the storage device include a RAM (Random Access Memory), a ROM (Read Only Memory), an EEPROM (Electrically Erasable and Programmable Read Only Memory), a flash memory, and other semiconductor storage devices such as an HDD (SD) An auxiliary storage device such as State Drive) or a storage medium (media) such as a DVD (Digital Versatile Disk) or a memory card is conceivable. The object output unit 14 includes a network interface when it is necessary to communicate via a network. Examples of the network interface include a network adapter such as NIC (Network Interface Card), a communication device such as an antenna, a communication port such as a connection port (connector), and the like. Examples of the network include the Internet, a LAN (Local Area Network), a wireless LAN (Wireless LAN), a WAN (Wide Area Network), a backbone (Backbone), a cable television (CATV) line, a fixed telephone network, a mobile phone network, WiMAX (IEEE 802.16a), 3G (3rd Generation), dedicated line (lease line), IrDA (Infrared Data Association), Bluetooth (registered trademark), serial communication line, data bus, and the like can be considered. However, actually, it is not limited to these examples.

<データアクセス処理>
図5を参照して、図4のコード生成部13内部の処理について説明する。
<Data access processing>
With reference to FIG. 5, the processing inside the code generation unit 13 of FIG. 4 will be described.

(1)ステップS201
コード生成部13は、データアクセスの際に、アクセス対象のデータ(ソースプログラムファイル1の変数)がfarデータかどうか確認する。ここでは、farデータではない場合、nearデータであるものとする。本発明において、変数がfarデータかどうかの判定方法については、図4のセグメント情報3を基に、セグメント情報設定部12が判定する。この場合、ソースコード中の「_near」や「_far」という修飾子による変数の領域配置指定と、セグメント情報3とが競合することになる。セグメント情報設定部12は、セグメント情報3を優先しても良いし、「_near」や「_far」という修飾子を優先しても良い。セグメント情報3を優先すると、コードサイズが削減される。「_near」や「_far」という修飾子を優先すると、ユーザの意図が反映される。
(1) Step S201
When the data is accessed, the code generation unit 13 checks whether the data to be accessed (variable in the source program file 1) is far data. Here, if it is not far data, it is assumed to be near data. In the present invention, the segment information setting unit 12 determines whether or not the variable is far data based on the segment information 3 in FIG. In this case, the segment information 3 conflicts with the variable area location designation by the modifiers “_near” and “_far” in the source code. The segment information setting unit 12 may prioritize the segment information 3 or may prioritize modifiers such as “_near” or “_far”. If the segment information 3 is prioritized, the code size is reduced. When the modifiers “_near” and “_far” are given priority, the intention of the user is reflected.

(2)ステップS202
コード生成部13は、farデータではない(nearデータである)場合、セグメントレジスタ設定コードは不要とする。例えば、コード生成部13は、セグメントレジスタにセグメント番号を設定することなくデータにアクセスし、オブジェクトコードを生成する。
(2) Step S202
If it is not far data (near data), the code generation unit 13 does not need a segment register setting code. For example, the code generation unit 13 accesses data without setting a segment number in the segment register, and generates an object code.

(3)ステップS203
コード生成部13は、farデータである場合、セグメントレジスタの値と変数のセグメント番号を比較する。
(3) Step S203
In the case of far data, the code generation unit 13 compares the value of the segment register with the segment number of the variable.

(4)ステップS204
コード生成部13は、セグメントレジスタの値が変更されたか否か判定する。
(4) Step S204
The code generation unit 13 determines whether or not the value of the segment register has been changed.

(5)ステップS205
コード生成部13は、セグメントレジスタの値が変更された場合、もしくは判定不能の場合、セグメントレジスタ設定コードを出力する。例えば、コード生成部13は、セグメント番号をセグメントレジスタに設定してからデータにアクセスし、オブジェクトコードを生成する。
(5) Step S205
The code generation unit 13 outputs a segment register setting code when the value of the segment register is changed or when determination is impossible. For example, the code generation unit 13 sets the segment number in the segment register, accesses the data, and generates an object code.

(6)ステップS206
コード生成部13は、セグメントレジスタの値が変更されていない場合、セグメントレジスタ設定コードは不要とする。例えば、コード生成部13は、セグメントレジスタにセグメント番号を設定することなくデータにアクセスし、オブジェクトコードを生成する。
(6) Step S206
If the value of the segment register is not changed, the code generation unit 13 does not need the segment register setting code. For example, the code generation unit 13 accesses data without setting a segment number in the segment register, and generates an object code.

図6は、図3と同じソースプログラムを、本発明の言語処理システムに入力して得られたオブジェクトコードである。   FIG. 6 shows object code obtained by inputting the same source program as FIG. 3 into the language processing system of the present invention.

<全体動作>
[1回目のコンパイル]
コンパイラ10は、1回目のコンパイルでは、従来と同様に、オブジェクトコードを生成する。このとき、セグメント情報3はまだ作られていないため、セグメント情報設定部12は何も行わない。コード生成部13は、データアクセスの際にfarデータかどうかを判定し、farデータの場合は、直前のセグメントと変数のセグメントを比較するが、セグメント情報が設定されていないため、判定不能としてセグメントレジスタに値を設定する(ための)オブジェクトコードを生成する。ここでは、コード生成部13は、farデータの場合は、セグメント情報の参照を試みることでセグメント情報の有無を確認し、セグメント情報が存在していれば、直前のセグメントと変数のセグメントを比較し、セグメント情報が存在していなければ、判定不能としてセグメントレジスタに値を設定するオブジェクトコードを生成する。但し、実際には、この例に限定されない。
<Overall operation>
[First compilation]
In the first compilation, the compiler 10 generates an object code as in the conventional case. At this time, since the segment information 3 has not been created yet, the segment information setting unit 12 does nothing. The code generation unit 13 determines whether the data is far data at the time of data access. If the data is far data, the previous segment is compared with the variable segment. Generate object code to set a value in a register. Here, in the case of far data, the code generation unit 13 checks the presence or absence of the segment information by trying to refer to the segment information. If the segment information exists, the code generation unit 13 compares the immediately preceding segment with the variable segment. If the segment information does not exist, an object code for setting a value in the segment register as indeterminable is generated. However, actually, it is not limited to this example.

[セグメント情報出力]
リンカ20は、コンパイラ10が生成したオブジェクトコードを基にメモリ配置を決定する。この際、各変数のアドレスが確定するので、リンカ20は、セグメント情報3を出力する。
[Segment information output]
The linker 20 determines the memory allocation based on the object code generated by the compiler 10. At this time, since the address of each variable is fixed, the linker 20 outputs the segment information 3.

[2回目以降のコンパイル]
コンパイラ10は、セグメント情報3を利用して、2回目以降のコンパイルを行う。セグメント情報設定部12は、セグメント情報を読み込み、コンパイラ10内部で変数のセグメント番号を情報として持つ。コード生成部13は、farデータにアクセスするコードを生成する際、セグメントレジスタの値と変数のセグメント番号を比較する。ここでは、1回目のコンパイルの際と同様に、コード生成部13は、farデータかどうかを判定し、farデータの場合は、セグメント情報の参照を試みることでセグメント情報の有無を確認し、セグメント情報が存在していれば、直前のセグメントと変数のセグメントを比較する。コード生成部13は、比較した両者(セグメントレジスタの値と変数のセグメント番号)が同じであれば、セグメントレジスタを設定するオブジェクトコードを生成しない。図6では、セグメント情報3において変数a,b,cのセグメント番号が同じであったために、コード生成部13は、変数bと変数cをアクセスする際に、セグメントレジスタに値を設定するオブジェクトコードを出力していない。
[The second and subsequent compilations]
The compiler 10 performs the second and subsequent compilations using the segment information 3. The segment information setting unit 12 reads the segment information and has the variable segment number as information inside the compiler 10. When generating a code for accessing far data, the code generation unit 13 compares the value of the segment register with the segment number of the variable. Here, as in the first compilation, the code generation unit 13 determines whether the data is far data. In the case of far data, the code generation unit 13 checks the presence or absence of the segment information by attempting to refer to the segment information. If the information exists, the previous segment is compared with the variable segment. If the compared two values (segment register value and variable segment number) are the same, the code generation unit 13 does not generate an object code for setting the segment register. In FIG. 6, since the segment numbers of the variables a, b, and c in the segment information 3 are the same, the code generation unit 13 sets an object code that sets a value in the segment register when accessing the variables b and c. Is not output.

なお、ここでは、同一の計算機上で1回目のコンパイルと2回目以降のコンパイルを実施する事例を想定して説明しているが、実際には、この例に限定されない。例えば、同じソースプログラムファイルを複数の計算機上でコンパイルする場合について、最初の1台目でのコンパイルを、1回目のコンパイルとみなし、このときにリンカが生成したセグメント情報を複数の計算機で共有するようにすれば、他の計算機でのコンパイルを、2回目以降のコンパイルとみなすことができる。複数の計算機上で複数回コンパイルする場合についても、最初の1台目での1回目のコンパイル以外は、全て2回目以降のコンパイルとみなすことができる。   Note that, here, a case where the first compile and the second and subsequent compiles are performed on the same computer has been described, but the present invention is not limited to this example. For example, when compiling the same source program file on a plurality of computers, the first compilation is regarded as the first compilation, and the segment information generated by the linker at this time is shared by the plurality of computers. By doing so, compilation on another computer can be regarded as the second and subsequent compilations. When compiling multiple times on a plurality of computers, all can be regarded as the second and subsequent compilations other than the first compilation on the first computer.

farデータにアクセスする際に、セグメントレジスタの値とこれからセグメントレジスタに設定しようとするセグメント番号が同じであるなら、セグメントレジスタを設定するコードを生成する必要はない。しかし、従来の技術では、コンパイル時に変数のメモリ配置が確定しないため、「セグメントレジスタの値とこれからセグメントレジスタに設定しようとするセグメント番号が同じであるかどうか」が判断できない。そのため、セグメントレジスタの設定コードが不要な場合でも、設定コードを出力していた。   When accessing the far data, if the value of the segment register is the same as the segment number to be set in the segment register, there is no need to generate a code for setting the segment register. However, in the conventional technique, since the memory arrangement of variables is not fixed at the time of compilation, it cannot be determined whether “the value of the segment register and the segment number to be set in the segment register are the same”. Therefore, even when the segment register setting code is unnecessary, the setting code is output.

本発明では、リンカが生成するセグメント情報を利用して再度コンパイルすることで、変数のセグメント番号が分かるため、必要のないセグメントレジスタ設定コードを削減できる。   In the present invention, since the segment number of the variable is known by recompiling using the segment information generated by the linker, unnecessary segment register setting codes can be reduced.

具体的には、1回目のコンパイルで従来のコンパイラと同様にオブジェクトコードを生成する。この場合は、セグメントレジスタに値を設定するコードを生成する。このコードを受け取ったリンカが「変数がどのセグメント番号に割り当たるか」という情報を出力し、その情報を利用して再度コンパイルする。この情報の集合体を「セグメント情報」と呼ぶ。2回目以降のコンパイル時には、セグメント情報から変数のセグメント番号が分かっているので、セグメントレジスタの書き換えが必要かどうか分かる。セグメントレジスタの書き換えが不要だと分かればセグメントレジスタの設定コードを削減することができる。   Specifically, the object code is generated in the first compilation in the same manner as in the conventional compiler. In this case, a code for setting a value in the segment register is generated. The linker that receives this code outputs the information “to which segment number the variable is assigned”, and recompiles using that information. This collection of information is called “segment information”. At the time of the second and subsequent compilations, since the segment number of the variable is known from the segment information, it can be determined whether the segment register needs to be rewritten. If it is known that rewriting of the segment register is unnecessary, the setting code of the segment register can be reduced.

以上、本発明の実施形態を詳述してきたが、実際には、上記の実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の変更があっても本発明に含まれる。   As mentioned above, although embodiment of this invention was explained in full detail, actually, it is not restricted to said embodiment, Even if there is a change of the range which does not deviate from the summary of this invention, it is included in this invention.

1… ソースプログラムファイル
2… ロードモジュールファイル
3… セグメント情報
10… コンパイラ(compiler)
11… 構文解析部
12… セグメント情報設定部
13… コード生成部
14… オブジェクト出力部
20… リンカ(linker)
1 ... Source program file 2 ... Load module file 3 ... Segment information 10 ... Compiler
DESCRIPTION OF SYMBOLS 11 ... Syntax analysis part 12 ... Segment information setting part 13 ... Code generation part 14 ... Object output part 20 ... Linker (linker)

Claims (15)

ソースプログラムファイルを読み込み、前記ソースプログラムファイルに基づいて、オブジェクトコードを生成するコンパイラと、
前記オブジェクトコードを読み込み、前記オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成するリンカと
を含み、
前記コンパイラは、
前記セグメント情報を読み込むセグメント情報設定部と、
前記セグメント情報が存在しない場合、セグメントレジスタに値を設定するオブジェクトコードを生成するコード生成部と
を具備する
言語処理システム。
A compiler that reads a source program file and generates object code based on the source program file;
The object code is read, and based on the object code, a load module file in which the memory allocation of functions and variables is determined and segment information that is a collection of information indicating which segment number the variable is assigned to are generated. Including the linker,
The compiler
A segment information setting unit for reading the segment information;
A language processing system comprising: a code generation unit that generates an object code for setting a value in a segment register when the segment information does not exist.
請求項1に記載の言語処理システムであって、
前記セグメント情報は、
変数のシンボル情報と、
所定のサイズのアドレス空間に収まるnearデータか、前記所定のサイズのアドレス空間に収まらないfarデータかを示す情報と、
farデータであればセグメント番号と
を有する
言語処理システム。
The language processing system according to claim 1,
The segment information is
Variable symbol information,
Information indicating whether the near data fits in an address space of a predetermined size or far data that does not fit in the address space of the predetermined size;
A language processing system having a segment number if it is far data.
請求項2に記載の言語処理システムであって、
前記コード生成部は、データアクセスの際にfarデータかどうかを判定し、farデータである場合、前記セグメントレジスタの値が変更されたか否か判定し、前記セグメントレジスタの値が変更された場合、もしくは前記セグメント情報が存在せず判定不能の場合、セグメント番号を前記セグメントレジスタに設定してからオブジェクトコードを生成する
言語処理システム。
The language processing system according to claim 2,
The code generation unit determines whether it is far data at the time of data access, and if it is far data, determines whether the value of the segment register is changed, and if the value of the segment register is changed, Alternatively, when the segment information does not exist and cannot be determined, a language processing system that generates an object code after setting a segment number in the segment register.
請求項2に記載の言語処理システムであって、
前記コード生成部は、データアクセスの際にfarデータかどうかを判定し、farデータではない場合、もしくはfarデータであっても、前記セグメントレジスタの値が変更されたか否か判定した際に、前記セグメントレジスタの値が変更されていない場合、セグメント番号を前記セグメントレジスタに設定するオブジェクトコードを不要とする
言語処理システム。
The language processing system according to claim 2,
The code generation unit determines whether it is far data at the time of data access, and when it is not far data, or when it is far data, when it is determined whether the value of the segment register has been changed, A language processing system that eliminates the need for an object code for setting a segment number in the segment register when the value of the segment register is not changed.
請求項2乃至4のいずれか一項に記載の言語処理システムであって、
前記コンパイラによる1回目のコンパイルの際、前記コード生成部は、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在しない場合、判定不能として前記セグメントレジスタに値を設定するオブジェクトコードを生成し、
前記リンカは、前記コード生成部が生成したオブジェクトコードを基にメモリ配置を決定し、各変数のアドレスが確定した後、前記セグメント情報を生成し、
前記コンパイラによる2回目以降のコンパイルの際、前記セグメント情報設定部は、前記セグメント情報を読み込み、前記コンパイラ内部で変数のセグメント番号を情報として保持し、
前記コード生成部は、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在する場合、前記セグメントレジスタの値と変数のセグメント番号とを比較し、前記セグメントレジスタの値と変数のセグメント番号とが同じであれば、前記セグメントレジスタを設定するオブジェクトコードを生成せず、前記セグメントレジスタの値と変数のセグメント番号とが同じでなければ、前記セグメントレジスタを設定するオブジェクトコードを生成する
言語処理システム。
The language processing system according to any one of claims 2 to 4,
When compiling for the first time by the compiler, the code generation unit determines whether it is far data at the time of data access, and in the case of far data, tries to refer to the segment information, and when the segment information does not exist, Generate an object code that sets a value in the segment register as being undecidable,
The linker determines a memory arrangement based on the object code generated by the code generation unit, and after determining the address of each variable, generates the segment information,
When compiling for the second and subsequent times by the compiler, the segment information setting unit reads the segment information, holds the segment number of the variable as information inside the compiler,
The code generation unit determines whether or not the data is far data at the time of data access. If the data is far data, the code generation unit attempts to refer to the segment information. If the segment register value and the variable segment number are the same, the object code for setting the segment register is not generated and the segment register value and the variable segment number must be the same. For example, a language processing system for generating an object code for setting the segment register.
コンパイラにより、ソースプログラムファイルを読み込み、前記ソースプログラムファイルに基づいて、オブジェクトコードを生成することと、
リンカにより、前記オブジェクトコードを読み込み、前記オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成することと、
前記コンパイラにより、前記セグメント情報を読み込むことと、
前記セグメント情報が存在しない場合、前記コンパイラにより、セグメントレジスタに値を設定するオブジェクトコードを生成することと
を含む
言語処理方法。
Reading a source program file with a compiler and generating object code based on the source program file;
The object code is read by the linker, and the load module file in which the memory locations of the functions and variables are determined based on the object code, and segment information that is a collection of information indicating which segment number the variable is assigned to, Generating
Reading the segment information by the compiler;
A language processing method comprising: generating object code for setting a value in a segment register by the compiler when the segment information does not exist.
請求項6に記載の言語処理方法であって、
前記セグメント情報は、
変数のシンボル情報と、
所定のサイズのアドレス空間に収まるnearデータか、前記所定のサイズのアドレス空間に収まらないfarデータかを示す情報と、
farデータであればセグメント番号と
を有する
言語処理方法。
The language processing method according to claim 6,
The segment information is
Variable symbol information,
Information indicating whether the near data fits in an address space of a predetermined size or far data that does not fit in the address space of the predetermined size;
A language processing method having a segment number for far data.
請求項7に記載の言語処理方法であって、
前記コンパイラにより、データアクセスの際にfarデータかどうかを判定することと、
farデータである場合、前記セグメントレジスタの値が変更されたか否か判定することと、
前記セグメントレジスタの値が変更された場合、もしくは前記セグメント情報が存在せず判定不能の場合、セグメント番号を前記セグメントレジスタに設定してからオブジェクトコードを生成することと
を更に含む
言語処理方法。
The language processing method according to claim 7,
Determining whether it is far data at the time of data access by the compiler;
if it is far data, determining whether the value of the segment register has been changed;
A language processing method further comprising: generating an object code after setting a segment number in the segment register when the value of the segment register is changed or when the segment information does not exist and determination is impossible.
請求項7に記載の言語処理方法であって、
前記コンパイラにより、データアクセスの際にfarデータかどうかを判定することと、
farデータではない場合、もしくはfarデータであっても、前記セグメントレジスタの値が変更されたか否か判定した際に、前記セグメントレジスタの値が変更されていない場合、セグメント番号を前記セグメントレジスタに設定するオブジェクトコードを不要とすることと
を更に含む
言語処理方法。
The language processing method according to claim 7,
Determining whether it is far data at the time of data access by the compiler;
If it is not far data, or even if it is far data, when it is determined whether the value of the segment register has been changed, if the value of the segment register has not been changed, the segment number is set in the segment register A language processing method, further comprising eliminating the need for an object code to be executed.
請求項7乃至9のいずれか一項に記載の言語処理方法であって、
前記コンパイラによる1回目のコンパイルの際、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在しない場合、判定不能として前記セグメントレジスタに値を設定するオブジェクトコードを生成することと、
前記リンカにより、前記コンパイラが生成したオブジェクトコードを基にメモリ配置を決定し、各変数のアドレスが確定した後、前記セグメント情報を生成することと、
前記コンパイラによる2回目以降のコンパイルの際、前記セグメント情報を読み込み、前記コンパイラ内部で変数のセグメント番号を情報として保持することと、
前記コンパイラにより、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在する場合、前記セグメントレジスタの値と変数のセグメント番号とを比較し、前記セグメントレジスタの値と変数のセグメント番号とが同じであれば、前記セグメントレジスタを設定するオブジェクトコードを生成せず、前記セグメントレジスタの値と変数のセグメント番号とが同じでなければ、前記セグメントレジスタを設定するオブジェクトコードを生成することと
を更に含む
言語処理方法。
A language processing method according to any one of claims 7 to 9, wherein
When compiling for the first time by the compiler, it is determined whether or not the data is far data at the time of data access. If the data is far data, the segment information is tried to be referred to. Generating object code to set the value to
The linker determines the memory allocation based on the object code generated by the compiler, and after the address of each variable is determined, generates the segment information;
Reading the segment information at the time of the second and subsequent compilations by the compiler, and holding the segment number of the variable as information inside the compiler;
When the data is accessed, the compiler determines whether the data is far data. If the data is far data, the compiler tries to refer to the segment information. If the segment information exists, the value of the segment register and the segment number of the variable are obtained. In comparison, if the value of the segment register and the segment number of the variable are the same, the object code for setting the segment register is not generated, and if the value of the segment register and the segment number of the variable are not the same, Generating an object code for setting the segment register.
コンパイラとして、ソースプログラムファイルを読み込み、前記ソースプログラムファイルに基づいて、オブジェクトコードを生成するステップと、
リンカとして、前記オブジェクトコードを読み込み、前記オブジェクトコードに基づいて、関数及び変数のメモリ配置が確定したロードモジュールファイルと、変数がどのセグメント番号に割り当たるかを示す情報の集合体であるセグメント情報とを生成するステップと、
前記コンパイラとして、前記セグメント情報を読み込むステップと、
前記セグメント情報が存在しない場合、前記コンパイラとして、セグメントレジスタに値を設定するオブジェクトコードを生成するステップと
を計算機に実行させるための
言語処理用プログラム。
As a compiler, reading a source program file and generating object code based on the source program file;
As a linker, the object code is read, a load module file in which memory allocation of functions and variables is determined based on the object code, and segment information which is a collection of information indicating which segment number a variable is assigned to A step of generating
Reading the segment information as the compiler;
When the segment information does not exist, a language processing program for causing a computer to execute an object code for setting a value in a segment register as the compiler.
請求項11に記載の言語処理用プログラムであって、
前記セグメント情報は、
変数のシンボル情報と、
所定のサイズのアドレス空間に収まるnearデータか、前記所定のサイズのアドレス空間に収まらないfarデータかを示す情報と、
farデータであればセグメント番号と
を有する
言語処理用プログラム。
The language processing program according to claim 11,
The segment information is
Variable symbol information,
Information indicating whether the near data fits in an address space of a predetermined size or far data that does not fit in the address space of the predetermined size;
A language processing program having a segment number if it is far data.
請求項12に記載の言語処理用プログラムであって、
前記コンパイラとして、データアクセスの際にfarデータかどうかを判定するステップと、
farデータである場合、前記セグメントレジスタの値が変更されたか否か判定するステップと、
前記セグメントレジスタの値が変更された場合、もしくは前記セグメント情報が存在せず判定不能の場合、セグメント番号を前記セグメントレジスタに設定してからオブジェクトコードを生成するステップと
を更に計算機に実行させるための
言語処理用プログラム。
The language processing program according to claim 12,
As the compiler, determining whether it is far data at the time of data access;
if it is far data, determining whether the value of the segment register has been changed;
When the value of the segment register is changed, or when the segment information does not exist and cannot be determined, a segment number is set in the segment register and then an object code is generated and a computer is further executed. Language processing program.
請求項12に記載の言語処理用プログラムであって、
前記コンパイラとして、データアクセスの際にfarデータかどうかを判定するステップと、
farデータではない場合、もしくはfarデータであっても、前記セグメントレジスタの値が変更されたか否か判定した際に、前記セグメントレジスタの値が変更されていない場合、セグメント番号を前記セグメントレジスタに設定するオブジェクトコードを不要とするステップと
を更に計算機に実行させるための
言語処理用プログラム。
The language processing program according to claim 12,
As the compiler, determining whether it is far data at the time of data access;
If it is not far data, or even if it is far data, when it is determined whether the value of the segment register has been changed, if the value of the segment register has not been changed, the segment number is set in the segment register A language processing program for causing a computer to further execute a step that does not require an object code to be executed.
請求項12乃至14のいずれか一項に記載の言語処理用プログラムであって、
前記コンパイラとして実施する1回目のコンパイルの際、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在しない場合、判定不能として前記セグメントレジスタに値を設定するオブジェクトコードを生成するステップと、
前記リンカとして、前記コンパイラが生成したオブジェクトコードを基にメモリ配置を決定し、各変数のアドレスが確定した後、前記セグメント情報を生成するステップと、
前記コンパイラとして実施する2回目以降のコンパイルの際、前記セグメント情報を読み込み、前記コンパイラ内部で変数のセグメント番号を情報として保持するステップと、
前記コンパイラとして、データアクセスの際にfarデータかどうかを判定し、farデータの場合、前記セグメント情報の参照を試み、前記セグメント情報が存在する場合、前記セグメントレジスタの値と変数のセグメント番号とを比較し、前記セグメントレジスタの値と変数のセグメント番号とが同じであれば、前記セグメントレジスタを設定するオブジェクトコードを生成せず、前記セグメントレジスタの値と変数のセグメント番号とが同じでなければ、前記セグメントレジスタを設定するオブジェクトコードを生成するステップと
を更に計算機に実行させるための
言語処理用プログラム。
The language processing program according to any one of claims 12 to 14,
When compiling for the first time implemented as the compiler, it is determined whether or not it is far data at the time of data access. In the case of far data, an attempt is made to refer to the segment information, and if the segment information does not exist, the determination is impossible. Generating object code for setting a value in the segment register;
Determining the memory allocation based on the object code generated by the compiler as the linker, and generating the segment information after the address of each variable is determined;
Reading the segment information during the second and subsequent compilations performed as the compiler, and holding the segment number of the variable as information inside the compiler;
The compiler determines whether it is far data at the time of data access. If it is far data, it tries to refer to the segment information. If the segment information exists, the value of the segment register and the segment number of the variable are obtained. In comparison, if the value of the segment register and the segment number of the variable are the same, the object code for setting the segment register is not generated, and if the value of the segment register and the segment number of the variable are not the same, A language processing program for causing a computer to further execute an object code setting step for setting the segment register.
JP2009281554A 2009-12-11 2009-12-11 Language processing system, language processing method and language-processing program Pending JP2011123719A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009281554A JP2011123719A (en) 2009-12-11 2009-12-11 Language processing system, language processing method and language-processing program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009281554A JP2011123719A (en) 2009-12-11 2009-12-11 Language processing system, language processing method and language-processing program

Publications (1)

Publication Number Publication Date
JP2011123719A true JP2011123719A (en) 2011-06-23

Family

ID=44287540

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009281554A Pending JP2011123719A (en) 2009-12-11 2009-12-11 Language processing system, language processing method and language-processing program

Country Status (1)

Country Link
JP (1) JP2011123719A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102012203928A1 (en) 2011-06-01 2012-12-06 Mitsubishi Electric Corporation Method for producing a semiconductor device
CN113360142A (en) * 2021-06-24 2021-09-07 广东工贸职业技术学院 Design and compiling method for numerical control embedded PLC intermediate file
CN113656004A (en) * 2021-06-21 2021-11-16 广东赛昉科技有限公司 Code generation method and readable storage medium for automatically generating register configuration

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01310437A (en) * 1988-06-08 1989-12-14 Nec Corp Load module generation system
JPH07105014A (en) * 1993-10-04 1995-04-21 Nec Corp Symbol processing system for language processing system
JPH07121380A (en) * 1993-10-28 1995-05-12 Fujitsu Ltd Compiling device
JPH10124325A (en) * 1996-10-25 1998-05-15 Toshiba Corp Method for optimally allocating variables, apparatus for optimally allocating variables, and computer-readable recording medium storing program for optimally allocating variables
JPH10320211A (en) * 1997-05-15 1998-12-04 Fujitsu Ltd Compiler and recording medium recording the program
JP2000010764A (en) * 1998-06-17 2000-01-14 Nec Ic Microcomput Syst Ltd Method and system for language processing
JP2005301415A (en) * 2004-04-07 2005-10-27 Ricoh Co Ltd Compile method, simulator, emulator and program development support system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01310437A (en) * 1988-06-08 1989-12-14 Nec Corp Load module generation system
JPH07105014A (en) * 1993-10-04 1995-04-21 Nec Corp Symbol processing system for language processing system
JPH07121380A (en) * 1993-10-28 1995-05-12 Fujitsu Ltd Compiling device
JPH10124325A (en) * 1996-10-25 1998-05-15 Toshiba Corp Method for optimally allocating variables, apparatus for optimally allocating variables, and computer-readable recording medium storing program for optimally allocating variables
JPH10320211A (en) * 1997-05-15 1998-12-04 Fujitsu Ltd Compiler and recording medium recording the program
JP2000010764A (en) * 1998-06-17 2000-01-14 Nec Ic Microcomput Syst Ltd Method and system for language processing
JP2005301415A (en) * 2004-04-07 2005-10-27 Ricoh Co Ltd Compile method, simulator, emulator and program development support system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102012203928A1 (en) 2011-06-01 2012-12-06 Mitsubishi Electric Corporation Method for producing a semiconductor device
CN113656004A (en) * 2021-06-21 2021-11-16 广东赛昉科技有限公司 Code generation method and readable storage medium for automatically generating register configuration
CN113360142A (en) * 2021-06-24 2021-09-07 广东工贸职业技术学院 Design and compiling method for numerical control embedded PLC intermediate file

Similar Documents

Publication Publication Date Title
CN110162296B (en) Method and device for generating application programming interface document and terminal equipment
CN102232216B (en) Systems and methods for managing endian mode of a device
US9880820B2 (en) Programming language with extensions using dynamic keywords
US20210349703A1 (en) Configuration management through information and code injection at compile time
US8997040B2 (en) Variable closure
CN113391826B (en) Solution method for software package dependence in customized mirror image
CN112527316A (en) Code compiling method and device, electronic equipment and storage medium
US9460306B1 (en) System and method for controlling access of machine code to operating system resources
CN103164249A (en) Extension mechanism for scripting language compiler
CN113204385B (en) Plug-in loading method and device, computing equipment and readable storage medium
CN111324396A (en) A block chain smart contract execution method, device and equipment
CN115328493B (en) Compiling method for vector instruction with mask, electronic device and medium
CN112558984A (en) Code compiling method and device, electronic equipment and server
CN113703779A (en) Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
US20090106744A1 (en) Compiling and translating method and apparatus
CN114879978A (en) Software package dependency processing method, computing device and readable storage medium
US20130275688A1 (en) Data processing device and method
CN116360788A (en) Compiling method, compiler and electronic device for structured text programming language
CN101311901A (en) Program re-writing apparatus
JP2011123719A (en) Language processing system, language processing method and language-processing program
CN117806607A (en) PLC program compilation method and device based on array mapped memory address
CN118626298A (en) A method and device for handling code exceptions
JP4768984B2 (en) Compiling method, compiling program, and compiling device
US9229698B2 (en) Method and apparatus for compiler processing for a function marked with multiple execution spaces
CN101782860B (en) Method and device for linking program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20120726

A977 Report on retrieval

Effective date: 20130416

Free format text: JAPANESE INTERMEDIATE CODE: A971007

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130513

A02 Decision of refusal

Effective date: 20130917

Free format text: JAPANESE INTERMEDIATE CODE: A02

A521 Written amendment

Effective date: 20131204

Free format text: JAPANESE INTERMEDIATE CODE: A523