JP4323393B2 - Processor - Google Patents

Processor Download PDF

Info

Publication number
JP4323393B2
JP4323393B2 JP2004210765A JP2004210765A JP4323393B2 JP 4323393 B2 JP4323393 B2 JP 4323393B2 JP 2004210765 A JP2004210765 A JP 2004210765A JP 2004210765 A JP2004210765 A JP 2004210765A JP 4323393 B2 JP4323393 B2 JP 4323393B2
Authority
JP
Japan
Prior art keywords
instruction
address
unit
bits
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP2004210765A
Other languages
Japanese (ja)
Other versions
JP2004288223A (en
Inventor
秀一 高山
一 小川
謙一 川口
信生 檜垣
謙介 小谷
哲也 田中
信哉 宮地
岳人 瓶子
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Corp
Panasonic Holdings Corp
Original Assignee
Panasonic Corp
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Panasonic Corp, Matsushita Electric Industrial Co Ltd filed Critical Panasonic Corp
Priority to JP2004210765A priority Critical patent/JP4323393B2/en
Publication of JP2004288223A publication Critical patent/JP2004288223A/en
Application granted granted Critical
Publication of JP4323393B2 publication Critical patent/JP4323393B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

本発明は、コンパイラ装置、最適化装置、アセンブラ装置、リンカ装置、デバッガ装置、及び逆アセンブラ装置に関し、読み出した命令の単位と無関係な単位で命令を実行するプロセッサを対象としたコンパイラ装置、最適化装置、アセンブラ装置、リンカ装置、デバッガ装置、及び逆アセンブラ装置に関する。   The present invention relates to a compiler device, an optimization device, an assembler device, a linker device, a debugger device, and a disassembler device, and relates to a compiler device for a processor that executes an instruction in a unit unrelated to a read instruction unit, and optimization The present invention relates to a device, an assembler device, a linker device, a debugger device, and a disassembler device.

一般に、プロセッサは、プログラムカウンタに基づき、命令をメモリから読み出し、実行する。図43は、プロセッサの基本構成の例を示すブロック図である。
命令メモリ4301は、プログラムを構成する命令列を記憶している。ここで、1命令は、8ビット長とし、4個の命令を1つの命令パケットとする。
プログラムカウンタ4300は、命令メモリ4301内での命令パケットのアドレスを指定する。
Generally, a processor reads an instruction from a memory and executes it based on a program counter. FIG. 43 is a block diagram illustrating an example of a basic configuration of a processor.
The instruction memory 4301 stores an instruction sequence constituting a program. Here, one instruction is 8 bits long, and four instructions are one instruction packet.
The program counter 4300 designates the address of the instruction packet in the instruction memory 4301.

命令読み出し部4302は、プログラムカウンタ4300により指定される命令パケットを命令メモリ4301から読み込む。
命令実行部4303は、読み出された命令パケットに含まれる4つの命令のすべてを1サイクル内で実行する。
このように、一般にプロセッサは、1つのプログラムカウンタによって指定される命令パケットを読み込み、読み出した4個の命令を1サイクルで実行することができる。
The instruction reading unit 4302 reads an instruction packet designated by the program counter 4300 from the instruction memory 4301.
The instruction execution unit 4303 executes all four instructions included in the read instruction packet within one cycle.
As described above, the processor generally reads an instruction packet designated by one program counter, and can execute the read four instructions in one cycle.

しかしながら、このようなプロセッサでは、読み込んだ命令パケット内のすべての命令を1サイクルの実行単位としているため、1つの命令パケット中に、I/Oやメモリ等のリソースが利用できない理由で実行できない命令が1つでもあると、そのリソースが利用できるようになるまで、その命令パケット内のすべての命令の実行が待たされることになる。その結果、このようなプロセッサは、命令の実行速度が遅い。   However, in such a processor, all instructions in the read instruction packet are used as one cycle of execution units, so instructions that cannot be executed in one instruction packet because resources such as I / O and memory cannot be used. If there is even one, the execution of all instructions in the instruction packet is waited until the resource becomes available. As a result, such a processor has a low instruction execution speed.

そこで、本発明はかかる問題点に鑑み、命令の読み出しと命令の実行の単位が異なるプログラムを実行できるプロセッサ及びそのようなプログラムを作成できるプログラム開発環境を提供することを目的とする。   In view of the above problems, an object of the present invention is to provide a processor capable of executing a program having different units for instruction reading and instruction execution, and a program development environment capable of creating such a program.

上記目的を達成するために、本発明は、メモリから命令を読み出すプロセッサにおいて、 メモリから自然数のバイト単位からなる少なくとも1つのメモリの1単位データを読み出し、前記メモリの1単位データは1つのオペレーションを示すプロセッサの1単位命令を含み、各メモリの1単位データはプロセッサによって実行されるものであり、前記1つのオペレーションを示すプロセッサの1単位命令のメモリの1単位データに含まれる数は、2のべき乗を除く自然数であり、第1のプログラムカウンタは、前記メモリの1単位データのメモリにおける格納位置を示し、第2のプログラムカウンタは、前記メモリの1単位データに含まれる1つのオペレーションを示すプロセッサの1単位命令の格納数で一巡し、前記メモリの1単位データにおける前記1つのオペレーションを示すプロセッサの1単位命令の格納位置を示し、前記第2のプログラムカウンタが格納位置を一巡した後、第1のプログラムカウンタは、前記メモリにおけるメモリの1単位データの次の格納位置を示すこととしている。   In order to achieve the above object, according to the present invention, in a processor for reading an instruction from a memory, one unit data of at least one memory consisting of a natural number of bytes is read from the memory, and the one unit data of the memory performs one operation. 1 unit instruction of the processor shown, 1 unit data of each memory is executed by the processor, and the number of 1 unit data in the memory of the 1 unit instruction of the processor showing one operation is 2 A processor that is a natural number excluding power, the first program counter indicates a storage position of one unit of data in the memory, and the second program counter indicates one operation included in the one unit of data in the memory 1 unit instruction stored in the memory, and 1 unit data in the memory 1 indicates the storage position of one unit instruction of the processor indicating the one operation in the memory, and after the second program counter makes a round of the storage position, the first program counter stores the next unit data of the memory in the memory. The storage position is indicated.

上述のような構成によって、桁上り方式によるアドレスの演算は、プログラムカウンタとPC相対値との上位ビットの演算と下位ビットの演算との間に連続性を備えたアドレス演算が可能となる。   With the configuration as described above, the address calculation based on the carry method can perform an address calculation with continuity between the upper bit calculation and the lower bit calculation of the program counter and the PC relative value.

以下、本発明の実施の形態について図面を用いて説明する。(第1の実施形態)
第1の実施形態は、命令の読み出しの単位と命令の実行の単位とが異なるプログラムを生成する最適化装置、アセンブラ装置、リンカ装置とそのプログラムを実行するプロセッサに関する。(プロセッサが実行する命令のフォーマット)
まず、本実施の形態に係るプロセッサが実行する命令のフォーマットについて説明する。
Hereinafter, embodiments of the present invention will be described with reference to the drawings. (First embodiment)
The first embodiment relates to an optimizing device, an assembler device, a linker device, and a processor that executes the program, which generate a program in which the instruction reading unit and the instruction execution unit are different. (Format of instructions executed by the processor)
First, the format of instructions executed by the processor according to the present embodiment will be described.

図1(a)〜図1(e)は本実施の形態のプロセッサが実行する命令のフォーマットを示す図である。プロセッサが実行する命令は21ビットを1単位(1ユニット)として構成される。命令には、1つのユニットで構成される21ビット命令(1ユニット命令)と2つのユニットで構成される42ビット命令(2ユニット命令)の2種類の命令が存在する。(以下、「命令」とは、21ビット命令又は42ビット命令のいずれかを指す)。   FIG. 1A to FIG. 1E are diagrams showing the format of instructions executed by the processor of the present embodiment. The instruction executed by the processor is composed of 21 bits as one unit (one unit). There are two types of instructions: a 21-bit instruction (one unit instruction) composed of one unit and a 42-bit instruction (two unit instructions) composed of two units. (Hereinafter, “instruction” refers to either a 21-bit instruction or a 42-bit instruction).

1ビットのフォーマット情報101は、その命令がいずれの長さの命令であるかを示す。具体的には、フォーマット情報101が“0”の時には、そのフォーマット情報101が含まれるユニットで1つの命令、すなわち、21ビット命令を構成する。フォーマット情報101が“1”の時には、そのフォーマット情報101が含まれるユニットと後続するユニットで1つの命令、すなわち、42ビット命令を構成する。   The 1-bit format information 101 indicates which length the instruction is. Specifically, when the format information 101 is “0”, a unit including the format information 101 forms one instruction, that is, a 21-bit instruction. When the format information 101 is “1”, a unit including the format information 101 and a subsequent unit constitute one instruction, that is, a 42-bit instruction.

1ビットの並列実行境界情報100は、その命令とそれに後続する命令との間に並列実行の境界が存在するか否かを示す。具体的には、並列実行境界情報100が“1”の時には、その並列実行境界情報100が含まれる命令と後続命令の間に並列実行の境界が存在し、これらの命令は異なるサイクルにおいて実行される。並列実行境界情報100が“0”の時には、並列実行境界情報100が含まれる命令と後続命令の間に並列実行の境界が存在せず、これらの命令は同一のサイクルにおいて実行される。   The 1-bit parallel execution boundary information 100 indicates whether or not a parallel execution boundary exists between the instruction and the subsequent instruction. Specifically, when the parallel execution boundary information 100 is “1”, a parallel execution boundary exists between an instruction including the parallel execution boundary information 100 and a subsequent instruction, and these instructions are executed in different cycles. The When the parallel execution boundary information 100 is “0”, there is no parallel execution boundary between the instruction including the parallel execution boundary information 100 and the subsequent instruction, and these instructions are executed in the same cycle.

フォーマット情報101と並列実行境界情報100以外の部分は、オペレーションを示す。すなわち、21ビット命令では19ビットの長さで、42ビット命令では40ビットの長さでオペレーションが指定される。具体的には、“Op1”、“Op2”、“Op3”、“Op4”のフィールドは、オペレーションの種類を表すオペコードを、“Rs”のフィールドは、ソースオペランドとなるレジスタのレジスタ番号を、“Rd”のフィールドは、デスティネーションオペランドとなるレジスタのレジスタ番号を示す。また、“imm5”及び“imm32”のフィールドは、それぞれ5ビットと32ビットの演算用定数オペランドを示す。そして、“disp13”及び“disp32”のフィールドは、それぞれ13ビットと32ビットの偏位(ディスプレースメント)を示す。   Portions other than the format information 101 and the parallel execution boundary information 100 indicate operations. That is, an operation is specified with a length of 19 bits for a 21-bit instruction and a length of 40 bits for a 42-bit instruction. Specifically, the “Op1”, “Op2”, “Op3”, and “Op4” fields are the opcodes indicating the type of operation, the “Rs” field is the register number of the register that is the source operand, The field “Rd” indicates the register number of the register serving as the destination operand. The fields “imm5” and “imm32” indicate 5-bit and 32-bit arithmetic constant operands, respectively. The fields “disp13” and “disp32” indicate 13-bit and 32-bit displacements, respectively.

32ビットの定数などの長い定数を扱う転送命令や演算命令、大きなディスプレースメントを指定する分岐命令は42ビット命令で定義され、それらを除くほとんどの命令は21ビット命令で定義される。42ビット命令の構成要素である2つのユニットのうち、後ろのユニットには、長い定数やディスプレースメントの一部のみが配置され、オペコードは配置されない。(プロセッサの命令の読み出しと実行の動作)
次に、本実施の形態のプロセッサによる命令の読み出しと実行の動作について説明する。本実施の形態のプロセッサは、静的な並列スケジューリングを前提としたプロセッサである。図2(a)は、命令の格納、及び読み出し単位である命令パケットを示す図である。命令パケットは、3個のユニット(63ビット)とダミーデータ(1ビット)で構成される。プロセッサは、1サイクルにおいて、64ビットの固定長(以下、「パケット」と呼ぶ)で命令を読み出す。つまり、1つの命令は21ビット単位であり、メモリからの読み出しに不便であるので、命令を複数個組み合わせたバイト単位の命令パケットを読み出しの単位としている。また、この例のように、命令パケット内のユニットの個数が2の巾乗数でない場合に、特に効果がある。後述するように、命令パケット内のユニットの位置を通常の2進数で表すと都合が悪いからである。以下、1パケットを構成する3個のユニットを、アドレス値の小さい方から順に第1ユニット、第2ユニット、第3ユニットと呼ぶことにする。
Transfer instructions and arithmetic instructions that handle long constants such as 32-bit constants, and branch instructions that specify large displacements are defined as 42-bit instructions, and most other instructions are defined as 21-bit instructions. Of the two units that are components of the 42-bit instruction, only a part of the long constant or displacement is arranged in the rear unit, and no opcode is arranged. (Processing to read and execute processor instructions)
Next, instruction read and execution operations by the processor of the present embodiment will be described. The processor of the present embodiment is a processor based on static parallel scheduling. FIG. 2A is a diagram illustrating an instruction packet which is a unit for storing and reading instructions. The instruction packet is composed of three units (63 bits) and dummy data (1 bit). The processor reads an instruction with a fixed length of 64 bits (hereinafter referred to as “packet”) in one cycle. That is, since one instruction is in units of 21 bits and is inconvenient for reading from the memory, an instruction packet in units of bytes in which a plurality of instructions are combined is used as a reading unit. In addition, this example is particularly effective when the number of units in the instruction packet is not a power of 2 as in this example. This is because, as will be described later, it is not convenient to represent the position of the unit in the instruction packet in a normal binary number. Hereinafter, the three units constituting one packet are referred to as a first unit, a second unit, and a third unit in order from the smallest address value.

図2(b)は、命令の読み出しの順序を示す図である。図に示すように、命令の読み出しは、各サイクル、1パケットである。
図2(c)は、命令の実行の順序を示す図である。図に示すように、1サイクルで実行する命令の単位は、並列実行の境界までである。つまり、各サイクルにおいて並列実行境界情報100が“1”である命令までの命令を並列実行する。読みだされながら実行されなかったユニットは、命令バッファに蓄積され、次のサイクル以降で実行される。
FIG. 2B is a diagram showing the order of reading instructions. As shown in the figure, the instruction is read in one cycle and one packet.
FIG. 2C is a diagram showing the order of instruction execution. As shown in the figure, the unit of instructions executed in one cycle is up to the boundary of parallel execution. That is, instructions up to the instruction whose parallel execution boundary information 100 is “1” are executed in parallel in each cycle. Units that have been read but not executed are stored in the instruction buffer and executed after the next cycle.

以上のように、本実施の形態のプロセッサは、固定長のパケット単位で命令を読み出し、各サイクルにおいて並列度に応じた適切な数のユニットを実行するものである。このように、本実施の形態のプロセッサは、命令パケット内の先頭の命令以外の命令でも、1サイクルの実行開始位置にすることができるのは、後述するように命令パケット内の命令の位置を指定する“パケット内アドレス”(下位PC)によるものである。   As described above, the processor according to the present embodiment reads instructions in units of fixed-length packets and executes an appropriate number of units according to the degree of parallelism in each cycle. As described above, the processor of the present embodiment can set the execution start position of one cycle even for an instruction other than the first instruction in the instruction packet by changing the position of the instruction in the instruction packet as described later. This is based on the designated “intra-packet address” (lower PC).

また、本実施の形態のプロセッサは、バイトアラインされていない命令、すなわち、語長がバイト単位でない命令を実行するのに、特に適しているという特徴をもつ。つまり、バイト単位の長さをもたない命令であっても、バイト単位の長さをもつ命令パケットの単位でプロセッサ内に読み込めば、命令パケット内でのその命令はパケット内アドレスによって指定できるからである。   The processor of the present embodiment has a feature that it is particularly suitable for executing an instruction that is not byte-aligned, that is, an instruction whose word length is not in units of bytes. In other words, even if an instruction does not have a length in bytes, if it is read into the processor in the unit of an instruction packet having a length in bytes, the instruction in the instruction packet can be specified by the address in the packet. It is.

図3は、一般のプロセッサで、バイトアラインされていない命令を実行する場合の命令の格納、読み出し方法の例を示す。命令が21ビットとバイトアラインされていない場合には、その命令をバイト単位で読み出しできるようにするため、その命令に3ビットの未使用領域を付加して、24ビット長とする。すなわち、本来21ビット長である1つの命令が24ビットを単位としてメモリに格納され、読み出しがなされる。この場合では、3つの命令の長さは72ビット長となるのに対して、本実施の形態では、3つの命令の長さは64ビット長であり、プログラムサイズを小さく抑えることができる。   FIG. 3 shows an example of a method for storing and reading instructions when executing a non-byte-aligned instruction in a general processor. If the instruction is not byte-aligned with 21 bits, a 3-bit unused area is added to the instruction so that the instruction can be read in byte units to have a 24-bit length. That is, one instruction that is originally 21 bits long is stored in the memory in units of 24 bits and is read out. In this case, the length of the three instructions is 72 bits, whereas in the present embodiment, the length of the three instructions is 64 bits, and the program size can be kept small.

なお、本実施の形態では、命令の語長が21ビット単位である場合のパケットの構成について説明しているが、これに限定するものでなく、その他の語長をもつ命令に対しても、パケットを構成して、パケット単位で命令を読み出すことができる。例えば、命令の語長がnビット単位である場合には、(n×m+r)mod8=0であって、n×m/(n×m+r)を最大にするようなmとrの組合わせを選択し、1パケットをnビットの命令単位がm個とrビットのダミーデータで構成することとしてもよい。これによって、ダミーデータの比率が小さな、バイト単位の長さをもつ命令パケットを構成することができる。(命令のアドレスの表現方法)
次に、本実施の形態における命令のアドレスの表現方法について説明する。命令のアドレスは、ユニットの位置を特定するアドレスを意味し、32ビットで表現される。
In this embodiment, the configuration of the packet when the word length of the instruction is in units of 21 bits is described. However, the present invention is not limited to this, and for instructions having other word lengths, A packet can be configured and instructions can be read out in packet units. For example, if the word length of the instruction is in n-bit units, (n × m + r) mod 8 = 0, and a combination of m and r that maximizes n × m / (n × m + r) is used. One packet may be composed of m pieces of n-bit instruction units and r-bit dummy data. As a result, an instruction packet having a byte unit length with a small dummy data ratio can be configured. (Expression method of instruction address)
Next, a method for expressing an instruction address in the present embodiment will be described. The instruction address means an address for specifying the position of the unit, and is expressed by 32 bits.

32ビット中の上位29ビットは、命令パケットを特定し、「パケットアドレス」と呼ぶ。「パケットアドレス」は、16進数29ビットの29’h01234567等で表記することとする。この「パケットアドレス」の値を左へ3ビット分ビットシフトした値は、命令パケットが格納されているメモリアドレスとなる。
32ビット中の下位3ビットは、命令パケットに含まれるユニットを特定し、「パケット内アドレス」と呼ぶ。「パケット内アドレス」は、2進数3ビットの3’b001等で表記することとする。パケット内アドレス3’b000は、パケット内の第1ユニットを示し、3’b010パケット内の第2ユニットを示し、3’b100パケット内の第3ユニットを示す。パケット内アドレスは、これに限定するものでない。3個の数値で、3個のユニットを示すこととすれば、他の数値で表現してもよい。
The upper 29 bits of the 32 bits specify an instruction packet and are called a “packet address”. The “packet address” is expressed in 29'h01234567 of hexadecimal 29 bits. A value obtained by shifting the value of the “packet address” to the left by 3 bits is a memory address where the instruction packet is stored.
The lower 3 bits of the 32 bits specify a unit included in the instruction packet and are referred to as “intra-packet address”. The “intra-packet address” is expressed in 3′b001 of binary 3 bits. The in-packet address 3′b000 indicates the first unit in the packet, indicates the second unit in the 3′b010 packet, and indicates the third unit in the 3′b100 packet. The in-packet address is not limited to this. If three units are represented by three numerical values, they may be expressed by other numerical values.

また、本実施の形態における命令のアドレスの指定は、1つの命令パケット8バイト分に対して3ビットを割り当てている。従って、本実施の形態における命令のアドレスの指定方法と、一般のプロセッサにおける1バイトごとに1つずつアドレスを割り当てるアドレスの指定方法とでは、上位29ビットで指定されるアドレスは、同一のメモリアドレスを示すことになる。(プロセッサが実行するオブジェクトコードの作成方法)
本実施の形態に係るプロセッサが実行するオブジェクトコードの作成方法について説明する。
In addition, in the designation of the instruction address in this embodiment, 3 bits are assigned to one instruction packet of 8 bytes. Therefore, in the method for specifying an instruction address in the present embodiment and the method for specifying an address for assigning one address for each byte in a general processor, the addresses specified by the upper 29 bits are the same memory address. Will be shown. (How to create object code to be executed by the processor)
A method for creating an object code executed by the processor according to the present embodiment will be described.

まず、本実施の形態において用いるいくつかの用語について説明する。
「PC相対値」とは、2つの命令のアドレスの差分値である。
「ラベル」は、プログラムに含まれるもので、条件分岐や、無条件分岐や、サブルーチンへの分岐や、サブルーチンからのリターンなどの分岐命令の行き先(分岐先)を示すものである。
First, some terms used in this embodiment will be described.
“PC relative value” is a difference value between the addresses of two instructions.
The “label” is included in the program and indicates the destination (branch destination) of a branch instruction such as a conditional branch, an unconditional branch, a branch to a subroutine, or a return from a subroutine.

「ラベル」には、「命令のアドレスに解決すべきラベル」と、「PC相対値に解決すべきラベル」がある。「命令のアドレスに解決すべきラベル」は、プログラムがオブジェクトコードに変換される過程で、命令の絶対アドレスにより置き換えられるもので、例えば、メモリからレジスタr1への命令の転送命令「movL2、r1」中のラベルL2が該当する。「PC相対値に解決すべきラベル」は、プログラムがオブジェクトコードに変換される過程で、PC相対値に置き換えられるもので、例えば、PC相対値への無条件分岐命令「braL1」中のラベルL1が該当する。また、別の分類として、ラベルには、「局所ラベル」と「外部ラベル」がある。すなわち、ラベルとラベルを含む命令が同一のモジュール、すなわち、1つの処理機能をもったひとまとまりのサブプログラムに含まれる場合には、そのラベルを「局所ラベル」と呼び、ラベルとラベルを含む命令が、別個のモジュールに含まれる場合には、そのラベルを「外部ラベル」と呼ぶ。   “Label” includes “label to be resolved to an instruction address” and “label to be resolved to a PC relative value”. The “label to be resolved to the address of the instruction” is replaced by the absolute address of the instruction in the process of converting the program into the object code. For example, the instruction “movL2, r1” for transferring the instruction from the memory to the register r1 The inside label L2 corresponds. The “label to be resolved to the PC relative value” is replaced with the PC relative value in the process of converting the program into the object code. For example, the label L1 in the unconditional branch instruction “braL1” to the PC relative value is used. Is applicable. As another classification, labels include “local labels” and “external labels”. That is, when a label and an instruction including the label are included in the same module, that is, a group of subprograms having one processing function, the label is referred to as a “local label” and the instruction including the label and the label is included. Is included in a separate module, the label is called an “external label”.

図4は、本実施の形態に係るプロセッサが実行するオブジェクトコードが、コンパイラ装置と、最適化装置と、アセンブラ装置と、リンカ装置により作成される過程を示す図である。ここでは、それぞれの機能の概略を説明する。
コンパイラ装置301は、C言語等の高級言語で書かれたソースコード300の内容を解析し、アセンブラコード302を出力する。
FIG. 4 is a diagram illustrating a process in which object code executed by the processor according to the present embodiment is created by a compiler device, an optimization device, an assembler device, and a linker device. Here, an outline of each function will be described.
The compiler device 301 analyzes the contents of the source code 300 written in a high-level language such as C language, and outputs an assembler code 302.

最適化装置303は、アセンブラコード302に仮アドレスを付与し、命令列を3ユニットごとに連結し、その結果である最適化コード304を出力する。その過程において、局所ラベルについては、それぞれPC相対値又は命令のアドレスを算出して、その値に基づき、命令が1ユニットで表されるか2ユニットで表されるかの命令の大きさが決められる。   The optimization device 303 assigns a temporary address to the assembler code 302, concatenates the instruction sequence every three units, and outputs an optimization code 304 as a result. In the process, for the local label, the PC relative value or the address of the instruction is calculated, and based on the value, the size of the instruction is determined as to whether the instruction is represented by one unit or two units. It is done.

アセンブラ装置305は、最適化コード304より再配置可能番地形式であるリロケータブルコード306を出力する。その過程において、局所ラベルであって、PC相対値に解決すべきラベルは、PC相対値に変換される。
リンカ装置307は、複数のモジュールを結合する。すなわち、複数のリロケータブルコード306を結合して、その結果であるオブジェクトコード308を出力する。その過程において、未解決なラベルは、PC相対値又は命令のアドレスに変換される。
The assembler device 305 outputs a relocatable code 306 which is a relocatable address format from the optimization code 304. In the process, a local label that is to be resolved to a PC relative value is converted into a PC relative value.
The linker device 307 combines a plurality of modules. That is, a plurality of relocatable codes 306 are combined, and the resulting object code 308 is output. In the process, unresolved labels are converted to PC relative values or instruction addresses.

プロセッサ309は、オブジェクトコード308を実行する。
以上のように、高級言語で記述されたプログラムが、コンパイラ装置301と、最適化装置303と、アセンブラ装置305と、リンカ装置307によって、プロセッサが実行可能な形式であるオブジェクトコードに変換される。プログラム中のラベルについては、オブジェクトコード生成過程のいずれかにおいて、PC相対値又は命令のアドレスに変換される。すなわち、局所ラベルであって、かつPC相対値に解決すべきラベルのアドレス解決は、アセンブラ装置305によって行われる。局所ラベルであって、かつ命令のアドレスに解決すべきラベルのアドレス解決、及び外部ラベルのアドレス解決は、リンカ装置307によって行われる。
The processor 309 executes the object code 308.
As described above, a program written in a high-level language is converted into an object code in a format that can be executed by a processor by the compiler device 301, the optimization device 303, the assembler device 305, and the linker device 307. The labels in the program are converted into PC relative values or instruction addresses in any of the object code generation processes. In other words, the assembler device 305 performs address resolution of a label that is a local label and should be resolved to a PC relative value. The linker unit 307 performs address resolution of a label that is a local label and should be resolved to an instruction address, and address resolution of an external label.

以下では、図3に示したプロセッサ309と、リンカ装置307と、アセンブラ装置305と、最適化装置303について、その構成及び動作の詳細を説明する。(プロセッサ)
図5は、プロセッサ309及び外部メモリの詳細を示すブロック図である。
プロセッサ309は、最大3命令を並列実行可能なプロセッサであり、演算器401a〜cと、汎用レジスタ402、上位PC403と、下位PC404と、上位PC演算器411と、下位PC演算器405と、INC412と、命令バッファ408と、プリフェッチ上位カウンタ410と、プリフェッチ下位カウンタ413と、命令デコーダ409a〜409cと、PC相対値セレクタ420と、即値セレクタ421と、オペランドデータバッファ423と、オペランドバッファ422により構成される。外部メモリは、データメモリ406、命令メモリ407より構成される。
Hereinafter, the configuration and operation details of the processor 309, the linker device 307, the assembler device 305, and the optimization device 303 illustrated in FIG. 3 will be described. (Processor)
FIG. 5 is a block diagram showing details of the processor 309 and the external memory.
The processor 309 is a processor capable of executing up to three instructions in parallel, and includes arithmetic units 401 a to 401 c, general-purpose registers 402, upper PC 403, lower PC 404, upper PC arithmetic unit 411, lower PC arithmetic unit 405, and INC 412. An instruction buffer 408, a prefetch upper counter 410, a prefetch lower counter 413, instruction decoders 409a to 409c, a PC relative value selector 420, an immediate value selector 421, an operand data buffer 423, and an operand buffer 422. The The external memory includes a data memory 406 and an instruction memory 407.

以下、上位PC403と下位PC404とを合わせてPCと称し、上位PC演算器411と下位PC演算器405とを合わせてPC演算器と称する。
第1演算器401aと、第2演算器401bと、第3演算器401cは、それぞれ1つの演算を実行する。これらの演算器は同時に実行可能である。
汎用レジスタ402は、データ、アドレス等を格納する。
Hereinafter, the upper PC 403 and the lower PC 404 are collectively referred to as a PC, and the upper PC calculator 411 and the lower PC calculator 405 are collectively referred to as a PC calculator.
The first computing unit 401a, the second computing unit 401b, and the third computing unit 401c each perform one computation. These computing units can be executed simultaneously.
The general-purpose register 402 stores data, addresses, and the like.

上位PC403は、次のサイクルで実行すべき命令群の先頭命令のアドレスの上位29ビット、すなわち、パケットアドレスを保持する。
下位PC404は、次のサイクルで実行すべき命令群の先頭命令のアドレスの下位3ビット、すなわち、パケット内アドレスを保持する。
命令メモリ407は、オブジェクトコード308で表された命令を記憶する。
The upper PC 403 holds the upper 29 bits of the address of the first instruction of the instruction group to be executed in the next cycle, that is, the packet address.
The lower PC 404 holds the lower 3 bits of the address of the first instruction of the instruction group to be executed in the next cycle, that is, the in-packet address.
The instruction memory 407 stores an instruction represented by the object code 308.

命令バッファ408は、命令メモリ407から読み出した命令を格納する。
第1命令デコーダ409aと、第2命令デコーダ409b、第3命令デコーダ409cは、命令を解読し、解読した命令が実行可能なら、他のプロセッサの構成要素を指示してその命令を実行させる。第1命令デコーダ409aには、命令バッファ408に格納されている先頭の命令が入力され、第2命令デコーダ409bには、その次の命令が入力され、第3命令デコーダ409cには、その次の命令が入力される。命令デコーダ409a〜409cは、ユニットの並列実行境界情報を調べて、そのサイクルにおいて実行可能な命令のみを実行させる。例えば、定数値を演算する命令の場合には、その定数値を即値セレクタ421を介して演算器401aに送って、演算を実行させる。分岐命令の場合には、PC相対値をPC相対値セレクタ420を介して上位PC演算器411及び下位PC演算器405に送って、PCを更新させる。そして、命令デコーダ409a〜409cは、実行されたユニット数を制御信号によりINC412に送りPCを更新させ、実行されたユニット数を制御信号により命令バッファ408に送り、命令バッファ408内の実行されたユニットを消去させる。
The instruction buffer 408 stores the instruction read from the instruction memory 407.
The first instruction decoder 409a, the second instruction decoder 409b, and the third instruction decoder 409c decode the instruction, and if the decoded instruction can be executed, instructs the other processor components to execute the instruction. The first instruction decoder 409a receives the first instruction stored in the instruction buffer 408, the second instruction decoder 409b receives the next instruction, and the third instruction decoder 409c receives the next instruction. An instruction is entered. The instruction decoders 409a to 409c check the parallel execution boundary information of the unit and execute only instructions that can be executed in the cycle. For example, in the case of an instruction for calculating a constant value, the constant value is sent to the calculator 401a via the immediate value selector 421 to execute the calculation. In the case of a branch instruction, the PC relative value is sent to the upper PC calculator 411 and the lower PC calculator 405 via the PC relative value selector 420 to update the PC. Then, the instruction decoders 409a to 409c send the executed unit number to the INC 412 by the control signal to update the PC, send the executed unit number to the instruction buffer 408 by the control signal, and execute the executed unit in the instruction buffer 408. To erase.

PC相対値セレクタ420は、命令デコーダ409a〜409cから出力されたPC相対値を上位PC演算器411及び下位PC演算器405へ出力する。
即値セレクタ421は、命令デコーダ409a〜409cから出力された即値を汎用レジスタ402又は演算器401a〜401cへ出力する
INC412は、命令デコーダ409a〜409cからの制御信号により、実行されたユニット数の情報を取得し、その分だけ上位PC403、下位PC404の値をインクリメントする。これによって、次のサイクルで実行すべき命令群の先頭の命令のパケットアドレスが上位PCに設定され、パケット内アドレスが下位PCに設定される。
The PC relative value selector 420 outputs the PC relative value output from the instruction decoders 409 a to 409 c to the upper PC calculator 411 and the lower PC calculator 405.
The immediate value selector 421 outputs the immediate value output from the instruction decoders 409a to 409c to the general-purpose register 402 or the arithmetic units 401a to 401c. Acquire and increment the values of the upper PC 403 and lower PC 404 accordingly. As a result, the packet address of the first instruction in the instruction group to be executed in the next cycle is set in the upper PC, and the in-packet address is set in the lower PC.

上位PC演算器411及び下位PC演算器405は、それぞれ上位PC403、下位PC404を更新する。命令デコーダ409a〜409cが分岐命令をデコードすると、当該分岐命令に含まれるPC相対値の上位29ビットが上位PC演算器411に送られ、PC相対値の下位3ビットが下位PC演算器405に送られる。下位PC演算器405は、現在の下位PC404の値と、PC相対値の下位3ビットの値とを加算又は減算し、その演算結果を更新値として下位PC404に送る。上位PC演算器411は、現在の上位PC403の値と、PC相対値の上位29ビットの値とを加算又は減算し、その演算結果を更新値として上位PC403に送る。なお、PC演算器の動作、すなわち演算方法については後述する。以上のようにして、分岐命令の実行にあたって、次に実行すべき分岐先命令のパケットアドレスが上位PC403に設定され、パケット内アドレスが下位PC404に設定される。また、上位PC演算器411及び下位PC演算器405は、PC相対値と汎用レジスタ402に格納されているアドレスとの演算により、PCを更新する場合もある。   The upper PC calculator 411 and the lower PC calculator 405 update the upper PC 403 and the lower PC 404, respectively. When the instruction decoders 409a to 409c decode the branch instruction, the upper 29 bits of the PC relative value included in the branch instruction are sent to the upper PC computing unit 411, and the lower 3 bits of the PC relative value are sent to the lower PC computing unit 405. It is done. The lower PC calculator 405 adds or subtracts the current value of the lower PC 404 and the lower 3 bits of the PC relative value, and sends the calculation result to the lower PC 404 as an update value. The upper PC calculator 411 adds or subtracts the current value of the upper PC 403 and the upper 29 bits of the PC relative value, and sends the calculation result to the upper PC 403 as an update value. The operation of the PC calculator, that is, the calculation method will be described later. As described above, when executing a branch instruction, the packet address of the branch destination instruction to be executed next is set in the upper PC 403 and the in-packet address is set in the lower PC 404. Further, the upper PC calculator 411 and the lower PC calculator 405 may update the PC by calculating the PC relative value and the address stored in the general-purpose register 402.

プリフェッチ上位カウンタ410は、命令メモリ407から読み出す命令群の先頭命令のアドレスの上位29ビット、すなわちパケットアドレスを示す。プリフェッチ上位カウンタ410は、通常、1サイクルごとに1つずつその値をインクリメントする。また、1つ前のサイクルで実行された命令が分岐命令である場合には、上述のようにして上位PC403に設定された分岐先の命令のパケットアドレスが上位PC403からプリフェッチ上位カウンタ410に送られ、プリフェッチ上位カウンタ410の値は上位PC403と同一の値に設定される。   The prefetch upper counter 410 indicates the upper 29 bits of the address of the first instruction of the instruction group read from the instruction memory 407, that is, the packet address. The prefetch upper counter 410 normally increments its value by one for each cycle. If the instruction executed in the previous cycle is a branch instruction, the packet address of the branch destination instruction set in the upper PC 403 as described above is sent from the upper PC 403 to the prefetch upper counter 410. The value of the prefetch upper counter 410 is set to the same value as the upper PC 403.

プリフェッチ下位カウンタ413は、命令メモリ407から読み出す命令群の先頭命令のアドレスの下位3ビット、すなわちパケット内アドレスを指定する。本実施の形態では、プリフェッチ下位カウンタ413は、3’b000に設定するものとする。従って、読み出される命令は命令パケット単位で指定されることになり、1サイクルごとに1パケットが命令メモリ407から命令バッファ408に送られる。   The prefetch lower counter 413 designates the lower 3 bits of the address of the first instruction of the instruction group read from the instruction memory 407, that is, the address within the packet. In the present embodiment, the prefetch lower counter 413 is set to 3'b000. Therefore, the instruction to be read is specified in units of instruction packets, and one packet is sent from the instruction memory 407 to the instruction buffer 408 every cycle.

データメモリ406は、オペランドデータを格納する。
オペランドデータバッファ423及びオペランドアドレスバッファ422は、データメモリとプロセッサとの間のバッファである。
次に、本実施の形態において最も特徴的である、命令のアドレスのインクリメント方法及び演算方法について説明する。(命令のアドレスのインクリメント方法)
本実施の形態における命令のアドレスのインクリメント方法について説明する。命令のアドレスのインクリメントは、命令のパケット内アドレスにインクリメント値を加算し、桁上がりがある場合には、その桁上がり数をパケットアドレスに加えることとする。
The data memory 406 stores operand data.
The operand data buffer 423 and the operand address buffer 422 are buffers between the data memory and the processor.
Next, an instruction address increment method and calculation method, which is the most characteristic feature of this embodiment, will be described. (Increment method of instruction address)
A method for incrementing the address of an instruction in this embodiment will be described. The instruction address is incremented by adding an increment value to the address in the packet of the instruction, and if there is a carry, the carry number is added to the packet address.

図6は、パケット内アドレスのインクリメントの規則を示すインクリメント表である。図に示すように、命令のアドレスのインクリメントは、パケット内アドレスが3’b000、又は3’b010の場合には、下位3ビットの値に2を加算する。パケット内アドレスが3’b100の場合には、パケットアドレスに桁上がりを発生させて(すなわち上位29ビットの値に1を加算)、下位3ビットの値を3’b000とする。つまり、パケット内アドレスのインクリメントは3’b000,3’b010,3’b100を巡回する3進演算である。例えば、インクリメント値が2で、インクリメント前のパケット内アドレスの値が3’b100であったとすると、インクリメント後のパケット内アドレスは3’b010となり、パケットアドレスに桁上がりが1発生する。   FIG. 6 is an increment table showing the rules for incrementing the in-packet address. As shown in the figure, the instruction address is incremented by adding 2 to the value of the lower 3 bits when the in-packet address is 3'b000 or 3'b010. When the in-packet address is 3'b100, a carry is generated in the packet address (that is, 1 is added to the value of the upper 29 bits), and the value of the lower 3 bits is set to 3'b000. That is, the increment of the in-packet address is a ternary operation that cycles through 3'b000, 3'b010, and 3'b100. For example, if the increment value is 2 and the value of the in-packet address before the increment is 3'b100, the in-packet address after the increment is 3'b010, and one carry occurs in the packet address.

このように、本実施の形態では、通常の2進数によりパケット内アドレスを表す必要がない。この点が、特に、命令パケット内のユニットの個数が2の巾乗数でない場合に対して効果的である。つまり、命令パケット内のユニットの個数が2の巾乗数でない場合には、命令パケット内のユニットの位置を通常の2進数で表現しても、ユニットの位置を移動する際に2進数の演算法を用いることができない。しかし、本実施の形態では、パケット内のユニットの位置を特有のm個の数値を用いて表し、ユニットの位置の移動するための演算としてm個の数値が巡回する演算を用いることによって、命令パケット内のユニットの個数が2の巾乗数でない場合にでも、ユニットの位置指定、ユニットの位置の移動のための演算が可能である。(命令のアドレスの演算方法)
次に、本実施の形態における命令のアドレスの演算方式の一つである桁上がり方式について説明する。命令のアドレスの演算方法には桁上がり方式以外にも、分離方式、絶対位置指定方式、リニアアドレス方式があるが、それらについては後述する。桁上がり方式では、命令のアドレスを上位29ビットと、下位3ビットに分離して演算する。すなわち、パケットアドレスとパケット内アドレスをそれぞれ別々に計算する。ただし、上位ビットの演算の際、下位3ビットの演算で発生した桁上がり数または桁借り数を含めた演算が行われる。
Thus, in this embodiment, it is not necessary to represent the in-packet address by a normal binary number. This is particularly effective when the number of units in the instruction packet is not a power of two. In other words, when the number of units in the instruction packet is not a power of two, even if the unit position in the instruction packet is expressed by a normal binary number, a binary arithmetic method is used when moving the unit position. Cannot be used. However, in the present embodiment, the unit position in the packet is expressed using specific m numerical values, and an operation in which m numerical values circulate is used as an operation for moving the unit position. Even when the number of units in the packet is not a power of two, calculations for specifying the position of the unit and moving the position of the unit are possible. (Instruction address calculation method)
Next, a carry method which is one of the instruction address calculation methods in this embodiment will be described. In addition to the carry method, the instruction address calculation method includes a separation method, an absolute position designation method, and a linear address method, which will be described later. In the carry method, the instruction address is divided into upper 29 bits and lower 3 bits for calculation. That is, the packet address and the intra-packet address are calculated separately. However, when the upper bit is calculated, an operation including the carry number or the borrow number generated by the lower 3 bit operation is performed.

まず、プロセッサ309が行う、分岐命令のアドレスとPC相対値とを加算して分岐先命令のアドレスを求める方法について説明する。図5に示す下位PC演算器405は、分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとを加算する。図7(a)は、分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。図に示すように、下位3ビットの加算は通常の2進演算と異なり、3’b000,3’b010,3’b100を巡回する3進演算である。図に示すような桁上がりが生じる場合には、下位PC演算器405は、上位PC演算器411に桁上がり数を送る。   First, a method performed by the processor 309 to obtain the address of the branch destination instruction by adding the address of the branch instruction and the PC relative value will be described. The lower PC calculator 405 shown in FIG. 5 adds the lower 3 bits of the branch instruction address and the lower 3 bits of the PC relative value. FIG. 7A is an addition table showing an addition rule for the lower 3 bits of the branch instruction address and the lower 3 bits of the PC relative value. As shown in the figure, the addition of the lower 3 bits is a ternary operation that cycles through 3'b000, 3'b010, and 3'b100, unlike a normal binary operation. When a carry as shown in the figure occurs, the lower PC calculator 405 sends the carry number to the upper PC calculator 411.

図5に示す上位PC演算器411は、分岐命令のアドレスの上位29ビットとPC相対値の上位29ビットとを加算する。この時、下位PC演算器405の演算で桁上がりが生じた場合には、その桁上がり数も加算する。加算方法は通常の2進演算である。
以上により算出された加算結果が分岐先命令のアドレスとなる。すなわち、加算結果のの下位3ビットが下位PC404に設定され、加算結果の上位29ビットが上位PC403に設定される。
The upper PC calculator 411 shown in FIG. 5 adds the upper 29 bits of the branch instruction address and the upper 29 bits of the PC relative value. At this time, if a carry occurs in the calculation of the lower PC calculator 405, the carry number is also added. The addition method is a normal binary operation.
The addition result calculated as described above becomes the address of the branch destination instruction. That is, the lower 3 bits of the addition result are set in the lower PC 404, and the upper 29 bits of the addition result are set in the upper PC 403.

次に、最適化装置303、アセンブラ装置305、リンカ装置307が行う、PC相対値を求める演算、すなわち、分岐先命令のアドレスから分岐命令のアドレスを減算方法について説明する。減算は、加算と同様に上位29ビットと下位3ビットに分離して行う。後述の最適化装置303の下位アドレス減算手段907、アセンブラ装置305の下位アドレス減算手段806、リンカ装置307の下位アドレス減算手段706は、分岐先命令のアドレスの下位3ビットから分岐命令のアドレスの下位3ビットを減算する。図7(b)は、分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。図に示すように、下位3ビットの減算は通常の2進演算と異なり、3’b000,3’b010,3’b100を巡回する3進演算である。図に示すような桁借りが生じる場合には、下位アドレス減算手段907等は、それぞれ、後述の上位アドレス減算手段910等に桁借り数を送る。   Next, an operation for obtaining the PC relative value performed by the optimization device 303, the assembler device 305, and the linker device 307, that is, a method of subtracting the branch instruction address from the branch destination instruction address will be described. Subtraction is performed by separating the upper 29 bits and the lower 3 bits as in the addition. The lower address subtracting means 907 of the optimizing device 303 to be described later, the lower address subtracting means 806 of the assembler device 305, and the lower address subtracting means 706 of the linker device 307 are the lower order of the address of the branch instruction from the lower 3 bits of the address of the branch destination instruction. Subtract 3 bits. FIG. 7B is a subtraction table showing a subtraction rule between the lower 3 bits of the branch destination instruction address and the lower 3 bits of the branch instruction address. As shown in the figure, the subtraction of the lower 3 bits is a ternary operation that cycles through 3'b000, 3'b010, and 3'b100, unlike a normal binary operation. When borrowing as shown in the figure occurs, the lower address subtracting means 907 sends the borrowing number to the upper address subtracting means 910 described later.

後述の最適化装置303の上位アドレス減算手段910と、アセンブラ装置305の上位アドレス減算手段809と、リンカ装置307の上位アドレス減算手段709は、分岐命令のアドレスの上位29ビットと分岐先命令の上位29ビットとを減算する。この時、下位アドレス減算手段907等の演算で桁借りが生じた場合には、その桁借り数も減算する。減算方法は通常の2進演算である。   The upper address subtracting means 910 of the optimizing device 303 described later, the upper address subtracting means 809 of the assembler device 305, and the upper address subtracting means 709 of the linker device 307 are the upper 29 bits of the address of the branch instruction and the upper address of the branch destination instruction. Subtract 29 bits. At this time, when borrowing occurs in the calculation by the lower address subtracting means 907, the borrowing number is also subtracted. The subtraction method is a normal binary operation.

以上により算出された下位3ビットの減算結果を下位3ビットとし、上位29ビットの減算結果を上位29ビットとした値がPC相対値となる。また、プロセッサにより行なわれる分岐命令のアドレスとPC相対値とを減算して分岐先命令のアドレスを求める場合にも、上述と同様の方法により行なわれる。
以上のように、分岐先命令のアドレスと分岐命令のアドレスとの差分よりプログラムカウンタ相対値を算出する最適化装置303、アセンブラ装置305、リンカ装置307と、そのプログラムカウンタ相対値を用いて分岐先命令のアドレスを算出するプロセッサ309とが、どちらも同一の桁上がり方式によるアドレス演算を行うことによって、プロセッサは、分岐命令の実行時にプログラム相対値から分岐先命令のアドレスを誤りなく算出できる。また、この桁上り方式によるアドレス演算は、プログラムカウンタとPC相対値との上位ビットの演算と下位ビットの演算との間に連続性を備えたアドレス演算が可能となる特徴を有する。(最適化装置)
図8は、図4に示した最適化装置303の構成要素及び入出力データを示すブロック図である。この最適化装置303の詳細について説明する。最適化装置303は、コンパイラ装置301が生成したアセンブラコード302を最適化し、命令列を3ユニットを単位とするパケットに連結し、その結果である最適化コード915を出力する。最適化装置303は、コード最適化手段902と、アドレス付与手段904と、ラベル検出手段905と、下位アドレス減算手段907と、上位アドレス減算手段910と、アドレス差算出手段912と、ラベル情報解決手段914により構成される。
The value obtained by subtracting the lower 3 bits calculated as described above from the lower 3 bits and the upper 29 bits from the subtraction result from the upper 29 bits is the PC relative value. Further, when the address of the branch destination instruction obtained by subtracting the address of the branch instruction performed by the processor and the PC relative value is obtained, the same method as described above is used.
As described above, the optimization device 303, the assembler device 305, the linker device 307 that calculate the program counter relative value from the difference between the address of the branch destination instruction and the address of the branch instruction, and the branch destination using the program counter relative value. The processor 309 that calculates the address of the instruction performs address calculation using the same carry method, so that the processor can calculate the address of the branch destination instruction without error from the program relative value when the branch instruction is executed. In addition, this carry-over address calculation has a feature that enables an address calculation having continuity between the high-order bit calculation and the low-order bit calculation of the program counter and the PC relative value. (Optimizer)
FIG. 8 is a block diagram showing the components and input / output data of the optimization apparatus 303 shown in FIG. Details of the optimization device 303 will be described. The optimization device 303 optimizes the assembler code 302 generated by the compiler device 301, concatenates the instruction sequence into a packet having a unit of 3 units, and outputs the optimization code 915 as a result. The optimization device 303 includes a code optimization unit 902, an address assignment unit 904, a label detection unit 905, a lower address subtraction unit 907, an upper address subtraction unit 910, an address difference calculation unit 912, and a label information resolution unit. 914.

コード最適化手段902は、アセンブラコード302の最適化を行い、最適化処理コード903を生成する。コード最適化手段902の処理は、公知の最適化装置による処理と同様であるので、詳細な説明は省略する。
アドレス付与手段904は、コード最適化手段902により得られた最適化処理コード903の各命令のアドレスの予測を行い、各命令に予測したアドレスの付与を行い(以下、このアドレスを「仮アドレス」と呼ぶ)、その結果であるアドレス付与コード916を出力する。
The code optimization unit 902 optimizes the assembler code 302 and generates an optimization processing code 903. Since the processing of the code optimization unit 902 is the same as the processing by a known optimization device, detailed description is omitted.
The address assigning means 904 predicts the address of each instruction of the optimization processing code 903 obtained by the code optimizing means 902, and assigns the predicted address to each instruction (hereinafter, this address is referred to as “temporary address”). The address assignment code 916 that is the result is output.

ラベル検出手段905は、アドレス付与コード916から「局所ラベル」を検出する。ラベル検出手段905は、検出したラベルが「命令のアドレスに解決すべきラベル」であれば、そのラベルが位置する命令の仮アドレスを取り込む。また、検出したラベルが「PC相対値に解決すべきラベル」であれば、分岐命令の仮アドレスと分岐先命令の仮アドレスを取り込む。そして、ラベル検出手段905は、ラベルを含む命令とそのラベルが解決される値についての情報からなるラベル情報906を出力する。   The label detection unit 905 detects a “local label” from the address assignment code 916. If the detected label is “label to be resolved to the instruction address”, the label detecting means 905 takes in the temporary address of the instruction in which the label is located. If the detected label is “label to be resolved to PC relative value”, the temporary address of the branch instruction and the temporary address of the branch destination instruction are fetched. Then, the label detection unit 905 outputs label information 906 composed of information about the instruction including the label and the value for which the label is resolved.

下位アドレス減算手段907と、上位アドレス減算手段910と、アドレス差算出手段912は、ラベル情報906中の「PC相対値に解決すべきラベル」について、PC相対値の算出を行う。
下位アドレス減算手段907は、分岐先命令の仮アドレスの下位3ビットから分岐命令の仮アドレスの下位3ビットを減算し、桁借り数908と下位減算結果909を算出する。
The lower address subtracting means 907, the upper address subtracting means 910, and the address difference calculating means 912 calculate the PC relative value for “label to be resolved to the PC relative value” in the label information 906.
The lower address subtracting means 907 subtracts the lower 3 bits of the temporary address of the branch instruction from the lower 3 bits of the temporary address of the branch destination instruction to calculate a borrow number 908 and a lower subtraction result 909.

上位アドレス減算手段910は、分岐先命令の仮アドレスの上位29ビットから分岐命令の仮アドレスの上位29ビットと下位アドレス減算手段907が算出した桁借り数908とを減算し、上位減算結果911を算出する。
アドレス差算出手段912は、下位アドレス減算手段907が算出した下位減算結果909を下位3ビットとし、上位アドレス減算手段910が算出した上位減算結果911を上位29ビットとするアドレス差913を算出する。
The upper address subtracting means 910 subtracts the upper 29 bits of the temporary address of the branch instruction from the upper 29 bits of the temporary address of the branch destination instruction and the borrow number 908 calculated by the lower address subtracting means 907, and obtains the upper subtraction result 911. calculate.
The address difference calculation unit 912 calculates an address difference 913 in which the lower subtraction result 909 calculated by the lower address subtraction unit 907 is the lower 3 bits and the upper subtraction result 911 calculated by the upper address subtraction unit 910 is the upper 29 bits.

ラベル情報解決手段914は、最適化処理コード903中のラベルを含む命令を、アドレス付与手段904が予測し付与したアドレス又は、アドレス差算出手段912が算出したアドレス差913の値から、その値の大きさに応じた命令に変換する。すなわち、ラベルを含む命令は、前記付与アドレスあるいは前記アドレス差の値が13ビット以内で表現できれば21ビット命令に変換され、そうでなければ42ビット命令に変換される。   The label information resolution unit 914 calculates an instruction including the label in the optimization processing code 903 from the address predicted by the address addition unit 904 or the address difference 913 calculated by the address difference calculation unit 912. Convert to instructions according to size. That is, an instruction including a label is converted into a 21-bit instruction if the given address or the address difference value can be expressed within 13 bits, and is converted into a 42-bit instruction otherwise.

そして、ラベル情報解決手段914は、ラベル解決後の命令列を3ユニットを単位とするパケットに連結し、その結果である最適化コード915を出力する。
次に、最適化装置の動作を具体例を用いて説明する。
図9は、最適化装置の動作手順を示すフローチャートである。
まず、コード最適化手段902は、入力されたアセンブラコード302を最適化し、最適化コード903を生成する。図10は、コード最適化手段902が生成した最適化処理コード903の一部分を示す。図10のいくつかの命令について説明を行う。「L1:movr2,r1」1000は、ラベルL1の位置を示し、レジスタr2からレジスタr1への転送を行う命令である。「jsrf」1001は、関数呼び出しであり、ラベルf(外部ラベル)への相対分岐を行う命令である。ret命令により、このアドレスに再び戻る。「addr0,r4」1002は、レジスタr0とレジスタr4の加算を行い、結果をr4へ格納する命令である。「andr1,r3」1003は、レジスタr1とr3の論理積を取り、結果をr3へ格納する命令である。「movL2,r2」1004は、ラベルL2が置かれている命令のアドレスを、レジスタr2に転送する命令である。「ld(r2),r0」1005は、レジスタr2が示すアドレスに格納されているデータをレジスタr0へ転送する命令である。「braL1」1006は、ラベルL1(局所ラベル)への相対分岐を行う命令である。なお、図10において、命令1007に後続する命令が省略してあるが、この後続する命令中には、ラベルfの位置する命令は存在しないこととする(ステップS3901)。
Then, the label information resolution unit 914 concatenates the instruction sequence after the label resolution into a packet having a unit of 3 units, and outputs an optimization code 915 as a result.
Next, the operation of the optimization apparatus will be described using a specific example.
FIG. 9 is a flowchart showing an operation procedure of the optimization apparatus.
First, the code optimizing unit 902 optimizes the input assembler code 302 and generates an optimized code 903. FIG. 10 shows a part of the optimization processing code 903 generated by the code optimization unit 902. Several instructions in FIG. 10 will be described. “L1: movr2, r1” 1000 indicates the position of the label L1, and is an instruction for transferring from the register r2 to the register r1. “Jsrf” 1001 is a function call and is an instruction for performing a relative branch to label f (external label). The ret instruction returns to this address again. “Addr0, r4” 1002 is an instruction for adding the register r0 and the register r4 and storing the result in r4. “Andr1, r3” 1003 is an instruction that takes the logical product of the registers r1 and r3 and stores the result in r3. “MovL2, r2” 1004 is an instruction for transferring the address of the instruction in which the label L2 is placed to the register r2. “Ld (r2), r0” 1005 is an instruction to transfer the data stored at the address indicated by the register r2 to the register r0. “BraL1” 1006 is an instruction for performing a relative branch to the label L1 (local label). In FIG. 10, the instruction following the instruction 1007 is omitted, but it is assumed that the instruction at the label f does not exist in the subsequent instructions (step S3901).

次に、アドレス付与手段904は、最適化処理コード903の各命令に対して仮アドレスを付与し、アドレス付与コード916を生成する。図11は、図10の最適化処理コードより生成されたアドレス付与コード916を示す。ここでは、32’h00000800から始まる仮アドレスが割り当てられている(ステップS3902)。
ラベル検出手段905は、アドレス付与コード916から局所ラベルの検索を行い、検索されたラベルを含む命令とそのラベルの解決される値についての情報とからなるラベル情報を出力する。図12は、図11のアドレス付与コード916から生成されたラベル情報906を示す。図に示すように、命令のアドレスに解決すべきラベルとして命令1104のL2、PC相対値に解決すべきラベルとして命令1106のL1が検出されている。ラベルL2については、L2を含む命令「movL2,r2」と解決されるアドレスの情報が取り込まれ、ラベルL1については、L1を含む命令「braL1」とPC相対値を計算するための分岐先命令のアドレスと分岐命令のアドレスの情報が取り込まれている。なお、命令1101のラベルfは外部ラベルであるため、最適化の対象外である(ステップS3903、S3904)。
Next, the address assignment unit 904 assigns a temporary address to each instruction of the optimization processing code 903 to generate an address assignment code 916. FIG. 11 shows an address assignment code 916 generated from the optimization processing code of FIG. Here, a temporary address starting from 32'h00000080 is assigned (step S3902).
The label detection unit 905 searches for a local label from the address assignment code 916, and outputs label information including an instruction including the searched label and information on a value to be resolved of the label. FIG. 12 shows label information 906 generated from the address assignment code 916 of FIG. As shown in the figure, L2 of the instruction 1104 is detected as a label to be resolved to the address of the instruction, and L1 of the instruction 1106 is detected as a label to be resolved to the PC relative value. For label L2, the instruction “movL2, r2” including L2 is fetched, and for label L1, the instruction “braL1” including L1 and the branch destination instruction for calculating the PC relative value are included. Address and branch instruction address information is captured. Since the label f of the instruction 1101 is an external label, it is not subject to optimization (steps S3903 and S3904).

ラベル情報906中にPC相対値に解決すべきラベルがある場合には、PC相対値の算出が行なわれる。下位アドレス減算手段907は、PC相対値であるL1が示す値の下位ビットを計算する。下位アドレス減算手段907は、分岐先命令1100の仮アドレス32’h00000800の下位3ビット3’b000から分岐命令1106の仮アドレス32’h00000812の下位3ビット3’b010を減算する。その結果、桁借り数908として1が得られ、下位減算結果909として3’b100が得られる(ステップS3905、S3906)。   If there is a label to be resolved in the PC relative value in the label information 906, the PC relative value is calculated. The lower address subtraction means 907 calculates the lower bit of the value indicated by L1 which is the PC relative value. The lower address subtracting means 907 subtracts the lower 3 bits 3'b010 of the temporary address 32'h000000812 of the branch instruction 1106 from the lower 3 bits 3'b000 of the temporary address 32'h000000800 of the branch destination instruction 1100. As a result, 1 is obtained as the borrowing number 908, and 3'b100 is obtained as the lower-order subtraction result 909 (steps S3905 and S3906).

上位アドレス減算手段910は、PC相対値であるL1が示す値の上位ビットを計算する。上位アドレス減算手段910は、分岐先命令1100の仮アドレスの上位29ビット29’h00000100から分岐命令1106の仮アドレスの上位29ビット29’h00000102と桁借り数908である1を減算する。その結果、上位減算結果911として29’h1ffffffd(10進数では−3を示す。以下、負数は2の補数で表す。)が得られる(ステップS3907)。   The upper address subtraction means 910 calculates the upper bits of the value indicated by L1 which is the PC relative value. The high-order address subtracting means 910 subtracts the high-order 29 bits 29'h0000102 of the temporary address of the branch instruction 1106 from the high-order 29 bits 29'h00000102 of the temporary address of the branch destination instruction 1100 and 1 which is the number of borrows 908. As a result, 29'h1ffffffd (decimal number is -3, hereinafter, the negative number is represented by 2's complement) is obtained as the high-order subtraction result 911 (step S3907).

アドレス差算出手段912は、下位演算結果900を下位ビットとし、上位演算結果911を上位ビットとしたアドレス差、すなわち、PC相対値を算出する。ここでは、3’b100を下位ビットとし、29’h1ffffffdを上位ビットして、アドレス差913である32’hffffffecが得られる(ステップS3908)。
ラベル情報解決手段914は、ラベル情報906のラベルが解決される値が13ビットで表現できるか否かにより、ラベルを含む命令の大きさを決定する。図12に示すラベルL2が解決される値は32’h12345678であり、13ビットで表すことができないので、ラベルL2を含む命令1104は42ビット命令となる。また、ラベルL1が解決される値は32’hffffffecであり、13ビットで表すことが可能なので、ラベルL1を含む命令1106は21ビット命令となる(ステップS3909、S3910、S3911)。
The address difference calculation unit 912 calculates an address difference, that is, a PC relative value, in which the lower operation result 900 is the lower bit and the upper operation result 911 is the upper bit. Here, 32′hffffffec, which is the address difference 913, is obtained by setting 3′b100 as the lower bit and 29′h1ffffffd as the upper bit (step S3908).
The label information resolution unit 914 determines the size of the instruction including the label depending on whether or not the value by which the label of the label information 906 is resolved can be expressed by 13 bits. The value to which the label L2 shown in FIG. 12 is resolved is 32′h12345678 and cannot be represented by 13 bits. Therefore, the instruction 1104 including the label L2 is a 42-bit instruction. Further, the value to be resolved by the label L1 is 32′hffffffec and can be represented by 13 bits. Therefore, the instruction 1106 including the label L1 is a 21-bit instruction (steps S3909, S3910, and S3911).

さらに、ラベル情報解決手段914は、アドレス付与コード916に基づいて命令列を3ユニットを単位とするパケットに連結する。この際に、ラベルを有する命令については、上記のようにして決定された大きさと一致するようにする。すなわち、21ビット命令については1ユニットを使用し、42ビット命令については2ユニットを使用するものとする。そして、ラベル情報解決手段914は、パケット化された命令列を最適化コードとして出力する。図13は、図11のアドレス付与コード916から生成された最適化コード915を示す。図13は、一つのパケットを構成する命令が一行に記述され、記号||によりパケット中の命令は区切られている。また、42ビット命令は、()でくくられた命令を後続させることにより、その命令が2つのユニット分の領域を使用することを示している(ステップS3912)。   Further, the label information resolution unit 914 concatenates the instruction sequence into a packet having a unit of 3 units based on the address assignment code 916. At this time, the instruction having the label is made to coincide with the size determined as described above. That is, one unit is used for a 21-bit instruction and two units are used for a 42-bit instruction. Then, the label information resolution unit 914 outputs the packetized instruction sequence as an optimization code. FIG. 13 shows an optimization code 915 generated from the address assignment code 916 of FIG. In FIG. 13, instructions constituting one packet are described in one line, and the instructions in the packet are delimited by the symbol ||. Further, the 42-bit instruction indicates that the instruction uses the area for two units by following the instruction enclosed in parentheses (step S3912).

以上のように、桁上がり方式によるアドレス演算を行って予測することにより、桁上がり方式に対応したプロセッサの最適化装置を実現することが可能となる。
なお、アドレス付与手段904において付与された仮アドレスと、アドレス差算出手段912において算出されたPC相対値は、すべてラベルを含む命令のサイズを確定させるために予測された値であって、実際の値とは異なる場合があるので、以降の処理では用いないこととする。(アセンブラ装置)
図14は、図4に示したアセンブラ装置305の構成及び関連する入出力データを示すブロック図である。このアセンブラ装置305の詳細について説明する。アセンブラ装置305は、最適化装置303が生成した最適化コード304を再配置可能番地形式であるリロケータブルコード306に変換するものである。アセンブラ装置305は、機械語コード生成手段802と、ラベル検出手段804と、下位アドレス減算手段806と、上位アドレス減算手段809と、アドレス差算出手段811と、ラベル情報解決手段813より構成される。
As described above, it is possible to realize a processor optimization apparatus corresponding to the carry method by performing the prediction by performing the address operation by the carry method.
The temporary address assigned by the address assigning unit 904 and the PC relative value calculated by the address difference calculating unit 912 are all predicted values for determining the size of the instruction including the label, and are actually Since it may be different from the value, it will not be used in the subsequent processing. (Assembler device)
FIG. 14 is a block diagram showing a configuration of the assembler device 305 shown in FIG. 4 and related input / output data. Details of the assembler device 305 will be described. The assembler device 305 converts the optimization code 304 generated by the optimization device 303 into a relocatable code 306 that is a relocatable address format. The assembler device 305 includes machine language code generation means 802, label detection means 804, lower address subtraction means 806, upper address subtraction means 809, address difference calculation means 811, and label information resolution means 813.

機械語コード生成手段802は、最適化コード304をプロセッサ309が実行可能な機械語コード803へ変換する。ただし、値が未解決なラベルについては、変換せずに機械語コード803中に保持する。その際に、機械語コード生成手段802は、各機械語コードに対してパケットアドレスとパケット内アドレスとを付与する。そして、この付与されたアドレスに基づいて、後述のラベルの解決がなされる。   The machine code generation unit 802 converts the optimization code 304 into machine code 803 that can be executed by the processor 309. However, labels whose values are unresolved are stored in the machine language code 803 without being converted. At that time, the machine language code generation unit 802 gives a packet address and an in-packet address to each machine language code. Based on the assigned address, the label described later is resolved.

ラベル検出手段804は、局所ラベルであって、2つの命令のアドレスの差分、すなわち、PC相対値に解決すべきラベルを検索し、分岐命令のアドレスと分岐先命令のアドレスを取り込む。そして、ラベル検出手段804は、ラベルを含む命令とそのラベルが解決される値についての情報からなるラベル情報805を出力する。
ラベル検出手段804で得られたラベル情報805を解決するため、下位アドレス減算手段806と、上位アドレス減算手段809と、アドレス差算出手段811は、以下のようにしてPC相対値の算出を行う。
The label detection unit 804 searches for a difference between two instruction addresses, that is, a label to be resolved to a PC relative value, and takes in the branch instruction address and the branch destination instruction address. Then, the label detection unit 804 outputs label information 805 composed of an instruction including the label and information about a value to which the label is resolved.
In order to solve the label information 805 obtained by the label detection unit 804, the lower address subtraction unit 806, the upper address subtraction unit 809, and the address difference calculation unit 811 calculate the PC relative value as follows.

下位アドレス減算手段806は、分岐先命令のアドレスの下位3ビットから分岐命令のアドレスの下位3ビットを減算し、桁借り数807と下位減算結果808を算出する。
上位アドレス減算手段809は、分岐先命令の仮アドレスの上位29ビットから分岐命令の仮アドレスの上位29ビットと下位アドレス減算手段806が算出した桁借り数807とを減算し、上位減算結果810を算出する。
The lower address subtracting means 806 subtracts the lower 3 bits of the branch instruction address from the lower 3 bits of the branch destination instruction address to calculate a borrow number 807 and a lower subtraction result 808.
The upper address subtracting means 809 subtracts the upper 29 bits of the temporary address of the branch instruction from the upper 29 bits of the temporary address of the branch destination instruction and the number of borrows 807 calculated by the lower address subtracting means 806 to obtain the upper subtraction result 810. calculate.

アドレス差算出手段811は、下位アドレス減算手段806が算出した下位減算結果808を下位3ビットとし、上位アドレス減算手段809が算出した上位減算結果810を上位29ビットとするアドレス差812を算出する。
ラベル情報解決手段813は、機械語コード803中のラベルを、アドレス差算出手段811が算出したアドレス差812に置換し、その結果であるリロケータブルコード306を出力する。
The address difference calculation unit 811 calculates an address difference 812 in which the lower subtraction result 808 calculated by the lower address subtraction unit 806 is the lower 3 bits and the upper subtraction result 810 calculated by the upper address subtraction unit 809 is the upper 29 bits.
The label information resolution unit 813 replaces the label in the machine language code 803 with the address difference 812 calculated by the address difference calculation unit 811 and outputs the relocatable code 306 as a result.

次に、アセンブラ装置の動作について、最適化装置303が出力した図13の最適化コードをアセンブラ装置305に入力した場合の例を用いて説明する。
図15は、アセンブラ装置の動作手順を示すフローチャートである。
まず、機械語コード生成手段802は、最適化コード304をパケットごとにプロセッサ309に対応した機械語コード803へ変換する。ただし、値が未解決なラベルについては、変換せずに機械語コード803中に保持する。そして、機械語コード生成手段802は、各機械語コード803に対して、パケットアドレス(以下、これを「局所パケットアドレス」と呼ぶ)とパケット内アドレスを割り振る。図16は、図13の最適化コードから生成された機械語コード803を示す。なお、実際の機械語コードは、0と1だけのバイナリ形式で表されるが、図16では説明の都合上、ニーモニック形式で示されている。また、各命令の並列実行境界情報100とビットフォーマット情報101もこの段階ですでに明らかになっているが、この図では特に示さない。図16では、29’h00000000から始まるパケットアドレス(局所パケットアドレス)が割り当てられている。また、パケット1300の命令「jsrf」中のラベルfと、パケット1301の命令「movL2,r2」中のラベルL2と、パケット1302の命令「braL1」中のラベルL1は、値が未解決なため、変換されていない(ステップS1500、S1501)。
Next, the operation of the assembler apparatus will be described using an example in which the optimization code of FIG. 13 output by the optimization apparatus 303 is input to the assembler apparatus 305.
FIG. 15 is a flowchart showing an operation procedure of the assembler apparatus.
First, the machine language code generation unit 802 converts the optimization code 304 into a machine language code 803 corresponding to the processor 309 for each packet. However, labels whose values are unresolved are stored in the machine language code 803 without being converted. The machine language code generation unit 802 allocates a packet address (hereinafter referred to as “local packet address”) and an in-packet address to each machine language code 803. FIG. 16 shows machine language code 803 generated from the optimized code of FIG. Note that the actual machine language code is expressed in a binary format consisting of only 0 and 1, but in FIG. 16, it is shown in a mnemonic format for convenience of explanation. Further, the parallel execution boundary information 100 and the bit format information 101 of each instruction have already been clarified at this stage, but are not particularly shown in this figure. In FIG. 16, packet addresses (local packet addresses) starting from 29'h00000000 are assigned. Further, since the label f in the instruction “jsrf” of the packet 1300, the label L2 in the instruction “movL2, r2” of the packet 1301, and the label L1 in the instruction “braL1” of the packet 1302 are unresolved, Not converted (steps S1500 and S1501).

次に、ラベル検出手段804は、機械語コード803中の未解決なラベルの中で、局所ラベルであって、PC相対値に解決すべきラベルを検出して、そのラベルが含まれる命令のアドレス、すなわち、分岐命令のアドレスと、分岐先命令のアドレスを取り込む。そして、ラベル検出手段804は、ラベルを含む命令とそのラベルが解決される値についての情報からなるラベル情報805を出力する。図17は、図16の機械語コードより作成されたラベル情報を示す。局所ラベルであって、PC相対値に解決すべきラベルとしてラベルL1が検出され、分岐命令のアドレスとして、32’h00000012が取り込まれて、分岐先命令のアドレス32’h00000000が取り込まれている(ステップS1502、S1503)。   Next, the label detection unit 804 detects a label that is a local label among unresolved labels in the machine language code 803 and should be resolved to a PC relative value, and an address of an instruction including the label. That is, the address of the branch instruction and the address of the branch destination instruction are fetched. Then, the label detection unit 804 outputs label information 805 including information about the instruction including the label and the value to which the label is resolved. FIG. 17 shows label information created from the machine language code of FIG. The label L1 is detected as a local label that should be resolved to the PC relative value, 32'h00000012 is fetched as the branch instruction address, and the branch destination instruction address 32'h00000000 is fetched (step). S1502, S1503).

次に、下位アドレス減算手段806は、PC相対値であるL1が示す値の下位ビットを計算する。下位アドレス減算手段806は、分岐先命令1401のアドレス32’h00000000の下位3ビット3’b000から分岐命令1409のアドレス32’h00000012の下位3ビット3’b010を減算する。その結果、桁借り数807として1が得られ、下位減算結果808として3’b100が得られる(ステップS1504)。   Next, the lower address subtracting means 806 calculates the lower bits of the value indicated by L1 which is the PC relative value. The lower address subtracting means 806 subtracts the lower 3 bits 3'b010 of the address 32'h00000012 of the branch instruction 1409 from the lower 3 bits 3'b000 of the address 32'h00000000 of the branch destination instruction 1401. As a result, 1 is obtained as the number of borrows 807, and 3'b100 is obtained as the lower-order subtraction result 808 (step S1504).

次に、上位アドレス減算手段809は、PC相対値であるL1が示す値の上位ビットを計算する。上位アドレス減算手段809は、分岐先命令1401のアドレスの上位29ビット29’h00000000から分岐命令1409のアドレスの上位29ビット29’h00000002と桁借り数807である1を減算する。その結果、上位減算結果810として29’h1ffffffd(10進数では−3を示す。以下、負数は2の補数で表す。)が得られる(ステップS1505)。   Next, the upper address subtracting means 809 calculates the upper bits of the value indicated by L1 which is the PC relative value. The high-order address subtracting means 809 subtracts the high-order 29 bits 29'h00000002 of the branch instruction 1409 address and 1 which is the borrow number 807 from the high-order 29 bits 29'h00000000 of the branch destination instruction 1401. As a result, 29'h1ffffffd (denotes -3 in decimal number, hereinafter, the negative number is represented by 2's complement) is obtained as the high-order subtraction result 810 (step S1505).

アドレス差算出手段811は、下位減算結果808を下位ビットとし、上位演算結果810を上位ビットとしたアドレス差、すなわち、PC相対値を算出する。この例では、3’b100を下位ビットとし、29’h1ffffffdを上位ビットして、アドレス差812である32’hffffffecが得られる(ステップS1506)。
次に、ラベル情報解決手段813は、アドレス差812が下位13ビットで表現できる場合には、そのアドレス差の下位13ビットをPC相対値とし、下位13ビットで表現できない場合には、そのアドレス差をPC相対値として、機械語コード803中のラベルPC相対値に置換する。図16のラベル情報中のラベルL1が解決されるアドレス差は32’hffffffecであり、下位13ビット13’h1fecで表すことが可能なので、図16の機械語コード中のラベルL1は下位13ビットの値に変換される。このようにして機械語コードが変換されて、リロケータブルコードを生成する。図18は、図16の機械語コード803から生成されたリロケータブルコードを示す。図18中の命令1609は、ラベルL1がPC相対値に変換された命令である。図18では、機械語コード803の出力時にすでに明らかになっていた各命令の並列実行境界情報100とビットフォーマット情報101が示され、パケット中の1ビットが未使用ビットになっていることも示されている(ステップS1507、S1508、S1509)。
The address difference calculation means 811 calculates an address difference, that is, a PC relative value, with the lower order subtraction result 808 as the lower bits and the upper operation result 810 as the upper bits. In this example, 3′b100 is set as the lower bit and 29′h1ffffffd is set as the upper bit, so that 32′hffffffec as the address difference 812 is obtained (step S1506).
Next, when the address difference 812 can be expressed by the lower 13 bits, the label information resolution unit 813 uses the lower 13 bits of the address difference as a PC relative value, and when the address difference 812 cannot be expressed by the lower 13 bits, the address difference Is replaced with the label PC relative value in the machine language code 803 as the PC relative value. The address difference for resolving the label L1 in the label information of FIG. 16 is 32′hffffffec and can be represented by the lower 13 bits 13′h1fec. Therefore, the label L1 in the machine language code of FIG. Converted to a value. In this way, the machine language code is converted to generate a relocatable code. FIG. 18 shows a relocatable code generated from the machine language code 803 of FIG. An instruction 1609 in FIG. 18 is an instruction in which the label L1 is converted into a PC relative value. FIG. 18 shows the parallel execution boundary information 100 and the bit format information 101 of each instruction that has already been clarified when the machine language code 803 is output, and also shows that one bit in the packet is an unused bit. (Steps S1507, S1508, S1509).

以上のように、桁上がり方式によるアドレス演算を行ってPC相対値を求めることにより、桁上がり方式に対応したプロセッサのアセンブラ装置を実現することが可能となる。(リンカ装置)
図19は、図4に示したリンカ装置307の構成及び関連する入出力データを示すブロック図である。このリンカ装置307の詳細について説明する。リンカ装置307は、複数のリロケータブルコード701を結合して、各命令のアドレスを決定し、プロセッサ309が実行可能な絶対番地形式であるオブジェクトコード308を出力するものである。リンカ装置307は、コード結合手段702と、再配置情報検出手段704と、下位アドレス減算手段706と、上位アドレス減算手段709と、アドレス差算出手段711と、再配置情報解決手段713とから構成される。
As described above, it is possible to realize an assembler device for a processor corresponding to the carry method by calculating the PC relative value by performing the address calculation by the carry method. (Linker device)
FIG. 19 is a block diagram showing a configuration of the linker device 307 shown in FIG. 4 and related input / output data. Details of the linker device 307 will be described. The linker device 307 combines a plurality of relocatable codes 701 to determine the address of each instruction, and outputs an object code 308 that is an absolute address format that can be executed by the processor 309. The linker device 307 includes code combination means 702, relocation information detection means 704, lower address subtraction means 706, upper address subtraction means 709, address difference calculation means 711, and relocation information resolution means 713. The

コード結合手段702は、入力された複数のリロケータブルコード701の結合を行い、すべての命令のアドレスを決定する。そして、コード結合手段702は、命令のアドレスに解決すべきラベルについては、上記の決定されたアドレスに解決し、その結果である結合コード703を出力する。
再配置情報検出手段704は、PC相対値に解決すべき外部ラベルを検索し、分岐命令のアドレスと分岐先命令のアドレスを取り込む。そして、再配置情報検出手段704は、ラベルを含む命令とそのラベルが解決される値についての情報からなる再配置情報705を出力する。ここで得られた再配置情報を解決するため、下位アドレス減算手段706と、上位アドレス減算手段709と、アドレス差算出手段711は、以下のようにしてPC相対値の算出を行う。
The code combining unit 702 combines a plurality of input relocatable codes 701 and determines the addresses of all instructions. Then, the code combining means 702 resolves the label to be resolved to the instruction address to the above determined address, and outputs the resultant combined code 703.
The relocation information detection unit 704 searches for an external label to be resolved to a PC relative value, and takes in the address of the branch instruction and the address of the branch destination instruction. Then, the rearrangement information detection unit 704 outputs rearrangement information 705 including information about a command including a label and a value for which the label is resolved. In order to solve the relocation information obtained here, the lower address subtraction means 706, the upper address subtraction means 709, and the address difference calculation means 711 calculate the PC relative value as follows.

下位アドレス減算手段706は、分岐先命令のアドレスの下位3ビットから分岐命令のアドレスの下位3ビットを減算し、桁借り数707と下位減算結果708を算出する。
上位アドレス減算手段709は、分岐先命令のアドレスの上位29ビットから分岐命令のアドレスの上位29ビットと下位アドレス減算手段706が算出した桁借り数707とを減算し、上位減算結果710を算出する。
The lower address subtracting means 706 subtracts the lower 3 bits of the branch instruction address from the lower 3 bits of the branch destination instruction address to calculate a borrow number 707 and a lower subtraction result 708.
The upper address subtracting unit 709 subtracts the upper 29 bits of the branch instruction address from the upper 29 bits of the branch destination instruction address and the number of borrows 707 calculated by the lower address subtracting unit 706 to calculate the upper subtraction result 710. .

アドレス差算出手段711は、下位アドレス減算手段706が算出した下位減算結果708を下位3ビットとし、上位アドレス減算手段709が算出した上位減算結果710を上位29ビットとするアドレス差712を算出する。
再配置情報解決手段713は、結合コード703中のラベルを、アドレス差算出手段711が算出したアドレス差712に置換し、その結果であるオブジェクトコード308を出力する。
The address difference calculation unit 711 calculates an address difference 712 in which the lower subtraction result 708 calculated by the lower address subtraction unit 706 is the lower 3 bits and the upper subtraction result 710 calculated by the upper address subtraction unit 709 is the upper 29 bits.
The rearrangement information resolution unit 713 replaces the label in the combined code 703 with the address difference 712 calculated by the address difference calculation unit 711, and outputs the resulting object code 308.

次に、リンカ装置の動作について、アセンブラ装置305が出力した図18のリロケータブルコードをリンカ装置307に入力した場合の例を用いて説明する。
図20は、リンカ装置の動作手順を示すフローチャートである。
まず、コード結合手段702は、複数個のリロケータブルコード701を結合する。図22は、図18に示すリロケータブルコード306と、別途生成された図21に示すリロケータブルコードと結合された状態を示す。すなわち、図21に示すリロケータブルコードの先頭のパケットアドレスを29’h00000000とし、図18に示すリロケータブルコードの先頭のパケットアドレスを29’h00000001として、これらの2つのリロケータブルコード結合されている(ステップS2000、S2001)。
Next, the operation of the linker device will be described using an example in which the relocatable code of FIG. 18 output from the assembler device 305 is input to the linker device 307.
FIG. 20 is a flowchart showing an operation procedure of the linker device.
First, the cord coupling means 702 couples a plurality of relocatable cords 701. FIG. 22 shows a state where the relocatable code 306 shown in FIG. 18 and the relocatable code shown in FIG. 21 generated separately are combined. That is, the first packet address of the relocatable code shown in FIG. 21 is 29'h00000000, and the first packet address of the relocatable code shown in FIG. 18 is 29'h00000001, and these two relocatable codes are combined (step S2000, S2001).

そして、これによって、すべての命令のアドレスが決定されたことになるので、コード結合手段702は、さらに、命令のアドレスに解決すべきラベルのアドレスを解決して、その結果である結合コード703を出力する。図22に示す命令1810「movL2,r2」のラベルL2のアドレスは、パケット1815の先頭のアドレスである。コード結合手段は、当該アドレスが32’h12345680と決定しているので、ラベルL2をこの値に置き換える。図23は、結合コード703を示す。図23中の結合コード1910は、ラベルL2が32’h12345680に置換えられたことを示す(ステップS2002)。   As a result, the addresses of all the instructions have been determined. Therefore, the code combining means 702 further resolves the address of the label to be resolved into the address of the instruction, and obtains the combined code 703 as a result. Output. The address of the label L2 of the instruction 1810 “movL2, r2” illustrated in FIG. 22 is the head address of the packet 1815. Since the code combining means determines that the address is 32'h12345680, the label L2 is replaced with this value. FIG. 23 shows the connection code 703. The combined code 1910 in FIG. 23 indicates that the label L2 has been replaced with 32'h12345680 (step S2002).

次に、再配置情報検出手段704は、結合コード703中で、PC相対値に解決すべき外部ラベルを検出して、そのラベル含まれる命令のアドレスと、ラベルが置かれている命令のアドレス、すなわち、分岐命令のアドレスと分岐先命令のアドレスを取り込む。そして、再配置情報検出手段704は、ラベルを含む命令とそのラベルが解決される値についての情報からなる再配置情報705を出力する。図24は、図23の結合コードから作成されたラベル情報を示す。PC相対値に解決すべき外部ラベルとしてラベルfが検出され、分岐命令のアドレスとして、32’h0000000aが取り込まれて、分岐先命令のアドレス32’h00000000が取り込まれている(ステップS2003、S2004)。   Next, the rearrangement information detection means 704 detects an external label to be resolved to the PC relative value in the combined code 703, and the address of the instruction included in the label, the address of the instruction where the label is placed, That is, the address of the branch instruction and the address of the branch destination instruction are fetched. Then, the rearrangement information detection unit 704 outputs rearrangement information 705 including information about a command including a label and a value for which the label is resolved. FIG. 24 shows label information created from the combined code of FIG. The label f is detected as an external label to be resolved to the PC relative value, 32'h0000000a is fetched as the branch instruction address, and the branch destination instruction address 32'h00000000 is fetched (steps S2003 and S2004).

下位アドレス減算手段706は、PC相対値であるfが示す値の下位ビットを計算する。下位アドレス減算手段706は、分岐先命令1901のアドレス32’h00000000の下位3ビット3’b000から分岐命令1906のアドレス32’h0000000aの下位3ビット3’b010を減算する。その結果、桁借り数707として1が得られ、下位減算結果708として3’b100が得られる(ステップS2005)。   The lower address subtracting means 706 calculates the lower bits of the value indicated by f which is the PC relative value. The lower address subtracting means 706 subtracts the lower 3 bits 3'b010 of the address 32'h0000000a of the branch instruction 1906 from the lower 3 bits 3'b000 of the address 32'h00000000 of the branch destination instruction 1901. As a result, 1 is obtained as the number of borrows 707, and 3'b100 is obtained as the lower-order subtraction result 708 (step S2005).

次に、上位アドレス減算手段709は、PC相対値であるfが示す値の上位ビットを計算する。上位アドレス減算手段709は、分岐先命令1901のアドレス32’h00000000の上位29ビット29’h00000000から分岐命令1906のアドレス32’h0000000aの上位29ビット29’h00000001と桁借り数707である1を減算する。その結果、上位減算結果710として29’h1ffffffeが得られる(ステップS2006)。   Next, the upper address subtracting means 709 calculates the upper bits of the value indicated by f which is the PC relative value. The high-order address subtracting means 709 subtracts 1 which is the number of borrows 707 from the high-order 29 bits 29'h00000001 of the address 32'h0000000a of the branch instruction 1906 from the high-order 29 bits 29'h00000000 of the address 32'h00000000 of the branch destination instruction 1901. . As a result, 29'h1ffffffe is obtained as the higher order subtraction result 710 (step S2006).

アドレス差算出手段811は、下位減算結果708を下位ビットとし、上位演算結果710を上位ビットとしたアドレス差、すなわち、PC相対値を算出する。3’b100を下位ビットとし、29’h1ffffffeを上位ビットして、アドレス差712である32’hfffffff4が得られる(ステップS2007)。
次に、再配置情報解決手段713は、アドレス差712が下位13ビットで表現できる場合には、そのアドレス差の下位13ビットをPC相対値とし、下位13ビットで表現できない場合には、そのアドレス差をPC相対値として、結合コード703中のラベルをPC相対値に置換する。図23の再配置情報中のラベルfが解決されるアドレス差は32’hfffffff4であり、下位13ビット13’h1ff4で表すことが可能なので、図22の結合コード中のラベルfは下位13ビットの値に変換される。このようにして結合コードが変換されて、オブジェクトコードが生成される。図25は、オブジェクトコードを示す。図25中、オブジェクトコード2106は、ラベルfがPC相対値に変換されていることを示している(ステップS2008、S2009、S2010)。
The address difference calculation means 811 calculates an address difference, that is, a PC relative value, with the lower order subtraction result 708 as the lower bits and the upper operation result 710 as the upper bits. 32′hfffffff4 which is an address difference 712 is obtained by setting 3′b100 as a lower bit and 29′h1ffffffe as an upper bit (step S2007).
Next, when the address difference 712 can be expressed by the lower 13 bits, the rearrangement information resolution unit 713 uses the lower 13 bits of the address difference as a PC relative value. Using the difference as the PC relative value, the label in the combined code 703 is replaced with the PC relative value. The address difference in which the label f in the relocation information in FIG. 23 is resolved is 32′hfffffff4 and can be represented by the lower 13 bits 13′h1ff4. Therefore, the label f in the combined code of FIG. Converted to a value. In this way, the combined code is converted and an object code is generated. FIG. 25 shows the object code. In FIG. 25, the object code 2106 indicates that the label f has been converted into a PC relative value (steps S2008, S2009, S2010).

以上のように、桁上がり方式によるアドレス演算を行ってPC相対値を求めることにより、桁上がり方式に対応したプロセッサのリンカ装置を実現することが可能となる。(プロセッサの具体的動作)
プロセッサの動作について、図25のオブジェクトコードが命令メモリ407に蓄えられている場合の例を用いて説明する。
As described above, by calculating the PC relative value by performing the address calculation by the carry method, it is possible to realize a linker device for a processor that supports the carry method. (Specific operation of the processor)
The operation of the processor will be described using an example in which the object code of FIG. 25 is stored in the instruction memory 407.

オブジェクトコードの実行開始時には、上位PC403は、29’h00000000に、下位PC404は、3’b000に設定されている。プリフェッチ上位カウンタ410は、上位PC403からの入力を受けて、29’h00000000に設定されている。
命令メモリ407から命令の読み出しは、プリフェッチ上位カウンタ410に基づき、パケット単位で行なわれる。すなわち、命令メモリ407に蓄えられた命令列のうち、プリフェッチ上位カウンタ410により指定されるパケット2100が、命令バッファ408に格納される。プリフェッチ上位カウンタ410の値は、1サイクルごとに1つずつインクリメントされるので、29’h00000001となる。以下、1サイクルごとに、プリフェッチ上位カウンタ410が指定するパケットが命令メモリ407から命令バッファ408へ読み出される。
At the start of object code execution, the upper PC 403 is set to 29'h00000000, and the lower PC 404 is set to 3'b000. The prefetch upper counter 410 is set to 29′h00000000 in response to an input from the upper PC 403.
Reading of instructions from the instruction memory 407 is performed on a packet basis based on the prefetch upper counter 410. That is, of the instruction sequence stored in the instruction memory 407, the packet 2100 specified by the prefetch upper counter 410 is stored in the instruction buffer 408. Since the value of the prefetch upper counter 410 is incremented by 1 every cycle, it becomes 29′h00000001. Thereafter, the packet designated by the prefetch upper counter 410 is read from the instruction memory 407 to the instruction buffer 408 every cycle.

次に、上位PC403によりパケット2104が指定され、さらに下位PC404によりパケット2104中の命令2107が指定されている時の、命令の解読と実行の動作について説明する。命令バッファ408に格納された命令は、命令デコーダ409a〜409cにより解釈される。第1命令デコーダ409aは、命令バッファ408に格納されている先頭のユニット2107を取り込み、そのユニットが1ユニット命令であるか、並列実行境界であるかを調べる。ユニット2107が1ユニット命令であり、並列実行境界でないので、第2命令デコーダ409bは、次のユニット2109を取り込み、そのユニットが1ユニット命令であるか、並列実行境界であるかを調べる。ユニット2109が1ユニット命令であり、並列実行境界ではないので、第3命令デコーダ409cは、次のユニットを取り込む、そのユニットが1ユニット命令であるか、並列実行境界であるかを調べる。そのユニットが1ユニット命令でないので、第3命令デコーダ409cは、次のユニットも取り込む。そして、第3命令デコーダ409cは、そのユニットが並列実行境界であることを知る。以上によって、命令2107、命令2109、命令2110が同時並列実行可能であることがわかる。   Next, the operation of decoding and executing the instruction when the packet 2104 is designated by the upper PC 403 and the instruction 2107 in the packet 2104 is designated by the lower PC 404 will be described. The instructions stored in the instruction buffer 408 are interpreted by the instruction decoders 409a to 409c. The first instruction decoder 409a takes in the first unit 2107 stored in the instruction buffer 408 and checks whether the unit is a one-unit instruction or a parallel execution boundary. Since the unit 2107 is a single unit instruction and not a parallel execution boundary, the second instruction decoder 409b fetches the next unit 2109 and checks whether the unit is a single unit instruction or a parallel execution boundary. Since the unit 2109 is a single unit instruction and not a parallel execution boundary, the third instruction decoder 409c takes in the next unit, and checks whether the unit is a single unit instruction or a parallel execution boundary. Since that unit is not a single unit instruction, the third instruction decoder 409c also captures the next unit. Then, the third instruction decoder 409c knows that the unit is a parallel execution boundary. From the above, it can be seen that the instruction 2107, the instruction 2109, and the instruction 2110 can be executed in parallel.

第1命令デコーダ409aは、命令「addr0,r4」をデコードし、制御信号を第1演算器401aに出力する。第1演算器401aは、レジスタr0とレジスタr4の値を加算し、その結果をレジスタr4へ格納する。第2命令デコーダ409bは、命令「andr1,r3」をデコードし、制御信号を第2演算器401bに出力する。第2演算器401bは、レジスタr1とレジスタr3の値の論理演算が行い、その結果をレジスタr3へ格納する。第3命令デコーダ409cは、命令「mov32’h12345680,r2」をデコードし、即値である32’h12345680を、レジスタr2に転送する。   The first instruction decoder 409a decodes the instruction “addr0, r4” and outputs a control signal to the first arithmetic unit 401a. The first computing unit 401a adds the values of the register r0 and the register r4 and stores the result in the register r4. The second instruction decoder 409b decodes the instruction “andr1, r3” and outputs a control signal to the second arithmetic unit 401b. The second computing unit 401b performs a logical operation on the values of the register r1 and the register r3, and stores the result in the register r3. The third instruction decoder 409c decodes the instruction “mov32′h12345680, r2” and transfers the immediate value 32′h12345680 to the register r2.

また、命令デコーダ409a〜409cは、この例では4つのユニットを実行したことを、制御信号によりINC412に知らせる。INC412は、4つのユニット分だけ、上位PC403及び下位PC404の値をインクリメントする。以上の結果、下位PC404は3’b000となり、上位PC403は桁上がりが2つ起こり29’h00000003となり、次のサイクルで実行する先頭命令は命令2112となる。   In addition, the instruction decoders 409a to 409c notify the INC 412 by the control signal that four units have been executed in this example. The INC 412 increments the values of the upper PC 403 and the lower PC 404 by four units. As a result, the lower PC 404 becomes 3'b000, the upper PC 403 has two carry and becomes 29'h00000003, and the head instruction to be executed in the next cycle becomes the instruction 2112.

次に、第1命令デコーダ409aは、命令バッファ408に格納されている先頭のユニット2112を取り込み、そのユニットが1ユニット命令であるか、並列実行境界であるかを調べる。ユニット2112が1ユニット命令であり、並列実行境界でないので、第2命令デコーダ409bは、次のユニット2113を取り込み、そのユニットが1ユニット命令であるか、並列実行境界であるかを調べる。第2命令デコーダ409bは、ユニット2113が1ユニット命令であり、並列実行境界であること知る。以上によって、命令2112、命令2113が同時並列実行可能であることがわかる。   Next, the first instruction decoder 409a takes in the first unit 2112 stored in the instruction buffer 408 and checks whether the unit is a one-unit instruction or a parallel execution boundary. Since the unit 2112 is a single unit instruction and not a parallel execution boundary, the second instruction decoder 409b fetches the next unit 2113 and checks whether the unit is a single unit instruction or a parallel execution boundary. The second instruction decoder 409b knows that the unit 2113 is a single unit instruction and is a parallel execution boundary. From the above, it can be seen that the instruction 2112 and the instruction 2113 can be executed simultaneously in parallel.

第1命令デコーダ409aは、命令「ld(r2),r0」がデコードし、レジスタr2の値をオペランドアドレスとするオペランドデータをデータメモリ406中から取り込み、レジスタr0へ格納する。第2命令デコーダ409bは、命令「bra13’h1fec」をデコードし、命令2113が分岐命令であるので、上位PC403及び下位PC404を分岐先命令のアドレスに更新する。   The first instruction decoder 409a decodes the instruction “ld (r2), r0”, fetches operand data having the value of the register r2 as an operand address from the data memory 406, and stores it in the register r0. The second instruction decoder 409b decodes the instruction “bra13′h1fec” and updates the upper PC 403 and the lower PC 404 to the addresses of the branch destination instructions because the instruction 2113 is a branch instruction.

まず、上位PC403及び下位PC404の指定するアドレスを補正する。PC相対値は、分岐命令から分岐先命令とのアドレスの差であるのに対して、上位PC403及び下位PC404はそのサイクルで実行する先頭の命令のアドレスを指定しており、整合性が取れていないので、上位PC403及び下位PC404を分岐命令のアドレスを指定するように補正する。すなわち、INC412は、実行単位の先頭命令2112から分岐命令2113までに存在するユニット数1だけ上位PC403及び下位PC404の値をインクリメントする。その結果、上位PCが29’h00000003となり、下位PCが3’b010となる。   First, the addresses designated by the upper PC 403 and the lower PC 404 are corrected. The PC relative value is the difference in address from the branch instruction to the branch destination instruction, whereas the upper PC 403 and the lower PC 404 specify the address of the first instruction to be executed in that cycle, and are consistent. Therefore, the upper PC 403 and the lower PC 404 are corrected so as to specify the address of the branch instruction. That is, the INC 412 increments the values of the upper PC 403 and the lower PC 404 by the number of units 1 existing from the first instruction 2112 to the branch instruction 2113 in the execution unit. As a result, the upper PC is 29'h00000003 and the lower PC is 3'b010.

次に、上位PC演算器411及び下位PC演算器405は、上記により補正された上位PC403及び下位PC404の値と、第2命令デコーダ409bから得られたPC相対値13’h1fecとを加算する。ここで、PC相対値は、32ビットに符号拡張した値32’hffffffecを用いる。加算は、上位29ビットと下位3ビットに分離して行われる。   Next, the upper PC calculator 411 and the lower PC calculator 405 add the values of the upper PC 403 and the lower PC 404 corrected as described above and the PC relative value 13'h1fec obtained from the second instruction decoder 409b. Here, a value 32'hffffffec that is sign-extended to 32 bits is used as the PC relative value. The addition is performed separately for the upper 29 bits and the lower 3 bits.

下位PC演算器405は、下位PC3’b010とPC相対値の下位3ビット3’b100を加算する。その結果、桁上がり数1と下位演算結果3’b000が得られ、桁上がり数は上位PC演算器411に送られ、下位演算結果は下位PC404に転送される。
次に、上位PC演算器411は、上位PC29’h00000003と、PC相対値の上位29ビット29’h1ffffffdと、桁上がり数1とを加算する。上位演算結果29’h00000001は上位PC403に転送されるとともに、上位PCからプリフェッチ上位カウンタ410に転送される。以上の処理により、プリフェッチ上位カウンタ410は29’h00000001となり、次にプリフェッチするパケットは、パケット2104となる。また、上位PC403は29’h00000001で、下位PC404は3’b000となり、次のサイクルで実行する先頭命令は命令2105となる。
The lower PC calculator 405 adds the lower PC 3′b010 and the lower 3 bits 3′b100 of the PC relative value. As a result, the carry number 1 and the lower calculation result 3′b000 are obtained, the carry number is sent to the upper PC calculator 411, and the lower calculation result is transferred to the lower PC 404.
Next, the upper PC computing unit 411 adds the upper PC 29′h00000003, the upper 29 bits 29′h1ffffffd of the PC relative value, and the carry number 1. The upper calculation result 29′h00000001 is transferred to the upper PC 403 and is transferred from the upper PC to the prefetch upper counter 410. With the above processing, the prefetch upper counter 410 becomes 29'h00000001, and the next prefetch packet becomes the packet 2104. Further, the upper PC 403 is 29'h00000001, the lower PC 404 is 3'b000, and the first instruction to be executed in the next cycle is the instruction 2105.

以下、同様にして、オブジェクトコードが順次、読み込まれ、実行されてゆく。以降の命令の説明については省略する。
以上、図4に示したプロセッサ309、リンカ装置307、アセンブラ装置305、最適化装置303についてその構成の詳細を記した。なお、コンパイラ装置301については、公知のコンパイラ装置の構成と同様であるため、詳細な説明は省略する。
In the same manner, the object code is sequentially read and executed in the same manner. The description of subsequent instructions is omitted.
The detailed configuration of the processor 309, the linker device 307, the assembler device 305, and the optimization device 303 shown in FIG. Since the compiler device 301 has the same configuration as a known compiler device, detailed description thereof is omitted.

なお、本実施の形態のプロセッサは、3個の命令デコーダ409a、409b、409cと3個の演算器401a、401b、401cを備えているものとしたが、これに限定するものでなく、1個の命令デコーダと、1個の演算器を有するものとしてもよい。
また、最適化装置303の機能をコンパイラ装置301に取り込んで、コンパイラ装置301と、アセンブラ装置305と、リンカ装置307によって、ソースコード300からオブジェクトコード308を生成することとしてもよい。
Although the processor of this embodiment includes three instruction decoders 409a, 409b, and 409c and three arithmetic units 401a, 401b, and 401c, the present invention is not limited to this. These instruction decoders and one arithmetic unit may be included.
Alternatively, the function of the optimization device 303 may be taken into the compiler device 301, and the object code 308 may be generated from the source code 300 by the compiler device 301, the assembler device 305, and the linker device 307.

また、本実施の形態では、プリフェッチ下位カウンタ413は、常時3’b000に設定するものとしたが、これに限定するものではなく、例えば、1サイクルごとに1ずつインクリメントすることととしてもよい。この場合には、1サイクルごとに1バイトデータが命令メモリ407から命令バッファ408に読み出されることになる。(第2の実施形態)
第2の実施形態は、分岐命令中のラベルが解決されるPC相対値として、第1の実施形態と異なるものを用いたプロセッサ及び、最適化装置、アセンブラ装置、リンカ装置に関する。
In this embodiment, the prefetch lower counter 413 is always set to 3′b000. However, the present invention is not limited to this. For example, the prefetch lower counter 413 may be incremented by 1 every cycle. In this case, 1-byte data is read from the instruction memory 407 to the instruction buffer 408 every cycle. (Second Embodiment)
The second embodiment relates to a processor, an optimization device, an assembler device, and a linker device using different PC relative values from those of the first embodiment as PC relative values for resolving labels in branch instructions.

第1の実施形態では、分岐命令のPC相対値は、分岐先命令のアドレスと分岐命令のアドレスとの差分値であったが、本実施の形態では、分岐命令のPC相対値は、分岐先命令のアドレスと実行単位の先頭アドレスとの差分値とする。
本実施の形態では、第1の実施形態とPC相対値の意味づけが異なる。しかし、プログラム生成側、すなわち、プログラム相対値を算出する最適化装置、アセンブラ装置、リンカ装置と、プログラム実行側、すなわち、プログラム相対値からもとのアドレスを算出するプロセッサとで、PC相対値を同一の意味で用いることとすれば、プロセッサは、分岐命令の実行時に、正しく分岐先命令にプログラムカウンタの値を移行させることができる。
In the first embodiment, the PC relative value of the branch instruction is a difference value between the address of the branch destination instruction and the address of the branch instruction. In this embodiment, the PC relative value of the branch instruction is the branch destination. The difference value between the instruction address and the start address of the execution unit.
In this embodiment, the meaning of the PC relative value is different from that in the first embodiment. However, the PC relative value is calculated on the program generation side, that is, the optimization device, the assembler device, and the linker device that calculate the program relative value, and on the program execution side, that is, the processor that calculates the original address from the program relative value. If used in the same meaning, the processor can correctly shift the value of the program counter to the branch destination instruction when the branch instruction is executed.

まず、本実施の形態の最適化装置303、アセンブラ装置305、リンカ装置307、プロセッサ309について説明する。
最適化装置303のラベル検出手段905は、「PC相対値に解決すべきラベル」については、第1の実施形態で分岐命令の仮アドレスと分岐先命令の仮アドレスを取り込んでラベル情報を作成した代わりに、分岐先命令の仮アドレスとその分岐命令と同一の実行単位に属する命令群の先頭の命令のアドレスを取り込んでラベル情報906を作成する。このラベル情報906から、第1の実施形態と同様にして、2つの仮アドレスの差であるアドレス差913が算出され、最適化コード915が算出される。アセンブラ装置、リンカ装置についても同様である。
First, the optimization device 303, the assembler device 305, the linker device 307, and the processor 309 of this embodiment will be described.
The label detection unit 905 of the optimization device 303 creates label information for the “label to be resolved to the PC relative value” by fetching the temporary address of the branch instruction and the temporary address of the branch destination instruction in the first embodiment. Instead, the label information 906 is created by fetching the temporary address of the branch destination instruction and the address of the first instruction of the instruction group belonging to the same execution unit as the branch instruction. From this label information 906, as in the first embodiment, an address difference 913 that is a difference between two temporary addresses is calculated, and an optimization code 915 is calculated. The same applies to the assembler device and the linker device.

本実施の形態により、オブジェクトコードが生成される具体例を示す。
アセンブラ装置305は、図16の機械語コード中の命令1409のラベルL1を、分岐先命令のアドレス32’h00000000から命令1409の実行単位の先頭である命令1408のアドレス32’h00000010を減算した減算値13’h1ff0に置き換える。リンカ装置307も、同様に、図23の結合コード中の命令1906のラベルfを、分岐先アドレス32’h00000000から命令1906の実行単位の先頭である命令1907のアドレス32’h00000008を減算した減算値13’h1ff8に置き換える。図26は、このようにして生成されるオブジェクトコードを示す。図26では、命令2206、命令2213のPC相対値が、図25に示すものと異なっていることが示されている。
A specific example in which an object code is generated according to the present embodiment will be described.
The assembler device 305 subtracts the label L1 of the instruction 1409 in the machine language code of FIG. 16 by subtracting the address 32′h00000010 of the instruction 1408 that is the head of the execution unit of the instruction 1409 from the address 32′h00000000 of the branch destination instruction Replace with 13'h1ff0. Similarly, the linker device 307 also subtracts the label f of the instruction 1906 in the combined code of FIG. 23 by subtracting the address 32′h00000008 of the instruction 1907 that is the head of the execution unit of the instruction 1906 from the branch destination address 32′h00000000. Replace with 13'h1ff8. FIG. 26 shows the object code generated in this way. 26 shows that the PC relative values of the instruction 2206 and the instruction 2213 are different from those shown in FIG.

次に、本実施の形態のプロセッサについて説明する。
プロセッサ309は、上述のようにして作成されたオブジェクトコードを実行する。プロセッサ309が分岐命令を実行する際に、分岐命令中のPC相対値は、その時の上位PC403及び下位PC404が指定しているアドレスと分岐先命令のアドレスとの差分値である。従って、プロセッサ309は、上位PC403、下位PC404の値を補正する処理をすることなく、第1の実施形態と同様にして、上位PC403の値及び下位PC404の値と分岐命令中のPC相対値とを加算し、加算結果を上位PC403及び下位PC404の値に更新する。プロセッサが図26に示すオブジェクトコードを実行する場合、命令2213の実行の際には、現在のPCの値32’h00000008とPC相対値13’h1ff8とを加算し、加算値32’h00000000にPCを更新する。
Next, the processor of this embodiment will be described.
The processor 309 executes the object code created as described above. When the processor 309 executes a branch instruction, the PC relative value in the branch instruction is a difference value between the address specified by the upper PC 403 and the lower PC 404 at that time and the address of the branch destination instruction. Accordingly, the processor 309 does not perform the process of correcting the values of the upper PC 403 and the lower PC 404, and similarly to the first embodiment, the value of the upper PC 403 and the value of the lower PC 404 and the PC relative value in the branch instruction. And the addition result is updated to the values of the upper PC 403 and the lower PC 404. When the processor executes the object code shown in FIG. 26, when the instruction 2213 is executed, the current PC value 32'h00000008 and the PC relative value 13'h1ff8 are added, and PC is added to the added value 32'h00000000. Update.

以上のように、本実施の形態のプロセッサは、分岐命令を実行する際に、第1の実施形態のようなプログラムカウンタの値を補正する処理は不要で、直接、PC相対値とPCの値とを加算することによって分岐先のアドレスが得られるので、実行時間を短縮できる。(第3の実施形態)
第3の実施形態は、命令のアドレスの下位3ビットを十分に活用して、命令の実行位置を指定できるプロセッサに関する。
As described above, the processor according to the present embodiment does not require the process of correcting the value of the program counter as in the first embodiment when executing the branch instruction, and directly compares the PC relative value and the PC value. The address of the branch destination can be obtained by adding and so the execution time can be shortened. (Third embodiment)
The third embodiment relates to a processor capable of specifying the execution position of an instruction by fully utilizing the lower 3 bits of the instruction address.

第1の実施形態では、命令のアドレスの下位3ビットを用いて、3個のユニットの位置を指定することとしたが、本実施の形態では、命令のアドレスの下位3ビットを十分に活用して、8個のユニットの位置を指定するものである。
図27(a)は、本実施の形態の命令パケットの構成を示す図である。命令パケットは、8個のユニットで構成される。命令パケットの1個のユニットは8ビット長であり、命令パケットの長さは64ビット長となる。プロセッサは、1サイクルにおいて、この64ビットの固定長で命令を読み出す。
In the first embodiment, the positions of the three units are specified using the lower 3 bits of the instruction address. However, in this embodiment, the lower 3 bits of the instruction address are fully utilized. The position of 8 units is designated.
FIG. 27A is a diagram illustrating a configuration of an instruction packet according to the present embodiment. The instruction packet is composed of 8 units. One unit of the instruction packet is 8 bits long, and the length of the instruction packet is 64 bits long. The processor reads an instruction with a fixed length of 64 bits in one cycle.

図27(b)は、命令の種類を示す図である。各命令は、8ビットのユニットを単位として構成されており、2ユニット命令、3ユニット命令、5ユニット命令、6ユニット命令が存在する。
図27(c)は、パケット内アドレスと、パケット内アドレスが指定するパケット内のユニットとの関係を示す図である。命令パケット内の位置は、第1の実施形態と同様に、命令のアドレスの下位3ビットで指定される。図に示すように、パケット内アドレスが3’b000なら第1ユニットを指定し、3’b001なら第2ユニットを指定し、3’b010なら第3ユニットを指定し、3’b011なら第4ユニットを指定し、3’b100なら第5ユニットを指定し、3’b101なら第6ユニットを指定し、3’b110なら第7ユニットを指定し、3’b111なら第8ユニットを指定する。
FIG. 27B shows the types of instructions. Each instruction is configured in units of 8 bits, and there are 2 unit instructions, 3 unit instructions, 5 unit instructions, and 6 unit instructions.
FIG. 27C is a diagram showing the relationship between the in-packet address and the unit in the packet specified by the in-packet address. The position in the instruction packet is designated by the lower 3 bits of the instruction address, as in the first embodiment. As shown in the figure, if the in-packet address is 3'b000, the first unit is specified. If 3'b001, the second unit is specified. If 3'b010, the third unit is specified. If 3'b011, the fourth unit is specified. 3′b100 specifies the fifth unit, 3′b101 specifies the sixth unit, 3′b110 specifies the seventh unit, and 3′b111 specifies the eighth unit.

以上のように、本実施の形態のプロセッサは、命令の下位アドレスの3ビットを最大限に用いて、命令の実行位置を指定できるので、1サイクルにおける命令の実行単位にバリエーションをもたせることができる。(第4の実施形態)
第4の実施形態は、桁上りなし方式による命令のアドレスの演算方法に関する。
第1の実施形態では、プログラムを実行するプロセッサと、プログラムを作成する最適化装置、アセンブラ装置、リンカ装置のすべてが共通して桁上り方式のアドレスの演算方法を用いることによって、プロセッサでPC相対値から分岐先命令のアドレスを誤りなく再現することができたが、桁上り方式以外のアドレスの演算方法であっても、プロセッサと、最適化装置と、アセンブラ装置と、リンカ装置が共通にその演算方法を用いさえすれば、プロセッサが分岐先命令のアドレスを誤りなく再現できるようなものがある。本実施の形態は、このような他のアドレスの演算方法の一つである桁上りなし方式に関するものである。
As described above, the processor according to the present embodiment can specify the execution position of an instruction by making the maximum use of 3 bits of the lower address of the instruction, so that the execution unit of the instruction in one cycle can have variations. . (Fourth embodiment)
The fourth embodiment relates to a method for calculating the address of an instruction using the no carry method.
In the first embodiment, a processor that executes a program and an optimization device, an assembler device, and a linker device that create a program all use a carry address calculation method in common, so that the processor uses a PC relative Although the address of the branch destination instruction could be reproduced without error from the value, the processor, the optimization device, the assembler device, and the linker device could share the same operation method for addresses other than the carry method. As long as an arithmetic method is used, there is a processor that can reproduce the address of the branch destination instruction without error. The present embodiment relates to a no carry method, which is one of such other address calculation methods.

桁上りなし方式では、命令のアドレスを上位29ビット、下位3ビットに分離して演算する点で、第1の実施形態の桁上がり方式と同じであるが、下位3ビットの演算で桁上がりあるいは桁借りを発生させない点で、桁上がり方式と異なる。
まず、プロセッサ309が行う、分岐命令のアドレスとPC相対値とを加算して分岐先命令のアドレスを求める方法について説明する。図5に示す下位PC演算器405は、分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとを加算する。図28(a)は、本実施の形態に係る桁上りなし方式のアドレス演算による分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。図に示すように、下位3ビットの加算は通常の2進演算と異なり、3’b000,3’b010,3’b100を巡回する3進演算である。この演算では、桁上がりは発生させない。
The no carry method is the same as the carry method of the first embodiment in that the instruction address is divided into upper 29 bits and lower 3 bits and is operated. It differs from the carry method in that no borrowing is generated.
First, a method performed by the processor 309 to obtain the address of the branch destination instruction by adding the address of the branch instruction and the PC relative value will be described. The lower PC calculator 405 shown in FIG. 5 adds the lower 3 bits of the branch instruction address and the lower 3 bits of the PC relative value. FIG. 28A is an addition table showing an addition rule between the lower 3 bits of the address of the branch instruction and the lower 3 bits of the PC relative value by the address operation of the no carry method according to the present embodiment. As shown in the figure, the addition of the lower 3 bits is a ternary operation that cycles through 3′b000, 3′b010, and 3′b100, unlike a normal binary operation. This operation does not generate a carry.

図5に示す上位PC演算器411は、分岐命令のアドレスの上位29ビットとPC相対値の上位29ビットとを加算する。分岐命令のアドレスの上位29ビットとのPC相対値の上位29ビットとの加算方法は通常の2進演算である。
以上により算出された加算結果が分岐先命令のアドレスとなる。すなわち、加算結果のの下位3ビットが下位PC404に設定され、加算結果の上位29ビットが上位PC403に設定される。
The upper PC calculator 411 shown in FIG. 5 adds the upper 29 bits of the branch instruction address and the upper 29 bits of the PC relative value. The method of adding the upper 29 bits of the address of the branch instruction to the upper 29 bits of the PC relative value is a normal binary operation.
The addition result calculated as described above becomes the address of the branch destination instruction. That is, the lower 3 bits of the addition result are set in the lower PC 404, and the upper 29 bits of the addition result are set in the upper PC 403.

次に、最適化装置303、アセンブラ装置305、リンカ装置307が行う、PC相対値を求める演算、すなわち、分岐先命令のアドレスから分岐命令のアドレスを減算方法について説明する。減算は、加算と同様に上位29ビットと下位3ビットに分離して行う。最適化装置303の下位アドレス減算手段907、アセンブラ装置305の下位アドレス減算手段806、リンカ装置307の下位アドレス減算手段706は、分岐先命令のアドレスの下位3ビットから分岐命令のアドレスの下位3ビットを減算する。図28(b)は、本実施の形態に係る桁上りなし方式のアドレス演算による分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。図に示すように、下位3ビットの減算は通常の2進演算と異なり、3’b000,3’b010,3’b100を巡回する3進演算である。この演算では、桁借りは発生させない。   Next, an operation for obtaining the PC relative value performed by the optimization device 303, the assembler device 305, and the linker device 307, that is, a method of subtracting the branch instruction address from the branch destination instruction address will be described. Subtraction is performed by separating the upper 29 bits and the lower 3 bits as in the addition. The lower address subtracting means 907 of the optimizing device 303, the lower address subtracting means 806 of the assembler device 305, and the lower address subtracting means 706 of the linker device 307 are the lower 3 bits of the branch instruction address from the lower 3 bits of the branch destination instruction address. Is subtracted. FIG. 28B is a subtraction table showing a subtraction rule between the lower 3 bits of the address of the branch destination instruction and the lower 3 bits of the address of the branch instruction by the address operation of the no carry method according to the present embodiment. As shown in the figure, the subtraction of the lower 3 bits is a ternary operation that cycles through 3'b000, 3'b010, and 3'b100, unlike a normal binary operation. This operation does not cause borrowing.

最適化装置303の上位アドレス減算手段910と、アセンブラ装置305の上位アドレス減算手段809と、リンカ装置307の上位アドレス減算手段709は、分岐命令のアドレスの上位29ビットと分岐先命令の上位29ビットとを減算する。減算方法は通常の2進演算である。
以上により算出された下位3ビットの減算結果を下位3ビットとし、上位29ビットの減算結果を上位29ビットとした値がPC相対値となる。
The upper address subtracting means 910 of the optimizing device 303, the upper address subtracting means 809 of the assembler device 305, and the upper address subtracting means 709 of the linker device 307 are the upper 29 bits of the branch instruction address and the upper 29 bits of the branch destination instruction. And subtract. The subtraction method is a normal binary operation.
The value obtained by subtracting the lower 3 bits calculated as described above from the lower 3 bits and the upper 29 bits from the subtraction result from the upper 29 bits is the PC relative value.

図29は、本実施の形態に係る桁上りなし方式のアドレス演算により生成されたオブジェクトコードを示す。図29では、命令2406と命令2413のPC相対値が、図25のものと異なっている。命令2406のPC相対値の算出法について説明する。
下位アドレス減算手段706は、命令2401の下位3ビットアドレス3’b000から命令2406の下位3ビットアドレス3’b010を、図28(b)に示す減算表に従って減算し、下位減算結果3’b100を得る。
FIG. 29 shows an object code generated by address calculation using the no carry method according to the present embodiment. In FIG. 29, the PC relative values of the instruction 2406 and the instruction 2413 are different from those in FIG. A method for calculating the PC relative value of the instruction 2406 will be described.
The lower address subtraction means 706 subtracts the lower 3 bit address 3′b010 of the instruction 2406 from the lower 3 bit address 3′b000 of the instruction 2401 according to the subtraction table shown in FIG. obtain.

上位アドレス減算手段709は、命令2401の上位29ビットアドレス29’h00000000から命令2406の上位29ビットアドレス29’h00000001を減算し、上位減算結果29’h1fffffffを得る。
アドレス差算出手段711は、上位減算結果29’h1fffffffを上位29ビットとし、下位減算結果3’b100を下位3ビットとしたアドレス差32’h1ffffffcを算出する。
The upper address subtracting means 709 subtracts the upper 29-bit address 29′h00000001 of the instruction 2406 from the upper 29-bit address 29′h00000000 of the instruction 2401 to obtain an upper subtraction result 29′h1ffffffff.
The address difference calculation means 711 calculates an address difference 32′h1ffffffc with the upper subtraction result 29′h1fffffff as the upper 29 bits and the lower subtraction result 3′b100 as the lower 3 bits.

再配置情報解決手段713は、アドレス差32’h1ffffffcが下位13ビット13’h1ffcで表現できるので、13’h1ffcをPC相対値としてラベルを置換えることによって、命令2406が生成される。
プロセッサ309は、上述のようにして作成されたオブジェクトコードを実行する。プロセッサ309は、分岐命令を実行する際に、分岐命令中のPC相対値と、分岐命令のアドレスを指定するように補正した上位PC403及び下位PC404の値とを桁上りなし方式により加算する。
Since the address difference 32′h1ffffffc can be expressed by the lower 13 bits 13′h1ffc, the rearrangement information resolution unit 713 generates the instruction 2406 by replacing the label with 13′h1ffc as the PC relative value.
The processor 309 executes the object code created as described above. When executing the branch instruction, the processor 309 adds the PC relative value in the branch instruction and the values of the upper PC 403 and the lower PC 404 corrected so as to specify the address of the branch instruction by the no carry method.

プロセッサが図29に示すオブジェクトコード中の命令2406を実行する際には、下位PC演算器405は、補正した下位PC404の値3’b010と、PC相対値の下位3ビット3’b100とを加算して、加算値3’b000に下位PC404を更新し、上位PC演算器411は、補正した上位PC403の値29’h00000001と、PC相対値の上位29ビット29’h1fffffffとを加算して、加算値29’h00000000に上位PC403を更新する。   When the processor executes the instruction 2406 in the object code shown in FIG. 29, the lower PC calculator 405 adds the corrected value 3′b010 of the lower PC 404 and the lower 3 bits 3′b100 of the PC relative value. Then, the lower PC 404 is updated to the addition value 3′b000, and the upper PC computing unit 411 adds the corrected value 29′h00000001 of the upper PC 403 and the upper 29 bits 29′h1fffffff of the PC relative value to add. The upper PC 403 is updated to the value 29′h00000000.

以上のように、桁上りなし方式によるアドレス演算では、下位PC演算器から上位PC演算器に桁上り数又は桁借り数が送られないので、単純なハードウエアによりアドレス演算が実現できる。(第5の実施形態)
第5の実施形態は、絶対値方式による命令のアドレスの演算方法に関する。
絶対値方式では、命令のアドレスを上位29ビット、下位3ビットに分離して演算する点で、第1の実施形態の桁上がり方式と同じであるが、命令の下位3ビットアドレスの値を下位3ビットの演算結果とする点で、桁上がり方式と異なる。
As described above, in the address calculation based on the no carry method, the carry number or the borrow number is not sent from the lower PC calculator to the upper PC calculator, so that the address calculation can be realized by simple hardware. (Fifth embodiment)
The fifth embodiment relates to an instruction address calculation method using an absolute value method.
The absolute value method is the same as the carry method of the first embodiment in that the instruction address is divided into upper 29 bits and lower 3 bits for operation, but the lower 3 bit address value of the instruction is lower. It differs from the carry method in that it is a 3-bit operation result.

まず、プロセッサ309が行う、分岐命令のアドレスとPC相対値とを加算して分岐先命令のアドレスを求める方法について説明する。図5に示す下位PC演算器405は、分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとを加算する。図30(a)は、本実施の形態に係る絶対値方式のアドレス演算による分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。図に示すように、PC相対値の下位3ビットが、下位3ビットの加算結果となる。   First, a method performed by the processor 309 to obtain the address of the branch destination instruction by adding the address of the branch instruction and the PC relative value will be described. The lower PC calculator 405 shown in FIG. 5 adds the lower 3 bits of the branch instruction address and the lower 3 bits of the PC relative value. FIG. 30A is an addition table showing an addition rule for the lower 3 bits of the address of the branch instruction and the lower 3 bits of the PC relative value by the absolute value type address calculation according to the present embodiment. As shown in the figure, the lower 3 bits of the PC relative value become the addition result of the lower 3 bits.

図5に示す上位PC演算器411は、分岐命令のアドレスの上位29ビットとPC相対値の上位29ビットとを加算する。分岐命令のアドレスの上位29ビットとのPC相対値の上位29ビットとの加算方法は通常の2進演算である。
以上により算出された加算結果が分岐先命令のアドレスとなる。すなわち、加算結果の下位3ビットが下位PC404に設定され、加算結果の上位29ビットが上位PC403に設定される。
The upper PC calculator 411 shown in FIG. 5 adds the upper 29 bits of the branch instruction address and the upper 29 bits of the PC relative value. The method of adding the upper 29 bits of the address of the branch instruction to the upper 29 bits of the PC relative value is a normal binary operation.
The addition result calculated as described above becomes the address of the branch destination instruction. That is, the lower 3 bits of the addition result are set in the lower PC 404, and the upper 29 bits of the addition result are set in the upper PC 403.

次に、最適化装置303、アセンブラ装置305、リンカ装置307が行う、PC相対値を求める演算、すなわち、分岐先命令のアドレスから分岐命令のアドレスを減算する減算方法について説明する。減算は、加算と同様に上位29ビットと下位3ビットに分離して行う。最適化装置303の下位アドレス減算手段907、アセンブラ装置305の下位アドレス減算手段806、リンカ装置307の下位アドレス減算手段706は、分岐先命令のアドレスの下位3ビットから分岐命令のアドレスの下位3ビットを減算する。図30(b)は、本実施の形態に係る絶対値方式のアドレス演算による分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。図に示すように、分岐先命令のアドレスの下位3ビットが、下位3ビットの加算結果となる。   Next, an operation for obtaining a PC relative value performed by the optimization device 303, the assembler device 305, and the linker device 307, that is, a subtraction method for subtracting the branch instruction address from the branch destination instruction address will be described. Subtraction is performed by separating the upper 29 bits and the lower 3 bits as in the addition. The lower address subtracting means 907 of the optimizing device 303, the lower address subtracting means 806 of the assembler device 305, and the lower address subtracting means 706 of the linker device 307 are the lower 3 bits of the branch instruction address from the lower 3 bits of the branch destination instruction address. Is subtracted. FIG. 30B is a subtraction table showing a subtraction rule between the lower 3 bits of the address of the branch destination instruction and the lower 3 bits of the address of the branch instruction by the absolute value type address calculation according to the present embodiment. As shown in the figure, the lower 3 bits of the address of the branch destination instruction become the addition result of the lower 3 bits.

最適化装置303の上位アドレス減算手段910と、アセンブラ装置305の上位アドレス減算手段809と、リンカ装置307の上位アドレス減算手段709は、分岐命令のアドレスの上位29ビットと分岐先命令の上位29ビットとを減算する。減算方法は通常の2進演算である。
以上により算出された下位3ビットの減算結果を下位3ビットとし、上位29ビットの減算結果を上位29ビットとした値がPC相対値となる。
The upper address subtracting means 910 of the optimizing device 303, the upper address subtracting means 809 of the assembler device 305, and the upper address subtracting means 709 of the linker device 307 are the upper 29 bits of the branch instruction address and the upper 29 bits of the branch destination instruction. And subtract. The subtraction method is a normal binary operation.
The value obtained by subtracting the lower 3 bits calculated as described above from the lower 3 bits and the upper 29 bits from the subtraction result from the upper 29 bits is the PC relative value.

図31は、本実施の形態に係る絶対値方式のアドレス演算により生成されたオブジェクトコードを示す。図31では、命令2606と命令2613のPC相対値が、図25のものと異なっている。命令2606のPC相対値の算出法について説明する。
下位アドレス減算手段706は、命令2601の下位3ビットアドレス3’b000から命令2606の下位3ビットアドレス3’b010を、図30(b)に示す減算表に従って減算し、下位減算結果3’b000を得る。
FIG. 31 shows an object code generated by an absolute value type address calculation according to the present embodiment. In FIG. 31, the PC relative values of the instruction 2606 and the instruction 2613 are different from those in FIG. A method for calculating the PC relative value of the instruction 2606 will be described.
The lower address subtraction means 706 subtracts the lower 3 bit address 3'b010 of the instruction 2606 from the lower 3 bit address 3'b000 of the instruction 2601 according to the subtraction table shown in FIG. obtain.

上位アドレス減算手段709は、命令2601の上位29ビットアドレス29’h00000000から命令2606の上位29ビットアドレス29’h00000001を減算し、上位減算結果29’h1fffffffを得る。
アドレス差算出手段711は、上位減算結果29’h1fffffffを上位29ビットとし、下位減算結果3’b000を下位3ビットとしたアドレス差32’h1ffffff8を算出する。
The upper address subtracting means 709 subtracts the upper 29-bit address 29′h00000001 of the instruction 2606 from the upper 29-bit address 29′h00000000 of the instruction 2601 to obtain the upper subtraction result 29′h1ffffffff.
The address difference calculation means 711 calculates an address difference 32′h1ffffff8 with the upper subtraction result 29′h1fffffff as the upper 29 bits and the lower subtraction result 3′b000 as the lower 3 bits.

再配置情報解決手段713は、アドレス差32’h1ffffff8が下位13ビット13’h1ff8で表現できるので、13’h1ff8をPC相対値としてラベルを置換えることによって、命令2606が生成される。
プロセッサ309は、上述のようにして作成されたオブジェクトコードを実行する。プロセッサ309は、分岐命令を実行する際に、分岐命令中のPC相対値と、分岐命令のアドレスを指定するように補正した上位PC403及び下位PC404の値とを絶対値方式により加算する。
Since the address difference 32′h1ffffff8 can be expressed by the lower 13 bits 13′h1ff8, the rearrangement information resolution unit 713 generates the instruction 2606 by replacing the label with 13′h1ff8 as the PC relative value.
The processor 309 executes the object code created as described above. When executing the branch instruction, the processor 309 adds the PC relative value in the branch instruction and the values of the upper PC 403 and the lower PC 404 corrected so as to specify the address of the branch instruction by an absolute value method.

プロセッサが図31に示すオブジェクトコード中の命令2606を実行する際には、下位PC演算器405は、補正した下位PC404の値3’b010と、PC相対値の下位3ビット3’b000とを加算して、加算値3’b000に下位PC404を更新し、上位PC演算器411は、補正した上位PC403の値29’h00000001と、PC相対値の上位29ビット29’h1fffffffとを加算して、加算値29’h00000000に上位PC403を更新する。   When the processor executes the instruction 2606 in the object code shown in FIG. 31, the lower PC calculator 405 adds the corrected value 3′b010 of the lower PC 404 and the lower 3 bits 3′b000 of the PC relative value. Then, the lower PC 404 is updated to the addition value 3′b000, and the upper PC computing unit 411 adds the corrected value 29′h00000001 of the upper PC 403 and the upper 29 bits 29′h1fffffff of the PC relative value to add. The upper PC 403 is updated to the value 29′h00000000.

以上のように絶対値方式によるアドレス演算では、下位ビットの演算が不要なので、演算速度を高めることができる。(第6の実施形態)
第6の実施形態は、リニア方式による命令のアドレスの演算方法に関する。
リニア方式では、他の実施形態と異なり、命令のアドレスを上位29ビットと、下位3ビットに分離せすに計算する。
As described above, in the address calculation based on the absolute value method, the calculation of the lower bits is unnecessary, so that the calculation speed can be increased. (Sixth embodiment)
The sixth embodiment relates to an instruction address calculation method using a linear method.
In the linear method, unlike the other embodiments, the instruction address is calculated by separating the upper 29 bits and the lower 3 bits.

まず、プロセッサが行う、分岐命令のアドレスとPC相対値とを加算して分岐先命令のアドレスを求める方法について説明する。桁上り方式のプロセッサは、上位29ビットのアドレスを演算する上位PC演算器と下位3ビットのアドレスを演算する下位PC演算器を備えていたが、リニア方式のプロセッサは、32ビットのアドレスを演算する1つのPC演算器を備えている。リニア方式のPC演算器は、32ビットの分岐命令のアドレスと32ビットのPC相対値とを加算する。加算方法は通常の2進演算である。   First, a method performed by the processor to obtain the address of the branch destination instruction by adding the address of the branch instruction and the PC relative value will be described. The carry type processor had a high-order PC computing unit that computes an upper 29-bit address and a low-order PC computing unit that computes a low-order 3 bit address, whereas a linear type processor computes a 32-bit address. One PC arithmetic unit is provided. The linear PC calculator adds the address of the 32-bit branch instruction and the 32-bit PC relative value. The addition method is a normal binary operation.

以上により算出された加算結果が分岐先命令のアドレスとなる。すなわち、加算結果の下位3ビットが下位PC404に設定され、加算結果の上位29ビットが上位PC403に設定される。
次に、最適化装置303、アセンブラ装置305、リンカ装置307が行う、PC相対値を求める演算、すなわち、分岐先命令のアドレスから分岐命令のアドレスを減算方法について説明する。リニア方式の最適化装置303、アセンブラ装置305、リンカ装置307は、リニア方式のプロセッサと同様に、32ビットのアドレスを演算する1つのアドレス減算手段を備えている。リニア方式のアドレス減算手段は、32ビットの分岐先命令のアドレスから32ビットの分岐命令のアドレスを減算する。減算方法は通常の2進演算である。
The addition result calculated as described above becomes the address of the branch destination instruction. That is, the lower 3 bits of the addition result are set in the lower PC 404, and the upper 29 bits of the addition result are set in the upper PC 403.
Next, an operation for obtaining the PC relative value performed by the optimization device 303, the assembler device 305, and the linker device 307, that is, a method of subtracting the branch instruction address from the branch destination instruction address will be described. The linear optimization device 303, the assembler device 305, and the linker device 307 are provided with one address subtracting means for calculating a 32-bit address, like the linear processor. The linear address subtracting means subtracts the address of the 32-bit branch instruction from the address of the 32-bit branch destination instruction. The subtraction method is a normal binary operation.

以上により算出された減算結果がPC相対値となる。
図32は、本実施の形態に係るリニア方式のアドレス演算を用いて生成されたオブジェクトコードを示す。図32では、命令2706と命令2713のPC相対値が、図25のものと異なっていることが示されている。命令2706のPC相対値の算出法について説明する。
The subtraction result calculated as described above becomes the PC relative value.
FIG. 32 shows an object code generated using the linear address calculation according to the present embodiment. FIG. 32 shows that the PC relative values of the instruction 2706 and the instruction 2713 are different from those in FIG. A method for calculating the PC relative value of the instruction 2706 will be described.

リニア方式のアドレス減算手段は、命令2701の32ビットアドレス32’h00000000から命令2706の32ビットアドレス32’h0000000aを減算し、アドレス差32’hfffffff6を得る。
再配置情報解決手段713は、アドレス差32’hfffffff6が下位13ビット13’h1ff6で表現できるので、13’h1ff6をPC相対値としてラベルを置換えることによって、命令2706が生成される。
The linear address subtracting means subtracts the 32-bit address 32′h0000000a of the instruction 2706 from the 32-bit address 32′h00000000 of the instruction 2701 to obtain an address difference 32′hfffffff6.
Since the relocation information resolution means 713 can express the address difference 32′hfffffff6 with the lower 13 bits 13′h1ff6, the instruction 2706 is generated by replacing the label with 13′h1ff6 as the PC relative value.

プロセッサ309は、上述のようにして作成されたオブジェクトコードを実行する。プロセッサ309は、分岐命令を実行する際に、分岐命令中のPC相対値と、分岐命令のアドレスを指定するように補正した上位PC403及び下位PC404の値とをリニア方式により加算する。
プロセッサが図32に示すオブジェクトコード中の命令2706を実行する際には、本実施の形態のPC演算器は、補正した上位PC403の値を上位29ビットとし、補正した下位PC404の値を下位3ビットとした32ビットのPCの値32’h0000000aと、PC相対値32’hfffffff6とを加算して、加算結果32’h00000000を得る。そして、PC演算器は、加算値の下位3ビット3’b000に下位PC404を更新し、加算値の上位29ビット29’h00000000に上位PC403を更新する。
The processor 309 executes the object code created as described above. When executing the branch instruction, the processor 309 adds the PC relative value in the branch instruction and the values of the upper PC 403 and the lower PC 404 corrected so as to specify the address of the branch instruction by a linear method.
When the processor executes the instruction 2706 in the object code shown in FIG. 32, the PC computing unit of the present embodiment sets the corrected value of the upper PC 403 as the upper 29 bits and sets the corrected value of the lower PC 404 as the lower 3 The 32-bit PC value 32′h0000000a, which is a bit, is added to the PC relative value 32′hfffffff6 to obtain an addition result 32′h00000000. Then, the PC computing unit updates the lower PC 404 to the lower 3 bits 3′b000 of the addition value, and updates the upper PC 403 to the upper 29 bits 29′h00000000 of the addition value.

以上のように、リニア方式によるアドレス演算では、PC演算器として通常の演算器を用いることができるので、プロセッサの構成を簡易にすることができる。(第7の実施形態)
第7の実施形態は、PC加算命令及びPC減算命令を解釈、実行するプロセッサ及びこれらの命令を生成するコンパイラ装置に関する。
As described above, in the address calculation by the linear method, a normal arithmetic unit can be used as the PC arithmetic unit, so that the configuration of the processor can be simplified. (Seventh embodiment)
The seventh embodiment relates to a processor that interprets and executes a PC addition instruction and a PC subtraction instruction, and a compiler apparatus that generates these instructions.

図33は、本実施の形態に係るプロセッサの構成図である。本実施の形態のプロセッサが図5に示す第1の実施形態に係るプロセッサと異なる点は、第2下位PC演算器2800と第2上位PC演算器2802が付加され、第1命令デコーダ2801aと、第2命令デコーダ2801bと、第2命令デコーダ2801cの機能が追加されたところである。
命令デコーダ2801aと、2801bと、2801cは、通常の命令に加えて、PC加算命令とPC減算命令も解読する。図34(a)は、PC加算命令のニーモニックとオペレーションの対応を示す。同図に示すように、PC加算命令は、PC相対値dispとレジスタに格納されているPCの値とを加算し、同一のレジスタに結果を格納するものである。図34(b)は、PC減算命令のニーモニックとオペレーションの対応を示す。PC減算命令は、レジスタに格納されているPCの値からPC相対値dispを減算し、同一のレジスタに結果を格納するものである。
FIG. 33 is a block diagram of the processor according to the present embodiment. The processor of this embodiment is different from the processor according to the first embodiment shown in FIG. 5 in that a second lower PC calculator 2800 and a second upper PC calculator 2802 are added, and a first instruction decoder 2801a The functions of the second instruction decoder 2801b and the second instruction decoder 2801c have been added.
The instruction decoders 2801a, 2801b, and 2801c decode a PC addition instruction and a PC subtraction instruction in addition to a normal instruction. FIG. 34 (a) shows the correspondence between mnemonics of PC addition instructions and operations. As shown in the figure, the PC addition instruction adds the PC relative value disp and the PC value stored in the register, and stores the result in the same register. FIG. 34 (b) shows the correspondence between mnemonics of PC subtraction instructions and operations. The PC subtraction instruction subtracts the PC relative value disp from the PC value stored in the register and stores the result in the same register.

第2下位PC演算器2800と第2上位PC演算器2802は、第1の実施形態における下位PC演算器405及び上位PC演算器411と同様の演算規則に従って、上記のPC加算命令とPC減算命令を実行する。
図35は、本実施の形態に係るコンパイラ装置の構成図である。
ソースコード2901はC言語等の高級言語で記述されたプログラムである。
The second lower PC calculator 2800 and the second upper PC calculator 2802 are arranged in accordance with the same operation rules as those of the lower PC calculator 405 and the upper PC calculator 411 in the first embodiment. Execute.
FIG. 35 is a configuration diagram of the compiler apparatus according to the present embodiment.
The source code 2901 is a program written in a high-level language such as C language.

中間コード変換部2902は、ソースコード2901をコンパイラ装置の内部表現である中間コード2903に変換する。中間コード変換部2902は公知の技術であるため、詳細な説明を省略する。
PC値加算命令変換部2904は、中間コード2903の中でPCの値と変数とを加算する中間コードを図33に示したPC加算命令のアセンブラコード2906に変換する。
The intermediate code conversion unit 2902 converts the source code 2901 into intermediate code 2903 that is an internal representation of the compiler apparatus. Since the intermediate code conversion unit 2902 is a known technique, a detailed description thereof is omitted.
The PC value addition instruction conversion unit 2904 converts the intermediate code for adding the PC value and the variable in the intermediate code 2903 into the assembler code 2906 of the PC addition instruction shown in FIG.

命令変換部2905は、その他の中間コードを対応するアセンブラコード2906に変換する。命令変換部2905は公知の技術であるため、詳細な説明を省略する。
次に、コンパイラ装置の動作を、具体例を用いて説明する。
図36は、コンパイラ装置の動作手順を示すフローチャートである。
まず、コンパイラ装置にソースコードが入力される。図37は、C言語で記述されたソースコードを示す。図中、外部関数g1、g2、g3、g4は宣言され、関数fはint型の変数iを受け取る関数として定義されている。この関数fは、iの値が1ならばポインタfpに関数g1のアドレスを代入し、iの値が2ならばポインタfpに関数g2のアドレスを代入し、iの値が3ならばポインタfpに関数g3のアドレスを代入し、iが以上の値でなければポインタfpに関数g4のアドレスを代入し、最後にfpの指す関数を呼び出すコードからなる(ステップS3600)。
The instruction conversion unit 2905 converts other intermediate codes into corresponding assembler codes 2906. Since the instruction conversion unit 2905 is a known technique, a detailed description thereof is omitted.
Next, the operation of the compiler apparatus will be described using a specific example.
FIG. 36 is a flowchart showing the operation procedure of the compiler apparatus.
First, source code is input to the compiler apparatus. FIG. 37 shows source code written in C language. In the figure, external functions g1, g2, g3, and g4 are declared, and a function f is defined as a function that receives an int type variable i. The function f substitutes the address of the function g1 for the pointer fp if the value of i is 1, substitutes the address of the function g2 for the pointer fp if the value of i is 2, and the pointer fp if the value of i is 3. The address of the function g3 is substituted for, and if i is not the above value, the address of the function g4 is substituted for the pointer fp, and finally the function indicated by fp is called (step S3600).

次に、中間コード変換部2902は、ソースコードを中間コードに変換する。その際に、特に、中間コード変換部2902は、外部関数へのポインタをポインタ変数に代入するソースコードを、関数の先頭のアドレスと外部関数の先頭のアドレスとの差分値と、関数の先頭のアドレスが格納された一時変数とを加算して、その結果をポインタ変数に代入する中間コードに変換する。   Next, the intermediate code conversion unit 2902 converts the source code into an intermediate code. At that time, in particular, the intermediate code conversion unit 2902 assigns the source code for assigning the pointer to the external function to the pointer variable, the difference value between the top address of the function and the top address of the external function, and the top of the function. The temporary variable in which the address is stored is added, and the result is converted into an intermediate code that is assigned to the pointer variable.

図38は、図37のソースプログラムが変換された中間コードを示す。図中、中間コード3201は、関数の先頭のラベルfを有し、一時変数tmpに現在のPCの値、すなわち関数fの先頭アドレスを代入する中間コードである。中間コード3202は、変数iが1と等しくないかを判定する中間コードである。中間コード3203は、中間コード3202の判定が真の場合、すなわちiが1と等しくない場合には、ラベルL1へ分岐する中間コードである。中間コード3204は、iと1が等しい場合に実行されるもので、関数g1の先頭アドレスから関数fの先頭のアドレスを減算した差分値と関数fの先頭アドレスが代入された一時変数tmpとを加算し、その結果を変数fpに代入する中間コードである。中間コード3205は、ラベルLへ分岐する中間コードである。   FIG. 38 shows intermediate code obtained by converting the source program of FIG. In the figure, an intermediate code 3201 is an intermediate code having a label f at the head of a function and substituting the current PC value, that is, the head address of the function f into a temporary variable tmp. The intermediate code 3202 is an intermediate code for determining whether the variable i is not equal to 1. The intermediate code 3203 is an intermediate code that branches to the label L1 when the determination of the intermediate code 3202 is true, that is, when i is not equal to 1. The intermediate code 3204 is executed when i is equal to 1, and a difference value obtained by subtracting the head address of the function f from the head address of the function g1 and a temporary variable tmp to which the head address of the function f is substituted are obtained. This is an intermediate code that adds and assigns the result to the variable fp. The intermediate code 3205 is an intermediate code that branches to the label L.

中間コード3206はラベルL1を有し、変数iが2と等しくないかを判定する中間コードである。中間コード3207は、中間コード3206の判定が真の場合、すなわち、iが2と等しくない場合には、ラベルL2へ分岐する中間コードである。中間コード3208は、iと2が等しい場合に実行され、関数g2の先頭アドレスから関数fの先頭のアドレスを減算した差分値と関数fの先頭アドレスが代入された一時変数tmpとを加算し、その結果を変数fpに代入する中間コードである。中間コード3209は、ラベルLへ分岐する中間コードである。   The intermediate code 3206 has the label L1 and is an intermediate code for determining whether the variable i is not equal to 2. The intermediate code 3207 is an intermediate code that branches to the label L2 when the determination of the intermediate code 3206 is true, that is, when i is not equal to 2. The intermediate code 3208 is executed when i and 2 are equal, and adds a difference value obtained by subtracting the head address of the function f from the head address of the function g2 and a temporary variable tmp into which the head address of the function f is substituted, This is an intermediate code that assigns the result to the variable fp. The intermediate code 3209 is an intermediate code that branches to the label L.

中間コード3210はラベルL2を有し、変数iが3と等しくないかを判定する中間コードである。中間コード3211は、中間コード3210の判定が真の場合、すなわち、iが3と等しくない場合には、ラベルL3へ分岐する中間コードである。中間コード3212は、iと3が等しい場合に実行され、関数g3の先頭アドレスから関数fの先頭のアドレスを減算した差分値と関数fの先頭アドレスが代入された一時変数tmpとを加算し、その結果を変数fpに代入する中間コードである。中間コード3213は、ラベルLへ分岐する中間コードである。   The intermediate code 3210 has the label L2 and is an intermediate code for determining whether the variable i is not equal to 3. The intermediate code 3211 is an intermediate code that branches to the label L3 when the determination of the intermediate code 3210 is true, that is, when i is not equal to 3. The intermediate code 3212 is executed when i is equal to 3, and adds a difference value obtained by subtracting the start address of the function f from the start address of the function g3 and a temporary variable tmp into which the start address of the function f is assigned, This is an intermediate code that assigns the result to the variable fp. The intermediate code 3213 is an intermediate code that branches to the label L.

中間コード3214は、ラベルL3を有し、関数g4の先頭アドレスから関数fの先頭のアドレスを減算した差分値と関数fの先頭アドレスが代入された一時変数tmpを加算し、その結果を変数fpに代入する中間コードである。中間コード3215は、ラベルLを有し、変数fpが指す関数を呼び出す中間コードである。
以上のように、図38に示す中間コードは、関数g1、g2、g3、g4の絶対アドレスを変数fpに代入するのではなく、関数fの先頭アドレスと関数g1、g2、g3、g4の先頭アドレスとの差分値を、関数fの先頭アドレスとを加算して、変数fpに代入するものである(ステップS3601〜S3603)。
The intermediate code 3214 has a label L3, adds a difference value obtained by subtracting the start address of the function f from the start address of the function g4, and a temporary variable tmp into which the start address of the function f is assigned, and the result is added to the variable fp. This is the intermediate code assigned to. The intermediate code 3215 is an intermediate code having a label L and calling a function indicated by the variable fp.
As described above, the intermediate code shown in FIG. 38 does not assign the absolute addresses of the functions g1, g2, g3, and g4 to the variable fp, but the beginning address of the function f and the beginnings of the functions g1, g2, g3, and g4. The difference value from the address is added to the head address of the function f and substituted into the variable fp (steps S3601 to S3603).

次に、PC値加算命令変換部2904及び中間コードをアセンブラコードに変換する。PC値加算命令変換部2904は、PCの値とPC相対値とを加算する中間コードを探し、その中間コードを第2下位PC演算器2800と第2上位PC演算器2802を使用するアセンブラコードに変換する。命令変換部2905は、その他の中間コードをアセンブラコードに変換する。   Next, the PC value addition instruction conversion unit 2904 and the intermediate code are converted into an assembler code. The PC value addition instruction conversion unit 2904 searches for an intermediate code that adds the PC value and the PC relative value, and converts the intermediate code into an assembler code that uses the second lower PC calculator 2800 and the second upper PC calculator 2802. Convert. The instruction conversion unit 2905 converts other intermediate code into assembler code.

PC値加算命令変換部2904は、図38中の中間コード3204が有する被演算子tmpが中間コード3201によりPCの値が転送されたものであり、演算子+はPCの値とPC相対値の加算であることをつきとめ、中間コード3204を第2下位PC演算器2800と第2上位PC演算器2802を使用して加算を行うアセンブラコードaddpcに変換する。PC値加算命令変換部2904は、中間コード3208、3212、3214に対しても同様にしてアセンブラコードaddpcに変換する。図38中のその他の中間コードは命令変換部2905によって変換される。   The PC value addition instruction conversion unit 2904 is obtained by transferring the PC value from the operand tmp of the intermediate code 3204 in FIG. 38 using the intermediate code 3201, and the operator + is the PC value and the PC relative value. The intermediate code 3204 is converted into an assembler code addpc for performing addition using the second lower PC calculator 2800 and the second upper PC calculator 2802. The PC value addition instruction conversion unit 2904 similarly converts the intermediate codes 3208, 3212, and 3214 into assembler code addpc. Other intermediate codes in FIG. 38 are converted by the instruction conversion unit 2905.

図39は、図38の中間コードが変換されたアセンブラコードを示す。図中、アセンブラコード3301は、関数の先頭のラベルfを有し、レジスタr1にPCの値を転送する命令である。アセンブラコード3302は、定数1とレジスタr0の値が等しくないか判定する命令である。アセンブラコード3303は、命令3302による判定が真の場合には、ラベルL1へ分岐する命令である。アセンブラコード3304は、関数g1の先頭アドレスと関数fの先頭のアドレスの差分値であるPC相対値とレジスタr1に格納されたfの先頭アドレスであるPCの値とを第2下位PC演算器2800と第2上位PC演算器2802により加算し、その結果をレジスタr1に転送する命令である。アセンブラコード3305は、ラベルLへ分岐する命令である。   FIG. 39 shows an assembler code obtained by converting the intermediate code shown in FIG. In the figure, an assembler code 3301 is an instruction having a label f at the head of the function and transferring the PC value to the register r1. The assembler code 3302 is an instruction for determining whether the value of the constant 1 and the register r0 are not equal. The assembler code 3303 is an instruction that branches to the label L1 when the determination by the instruction 3302 is true. The assembler code 3304 displays a PC relative value that is a difference value between the start address of the function g1 and the start address of the function f and a PC value that is the start address of f stored in the register r1 as a second lower-order PC computing unit 2800. Are added by the second higher-order PC computing unit 2802 and the result is transferred to the register r1. The assembler code 3305 is an instruction that branches to the label L.

アセンブラコード3306は、ラベルL1を有し、定数2とレジスタr0の値が等しくないか判定する命令である。アセンブラコード3307は、命令3306の判定が真の場合には、ラベルL2へ分岐する命令である。アセンブラコード3308は、関数g2の先頭アドレスと関数fの先頭のアドレスとの差分値であるPC相対値とレジスタr1に格納されたfの先頭アドレスであるPCの値とを第2下位PC演算器2800と第2上位PC演算器2802により加算し、その結果をレジスタr1に転送する命令である。アセンブラコード3309は、ラベルLへ分岐する命令である。   The assembler code 3306 is an instruction having a label L1 and determining whether the value of the constant 2 and the register r0 are not equal. The assembler code 3307 is an instruction that branches to the label L2 when the determination of the instruction 3306 is true. The assembler code 3308 is a second lower-order PC computing unit that calculates the PC relative value, which is the difference between the start address of the function g2 and the start address of the function f, and the PC value, which is the start address of f stored in the register r1. This is an instruction to add 2800 and the second upper PC calculator 2802 and transfer the result to the register r1. The assembler code 3309 is an instruction that branches to the label L.

アセンブラコード3310は、ラベルL2を有し、定数3とレジスタr0の値が等しくないか判定する命令である。アセンブラコード3311は、命令3310の判定が真の場合には、ラベルL3へ分岐する命令である。アセンブラコード3312は、関数g3の先頭アドレスと関数fの先頭のアドレスとの差分値であるPC相対値とレジスタr1に格納されたfの先頭アドレスであるPCの値とを第2下位PC演算器2800と第2上位PC演算器2802により加算し、その結果をレジスタr1に転送する命令である。アセンブラコード3313は、ラベルLへ分岐する命令である。   The assembler code 3310 is an instruction having a label L2 and determining whether the value of the constant 3 and the register r0 are not equal. The assembler code 3311 is an instruction that branches to the label L3 when the determination of the instruction 3310 is true. The assembler code 3312 is a second lower-order PC computing unit that calculates the PC relative value that is the difference between the start address of the function g3 and the start address of the function f and the PC value that is the start address of f stored in the register r1. This is an instruction to add 2800 and the second upper PC calculator 2802 and transfer the result to the register r1. The assembler code 3313 is an instruction that branches to the label L.

アセンブラコード3314はラベルL3を有し、関数g4の先頭アドレスと関数fの先頭のアドレスとの差分値であるPC相対値とレジスタr1に格納されたfの先頭アドレスであるPCの値とを第2下位PC演算器2800と第2上位PC演算器2802により加算し、その結果をレジスタr1に転送する命令である。アセンブラコード3315は、ラベルLを有し、r1が指す関数を呼び出す命令である。アセンブラコード3316は関数を終了する命令である。   The assembler code 3314 has a label L3, and stores the PC relative value, which is the difference between the start address of the function g4 and the start address of the function f, and the PC value, which is the start address of f stored in the register r1. This instruction is added by the second lower PC calculator 2800 and the second upper PC calculator 2802 and the result is transferred to the register r1. The assembler code 3315 has a label L and is an instruction for calling a function indicated by r1. Assembler code 3316 is an instruction to end the function.

以上説明してきたように、本実施の形態のコンパイラ装置は、関数f中に外部関数gへのポインタをポインタ変数に代入するソースコードがある場合、外部関数gへのアドレスをレジスタr1へ転送する命令(movr1、g)を生成するのではなく、関数fのアドレスと外部関数gのアドレスとの差分値(g−f)と、レジスタr1に格納された関数fのアドレスとを加算して、その結果をレジスタr1へ転送する命令(addPC g−f r1)を生成する。絶対アドレスg1よりもPC相対値g−fの方が値が小さいので、addpc命令を用いることによって、コードサイズを縮小することができる。また、実行時にプログラムのメモリ上のアドレスが決定されるPICコードにおいては、絶対アドレスを避けたコード表現が要求され、このPC相対値を用いた演算命令が必要不可欠である。   As described above, the compiler apparatus according to the present embodiment transfers the address to the external function g to the register r1 when there is source code for substituting the pointer to the external function g into the pointer variable in the function f. Rather than generating the instruction (movr1, g), the difference value (g−f) between the address of the function f and the address of the external function g is added to the address of the function f stored in the register r1, An instruction (addPC g-f r1) for transferring the result to the register r1 is generated. Since the PC relative value g−f is smaller than the absolute address g1, the code size can be reduced by using the addpc instruction. Further, in the PIC code in which the address on the memory of the program is determined at the time of execution, a code expression that avoids the absolute address is required, and an arithmetic instruction using this PC relative value is indispensable.

本実施の形態のコンパイラ装置が出力したアセンブラコードは、第1の実施形態と同様に、最適化装置303、アセンブラ装置305、リンカ装置307によってプロセッサが実行するオブジェクトコードに変換される。プロセッサは、生成されたオブジェクトコードに含まれるPC加算命令addPC g−f r1を第2下位PC演算器2800と第2上位PC演算器2802によって実行する。すなわち、第2下位PC演算器2800は、定数値g−fの下位3ビットとレジスタr1に格納された数値の下位3ビットを加算し、桁上りがあれば桁上り数を第2上位PC演算器2802に送る。第2上位PC演算器2802は、定数値g−fの上位29ビットとレジスタr1に格納された数値の上位29ビットとを加算し、第2下位PC演算器2800からの桁上りがあれば桁上り数をも加算する。第2下位PC演算器2800による加算結果を下位3ビットとし、第2上位PC演算器2802による加算結果を上位29ビットとした値がレジスタr1に格納される。   The assembler code output by the compiler apparatus according to the present embodiment is converted into object code executed by the processor by the optimization apparatus 303, the assembler apparatus 305, and the linker apparatus 307, as in the first embodiment. The processor executes the PC addition instruction addPC g-f r1 included in the generated object code by the second lower PC calculator 2800 and the second upper PC calculator 2802. That is, the second lower PC calculator 2800 adds the lower 3 bits of the constant value g−f and the lower 3 bits of the numerical value stored in the register r1, and if there is a carry, the carry number is calculated by the second upper PC calculation. Send to vessel 2802. The second upper PC calculator 2802 adds the upper 29 bits of the constant value g−f and the upper 29 bits of the numerical value stored in the register r1, and if there is a carry from the second lower PC calculator 2800, the digit. Also add the number of uplinks. The value obtained by setting the addition result by the second lower PC calculator 2800 as the lower 3 bits and the addition result by the second upper PC calculator 2802 as the upper 29 bits is stored in the register r1.

なお、図35に示した命令は定数値とレジスタとの加減算であったが、これに限定するものでなく、レジスタ間の加減算、PCとレジスタの間の加減算とすることもできる。
また、第2下位PC演算器2800と第2上位PC演算器2802の演算方法は、第1の実施形態の桁上り方式に限定するものでなく、オブジェクトコードを生成した最適化装置303、アセンブラ装置305、リンカ装置307で用いた方式と同一の方式をプロセッサが採用することとすれば、桁上りなし方式、リニア方式、絶対値方式のいずれを用いてもよい。(第8の実施形態)
第8の実施形態は、デバッガ装置及び逆アセンブラ装置に関する。
The instruction shown in FIG. 35 is addition / subtraction between a constant value and a register. However, the present invention is not limited to this, and addition / subtraction between registers and addition / subtraction between PCs and registers can also be performed.
The calculation method of the second lower PC calculator 2800 and the second upper PC calculator 2802 is not limited to the carry method of the first embodiment, and the optimization device 303 and the assembler device that generate the object code If the processor adopts the same method as that used in 305 and the linker device 307, any one of the no carry method, the linear method, and the absolute value method may be used. (Eighth embodiment)
The eighth embodiment relates to a debugger device and a disassembler device.

図40は、本実施の形態に係るデバッガ装置と逆アセンブラ装置の構成を示すブロック図である。
入力制御部4000は、オペレータからの入力を受け付け、入力された内容に応じて他の構成要素を制御する。
パケットアドレス特定部4001は、入力された命令のアドレスの上位29ビットを算出する。
FIG. 40 is a block diagram showing the configuration of the debugger device and the disassembler device according to this embodiment.
The input control unit 4000 receives an input from the operator and controls other components according to the input content.
The packet address specifying unit 4001 calculates the upper 29 bits of the address of the input instruction.

パケット内アドレス特定部4002は、入力された命令のアドレスの下位3ビットを算出する。
命令メモリ4004は、デバッグ及び逆アセンブルの対象となる命令を保持する。命令のアドレスは、第1の実施形態と同様であり、パケットアドレスを上位29ビットとし、パケット内アドレスを下位3ビットとする32ビット値である。図40では、図24に示した命令が格納されている状態が示されている。
The in-packet address specifying unit 4002 calculates the lower 3 bits of the address of the input instruction.
The instruction memory 4004 holds instructions to be debugged and disassembled. The instruction address is the same as in the first embodiment, and is a 32-bit value in which the packet address is the upper 29 bits and the in-packet address is the lower 3 bits. FIG. 40 shows a state in which the instruction shown in FIG. 24 is stored.

命令読み出し部4003は、パケットアドレス特定部4001で特定されたパケットアドレスで指定される命令パケットを命令メモリ4004から読み出す。
命令バッファ4005は、命令読み出し部4004が命令メモリ4004から読み出した命令パケットを格納する。
命令解読部4006は、パケット内アドレス特定部4002で特定されたパケット内アドレスをもつユニットを命令バッファ4005から取り出し、取り出したユニットを解読する。命令解読部4006は、ユニットが分岐命令である場合には、PC相対値4007を下位PC演算器4008及び上位PC演算器4009に送る。
The instruction reading unit 4003 reads an instruction packet specified by the packet address specified by the packet address specifying unit 4001 from the instruction memory 4004.
The instruction buffer 4005 stores the instruction packet read from the instruction memory 4004 by the instruction reading unit 4004.
The instruction decoding unit 4006 takes out the unit having the in-packet address specified by the in-packet address specifying unit 4002 from the instruction buffer 4005, and decodes the extracted unit. If the unit is a branch instruction, the instruction decoding unit 4006 sends the PC relative value 4007 to the lower PC calculator 4008 and the upper PC calculator 4009.

ラベルテーブル4011は、ラベル名とそのラベルの命令のアドレスの対応を保持するテーブルである。ラベルテーブル4011は、第1の実施形態で説明したアセンブラ装置が機械語コードを生成する際に、最適化コードから抽出することによって作成される。
図40では、アドレス32’h00000000とラベル名fが対応し、アドレス32’h00000008とラベル名L1が対応し、アドレス32’h12345680とラベル名L2とが対応していることが示されている。
The label table 4011 is a table that holds a correspondence between a label name and an instruction address of the label. The label table 4011 is created by extracting from the optimized code when the assembler apparatus described in the first embodiment generates a machine language code.
In FIG. 40, it is shown that the address 32′h00000000 corresponds to the label name f, the address 32′h00000008 corresponds to the label name L1, and the address 32′h1345680 corresponds to the label name L2.

表示部4012は、命令を逆アセンブルした結果を表示する。
命令置換部4013は、入力された置換後の命令を命令バッファ4005内のパケット内アドレス特定部4002で特定されたパケット内アドレスで指定されるユニットに書き込む。
命令書き込み部4014は、命令メモリ4004内のパケットアドレス特定部4001により特定されたパケットアドレスを有する命令パケットを命令バッファ4005内の置換後の命令パケットに書き換える。
The display unit 4012 displays the result of disassembling instructions.
The instruction replacement unit 4013 writes the input instruction after replacement into the unit specified by the in-packet address specified by the in-packet address specifying unit 4002 in the instruction buffer 4005.
The instruction writing unit 4014 rewrites the instruction packet having the packet address specified by the packet address specifying unit 4001 in the instruction memory 4004 to the replaced instruction packet in the instruction buffer 4005.

上位PC演算器4009は、パケットアドレス特定部4001で特定された命令のアドレスの上位29ビットとPC相対値4007の上位29ビットとを演算する。
下位PC演算器4008は、パケット内アドレス特定部4002で特定された命令のアドレスの下位3ビットとPC相対値4007の下位3ビットを演算する。これらのPC演算器の演算方法は、オブジェクトコード生成過程で採用した方式と同一とする。
The upper PC calculator 4009 calculates the upper 29 bits of the address of the instruction specified by the packet address specifying unit 4001 and the upper 29 bits of the PC relative value 4007.
The lower PC calculator 4008 calculates the lower 3 bits of the address of the instruction specified by the in-packet address specifying unit 4002 and the lower 3 bits of the PC relative value 4007. The calculation method of these PC calculators is the same as the method adopted in the object code generation process.

次に、本実施の形態の逆アセンブラ装置の動作を具体例を用いて説明する。
図41は、逆アセンブラ装置の動作手順を示すフローチャートである。
まず、入力制御部4000は、逆アセンブルを指示するコマンドと逆アセンブルする命令のアドレスの入力を受け付ける。具体例では、命令のアドレスとして32’h0000001aが入力されたとする。(ステップS4100)。
Next, the operation of the disassembler apparatus according to the present embodiment will be described using a specific example.
FIG. 41 is a flowchart showing the operation procedure of the disassembler apparatus.
First, the input control unit 4000 receives an input of a command for instructing disassembly and an address of an instruction to be disassembled. In a specific example, it is assumed that 32'h0000001a is input as an instruction address. (Step S4100).

次に、パケットアドレス特定部4001は、命令のアドレスの上位29ビットよりパケットアドレスを特定する。そして、命令読み出し部4003は、特定したパケットアドレスをもつ命令パケットを命令メモリ4004から取り出し、命令バッファ4005に格納する。具体例では、パケットアドレスとして29’h00000003が特定され、ld(r2),r0||bra13’h1fec||add r2,r3の命令列からなる命令パケットが命令バッファ4005に格納される(ステップS4101)。   Next, the packet address specifying unit 4001 specifies the packet address from the upper 29 bits of the instruction address. Then, the instruction reading unit 4003 takes out an instruction packet having the specified packet address from the instruction memory 4004 and stores it in the instruction buffer 4005. In the specific example, 29′h00000003 is specified as the packet address, and an instruction packet including an instruction sequence of ld (r2), r0 || bra13′h1fec || add r2, r3 is stored in the instruction buffer 4005 (step S4101). .

そして、パケット内アドレス特定部4003は、命令のアドレスの下位3ビットからパケット内アドレスを特定し、特定したパケット内アドレスをもつユニットを命令解読部4006に通知する。命令解読部4006は、通知されたユニットを命令バッファ4005から取り出す。具体例では、パケット内アドレスとして3’b010が特定され、命令バッファ4005中の第2ユニットの命令であるbra13’h1fecが命令解読部4006に入力される(ステップS4102)。   The in-packet address specifying unit 4003 specifies the in-packet address from the lower 3 bits of the instruction address, and notifies the instruction decoding unit 4006 of the unit having the specified in-packet address. The instruction decoding unit 4006 takes out the notified unit from the instruction buffer 4005. In the specific example, 3′b010 is specified as the in-packet address, and bra13′h1fec, which is the instruction of the second unit in the instruction buffer 4005, is input to the instruction decoding unit 4006 (step S4102).

命令解読部4006は、取り出した命令が分岐命令であるかを判定する。具体例では、取り出した命令bra13’h1fecは、分岐命令である(ステップS4103)。
分岐命令であれば、命令中に指定されるPC相対値4007と入力された命令のアドレス値とが演算される。すなわち、下位PC演算器4008は、入力された命令のパケット内アドレス値と、PC相対値4007の下位3ビットの値とを加算又は減算し、その演算結果をラベル検索部4010に送る。また、上位PC演算器4008は、入力された命令のパケットアドレス値と、PC相対値4007の上位29ビットの値と、場合により下位PC演算器4008からの桁上がり数又は桁借り数とを加算又は減算し、その演算結果をラベル検索部4010に送る。ラベル検索部4010は、下位ビット演算結果と上位ビット演算結果より、ラベルのアドレスを特定する。具体例では、入力された命令のアドレスである32’h0000001aとPC相対値13’h1fecとの演算によって、ラベルのアドレスが32’h00000008として特定される(ステップS4103、S4104)。
The instruction decoding unit 4006 determines whether the fetched instruction is a branch instruction. In the specific example, the fetched instruction bra13′h1fec is a branch instruction (step S4103).
If it is a branch instruction, the PC relative value 4007 specified in the instruction and the address value of the input instruction are calculated. That is, the low-order PC computing unit 4008 adds or subtracts the in-packet address value of the input instruction and the low-order 3 bits of the PC relative value 4007, and sends the calculation result to the label search unit 4010. The upper PC calculator 4008 adds the packet address value of the input instruction, the upper 29 bits of the PC relative value 4007, and the number of carry or borrow from the lower PC calculator 4008 as the case may be. Alternatively, subtraction is performed, and the calculation result is sent to the label search unit 4010. The label search unit 4010 specifies the label address from the lower bit operation result and the upper bit operation result. In the specific example, the label address is specified as 32′h00000008 by the calculation of the input instruction address 32′h0000001a and the PC relative value 13′h1fec (steps S4103 and S4104).

次に、ラベル検索部4010は、、ラベルテーブル4011を参照して上記特定したアドレスをもつラベル名を検索する。具体例では、アドレス32’h00000008に対応するラベル名がL1であることが検索される(ステップS4107)。
そして、表示部4012は、分岐命令のアセンブラ名と検索したラベル名を表示する。具体例では、分岐命令のアセンブラ名であるbraと検索したラベル名であるL1が表示される(ステップS4108)。
Next, the label search unit 4010 searches the label name having the specified address with reference to the label table 4011. In the specific example, it is searched that the label name corresponding to the address 32′h00000008 is L1 (step S4107).
The display unit 4012 displays the assembler name of the branch instruction and the searched label name. In the specific example, bra, which is the assembler name of the branch instruction, and L1, which is the searched label name, are displayed (step S4108).

また、命令解読部4006は、取り出した命令が分岐命令でない場合には、表示部4012を指示して、そのアセンブラ名を表示させる(ステップS4109)。
次に、本実施の形態のデバッガ装置の動作を具体例を用いて説明する。
図42は、デバッガ装置の動作手順を示すフローチャートである。
まず、入力制御部4000は、デバッグを指示するコマンドと置換される命令のアドレスと置換後の命令の入力を受け付ける。具体例では、置換される命令のアドレスとして32’h0000001aが入力され、置換後の命令として減算命令subr0,r1が入力されたとする(ステップS4200)。
If the fetched instruction is not a branch instruction, the instruction decoding unit 4006 instructs the display unit 4012 to display the assembler name (step S4109).
Next, the operation of the debugger apparatus according to the present embodiment will be described using a specific example.
FIG. 42 is a flowchart showing the operation procedure of the debugger apparatus.
First, the input control unit 4000 receives an address of an instruction to be replaced with a command instructing debugging and an input of the instruction after replacement. In a specific example, it is assumed that 32′h0000001a is input as the address of the instruction to be replaced, and subtraction instructions subr0, r1 are input as the instruction after replacement (step S4200).

次に、パケットアドレス特定部4001は、置換される命令のアドレスの上位29ビットよりパケットアドレスを特定する。そして、命令読み出し部4003は、特定されたパケットアドレスをもつ命令パケットを命令メモリ4004から取りだし、命令バッファ4005に格納する。具体例では、パケットアドレスとして29’h00000003が特定され、ld(r2),r0||bra13’h1fec||add r2,r3の命令列からなる命令パケットが命令バッファ4005に格納される(ステップS4201)。   Next, the packet address specifying unit 4001 specifies the packet address from the upper 29 bits of the address of the instruction to be replaced. Then, the instruction reading unit 4003 takes out an instruction packet having the specified packet address from the instruction memory 4004 and stores it in the instruction buffer 4005. In the specific example, 29′h00000003 is specified as the packet address, and an instruction packet including an instruction sequence of ld (r2), r0 || bra13′h1fec || add r2, r3 is stored in the instruction buffer 4005 (step S4201). .

次に、パケット内アドレス特定部4002は、置換される命令のアドレスの下位3ビットよりパケット内アドレスを特定する。具体例では、パケット内アドレスとして3’b010が特定される(ステップS4202)。
次に、命令置換部4013は、特定されたパケット内アドレスが3’b000なら、命令バッファ中の命令パケットの第1ユニットを入力された置換後の命令に置換し、特定されたパケット内アドレスが3’b010なら、命令バッファ中の命令パケットの第2ユニットを入力された置換後の命令に置換し、特定されたパケット内アドレスが3’b100なら、命令バッファ中の命令パケットの第3ユニットを入力された置換後の命令に置換する。具体例では、特定されたパケット内アドレスが3’b010なので、第2ユニットの命令bra13’h1fecが置換後の命令subr0,r1に置換される。その結果、命令バッファ4005内の命令パケットはld(r2),r0||subr0,r1||add r2,r3となる(ステップS4203〜S4207)。
Next, the in-packet address specifying unit 4002 specifies the in-packet address from the lower 3 bits of the address of the instruction to be replaced. In the specific example, 3′b010 is specified as the in-packet address (step S4202).
Next, if the specified in-packet address is 3′b000, the instruction replacement unit 4013 replaces the first unit of the instruction packet in the instruction buffer with the input instruction after replacement, and the specified in-packet address is If 3′b010, the second unit of the instruction packet in the instruction buffer is replaced with the input instruction after replacement. If the specified in-packet address is 3′b100, the third unit of the instruction packet in the instruction buffer is replaced. Replace with the replaced instruction entered. In the specific example, since the specified in-packet address is 3′b010, the instruction bra13′h1fec of the second unit is replaced with the replaced instructions subr0 and r1. As a result, the instruction packet in the instruction buffer 4005 becomes ld (r2), r0 || subr0, r1 || add r2, r3 (steps S4203 to S4207).

そして、命令書き込み部4014は、命令メモリ4004内のパケットアドレスで指定される命令パケットを命令バッファ4005に格納されている命令パケットに置き換える。
具体例では、命令メモリ4004内のパケットアドレス29’h00000003で指定される命令パケットld(r2),r0||bra13’h1fec||add r2,r3が命令バッファ4005内の命令パケットld(r2),r0||subr0,r1||add r2,r3に置換される。
Then, the instruction writing unit 4014 replaces the instruction packet specified by the packet address in the instruction memory 4004 with the instruction packet stored in the instruction buffer 4005.
In the specific example, the instruction packet ld (r2), r0 || bra13'h1fec || add r2, r3 specified by the packet address 29'h00000003 in the instruction memory 4004 is the instruction packet ld (r2), r0 || subr0, r1 || add is replaced by r2, r3.

以上のように、本実施の形態における逆アセンブラ装置は、第1の実施形態に係るプロセッサが実行する命令を逆アセンブルすることができる。また、逆アセンブルする命令が分岐命令である場合にも、PC相対値をそのまま表示するのでなく、上位PC演算器及び下位PC演算器によってラベルの置かれているアドレスを算出し、そのアドレスからラベルテーブルを参照することによって、適切なラベル名を表示できる。   As described above, the disassembler apparatus according to the present embodiment can disassemble instructions executed by the processor according to the first embodiment. Also, when the instruction to be disassembled is a branch instruction, the PC relative value is not displayed as it is, but the address where the label is placed is calculated by the upper PC calculator and the lower PC calculator, and the label is calculated from the address. By referring to the table, the appropriate label name can be displayed.

また、本実施の形態におけるデバッガ装置は、バイトアラインされた命令パケットの単位で命令をメモリから命令バッファに読み出して、命令バッファ中で命令を書き換えて、命令パケットの単位で命令をメモリへ書き込むので、バイトアラインされていない命令のデバッグに適している。
なお、本実施の形態における上位PC演算器及び下位PC演算器の演算方式は、第1の実施形態における桁上がり方式に限定するものでなく、分離方式、絶対値方式、リニア方式のいずれを用いてもよい。
In addition, the debugger apparatus according to the present embodiment reads an instruction from the memory into the instruction buffer in units of byte-aligned instruction packets, rewrites the instruction in the instruction buffer, and writes the instruction into the memory in units of instruction packet. Suitable for debugging byte-aligned instructions.
Note that the calculation method of the upper PC calculator and the lower PC calculator in this embodiment is not limited to the carry method in the first embodiment, and any one of a separation method, an absolute value method, and a linear method is used. May be.

以上、第1〜第8の実施形態に係るコンパイラ装置、最適化装置、アセンブラ装置、リンカ装置、プロセッサ、逆アセンブラ装置、デバッガ装置に関する実施の形態を説明したが、本発明は、これら実施の形態に限られないことは勿論である。(1)第1〜第6の実施形態において、アセンブラコード302、最適化コード304、リロケータブルコード306、オブジェクトコード308はマスクROM、フラッシュメモリ等の半導体集積メモリや、フロッピー(登録商標)ディスク、ハードディスク等の磁気記録媒体や、CD−ROM,DVD等の光ディスクに記録することもできる。(2)第7の実施形態において、アセンブラコード2906は、マスクROM、フラッシュメモリ等の半導体集積メモリや、フロッピー(登録商標)ディスク、ハードディスク等の磁気記録媒体や、CD−ROM,DVD等の光ディスクに記録することもできる。   The embodiments of the compiler device, the optimization device, the assembler device, the linker device, the processor, the disassembler device, and the debugger device according to the first to eighth embodiments have been described above, but the present invention is not limited to these embodiments. Of course, it is not limited to. (1) In the first to sixth embodiments, the assembler code 302, the optimization code 304, the relocatable code 306, and the object code 308 are a semiconductor integrated memory such as a mask ROM and a flash memory, a floppy (registered trademark) disk, a hard disk It is also possible to record on a magnetic recording medium such as CD-ROM or DVD. (2) In the seventh embodiment, the assembler code 2906 includes a semiconductor integrated memory such as a mask ROM and a flash memory, a magnetic recording medium such as a floppy (registered trademark) disk and a hard disk, and an optical disk such as a CD-ROM and DVD. Can also be recorded.

(まとめ)
以上の説明から明らかなように、本発明は、1バイトデータをメモリの1単位データとして命令を格納するメモリからプログラムカウンタの値に基いて命令を読み出し、実行するプロセッサにおいて、前記メモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データの前記メモリ内の格納位置を指定する値を保持する第1のプログラムカウンタと、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定する値を保持する第2のプログラムカウンタとを備えたことを特徴とする。
(Summary)
As is apparent from the above description, the present invention reads out an instruction based on the value of a program counter from a memory that stores an instruction using 1-byte data as one unit of data in the memory, and executes the instruction in one unit of the memory. A first program counter that holds a value that specifies a storage position in the memory of one unit data of the processor constituted by data or one unit data of a plurality of memories, and a processor included in the one unit data of the processor And a second program counter for holding a value for designating a position of one unit instruction of the processor indicating one operation to be executed.

これによって、第1のプログラムカウンタは、バイト単位の長さをもつプロセッサの1単位データのメモリ内の格納位置を指定し、その値に基づいて命令がメモリから読み出される。また、第2のプログラムカウンタは、メモリからプロセッサ内に読み込んだプロセッサの1単位データに含まれるどのプロセッサの1単位命令であっても、その位置を指定することができる。つまり、命令の実行単位は、読み出し単位と関係なく任意に設定することができる。従って、メモリからプロセッサへ読み出す単位はバイト単位でなくてはならない場合にでも、命令の語長がバイト単位でない命令を実行することができる。   As a result, the first program counter designates the storage position in the memory of one unit data of the processor having a length in bytes, and the instruction is read from the memory based on the value. Further, the second program counter can designate the position of any one unit instruction of any processor included in one unit data of the processor read into the processor from the memory. That is, the instruction execution unit can be arbitrarily set regardless of the read unit. Therefore, even when the unit to be read from the memory to the processor must be a byte unit, an instruction whose instruction word length is not a byte unit can be executed.

ここで、前記プロセッサは、さらに、第1のプログラムカウンタ更新手段と、第2のプログラムカウンタ更新手段とを含み、前記第2のプログラムカウンタ更新手段は、前記第2のプログラムカウンタの値を1つ前のサイクルで実行した命令の分だけインクリメントし、桁上りがあれば、桁上り数を前記第1のプログラムカウンタ更新手段に送り、前記第1のプログラムカウンタ更新手段は、前記第1のプログラムカウンタの値を前記第2のプログラムカウンタ更新手段から送られた桁上り数だけ加算することを特徴としてもよい。   Here, the processor further includes a first program counter update unit and a second program counter update unit, and the second program counter update unit sets the value of the second program counter to one. Incremented by the number of instructions executed in the previous cycle, and if there is a carry, the number of carry is sent to the first program counter update means, and the first program counter update means May be added by the carry number sent from the second program counter updating means.

これによって、プロセッサが実行した命令の分だけ、プログラムカウンタの値をインクリメントできるので、プログラムカウンタを次のサイクルで実行する命令の先頭位置に移行させることができる。
ここで、前記プロセッサであって、実行命令が、その命令と同一のサイクルで実行する先頭の命令のアドレスを基準とするプログラムカウンタ相対値を含む命令である場合には、当該プログラムカウンタ相対値を抽出するプログラムカウンタ相対値抽出手段と、前記第1のプログラムカウンタの値及び前記第2のプログラムカウンタの値と前記プログラムカウンタ相対値とを加算し、その演算結果を前記第1のプログラムカウンタの値及び前記第2のプログラムカウンタの値として設定する演算手段とをさらに備えたことを特徴としてもよい。
As a result, the value of the program counter can be incremented by the number of instructions executed by the processor, so that the program counter can be shifted to the head position of the instruction to be executed in the next cycle.
Here, in the processor, when the execution instruction is an instruction including a program counter relative value based on the address of the first instruction executed in the same cycle as the instruction, the program counter relative value is Program counter relative value extracting means for extracting, the value of the first program counter, the value of the second program counter, and the value of the program counter relative value are added, and the operation result is the value of the first program counter. And an arithmetic means for setting the value of the second program counter.

これによって、プロセッサが分岐命令を実行した際に、プログラムカウンタの値と、分岐命令を実行する時のプログラムカウンタ値と分岐先命令のアドレスとの差分値であるプログラムカウンタ相対値とが加算されて、加算結果にプログラムカウンタが更新されるので、プログラムカウンタを分岐先命令のアドレスに移行させることができる。
ここで、前記演算手段は、第1演算部と、第2演算部とを含み、前記第2演算部は、前記第2のプログラムカウンタの値と前記プログラムカウンタ相対値の下位ビットとを加算し、その加算結果を前記第2のプログラムカウンタの値として設定し、桁上りがある場合には、桁上り数を前記第1演算部に送り、桁借りがある場合には、桁借り数を前記第1演算部に送り、前記第1演算部は、前記第1のプログラムカウンタの値と前記プログラムカウンタ相対値の上位ビットとを加算し、さらに前記第2演算部より桁上り数を受けとった場合には、当該桁上り数を加算し、又は前記第2演算部より桁借り数を受けとった場合には、当該桁借り数を減算し、それらの演算結果を前記第1のプログラムカウンタの値として設定することを特徴としてもよい。
As a result, when the processor executes the branch instruction, the value of the program counter is added to the program counter relative value that is the difference between the program counter value when the branch instruction is executed and the address of the branch destination instruction. Since the program counter is updated to the addition result, the program counter can be shifted to the address of the branch destination instruction.
Here, the calculation means includes a first calculation unit and a second calculation unit, and the second calculation unit adds the value of the second program counter and the lower bits of the program counter relative value. The result of the addition is set as the value of the second program counter, and when there is a carry, the carry number is sent to the first arithmetic unit. When the first arithmetic unit adds the value of the first program counter and the upper bit of the relative value of the program counter, and further receives the carry number from the second arithmetic unit In the case where the carry number is added or the borrow number is received from the second calculation unit, the borrow number is subtracted and the result of the calculation is used as the value of the first program counter. Also features to set There.

これによって、プロセッサが分岐命令を実行する際に、プログラムカウンタとプログラムカウンタ相対値との演算において、下位ビットの演算で発生した桁上り数又は桁借り数が上位ビットの演算で考慮されるので、上位ビットの演算と下位ビットの演算との間に連続性を備えたアドレス演算が可能となる。
ここで、前記演算手段は、第1演算部と、第2演算部とを含み、前記第2演算部は、前記第2のプログラムカウンタの値と前記プログラムカウンタ相対値の下位ビットとを桁上げ、又は桁借りを発生させずに加算し、その加算結果を前記第2のプログラムカウンタの値として設定し、前記第1演算部は、前記第1のプログラムカウンタの値と前記プログラムカウンタ相対値の上位ビットとを加算し、その加算結果を前記第1のプログラムカウンタの値として設定することを特徴としてもよい。
As a result, when the processor executes a branch instruction, in the calculation of the program counter and the program counter relative value, the carry number or the borrow number generated in the lower bit calculation is considered in the upper bit calculation. It is possible to perform an address operation with continuity between the upper bit operation and the lower bit operation.
Here, the calculation means includes a first calculation unit and a second calculation unit, and the second calculation unit carries the value of the second program counter and the lower bits of the program counter relative value. Or adding without causing borrowing, and setting the result of the addition as the value of the second program counter, and the first operation unit calculates the value of the first program counter and the relative value of the program counter. The high-order bits may be added and the addition result set as the value of the first program counter.

これによって、プロセッサが分岐命令を実行する際に、第2のプログラムカウンタの値とプログラムカウンタ相対値の下位ビットとを演算する第2の演算器から、第1のプログラムカウンタの値とプログラムカウンタ相対値の上位ビットとを演算する第1の演算器へ、桁上げ数又は桁借り数が送られないので、第2の演算器と第1の演算器としては互いに独立して動作すればよい単純なハードウエアを用いることができる。   Thus, when the processor executes a branch instruction, the second program counter value and the lower bit of the program counter relative value are calculated from the second program counter value and the program counter relative value. Since the carry number or the borrow number is not sent to the first arithmetic unit that calculates the upper bits of the value, the second arithmetic unit and the first arithmetic unit need only operate independently from each other. Hardware can be used.

ここで、前記演算手段は、前記第1のプログラムカウンタの値と前記プログラムカウンタ相対値の上位ビットとを加算し、その加算結果を前記第1のプログラムカウンタの値として設定し、前記プログラムカウンタ相対値の下位ビットを前記第2のプログラムカウンタの値として設定することを特徴としてもよい。
これによって、プロセッサが分岐命令を実行する際に、第2のプログラムカウンタの値とプログラムカウンタ相対値の下位ビットとの演算が不要となるので、プロセッサの分岐命令の実行速度が早くなる。
Here, the computing means adds the value of the first program counter and the upper bits of the program counter relative value, sets the addition result as the value of the first program counter, and sets the program counter relative The lower bits of the value may be set as the value of the second program counter.
As a result, when the processor executes the branch instruction, the operation of the value of the second program counter and the lower bits of the program counter relative value is not required, so that the execution speed of the branch instruction of the processor is increased.

ここで、前記演算手段は、前記第1のプログラムカウンタの値を上位ビットとし、前記第2のプログラムカウンタの値を下位ビットとする値と前記プログラムカウンタ相対値とを加算し、その加算結果の上位ビットを前記第1のプログラムカウンタの値として設定し、その加算結果の下位ビットを前記第2のプログラムカウンタの値として設定することを特徴としてもよい。   Here, the arithmetic means adds a value having the value of the first program counter as an upper bit, a value having the value of the second program counter as a lower bit, and the relative value of the program counter. The upper bit may be set as the value of the first program counter, and the lower bit of the addition result may be set as the value of the second program counter.

これによって、プロセッサが分岐命令を実行の際に、プログラムカウンタ値とプログラムカウンタ相対値との演算を通常の演算器を用いて実行することができるので、プロセッサの構成を簡易にすることができる。
ここで、前記プロセッサであって、実行命令が、その命令のアドレスを基準とするプログラムカウンタ相対値を含む命令である場合には、当該プログラムカウンタ相対値を抽出するプログラムカウンタ相対値抽出手段と、前記第1のプログラムカウンタの値及び前記第2のプログラムカウンタの値を、前記実行命令のアドレスを指定するように補正するプログラムカウンタ補正手段と、前記補正された第1のプログラムカウンタの値及び第2のプログラムカウンタの値と前記プログラムカウンタ相対値とを加算し、その加算結果を前記第1のプログラムカウンタの値及び前記第2のプログラムカウンタの値として設定する演算手段とをさらに備えたことを特徴としてもよい。
As a result, when the processor executes the branch instruction, the operation of the program counter value and the program counter relative value can be executed using a normal arithmetic unit, so that the configuration of the processor can be simplified.
Here, in the processor, when the execution instruction is an instruction including a program counter relative value based on the address of the instruction, a program counter relative value extraction unit that extracts the program counter relative value; Program counter correction means for correcting the value of the first program counter and the value of the second program counter so as to specify the address of the execution instruction, and the corrected value of the first program counter and the value of the first program counter And a calculation means for adding the value of the program counter of 2 and the relative value of the program counter and setting the addition result as the value of the first program counter and the value of the second program counter. It may be a feature.

これによって、プログラムカウンタ相対値は、分岐命令のアドレスと分岐先命令の差分値で表されるので、プログラム中の並列実行の境界を変更したい事情が生じた場合にでも、プログラムカウンタ相対値の変更は不要となる。
ここで、前記プロセッサであって、レジスタ又は又は第1のプログラムカウンタ及び第2のプログラムカウンタに格納されたプログラムカウンタの値と、プログラムカウンタ相対値とを加算する加算命令又は減算する減算命令を解読するプログラムカウンタ相対値演算命令解読手段と、前記プログラムカウンタの値と前記プログラムカウンタ相対値とを加算又は減算し、演算結果を算出する演算手段と、前記演算結果にレジスタ又は第1のプログラムカウンタ及び第2のプログラムカウンタを更新するプログラムカウンタ値更新手段とをさらに備えたことを特徴としてもよい。
As a result, the program counter relative value is expressed by the difference value between the branch instruction address and the branch destination instruction. Is no longer necessary.
Here, the processor decodes an add instruction for adding or subtracting a program counter relative value and a register counter or the value of the program counter stored in the first program counter and the second program counter. Program counter relative value calculation instruction decoding means, calculation means for adding or subtracting the program counter value and the program counter relative value to calculate the calculation result, a register or a first program counter in the calculation result, Program counter value updating means for updating the second program counter may be further provided.

これによって、関数の絶対アドレスをレジスタに格納する命令を使用する代わりに、プログラムカウンタとプログラムカウンタ相対値との演算を用いる命令を使用できる。従って、プログラムカウンタ相対値は命令の絶対アドレスよりも短いビット長で表すことができるので、プログラムのコードサイズを小さくすることができる。また、実行時にはじめてプログラムのメモリ上のアドレスが決定されるPICコードでは、絶対アドレスを用いることができないので、このプログラムカウンタとプログラムカウンタ相対値を用いた演算命令が必要不可欠である。   Thereby, instead of using an instruction for storing the absolute address of a function in a register, an instruction using an operation of a program counter and a program counter relative value can be used. Accordingly, since the program counter relative value can be expressed by a bit length shorter than the absolute address of the instruction, the code size of the program can be reduced. In addition, since an absolute address cannot be used in a PIC code in which an address on a memory of a program is determined for the first time at the time of execution, an operation instruction using this program counter and a program counter relative value is indispensable.

ここで、前記第1のプログラムカウンタは、前記プロセッサの1単位データの長さがnバイトの時に、第1のプログラムカウンタの値をlog2nだけ左へビットシフトとした値を番地とするプロセッサの1単位データの前記メモリ内の格納位置であるメモリアドレスを指定することを特徴としてもよい。
これによって、メモリに1バイトごとに1つのアドレスが付与されている場合において、第1のプログラムカウンタの値と、メモリに格納された各プロセッサの1単位データが1対1に対応するので、プロセッサからプロセッサの1単位データの指定が容易となる。
Here, when the length of one unit data of the processor is n bytes, the first program counter is one of the processors whose address is a value obtained by bit-shifting the value of the first program counter to the left by log2n. A memory address that is a storage position of the unit data in the memory may be specified.
As a result, when one address is assigned to each byte in the memory, the value of the first program counter and the unit data of each processor stored in the memory correspond one-to-one. Therefore, it is easy to specify one unit data of the processor.

ここで、前記プロセッサであって、命令を一時的に記憶する命令バッファと、前記命令バッファの空き状態に応じて、前記プロセッサの1単位データに限定されず、メモリから命令をメモリの1単位データを最小単位として命令バッファへ読み出す命令読み出し手段とをさらに備えたことを特徴としてもよい。
これによって、メモリからプロセッサ内に読み出す命令の読み出し単位は任意に設定することができるので、プロセッサの命令の読み出しのための機構に柔軟性をもたせることができる。
Here, the processor is not limited to one unit data of the processor according to the instruction buffer for temporarily storing the instruction and the empty state of the instruction buffer, but the unit unit data of the memory is not limited to the unit data of the processor. It is also possible to further include an instruction reading means for reading out to the instruction buffer using the minimum unit as a minimum unit.
As a result, the read unit of the instruction read from the memory into the processor can be arbitrarily set, so that the mechanism for reading the instruction of the processor can be made flexible.

また、上記目的を達成するために、本発明は、命令列から最適化コードを生成する命令列最適化装置であって、前記命令列の各命令の大きさを予測して、各命令に対して、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するアドレスを付与するアドレス付与手段と、前記命令列から、特定の1つの命令のアドレスに解決すべきラベルを検出し、当該命令のアドレスを取得するとともに、特定の2つの命令のアドレスの差分に解決すべきラベルを検出し、当該2つの命令のアドレスを取得するラベル検出手段と、前記特定の2つの命令のアドレスの差分に解決すべきラベルが検出された場合に、前記特定の2つの命令の一方の命令のアドレスから他方の命令のアドレスを減算し、プログラムカウンタ相対値を算出するプログラムカウンタ相対値算出手段と、前記特定の1つの命令のアドレスに解決すべきラベルを有する命令については、その大きさを前記特定の1つの命令のアドレスの大きさに応じた命令の大きさに変換し、前記特定の2つの命令のアドレスの差分に解決すべきラベルを有する命令については、その大きさを前記プログラムカウンタ相対値の大きさに応じた命令の大きさに変換する変換手段と、前記変換された命令の大きさに応じて、各命令のアドレスを変換して、最適化コードを生成する最適化コード生成手段とを備えたことを特徴とする。   In order to achieve the above object, the present invention provides an instruction sequence optimization device for generating an optimization code from an instruction sequence, predicting the size of each instruction in the instruction sequence, and for each instruction The upper bit designates a memory address in which one unit data of a processor composed of one unit data of a memory having a length of 1 byte or one unit data of a plurality of memories is stored. Address giving means for assigning an address for designating the position of one unit instruction of the processor indicating one operation executed by the processor included in one unit data, and the address of the specific instruction should be resolved from the instruction sequence The label is detected to obtain the address of the instruction, and the label to be resolved to the difference between the addresses of the two specific instructions is detected. When a label to be resolved and a label to be resolved by the difference between the addresses of the two specific instructions are detected, the address of the other instruction is determined from the address of one instruction of the specific two instructions. The program counter relative value calculating means for subtracting and calculating the program counter relative value, and the instruction having the label to be resolved to the address of the specific one instruction, the size of the address of the specific one instruction For an instruction having a label that should be resolved to the difference between the addresses of the two specific instructions, the instruction size corresponding to the magnitude of the program counter relative value. Conversion means for converting to the size of the instruction, and an optimization code for generating an optimized code by converting the address of each instruction according to the size of the converted instruction Characterized by comprising a code generating means.

これによって、分岐命令を実行するプロセッサを対象としたプログラムを生成する最適化装置を実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、桁借りがある場合には、桁借り数を前記上位ビット減算部に送り、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、さらに前記下位ビット減算部より桁借り数を受けとった場合には、当該桁借り数を減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
Thus, it is possible to realize an optimization device that generates a program for a processor that executes a branch instruction.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtract the lower bit of the address of the instruction, set the subtraction result as the lower bit of the relative value of the program counter, and if there is a borrow, send the borrow number to the upper bit subtracting unit, The subtracting unit subtracts the high order bit of the address of the other instruction from the high order bit of the address of one of the specific two instructions, and further receives the borrowing number from the low order bit subtracting unit, The borrowing number may be subtracted, and the subtraction result may be set as the upper bits of the program counter relative value.

これによって、分岐命令を実行する際に桁上り方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成する最適化装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを桁借りを発生させずに減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
As a result, it is possible to realize an optimization device that generates a program targeted for a processor that calculates the address of a branch destination instruction by an address operation using a carry method when executing a branch instruction.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtracting the lower bit of the address of the instruction without causing borrowing, setting the subtraction result as the lower bit of the program counter relative value, and the upper bit subtracting unit is one of the two specific instructions The high order bit of the instruction address may be subtracted from the high order bit of the other instruction address, and the subtraction result may be set as the high order bit of the program counter relative value.

これによって、分岐命令を実行する際に桁上りなし方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成する最適化装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定し、前記特定の2つの命令の一方の命令のアドレスの下位ビットを前記プログラムカウンタ相対値の下位ビットとして設定することを特徴としてもよい。
As a result, it is possible to realize an optimization device that generates a program for a processor that calculates an address of a branch destination instruction by an address operation using a no carry method when a branch instruction is executed.
Here, the program counter relative value calculation means subtracts the upper bit of the address of the other instruction from the upper bit of the address of the other instruction from the upper bit of the address of the one instruction of the specific two instructions. It may be set as an upper bit, and a lower bit of the address of one of the two specific instructions may be set as a lower bit of the program counter relative value.

これによって、分岐命令を実行する際に絶対値方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成する最適化装置が実現できる。
また、上記目的を達成するために、本発明は、命令列からリロケータブルコードを生成するアセンブラ装置であって、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するアドレスが付与された命令からなる命令列を取得する命令列取得手段と、前記命令列中の特定の2つの命令のアドレスの差分に解決すべきラベルを検出し、当該2つの命令のアドレスを取得するラベル検出手段と、前記特定の2つの命令の一方の命令のアドレスから他方の命令のアドレスを減算し、プログラムカウンタ相対値を算出するプログラムカウンタ相対値算出手段と、前記ラベルを前記算出されたプログラムカウンタ相対値に置換する置換手段とを備えたことを特徴とする。
As a result, it is possible to realize an optimization device that generates a program for a processor that calculates the address of a branch destination instruction by an address operation using an absolute value method when executing a branch instruction.
In order to achieve the above object, the present invention provides an assembler device for generating a relocatable code from an instruction sequence, wherein the upper bits are 1 unit data of a memory having a length of 1 byte or 1 unit data of a plurality of memories. The memory address where 1 unit data of the processor configured is stored is specified, and the lower bit specifies the position of the 1 unit instruction of the processor indicating one operation executed by the processor included in the 1 unit data of the processor An instruction sequence acquisition means for acquiring an instruction sequence including an instruction to which an address to be assigned is detected, a label to be resolved to a difference between addresses of two specific instructions in the instruction sequence, and an address of the two instructions Subtract the address of the other instruction from the address of one of the two specific instructions and the label detection means to obtain A program counter relative value calculating means for calculating a gram counter relative value, characterized in that a replacement means for replacing the label on the calculated program counter relative value.

これによって、分岐命令を実行するプロセッサを対象としたプログラムを生成するアセンブラ装置を実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、桁借りがある場合には、桁借り数を前記上位ビット減算部に送り、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、さらに前記下位ビット減算部より桁借り数を受けとった場合には、当該桁借り数を減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
Thus, it is possible to realize an assembler device that generates a program for a processor that executes a branch instruction.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtract the lower bit of the address of the instruction, set the subtraction result as the lower bit of the relative value of the program counter, and if there is a borrow, send the borrow number to the upper bit subtracting unit, The subtracting unit subtracts the high order bit of the address of the other instruction from the high order bit of the address of one of the specific two instructions, and further receives the borrowing number from the low order bit subtracting unit, The borrowing number may be subtracted, and the subtraction result may be set as the upper bits of the program counter relative value.

これによって、分岐命令を実行する際に桁上り方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するアセンブラ装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを桁借りを発生させずに減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
As a result, it is possible to realize an assembler device that generates a program for a processor that calculates the address of a branch destination instruction by an address operation using a carry method when a branch instruction is executed.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtracting the lower bit of the address of the instruction without causing borrowing, setting the subtraction result as the lower bit of the program counter relative value, and the upper bit subtracting unit is one of the two specific instructions The high order bit of the instruction address may be subtracted from the high order bit of the other instruction address, and the subtraction result may be set as the high order bit of the program counter relative value.

これによって、分岐命令を実行する際に桁上りなし方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するアセンブラ装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定し、前記特定の2つの命令の一方の命令のアドレスの下位ビットを前記プログラムカウンタ相対値の下位ビットとして設定することを特徴としてもよい。
Thus, it is possible to realize an assembler device that generates a program for a processor that calculates an address of a branch destination instruction by an address operation using a no carry method when a branch instruction is executed.
Here, the program counter relative value calculation means subtracts the upper bit of the address of the other instruction from the upper bit of the address of the other instruction from the upper bit of the address of the one instruction of the specific two instructions. It may be set as an upper bit, and a lower bit of the address of one of the two specific instructions may be set as a lower bit of the program counter relative value.

これによって、分岐命令を実行する際に絶対値方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するアセンブラ装置が実現できる。
また、上記目的を達成するために、本発明は、リロケーターブルコードを結合してオブジェクトコードを生成するリンカ装置であって、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するアドレスが付与された命令からなるリロケータブルコードを取得するリロケータブルコード取得手段と、前記リロケータブルコードから特定の2つの命令のアドレスの差分に解決すべきラベルを検出し、当該2つの命令のアドレスを取得する再配置情報検出手段と、前記特定の2つの命令の一方の命令のアドレスから他方の命令のアドレスを減算し、プログラムカウンタ相対値を算出するプログラムカウンタ相対値算出手段と、前記ラベルを前記算出されたプログラムカウンタ相対値に置換する置換手段とを備えたことを特徴とする。
Thus, it is possible to realize an assembler device that generates a program intended for a processor that calculates the address of a branch destination instruction by an address operation using an absolute value method when executing a branch instruction.
In order to achieve the above object, the present invention is a linker device that generates an object code by combining relocatable codes, and the upper bit is one unit data or a plurality of data in a memory having a length of 1 byte. A memory address in which 1 unit data of the processor configured by 1 unit data of the memory is stored is specified, and the lower bit indicates one unit of the processor indicating one operation executed by the processor included in the 1 unit data of the processor A relocatable code acquisition means for acquiring a relocatable code including an instruction to which an address for specifying an instruction is assigned, and a label to be resolved into a difference between addresses of two specific instructions from the relocatable code. A rearrangement information detecting means for acquiring an address of an instruction; A program counter relative value calculating means for calculating the program counter relative value by subtracting the address of the other instruction from the address of one instruction of the instruction, and a replacing means for replacing the label with the calculated program counter relative value. It is characterized by having.

これによって、分岐命令を実行するプロセッサを対象としたプログラムを生成するリンカ装置を実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、桁借りがある場合には、桁借り数を前記上位ビット減算部に送り、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、さらに前記下位ビット減算部より桁借り数を受けとった場合には、当該桁借り数を減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
As a result, a linker device that generates a program for a processor that executes a branch instruction can be realized.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtract the lower bit of the address of the instruction, set the subtraction result as the lower bit of the relative value of the program counter, and if there is a borrow, send the borrow number to the upper bit subtracting unit, The subtracting unit subtracts the high order bit of the address of the other instruction from the high order bit of the address of one of the specific two instructions, and further receives the borrowing number from the low order bit subtracting unit, The borrowing number may be subtracted, and the subtraction result may be set as the upper bits of the program counter relative value.

これによって、分岐命令を実行する際に桁上り方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するリンカ装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの下位ビットから他方の命令のアドレスの下位ビットとを桁借りを発生させずに減算し、減算結果を前記プログラムカウンタ相対値の下位ビットとして設定し、前記上位ビット減算部は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果を前記プログラムカウンタ相対値の上位ビットとして設定することを特徴としてもよい。
Thus, it is possible to realize a linker device that generates a program for a processor that calculates an address of a branch destination instruction by an address operation using a carry method when executing a branch instruction.
Here, the program counter relative value calculating means includes an upper bit subtracting section and a lower bit subtracting section, and the lower bit subtracting section uses the lower bit of the address of one instruction of the specific two instructions to the other. Subtracting the lower bit of the address of the instruction without causing borrowing, setting the subtraction result as the lower bit of the program counter relative value, and the upper bit subtracting unit is one of the two specific instructions The high order bit of the instruction address may be subtracted from the high order bit of the other instruction address, and the subtraction result may be set as the high order bit of the program counter relative value.

これによって、分岐命令を実行する際に桁上りなし方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するリンカ装置が実現できる。
ここで、前記プログラムカウンタ相対値算出手段は、前記特定の2つの命令の一方の命令のアドレスの上位ビットから他方の命令のアドレスの上位ビットとを減算し、減算結果をプログラムカウンタ相対値の上位ビットとして設定し、前記特定の2つの命令の一方の命令のアドレスの下位ビットをプログラムカウンタ相対値の下位ビットとして設定することを特徴としてもよい。
Accordingly, it is possible to realize a linker device that generates a program targeted for a processor that calculates the address of a branch destination instruction by an address operation using a no carry method when a branch instruction is executed.
Here, the program counter relative value calculation means subtracts the upper bit of the address of the other instruction from the upper bit of the address of the other instruction from the upper bit of the address of the one instruction of the specific two instructions. It may be set as a bit, and the lower bit of the address of one of the specific two instructions may be set as the lower bit of the program counter relative value.

これによって、分岐命令を実行する際に絶対値方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを生成するリンカ装置が実現できる。
また、上記目的を達成するために、本発明は、オブジェクトコード中の命令のアドレスを指定して、そのアドレスで特定される命令のアセンブラ名を出力する逆アセンブラ装置であって、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するアドレスが付与された命令からなるオブジェクトコードを取得するオブジェクトコード取得手段と、前記特定される命令がプログラムカウンタ相対値を含む命令である場合に、前記特定される命令中からプログラムカウンタ相対値を抽出するプログラムカウンタ相対値抽出手段と、ラベルの位置を示すラベルアドレスとラベル名とを対応させて記憶する記憶手段と、前記指定した命令のアドレスとプログラムカウンタ相対値とを加算し、加算結果をラベルアドレスとするラベルアドレス算出手段と、前記記憶手段を参照して、前記算出したラベルアドレスに対応するラベル名を検索する検索手段とを備えたことを特徴とする。
Thus, it is possible to realize a linker device that generates a program targeted for a processor that calculates an address of a branch destination instruction by an address operation using an absolute value method when executing a branch instruction.
In order to achieve the above object, the present invention provides a disassembler device for designating an address of an instruction in an object code and outputting an assembler name of the instruction specified by the address, A memory address in which one unit data of a processor composed of one unit data of a memory having a length of 1 byte or one unit data of a plurality of memories is specified, and a lower bit is included in the one unit data of the processor Object code acquisition means for acquiring an object code composed of an instruction to which an address specifying the position of one unit instruction of the processor indicating one operation executed by the processor is provided, and the specified instruction includes a program counter relative value If it is an instruction, the program counter relative value is selected from the specified instructions. The program counter relative value extracting means to be output, the storage means for storing the label address indicating the label position and the label name in association with each other, adding the address of the designated instruction and the program counter relative value, and adding the result A label address calculating means for making a label address, and a searching means for searching for a label name corresponding to the calculated label address with reference to the storage means are provided.

これによって、分岐命令を含むプログラムを逆アセンブルすることができる。つまり、逆アセンブルする命令が分岐命令である場合にも、プログラムカウンタ相対値から分岐先命令のアドレスを算出し、そのアドレスからラベルテーブルを参照して、ラベル名を取得できるので、プログラムカウンタ相対値よりも、わかりやすい形式であるラベル名により分岐先をユーザに提示することできる。   As a result, the program including the branch instruction can be disassembled. In other words, even when the instruction to be disassembled is a branch instruction, the address of the branch destination instruction is calculated from the program counter relative value, and the label name can be obtained by referring to the label table from the address. The branch destination can be presented to the user by a label name in a format that is easier to understand.

ここで、前記ラベルアドレス算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記指定した命令のアドレスの下位ビットと前記プログラムカウンタ相対値の下位ビットとを加算し、加算結果を前記ラベルアドレスの下位ビットとし、桁上りがある場合には、桁上り数を前記上位ビット演算部に送り、桁借りがある場合には、桁借り数を前記上位ビット演算部に送り、前記上位ビット減算部は、前記指定した命令のアドレスの上位ビットと前記プログラムカウンタ相対値の上位ビットとを加算し、さらに前記下位ビット演算部より桁上り数が受けとった場合には、当該桁上り数を加算し、又は前記下位ビット演算部より桁借り数を受けとった場合には、当該桁借り数を減算し、それらの演算結果を前記ラベルアドレスの上位ビットとすることを特徴としてもよい。   Here, the label address calculation means includes an upper bit subtraction unit and a lower bit subtraction unit, and the lower bit subtraction unit includes a lower bit of the address of the designated instruction and a lower bit of the relative value of the program counter. The addition result is set as the lower bit of the label address, and when there is a carry, the carry number is sent to the upper bit calculation unit, and when there is a carry, the borrow number is set to the upper bit. When the upper bit subtraction unit adds the upper bit of the address of the designated instruction and the upper bit of the relative value of the program counter, and when the carry number is received from the lower bit calculation unit Adds the carry number or, when the borrowed number is received from the lower bit calculation unit, subtracts the borrowed number, and calculates the result of the calculation It may be characterized in that the upper bits of the bell address.

これによって、分岐命令を実行する際に桁上り方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを逆アセンブルする逆アセンブラ装置を実現できる。
ここで、前記ラベルアドレス算出手段は、上位ビット減算部と、下位ビット減算部とを含み、前記下位ビット減算部は、前記指定した命令のアドレスの下位ビットと前記プログラムカウンタ相対値の下位ビットとを桁上げ、又は桁借りを発生させずに加算し、加算結果を前記ラベルアドレスの下位ビットとし、前記上位ビット減算部は、前記指定した命令のアドレスの上位ビットと前記プログラムカウンタ相対値の上位ビットとを加算し、加算結果を前記ラベルアドレスの上位ビットとすることを特徴としてもよい。
Thus, it is possible to realize a disassembler device for disassembling a program intended for a processor that calculates the address of a branch destination instruction by an address operation using a carry method when executing a branch instruction.
Here, the label address calculation means includes an upper bit subtraction unit and a lower bit subtraction unit, and the lower bit subtraction unit includes a lower bit of the address of the designated instruction and a lower bit of the relative value of the program counter. Are added without causing a carry or a borrow, and the addition result is used as the lower bits of the label address. Bits may be added, and the addition result may be the upper bits of the label address.

これによって、分岐命令を実行する際に桁上りなし方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを逆アセンブルする逆アセンブラ装置が実現できる。
ここで、前記ラベルアドレス算出手段は、前記指定した命令のアドレスの上位ビットと前記プログラムカウンタ相対値の上位ビットとを加算し、加算結果を前記ラベルアドレスの上位ビットとし、前記プログラムカウンタ相対値の下位ビットを前記ラベルアドレスの下位ビットとすることを特徴としてもよい。
Accordingly, it is possible to realize a disassembler device that disassembles a program intended for a processor that calculates the address of a branch destination instruction by an address operation using a no carry method when executing a branch instruction.
Here, the label address calculation means adds the upper bit of the address of the designated instruction and the upper bit of the program counter relative value, and sets the addition result as the upper bit of the label address. The lower bit may be a lower bit of the label address.

これによって、分岐命令を実行する際に絶対値方式によるアドレス演算によって分岐先命令のアドレスを算出するプロセッサを対象としたプログラムを逆アセンブルする逆アセンブラ装置が実現できる。
また、上記目的を達成するために、本発明は、オブジェクトコード中の命令のアドレスと変換命令を指定して、そのアドレスで特定される命令を変換命令に置換するデバッガ装置であって、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するアドレスが付与された命令からなるオブジェクトコードを取得するオブジェクトコード取得手段と、前記指定した命令のアドレスの上位ビットで特定されるプロセッサの1単位データをメモリから読み出して命令バッファに書き込むプロセッサの1単位データ読み出し手段と、前記命令バッファ内のプロセッサの1単位データに含まれる前記指定した命令のアドレスの下位ビットで特定される命令の位置に前記変換命令を書き込む命令書き込み手段と、前記命令書き込み後の命令バッファ内のプロセッサの1単位データをメモリに戻すプロセッサの1単位データ書き込み手段とを備えたことを特徴とする。
Thus, it is possible to realize a disassembler device that disassembles a program intended for a processor that calculates the address of a branch destination instruction by an address operation using an absolute value method when executing a branch instruction.
In order to achieve the above object, the present invention provides a debugger device for designating an instruction address and a conversion instruction in an object code and replacing an instruction specified by the address with a conversion instruction. Designates a memory address where 1 unit data of a processor composed of 1 unit data of a memory having a length of 1 byte or 1 unit data of a plurality of memories is stored, and a lower bit indicates 1 unit data of the processor An object code acquisition means for acquiring an object code consisting of an instruction to which an address specifying the position of one unit instruction of the processor indicating one operation executed by the included processor is provided, and an upper bit of the address of the specified instruction 1 unit data of specified processor is read from memory and written to instruction buffer 1 unit data reading means of a processor, instruction writing means for writing the conversion instruction at a position of an instruction specified by a lower bit of an address of the designated instruction included in 1 unit data of the processor in the instruction buffer, 1 unit data writing means for the processor for returning 1 unit data of the processor in the instruction buffer after the instruction is written to the memory.

これによって、バイト単位の長さであるプロセッサの1単位データを単位としてメモリから命令を命令バッファに読み出して、命令バッファ中で命令を書き換えて、命令パケットの単位で命令をメモリへ書き込むので、バイト単位の長さでない命令でもデバッグができるデバッガ装置が実現できる。
また、上記目的を達成するために、本発明は、ソースコードから命令列を生成するコンパイラ装置であって、上位ビットは、1バイト長であるメモリの1単位データ又は複数のメモリの1単位データより構成されるプロセッサの1単位データが格納されるメモリアドレスを指定し、下位ビットは、前記プロセッサの1単位データに含まれるプロセッサが実行する1つのオペレーションを示すプロセッサの1単位命令の位置を指定するプログラムカウンタの値とプログラムカウンタ相対値とを加算又は減算し、演算結果をプログラムカウンタの値とする命令をプロセッサに実行させるプログラムカウンタ相対値演算命令を生成することを特徴とする。
As a result, an instruction is read from the memory to the instruction buffer in units of 1-unit data of the processor, which has a length in bytes, and the instruction is rewritten in the instruction buffer, and the instruction is written to the memory in units of instruction packets. A debugger device that can debug even an instruction that is not unit length can be realized.
In order to achieve the above object, the present invention is a compiler apparatus for generating an instruction sequence from source code, wherein the upper bits are 1 unit data of a memory having a length of 1 byte or 1 unit data of a plurality of memories. The memory address where the 1 unit data of the processor configured is stored is specified, and the lower bit specifies the position of the 1 unit instruction of the processor indicating one operation executed by the processor included in the 1 unit data of the processor The program counter relative value calculation instruction is generated by adding or subtracting the program counter value and the program counter relative value to cause the processor to execute an instruction having the calculation result as the program counter value.

これによって、プログラムカウンタ相対値演算命令を実行するプロセッサを対象としたプログラムを生成するコンパイラ装置を実現できる。
ここで、前記プログラムカウンタ相対値演算命令は、前記プログラムカウンタの値の下位ビットとプログラムカウンタ相対値の下位ビットとを加算又は減算し、演算結果をプログラムカウンタの値の下位ビットとし、桁上りがある場合には、桁上り数を上位ビット演算部に送り、桁借りがある場合には、桁借り数を上位ビット演算部に送る下位ビット演算をプロセッサの下位ビット演算部に実行させ、前記プログラムカウンタの値の上位ビットとプログラムカウンタ相対値の上位ビットとを加算又は減算し、さらに前記下位ビット演算部より桁上り数が受けとった場合には、当該桁上り数を加算し、又は前記下位ビット演算部より桁借り数を受けとった場合には、当該桁借り数を減算し、それらの演算結果をプログラムカウンタの値の上位ビットとする上位ビット演算をプロセッサの上位ビット演算部に実行させることを特徴としてもよい。
Thus, it is possible to realize a compiler device that generates a program for a processor that executes a program counter relative value calculation instruction.
Here, the program counter relative value calculation instruction adds or subtracts the lower bit of the program counter value and the lower bit of the program counter relative value, sets the calculation result as the lower bit of the program counter value, and carries a carry. In some cases, the number of carry is sent to the upper bit operation unit, and when there is a borrow, the lower bit operation unit that sends the number of borrowing to the upper bit operation unit is executed by the lower bit operation unit of the processor, and the program Add or subtract the upper bit of the counter value and the upper bit of the program counter relative value, and if the carry number is received from the lower bit calculation unit, add the carry number or the lower bit When the borrowing number is received from the calculation unit, the borrowing number is subtracted and the result of the calculation is displayed as the upper bit of the program counter value. It may be characterized in that to execute the high-order bit operation and bets the upper bit arithmetic unit of the processor.

これによって、プログラムカウンタ相対値演算命令を実行する際に、桁上り方式によりプログラムカウンタの値とプログラムカウンタ相対値とを演算するプロセッサを対象としたプログラムを生成するコンパイラ装置を実現できる。
ここで、前記プログラムカウンタ相対値演算命令は、前記プログラムカウンタの値の下位ビットとプログラムカウンタ相対値の下位ビットとを桁上り、桁借りは発生させずに、加算又は減算し、演算結果をプログラムカウンタの値の下位ビットとする下位ビット演算をプロセッサの下位ビット演算部に実行させ、前記プログラムカウンタの値の上位ビットとプログラムカウンタ相対値の上位ビットとを加算又は減算し、演算結果をプログラムカウンタの値の上位ビットとする上位ビット演算をプロセッサの上位ビット演算部に実行させることを特徴としてもよい。
As a result, when executing the program counter relative value calculation instruction, it is possible to realize a compiler device that generates a program for a processor that calculates the value of the program counter and the program counter relative value by the carry method.
Here, the program counter relative value calculation instruction adds or subtracts the lower bit of the value of the program counter and the lower bit of the program counter relative value without causing a borrow, and programs the calculation result. The lower bit operation part of the processor executes the lower bit operation to be the lower bit of the counter value, and adds or subtracts the upper bit of the program counter value and the upper bit of the program counter relative value, and the operation result is the program counter. It is also possible to cause the high-order bit calculation unit of the processor to execute high-order bit calculation that uses the high-order bit of the value of.

これによって、プログラムカウンタ相対値演算命令を実行する際に、桁上りなし方式によりプログラムカウンタの値とプログラムカウンタ相対値とを演算するプロセッサを対象としたプログラムを生成するコンパイラ装置を実現できる。
ここで、前記プログラムカウンタ相対値演算命令は、前記プログラムカウンタの値の上位ビットとプログラムカウンタ相対値の上位ビットとを加算又は減算し、演算結果をプログラムカウンタの値の上位ビットとする上位ビット演算をプロセッサの上位ビット演算部に実行させ、前記プログラムカウンタ相対値の下位ビットをプログラムカウンタの値の下位ビットとすることを特徴としてもよい。
Thus, it is possible to realize a compiler device that generates a program for a processor that calculates the value of the program counter and the program counter relative value by the no carry method when executing the program counter relative value calculation instruction.
Here, the program counter relative value calculation instruction adds or subtracts the high order bit of the program counter value and the high order bit of the program counter relative value, and uses the calculation result as the high order bit of the program counter value. May be executed by an upper bit arithmetic unit of the processor, and the lower bit of the program counter relative value may be used as the lower bit of the value of the program counter.

これによって、プログラムカウンタ相対値演算命令を実行する際に、絶対値方式によりプログラムカウンタの値とプログラムカウンタ相対値とを演算するプロセッサを対象としたプログラムを生成するコンパイラ装置を実現できる。   Thus, it is possible to realize a compiler device that generates a program for a processor that calculates the value of the program counter and the program counter relative value by the absolute value method when executing the program counter relative value calculation instruction.

本発明に係るプロセッサは、命令の実行速度の向上したプロセッサとして、コンパイラ装置、最適化装置、アセンブラ装置等に利用できる。   The processor according to the present invention can be used in a compiler device, an optimization device, an assembler device, and the like as a processor with improved instruction execution speed.

図1(a)は、第1の実施形態のプロセッサが実行する命令のフォーマットを示す。 図1(b)は、第1の実施形態のプロセッサが実行する命令のフォーマットを示す。 図1(c)は、第1の実施形態のプロセッサが実行する命令のフォーマットを示す。 図1(d)は、第1の実施形態のプロセッサが実行する命令のフォーマットを示す。FIG. 1A shows the format of instructions executed by the processor of the first embodiment. FIG. 1B shows a format of instructions executed by the processor of the first embodiment. FIG. 1C shows the format of instructions executed by the processor of the first embodiment. FIG. 1D shows the format of instructions executed by the processor of the first embodiment.

図1(e)は、第1の実施形態のプロセッサが実行する命令のフォーマットを示す。
図2(a)は、命令の格納、及び読み出し単位である命令パケットを示す図である。 図2(b)は、命令の読み出しの順序を示す図である。 図2(c)は、命令の実行の順序を示す図である。 通常のプロセッサで、バイトアラインされていない命令を実行する場合の命令の格納、読み出し方法の例を示す図である。 プロセッサが実行するオブジェクトコードが、コンパイラ装置と、最適化装置と、アセンブラ装置と、リンカ装置により作成される過程を示す図である。 プロセッサ309及び外部メモリの詳細を示すブロック図である。 パケット内アドレスのインクリメントの規則を示すインクリメント表である。 図7(a)は、分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。
FIG. 1E shows a format of instructions executed by the processor of the first embodiment.
FIG. 2A is a diagram illustrating an instruction packet which is a unit for storing and reading instructions. FIG. 2B is a diagram showing the order of reading instructions. FIG. 2C is a diagram showing the order of instruction execution. It is a figure which shows the example of the storing and reading method of an instruction | indication in the case of executing the instruction | command which is not byte-aligned in a normal processor. It is a figure which shows the process in which the object code which a processor performs is produced by a compiler apparatus, an optimization apparatus, an assembler apparatus, and a linker apparatus. It is a block diagram which shows the detail of the processor 309 and external memory. It is an increment table which shows the rule of the increment of the address in a packet. FIG. 7A is an addition table showing an addition rule between the lower 3 bits of the branch instruction address and the lower 3 bits of the PC relative value.

図7(b)は、分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。
最適化装置303の構成要素及び入出力データを示すブロック図である。 最適化装置303の動作手順を示すフローチャートである。 コード最適化手段902が生成した最適化処理コード903の一部分を示す。 図10の最適化処理コードより生成されたアドレス付与コード916を示す。 図11のアドレス付与コードから生成されたラベル情報906を示す。 図11のアドレス付与コードから生成された最適化コード915を示す。 アセンブラ装置305の構成及び関連する入出力データを示すブロック図である。 アセンブラ装置305の動作手順を示すフローチャートである。 図13の最適化コードから生成された機械語コード803を示す。 図16の機械語コードより作成されたラベル情報を示す。 図16の機械語コード803から生成されたリロケータブルコードを示す。 リンカ装置307の構成及び関連する入出力データを示すブロック図である。 リンカ装置307の動作手順を示すフローチャートである。 リロケータブルコードを示す。 図18に示すリロケータブルコード306と、別途生成された図21に示すリロケータブルコードと結合された状態を示す。 結合コード703を示す。 図23の結合コードより作成されたラベル情報を示す。 図23の結合コードより生成されたオブジェクトコードを示す。 第2の実施形態に係るオブジェクトコードを示す。 図27(a)は、第3の実施形態に係る命令パケットの構成を示す。
FIG. 7B is a subtraction table showing a subtraction rule between the lower 3 bits of the branch destination instruction address and the lower 3 bits of the branch instruction address.
It is a block diagram which shows the component of the optimization apparatus 303, and input-output data. 4 is a flowchart showing an operation procedure of the optimization device 303. A part of the optimization processing code 903 generated by the code optimization unit 902 is shown. An address assignment code 916 generated from the optimization processing code of FIG. 10 is shown. 12 shows label information 906 generated from the address assignment code of FIG. 12 shows an optimization code 915 generated from the address assignment code of FIG. It is a block diagram which shows the structure of the assembler apparatus 305, and related input / output data. 4 is a flowchart illustrating an operation procedure of an assembler device 305. FIG. 14 shows a machine language code 803 generated from the optimized code of FIG. The label information created from the machine language code of FIG. 16 is shown. FIG. 17 shows a relocatable code generated from the machine language code 803 of FIG. 16. FIG. It is a block diagram which shows the structure of the linker apparatus 307, and related input-output data. It is a flowchart which shows the operation | movement procedure of the linker apparatus 307. Indicates a relocatable code. The relocatable code | cord | chord 306 shown in FIG. 18 and the state couple | bonded with the relocatable code | cord | chord shown in FIG. 21 produced | generated separately are shown. A connection code 703 is shown. The label information created from the combined code of FIG. 23 is shown. 24 shows an object code generated from the combined code of FIG. The object code which concerns on 2nd Embodiment is shown. FIG. 27A shows a configuration of an instruction packet according to the third embodiment.

図27(b)は、命令の種類を示す。
図27(c)は、パケット内アドレスと、パケット内アドレスが指定するパケット内のユニットとの関係を示す。
図28(a)は、第4の実施形態に係る桁上りなし方式のアドレス演算による分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。
FIG. 27B shows the types of instructions.
FIG. 27C shows the relationship between the in-packet address and the unit in the packet specified by the in-packet address.
FIG. 28A is an addition table showing an addition rule between the lower 3 bits of the address of the branch instruction and the lower 3 bits of the PC relative value by the address operation of the no carry method according to the fourth embodiment.

図28(b)は、第4の実施形態に係る桁上りなし方式のアドレス演算による分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。
第4の実施形態に係る桁上りなし方式のアドレス演算を用いて生成されたオブジェクトコードの具体例である。 図30(a)は、第5の実施形態に係る絶対値方式のアドレス演算による分岐命令のアドレスの下位3ビットとPC相対値の下位3ビットとの加算規則を示す加算表である。
FIG. 28B is a subtraction table showing a subtraction rule between the lower 3 bits of the address of the branch destination instruction and the lower 3 bits of the address of the branch instruction by the address operation of the no carry method according to the fourth embodiment. .
It is a specific example of the object code produced | generated using the address calculation of the no carry method based on 4th Embodiment. FIG. 30A is an addition table showing an addition rule for the lower 3 bits of the address of the branch instruction and the lower 3 bits of the PC relative value by the absolute value type address operation according to the fifth embodiment.

図30(b)は、第5の実施形態に係る絶対値方式のアドレス演算による分岐先命令のアドレスの下位3ビットと分岐命令のアドレスの下位3ビットとの減算規則を示す減算表である。
第5の実施形態に係る絶対値方式のアドレス演算を用いて生成されたオブジェクトコードの具体例である。 第6の実施形態に係るリニア方式のアドレス演算を用いて生成されたオブジェクトコードを示す。 第7の実施形態に係るプロセッサの構成図である。 図34(a)は、PC加算命令のニーモニックとオペレーションの対応を示す。
FIG. 30B is a subtraction table showing a subtraction rule between the lower 3 bits of the address of the branch destination instruction and the lower 3 bits of the address of the branch instruction by the absolute value type address operation according to the fifth embodiment.
It is a specific example of the object code produced | generated using the address calculation of the absolute value system which concerns on 5th Embodiment. The object code produced | generated using the linear type address calculation which concerns on 6th Embodiment is shown. It is a block diagram of the processor which concerns on 7th Embodiment. FIG. 34 (a) shows the correspondence between mnemonics of PC addition instructions and operations.

図34(b)は、PC減算命令のニーモニックとオペレーションの対応を示す。
第8の実施形態に係るコンパイラ装置の構成図である。 コンパイラ装置の動作手順を示すフローチャートである。 C言語で記述されたソースコードを示す。 図37のソースプログラムが変換された中間コードを示す。 図38の中間コードが変換されたアセンブラコードを示す。 第8の実施形態に係るデバッガ装置と逆アセンブラ装置の構成を示すブロック図である。 逆アセンブラ装置の動作手順を示すフローチャートである。 デバッガ装置の動作手順を示すフローチャートである。 従来のプロセッサの基本構成を示すブロック図である。
FIG. 34 (b) shows the correspondence between mnemonics of PC subtraction instructions and operations.
It is a block diagram of the compiler apparatus which concerns on 8th Embodiment. It is a flowchart which shows the operation | movement procedure of a compiler apparatus. The source code described in C language is shown. The intermediate code into which the source program of FIG. 37 was converted is shown. FIG. 40 shows an assembler code obtained by converting the intermediate code of FIG. It is a block diagram which shows the structure of the debugger apparatus and disassembler apparatus which concern on 8th Embodiment. It is a flowchart which shows the operation | movement procedure of a disassembler apparatus. It is a flowchart which shows the operation | movement procedure of a debugger apparatus. It is a block diagram which shows the basic composition of the conventional processor.

符号の説明Explanation of symbols

100 並列実行境界情報
101 ビットフォーマット情報
300 ソースコード
301 コンパイラ装置
302 アセンブラコード
303 最適化装置
304 最適化コード
305 アセンブラ装置
306 リロケータブルコード
307 リンカ装置
308 オブジェクトコード
309 プロセッサ
401a〜401c 演算器
402 汎用レジスタ
403 上位PC
404 下位PC
405 下位PC演算器
406 データメモリ
407 命令メモリ
408 命令バッファ
409a〜409c 命令デコーダ
410 フェッチ上位カウンタ
411 上位PC演算器
412 INC
413 プリフェッチ下位カウンタ
420 PC相対値セレクタ
421 即値セレクタ
422 オペランドアドレスバッファ
423 オペランドデータバッファ
424a〜c 制御信号
702 コード結合手段
703 結合コード
704 再配置情報検出手段
705 再配置情報
706 下位アドレス減算手段
707 桁借り数
708 下位減算結果
709 上位アドレス減算手段
710 上位減算結果
711 アドレス差算出手段
712 アドレス差
713 再配置情報解決手段
802 機械語コード生成手段
803 機械語コード
804 ラベル検出手段
805 ラベル情報
806 下位アドレス減算手段
807 桁借り数
808 下位減算結果
809 上位アドレス減算手段
810 上位減算結果
811 アドレス差算出手段
812 アドレス差
813 ラベル情報解決手段
902 コード最適化手段
903 最適化処理コード
904 アドレス付与手段
905 ラベル検出手段
906 ラベル情報
907 下位アドレス減算手段
908 桁借り数
909 下位減算結果
910 上位アドレス減算手段
911 上位減算結果
912 アドレス差算出手段
913 アドレス差
914 ラベル情報解決手段
916 アドレス付与コード
2800 第2下位PC演算器
2801a〜2801c 命令デコーダ
2802 第2上位PC演算器
2901 ソースコード
2902 中間コード変換部
2903 中間コード
2904 PC値加算命令変換部
2905 命令変換部
2906 アセンブラコード
4000 入力制御部
4001 パケットアドレス特定部
4002 パケット内アドレス特定部
4003 パケット内アドレス特定部
4004 命令メモリ
4005 命令バッファ
4006 命令解読部
4007 PC相対値
4008 下位PC演算器
4009 上位PC演算器
4010 ラベル検索部
4011 ラベルテーブル
4012 表示部
4013 命令置換部
4300 プログラムカウンタ
4301 命令メモリ
4302 命令読み出し部
4303 命令実行部
100 Parallel execution boundary information 101 Bit format information 300 Source code 301 Compiler device 302 Assembler code 303 Optimization device 304 Optimization code 305 Assembler device 306 Relocatable code 307 Linker device 308 Object code 309 Processor 401a to 401c Operation unit 402 General-purpose register 403 High-order PC
404 Subordinate PC
405 Lower PC calculator 406 Data memory 407 Instruction memory 408 Instruction buffer 409a to 409c Instruction decoder 410 Upper fetch counter 411 Upper PC calculator 412 INC
413 Prefetch lower counter 420 PC relative value selector 421 Immediate value selector 422 Operand address buffer 423 Operand data buffer 424a-c Control signal 702 Code combining means 703 Combined code 704 Relocation information detecting means 705 Relocation information 706 Lower address subtracting means 707 Digit borrowing Number 708 Lower subtraction result 709 Upper address subtraction means 710 Upper subtraction result 711 Address difference calculation means 712 Address difference 713 Relocation information resolution means 802 Machine language code generation means 803 Machine language code 804 Label detection means 805 Label information 806 Lower address subtraction means 807 Number of digits borrowed 808 Lower subtraction result 809 Upper address subtraction means 810 Upper subtraction result 811 Address difference calculation means 812 Address difference 813 Information information resolution means 902 code optimization means 903 optimization processing code 904 address assignment means 905 label detection means 906 label information 907 lower address subtraction means 908 number of borrows 909 lower subtraction result 910 upper address subtraction means 911 upper subtraction result 912 address difference Calculation means 913 Address difference 914 Label information resolution means 916 Address assignment code 2800 Second lower PC calculator 2801a to 2801c Instruction decoder 2802 Second upper PC calculator 2901 Source code 2902 Intermediate code conversion unit 2903 Intermediate code 2904 PC value addition instruction conversion Part 2905 Instruction conversion part 2906 Assembler code 4000 Input control part 4001 Packet address specifying part 4002 In-packet address specifying part 4003 In-packet address Identification unit 4004 Instruction memory 4005 Instruction buffer 4006 Instruction decoding unit 4007 PC relative value 4008 Lower PC computing unit 4009 Upper PC computing unit 4010 Label search unit 4011 Label table 4012 Display unit 4013 Instruction replacement unit 4300 Program counter 4301 Instruction memory 4302 Instruction reading unit 4303 Instruction execution unit

Claims (1)

メモリから命令を読み出すプロセッサにおいて、
メモリから自然数のバイト単位からなる少なくとも1つのメモリの1単位データを読み出し、前記メモリの1単位データは1つのオペレーションを示すプロセッサの1単位命令を含み、各メモリの1単位データはプロセッサによって実行されるものであり、前記1つのオペレーションを示すプロセッサの1単位命令のメモリの1単位データに含まれる数は、2のべき乗を除く自然数であり、
第1のプログラムカウンタは、前記メモリの1単位データのメモリにおける格納位置を示し、
第2のプログラムカウンタは、前記メモリの1単位データに含まれる1つのオペレーションを示すプロセッサの1単位命令の格納数で一巡し、前記メモリの1単位データにおける前記1つのオペレーションを示すプロセッサの1単位命令の格納位置を示し、
前記第2のプログラムカウンタが格納位置を一巡した後、第1のプログラムカウンタは、前記メモリにおけるメモリの1単位データの次の格納位置を示すことを特徴とするプロセッサ。

In a processor that reads instructions from memory,
One unit data of at least one memory consisting of a natural number of bytes is read from the memory. The one unit data of the memory includes one unit instruction of the processor indicating one operation, and the one unit data of each memory is executed by the processor. The number included in one unit data of the memory of one unit instruction of the processor indicating the one operation is a natural number excluding the power of 2,
The first program counter indicates a storage position in the memory of one unit data of the memory,
The second program counter makes a round with the number of stored one unit instructions of the processor indicating one operation included in one unit data of the memory, and one unit of the processor indicating the one operation in one unit data of the memory Indicates the instruction storage location,
After the second program counter makes a round of storage locations, the first program counter indicates the next storage location of one unit of data in the memory in the memory.

JP2004210765A 1998-04-28 2004-07-16 Processor Expired - Lifetime JP4323393B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004210765A JP4323393B2 (en) 1998-04-28 2004-07-16 Processor

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP11832698 1998-04-28
JP2004210765A JP4323393B2 (en) 1998-04-28 2004-07-16 Processor

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2001028234A Division JP3595269B2 (en) 1998-04-28 2001-02-05 Instruction sequence optimization device, assembler device, linker device, disassembler device, compiler device, and recording medium

Publications (2)

Publication Number Publication Date
JP2004288223A JP2004288223A (en) 2004-10-14
JP4323393B2 true JP4323393B2 (en) 2009-09-02

Family

ID=33301326

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004210765A Expired - Lifetime JP4323393B2 (en) 1998-04-28 2004-07-16 Processor

Country Status (1)

Country Link
JP (1) JP4323393B2 (en)

Also Published As

Publication number Publication date
JP2004288223A (en) 2004-10-14

Similar Documents

Publication Publication Date Title
US7823142B2 (en) Processor for executing instructions in units that are unrelated to the units in which instructions are read, and a compiler, an optimization apparatus, an assembler, a linker, a debugger and a disassembler for such processor
JP6591978B2 (en) Instruction set conversion system and method
JP4295804B2 (en) Processor, compile device, and recording medium recording compile program
US7533243B2 (en) Processor for executing highly efficient VLIW
EP1157329B1 (en) Methods and apparatus for branch prediction using hybrid history with index sharing
JP2816248B2 (en) Data processor
KR100328162B1 (en) Information Processing Circuits and Microcomputers and Electronic Devices
US5129068A (en) Operand address calculation in a pipeline processor by decomposing the operand specifier into sequential step codes
KR100254008B1 (en) Data processor simultaneously executable two instruction
US7480783B2 (en) Systems for loading unaligned words and methods of operating the same
US4945511A (en) Improved pipelined processor with two stage decoder for exchanging register values for similar operand instructions
US6611956B1 (en) Instruction string optimization with estimation of basic block dependence relations where the first step is to remove self-dependent branching
US6170998B1 (en) Processor which returns from a subroutine at high speed and a program translating apparatus which generates machine programs that makes a high-speed return from a subroutine
JP3983482B2 (en) PC relative branching with high-speed displacement
US7010665B1 (en) Method and apparatus for decompressing relative addresses
JP4323393B2 (en) Processor
US6209080B1 (en) Constant reconstruction processor that supports reductions in code size and processing time
JP3595269B2 (en) Instruction sequence optimization device, assembler device, linker device, disassembler device, compiler device, and recording medium
US5774694A (en) Method and apparatus for emulating status flag
JP3190639B2 (en) Processor
US7415599B1 (en) Instruction operation and operand memory location determined based on preceding instruction operation and operand memory location
JP2007004475A (en) Processor and method for executing program
US7111148B1 (en) Method and apparatus for compressing relative addresses
JP4457127B2 (en) Processor, compile device, and recording medium recording compile program
JP4709806B2 (en) Processor, compile device, and recording medium recording compile program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060414

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090512

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090604

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120612

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120612

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120612

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130612

Year of fee payment: 4

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term