JP4032822B2 - Address description conversion system and program for assembler program - Google Patents

Address description conversion system and program for assembler program Download PDF

Info

Publication number
JP4032822B2
JP4032822B2 JP2002144512A JP2002144512A JP4032822B2 JP 4032822 B2 JP4032822 B2 JP 4032822B2 JP 2002144512 A JP2002144512 A JP 2002144512A JP 2002144512 A JP2002144512 A JP 2002144512A JP 4032822 B2 JP4032822 B2 JP 4032822B2
Authority
JP
Japan
Prior art keywords
address
instruction
program
character string
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 - Fee Related
Application number
JP2002144512A
Other languages
Japanese (ja)
Other versions
JP2003337708A (en
Inventor
孝寛 久村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP2002144512A priority Critical patent/JP4032822B2/en
Publication of JP2003337708A publication Critical patent/JP2003337708A/en
Application granted granted Critical
Publication of JP4032822B2 publication Critical patent/JP4032822B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、あるプロセッサの命令記述を別のプロセッサの命令記述へ変換する技術に関する。
【0002】
【従来の技術】
プロセッサは、処理内容を複数の命令からなるプログラムとして与えることができる計算機である。プログラムの最小構成単位は命令である。命令には加算や減算、プロセッサに接続されたメモリからデータを読み込んだり、メモリへデータを書き出したりする処理が含まれる。通常、命令はプロセッサによって異なる。従って、あるプロセッサ用の命令で記述されたプログラムは他のプロセッサでは動作しない。これを動作させるには、プログラムに記述された命令を目的のプロセッサの命令へ変換する必要がある。
【0003】
変換の方法は大きく分けて2種類ある。ひとつはバイナリコードレベルでの変換であり、もうひとつはソースコードレベルの変換である。バイナリコードレベルでの変換に関しては、IBM社(http://www.ibm.com)のDAISY [文献1, 2], DEC社のFX!32 [文献3],Transmeta 社 (http://www.transmeta.com) の Crusoe プロセッサ[文献4],Transitive 社 (http://www.transitive.com) の Dynamite [文献5] 等が知られている。ソースコードレベルの変換に関しては、 アセンブリ言語で記述されたソースコードの変換の例として[文献6]や[文献7]がある。
【0004】
・[文献1];K. Ebcioglu, E. Altman, M. Gschwind, and S. Sathaye, "Dynamic binary translation and optimization," IEEE Transactions on Computers, Vol. 50, Issue 6, pp. 529-548, Jun. 2001.
・[文献2];Http://oss.software.ibm.com/developerworks/opensource/daisy/
・[文献3];A. Chernoff, M. Herdeg, R. Hookway, C. Reeve, N. Rubin, T. Tye, S.B. Yadavalli, and J. Yates, "FX!32 A Profile-Directed Binary Translator," IEEE Micro, vol. 18, no. 2, pp. 56-64, Mar. 1998.
・[文献4];Alexander Klaib, "The Technology Behind Crusoe Processors," Technical report, Transmeta Corp., Santa Clara, Calif. USA, Jan. 2000, available at http://www.transmeta.com.
・[文献5];"The Technology Behind Crusoe Processors," Product data sheet, Transitive Technologies Ltd., 2001, available at http://www.transitives.com.
・[文献6];M. F. Smith and B. E. Luff, "Automatic assembler source translation from the Z80 to the MC6809," IEEE Micro, Vol. 4, No 2, pp. 3-9, Apr. 1984.
・[文献7];Texas Instruments Europe, "TMS320C5x to TMS320C54x Translation Utility," Literature Number: BPRA075, Feb. 1998.
【0005】
IBM 社のDAISY は、Intel 社の x86 アーキテクチャや IBM 社の PowerPC アーキテクチャ用のバイナリコードを、実行時にIBM 社のVLIW (very long instruction word) プロセッサへ変換するソフトウェアである[文献1, 2]。 DEC 社の FX!32 は x86 アーキテクチャ用のバイナリコードを、DEC 社の Alphaプロセッサ上で実行できるように変換するソフトウェアである[文献3]。 Transmeta社の Crusoe というプロセッサは Intel 社の x86 アーキテクチャとは異なる命令セットをもっているにもかかわらず、Crusoe はプログラム実行時に x86 命令を Crusoe 命令へバイナリレベルで変換することができるので、 x86 アーキテクチャ用に記述されたプログラムを実行することができる[文献3]。Transitive 社は、あるプロセッサ用のバイナリコードを別のプロセッサ用のバイナリコードへ変換するソフトウェアを提供している[文献5]。
【0006】
一方、[文献6] では Zilog 社 (http://www.zilog.com) の Z80 プロセッサ用の アセンブリ言語で記述されたソースコードを Motorola 社 (http://www.motorola.com) の MC6809用 プロセッサ用のアセンブリ言語で記述されたソースコードへ変換する技術について述べられている。 [文献7] では Texas Instruments 社 (http://www.ti.com) の TMS320C5x プロセッサ用のアセンブリ言語で記述されたソースコードを 同社の TMS320C54x プロセッサ用のアセンブリ言語で記述されたソースコードへ変換する技術について述べられている。
【0007】
バイナリレベル変換のメリットは、一度あるプロセッサ用に作成したバイナリコードに何の変更も加えることなく、それを別のプロセッサで実行できることである。元のソースコードがなくてもバイナリコードだけがあればよい。変換後のバイナリコードはそれを実行するプロセッサによって解釈される。プログラムの実行時に変換が行われる場合、ユーザが変換に関わることはなく、プログラムが変換されていることすら意識する必要がない。
【0008】
一方、バイナリレベル変換のデメリットは変換後バイナリコードをユーザが修正することが非常に困難であることである。なぜなら、変換後バイナリコードを編集するにはそれを逆アセンブルすることが必要であるが、そうして得られるアセンブリソースコードは非常に理解しがたいからである。もし、変換後バイナリコードの実行速度にユーザが満足できないとしても、それを改善することはほとんど不可能である。
【0009】
もしユーザが変換後バイナリコードの実行時間をできるだけ短くしたい場合、
バイナリレベル変換は適していない。それよりはソースコードレベルの変換が適している。もしユーザが変換元プログラムのソースコードをもっているなら、それをターゲットとなるプロセッサ用に再コンパイルできる。変換元プログラムが C言語などの高級言語で記述されていれば、ターゲットプロセッサへの再コンパイルは非常に簡単である。変換元プログラムがアセンブリ言語で記述されている場合、そのソースコードをターゲットプロセッサのアセンブリ言語で記述されたソースコードへ変換できさえすれば、変換後にユーザが最適化することも可能である。
【0010】
これまで述べてきた従来のコード変換技術では、アドレス体系が同一のプロセッサを対象にしていた。プロセッサは一般に1バイト(8ビット)のデータごとにひとつのアドレスをつけている。これはバイトアドレス方式と呼ばれる。参考文献として示した従来例のほとんどはバイトアドレス方式にもとづくプロセッサ間でコードを変換する技術である。一方、複数バイトのデータごとにアドレスをつけるプロセッサもある。たとえば、Texas Instruments 社の TMS320C5x やTMS320C54x という信号処理プロセッサは、2バイト(16ビット,1ワード)ごとにアドレスをつけている。これは一般にワードアドレス方式と呼ばれる。
【0011】
アドレス体系が異なるプロセッサ間でもコード変換は理論的に可能ではあるが、そのようなコード変換に関する技術はこれまで報告されていない。例えばワードアドレス方式のプロセッサ用に記述されたプログラムをバイトアドレス方式のプロセッサ用のプログラムへ変換することは可能であるが、このような変換に関する報告例はない。報告例がない理由のひとつは、アドレス体系が異なるプロセッサ間でプログラムを変換する場合、プログラムに含まれるアドレス記述を変換することが困難だったからである。従来は元プログラムに含まれる全てのアドレス記述を自動的に効率よく変換できなかった。変換後プログラムの実行時間やコードサイズが元プログラムに比べて著しく劣化したり、アドレス記述変換を手作業で行う必要があったために、アドレス体系が異なるプロセッサ間での効率のよいコード変換ができなかった。
【0012】
アドレス体系が異なるプロセッサ間でプログラムを変換する場合、従来はエミュレーションという技術を用いていた。エミュレーションとはあるプロセッサ用に記述されたプログラムを別のプロセッサで実行するための技術である。例えば、エミュレーションを使って、プロセッサA用のプログラムをプロセッサBで実行する場合、まず仮想的なプロセッサAをプロセッサB上に構築する。そして、その仮想的プロセッサAがプロセッサA用のプログラムを実行する。エミュレーションは、仮想的プロセッサを介在して他のプロセッサ用のプログラムを実行することになるので、プログラムの実行速度は劣化する。プログラムを高速に実行するためには、プログラムを変換して、プロセッサAがプログラムを直接実行する方がよいのは明らかである。
【0013】
【発明が解決しようとする課題】
複数バイトのデータに対してひとつのアドレスを割り当てるワードアドレス方式にもとづくプロセッサから1バイトのデータに対してひとつのアドレスを割り当てるバイトアドレス方式にもとづくプロセッサへプログラムを変換する場合に、元プログラムに含まれる全てのアドレス記述を自動的に効率よく変換できなかったので、変換後プログラムの実行時間やコードサイズが元プログラムに比べて著しく劣化したり、アドレス記述変換を手作業で行う必要があった。
【0014】
本発明はこの点に注目し、アドレス体系が互いに異なる二つのプロセッサにおけるコード変換において、効率よくアドレス記述を変換することを目的とする。具体的には、第1のバイト数のデータに対してひとつのアドレスを割り当てるアドレス方式に基づく変換元プロセッサ用の変換元プログラムから、第2のバイト数のデータに対してひとつのアドレスを割り当てるアドレス方式に基づく変換後プロセッサ用の変換後プログラムへ変換において、変換後プログラムの実行時間やコードサイズに関して、効率よくアドレス記述を変換することを目的とする。
【0015】
【課題を解決するための手段】
本発明の文字列変換システム(図1の100)は、上記目的を達成するため、文字列置換手段(図1の110)と、文字列置換手段(図1の121)と、文字列挿入手段(図1の122)と、不要命令削除手段(図1の130)と、出力手段(図1の140)とを持つ。
【0016】
文字列変換システム(図1の100)には変換元プログラムが入力される。文字列置換手段(図1の110)は、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を、上記入力された変換元プログラム中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍[L=(変換元プロセッサが一つのアドレスを割り当てるデータのバイト数)/(変換後プロセッサが一つのアドレスを割り当てるバイト数)であり、2以上の整数)]する記述に置き換える。
【0017】
文字列置換手段(図1の121)は、第1の文字列置換手段(図1の110)での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使っメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。
【0018】
文字列挿入手段(図1の122)は、第1の文字列置換手段(図1の110)での置き換えが済んだプログラム中に、プロセッサの汎用レジスタに格納したアドレスを使ってメモリから値を読み込む処理を伴う命令あるいは汎用レジスタに格納したアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、該命令が参照するアドレスを格納した汎用レジスタをL倍する命令を該命令の前のサイクルで実行されるよう挿入し、さらに該汎用レジスタを1/L倍する命令を該命令の後のサイクルで実行されるよう挿入する。
【0019】
不要命令削除手段(図1の130)は、文字列置換手段(図1の121)と文字列挿入手段(図1の122)によって処理された文字列を含む全ての文字列から不必要な命令を削除する。出力手段(図1の140)は、不要命令削除手段(図1の130)によって削除されなかった命令を含む全ての文字列を出力する。
【0020】
また、本発明の文字列変換システム(図2の200)は、上記目的を達成するため、第1の文字列置換手段(図2の210)と、第2の文字列置換手段(図2の221)と、第3の文字列置換手段(図2の222)と、第1の文字列挿入手段(図2の223)と、第2の文字列挿入手段(図2の224)と、不要命令削除手段(図2の230)と、出力手段(図2の240)とを持つ。
【0021】
文字列置換手段(図2の210)は、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を入力された変換元プログラム中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍のアドレスにする記述へ置き換える。
【0022】
文字列置換手段(図2の221)は、文字列置換手段(図2の210)での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。
【0023】
文字列置換手段(図2の222)は、文字列置換手段(図2の210)での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してシンボル文字列や数値で記述された値を転送する命令があればそれらシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。
【0024】
文字列挿入手段(図2の223)は、文字列置換手段(図2の210)での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令があれば、該アドレス専用レジスタに格納された値をL倍する命令を該命令の後のサイクルで実行されるよう挿入する。もしくは転送元の値をL倍する命令を該命令の前のサイクルで実行されるように挿入し、転送元の値を1/L倍する命令を該命令の後のサイクルで実行されるよう挿入する。
【0025】
文字列挿入手段(図2の224)は、文字列置換手段(図2の210)での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令があれば、転送後の値を1/L倍する命令を該命令の後のサイクルで実行されるように挿入する。もしくは該アドレス専用レジスタに格納された値を1/L倍する命令を該命令の前のサイクルで実行されるように挿入し、さらに該アドレス専用レジスタに格納された値をL倍する命令を該命令の後のサイクルで実行されるように挿入する。
【0026】
不要命令削除手段(図2の230)は、文字列変換手段(図2の220)によって挿入された命令の中から、不要な命令を探し出し削除する。出力手段(図2の240)は不要命令削除手段(図2の230)が削除しなかった命令を含む全ての文字列を出力する。
【0027】
【発明の実施の形態】
次に本発明の実施の形態について図面を参照して詳細に説明する。
【0028】
【構成の説明】
プロセッサのプログラムにおいて、アドレスを表す値は一般にベースアドレスとオフセットアドレスとにわけられる。一般にベースアドレスはシンボル文字列として参照される。例えばメモリ上の配列の先頭アドレスを参照するために、配列の名称(シンボル文字列)が使用される。オフセットアドレスは数値で直接記述されたり、もしくは数値を割り当てたシンボル文字列で記述される。あるいは、配列の名称として自動的にアドレスを与えられるシンボル文字列どおしの差分としてオフセットアドレスが表されることもある。
【0029】
以降では、Lバイト(Lは2以上の整数)のデータに対してひとつのアドレスを割り当てるアドレス方式をワードアドレス方式と呼ぶことにする。ワードアドレスを使用するプロセッサを仮にプロセッサW、バイトアドレスを使用するプロセッサを仮にプロセッサBとする。プロセッサ W 用に記述されたプログラムでは、リンカ等のツールが自動的に配列の名称を示すシンボル文字列にワードアドレスを割り当てる。プロセッサB用にアセンブリ言語で記述されたソースコードでは、リンカ等のツールが自動的に配列の名称を示すシンボル文字列にバイトアドレスを割り当てる。
【0030】
仮に、プロセッサWとプロセッサBがアドレス体系だけを除いて同一のアーキテクチャであって、全く同一の命令セットをもっているとする。この場合、プロセッサWの命令が記述されたプログラムを、そのままの状態でプロセッサB用のプログラムとして解釈すると、リンカなどによって自動的にアドレスが割り当てられるシンボル文字列だけがバイトアドレスをもち、それ以外のアドレスを示す数値やシンボル文字列はワードアドレスを保持することになる。
【0031】
仮にプロセッサWとプロセッサBが全く同一の命令セットを持っていても、アドレス体系が異なるのでプロセッサWの命令が記述されたプログラムをプロセッサB用のプログラムとして解釈するには、アドレスに関する記述を変換する必要がある。仮にプロセッサWとプロセッサBが異なる命令セットを持っていたとしたら、個々の命令を変換することに加えて、やはりアドレスに関する記述を変換する必要がある。
【0032】
本発明は、あるアドレス方式のプログラムを他のアドレス方式のプログラムに変換する際(例えば、ワードアドレス方式にもとづくプロセッサWの命令が記述されたプログラムを、バイトアドレス方式にもとづくプロセッサB用のプログラムへ変換する際や、一つのアドレスを割り当てるデータのバイト数が異なり、その比が2以上の整数であるワードアドレス方式のプロセッサ間でプログラムを変換する際等)に必要となる、プログラムの中のアドレス記述を変換するシステムである。
【0033】
まず、プロセッサWとプロセッサBが全く同一の命令セットを持っていて、 アセンブリ言語仕様も全く同じで、アドレス体系だけが異なる場合について、 アドレス記述を変換するシステムについて述べる。
【0034】
図1を参照すると、本発明にかかる文字列変換システム100の第1の実施の形態は、文字列置換手段110、文字列変換手段120、不要命令削除手段130、出力手段140及び記録媒体K1から構成される。文字列変換手段120は、文字列置換手段121と、文字列挿入手段122とから構成される。記録媒体K1は、ディスク、半導体メモリ、その他の記録媒体であり、コンピュータを文字列変換システム100として機能させるためのプログラムが記録されている。このプログラムは、コンピュータによって読み取られ、その動作を制御することで、コンピュータ上に、文字列置換手段110、文字列変換手段120、不要命令削除手段130、出力手段140を実現する。
【0035】
まず、文字列置換手段110について説明する。文字列置換手段110は、リンカなど他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列がプログラムの中で参照されたら、そのシンボル文字列に割り当てられるアドレスをその1/L倍のアドレスにする記述へ変換する。ここで、LはプロセッサWにおいてアドレスが割り当てられる最小のデータ幅を示すバイト数である。例えば、2バイトのデータに対してひとつアドレスが割り当てられる場合、Lは2である。
【0036】
例えば、変換元プログラムにおいて、他のソフトウェアによってワードアドレスが自動的に割り当てられるシンボル文字列labelが参照されている場合、変換後プログラムでは labelを(label/L) へ変換する。あるいはxを1/L倍する関数div(x,L)を定義して、labelをdiv(label,L)へ変換する。変換後プログラムではlabel がバイトアドレスをもつので、(label/L) やdiv(x,L)は変換元プロセッサにおけるワードアドレスを示す。
【0037】
ただし、分岐命令においてプログラムの分岐先を示すために使用されているシンボル文字列は置き換えの対象とされない。分岐命令とはプログラムの実行の流れを切り替える命令である。
【0038】
次に、文字列変換手段120について説明する。文字列変換手段120は、文字列置換手段110の処理が終了したプログラムの中のアドレス記述を含んだ命令を変換する。アドレス記述を含んだ命令とは、メモリからデータを読み込む処理を伴う命令、メモリへデータを書き込む処理を伴う命令などである。
【0039】
以下、文字列変換手段120について詳しく述べる。文字列変換手段120の動作を説明するには、プロセッサのアーキテクチャや命令セットを仮定する必要がある。そこで、図3にプロセッサWおよびプロセッサBのレジスタ構成を示す。プロセッサWおよびプロセッサBはN個の汎用レジスタとM個のアドレス専用レジスタを持つ。NとMは0以上の整数である。ここでは汎用レジスタRnと呼ぶことにする。nには0からN-1のいずれかの数字が当てはまる。Nが0の場合には汎用レジスタRnは存在しないとする。ここではアドレス専用レジスタをAmと呼ぶことにする。mには0からM-1のいずれかの数字が当てはまる。Mが0の場合にはアドレス専用レジスタAmが存在しないとする。汎用レジスタRnはプロセッサが計算に使用する値や計算結果を格納する場所である。また汎用レジスタRnにはメモリ上のデータや命令の位置を示すアドレスを格納することもできる。一方アドレス専用レジスタAmはメモリ上のデータや命令の位置を示すアドレスを格納する場所である。
【0040】
本実施の形態にかかる文字列変換システム100では、プロセッサがメモリからデータを読み込んだりメモリへデータを書き込んだりする際に使用するアドレスに関して、メモリのアドレスの一部または全てをシンボル文字列や数値で直接記述したり、汎用レジスタにメモリのアドレスの一部または全てを格納しておくと仮定する。
【0041】
文字列変換手段120において、処理の対象となるプロセッサの命令はメモリからデータを読み込む処理を伴う命令と、メモリへデータを書き込む処理を伴う命令である。これらの命令において、データの場所を示すアドレスがどのように命令の中に記述されているかで処理内容が異なる。以下に処理内容を決定するルールを示す。
【0042】
ルール(1)
「アドレスの一部または全てがシンボル文字列や数値で記述されているなら、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。」
ルール(2)
「アドレスの一部または全てが汎用レジスタ Rn に格納されているなら、汎用レジスタRnに格納されているアドレスをL倍する命令を当該命令の前のサイクルで実行されるよう挿入し、さらに該汎用レジスタRnに格納されているアドレスを1/L倍する命令を該命令の後のサイクルで実行されるよう挿入する。」
【0043】
文字列変換手段120は、文字列置換手段121と、文字列挿入手段122とを含んでいる。ルール(1)に該当する命令があれば、文字列置換手段121がルール(1)に記述された処理を実行する。ルール(2)に該当する命令があれば、文字列挿入手段122がルール(2)に記述された処理を実行する。複数のルールに該当する命令があれば、 該当する全てのルールに記述された処理が実行される。
【0044】
プロセッサWおよびプロセッサBの基本命令セット21(図4)を使って、上記ルール(1)、(2)の具体例について説明する。図4には変換対象となる命令と変換に必要な命令が示されている。図4に示した命令を参照するために、図4の命令参照記号を使用する。命令の記述方法はプロセッサによって異なるし、命令が記述されるファイル形式によっても異なるが、ここでは図4に示した記述例を使って説明する。
【0045】
命令LDST0の変換方法
命令LDST0は、シンボル文字列や数値によって記述されたアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(1)を適用する。命令LDST0において、アドレスの一部または全てを示すシンボル文字列や数値をL倍する記述へ変換する。例えば、
R0=*[label+K]

R0=*[(label+K)*L]
へ変換する。ここでlabelはリンカなど他のソフトウェアによってアドレスが自動的に割り当てられるシンボル文字列であり、Kは任意の定数を表すシンボル文字列または数値である。
【0046】
命令LDST1の変換方法
命令LDST1は、汎用レジスタが示すアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(2)を適用する。 命令 LDST1において、アドレスの一部または全てを保持する汎用レジスタを L倍する命令を変換対象命令の前のサイクルで実行されるように挿入する。さらにアドレスの一部または全てを保持する汎用レジスタを 1/L 倍する命令を変換対象命令の後のサイクルで実行されるように挿入する。例えばL=2の場合は、
R0=*[R4]

R4=R4+R4
R0=*[R4]
R4=R4>>1
の三つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令 R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。
【0047】
命令LDST2の変換方法
命令LDST2 は、シンボル文字列や数値によって記述されたアドレスと汎用レジスタの和が示すアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(1)およびルール(2)を適用する。命令LDST2において、アドレスの一部または全てを示すシンボル文字列や数値をL倍する記述へ変換する。さらにアドレスの一部または全てを保持する汎用レジスタをL倍する命令を変換対象命令の前のサイクルで実行されるように挿入する。 さらにアドレスの一部または全てを保持する汎用レジスタを1/L倍する命令を変換対象命令の後のサイクルで実行されるように挿入する。例えばL=2の場合は、
R0=*[R4+K]

R4=R4+R4
R0=*[R4+(K)*2]
R4=R4>>1
の三つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令 R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。
【0048】
命令LDST3の変換方法
命令LDST3は、ある汎用レジスタと別の汎用レジスタの和で示されるアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(2)を適用する。命令LDST3において、アドレスの一部または全てを保持する汎用レジスタをそれぞれL倍する命令を変換対象命令の前のサイクルで実行されるように挿入する。さらにアドレスの一部または全てを保持する汎用レジスタをそれぞれ1/L倍する命令を変換対象命令の後のサイクルで実行されるように挿入する。例えばL=2 の場合は、
R0=*[R4+R5]

R4=R4+R4
R5=R5+R5
R0=*[R4+R5]
R4=R4>>1
R5=R5>>1
の五つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。同様に、加算命令R5=R5+R5の代わりに左シフト命令R5=R5<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。同様に、右1ビットシフト命令の代わりにR4を1/2倍する他の命令を使用してもよい。
【0049】
命令ADD1の変換方法
命令ADD1は、汎用レジスタに格納された値と、メモリからロードした値とを加算してその結果を汎用レジスタへ転送する命令である。命令ADD1において、例えばメモリからロードすべきデータのアドレスの一部または全てがシンボル文字列や数値で記述される場合、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。あるいは命令ADD1において、例えばメモリからロードすべきデータのアドレスの一部または全てが汎用レジスタに格納される場合、汎用レジスタに格納されたアドレスをL倍する命令を変換対象命令の前のサイクルで実行されるように挿入し、さらに汎用レジスタに格納されたアドレスを1/L倍する命令を変換対象命令の後のサイクルで実行されるように挿入する。
【0050】
命令 ADD1 において、例えばシンボル文字列や数値によってアドレスが記述される場合、ルール(1)を適用する。例えば、
R0=R0+*[label+K]

R0=R0+*[(label+K)*L]
へ変換する。ここで、labelはリンカなど他のソフトウェアによってアドレスが自動的に割り当てられるシンボル文字列であり、Kは任意の定数を表すシンボル文字列または数値である。
【0051】
命令ADD1において、例えばL=2で、汎用レジスタ R4 にアドレスが格納される場合、ルール(2)を適用する。例えば、
R0=R0+*[R4]

R4=R4+R4
R0=R0+*[R4]
R4=R4>>1
の三つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令 R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。
【0052】
命令ADD1において、例えばL=2で、汎用レジスタR4とシンボル文字列Kの和でアドレスが表される場合、ルール(1)およびルール(2)を適用する。例えば、
R0=R0+*[R4+K]

R4=R4+R4
R0=R0+*[R4+(K)*2]
R4=R4>>1
の三つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令 R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。
【0053】
命令ADD1において、例えばL=2で、汎用レジスタR4と汎用レジスタR5の和でアドレスが表される場合、ルール(2)を適用する。例えば、
R0=R0+*[R4+R5]

R4=R4+R4
R5=R5+R5
R0=R0+*[R4+R5]
R4=R4>>1
R5=R5>>1
の五つの命令へ変換する。ここでは汎用レジスタR4を2倍するために加算命令 R4=R4+R4を使用したが、左シフト命令R4=R4<<1を使用してもよい。同様に、加算命令R5=R5+R5の代わりに左シフト命令R5=R5<<1を使用してもよい。汎用レジスタR4を1/2倍するために右1ビットシフト命令を使用したが、R4を1/2倍する他の命令を使用してもよい。同様に、右1ビットシフト命令の代わりにR4を1/2倍する他の命令を使用してもよい。
【0054】
図4には記述されていない他の命令、例えば減算命令、乗算命令、除算命令、シフト命令、論理演算命令などにおいて、メモリから値を読み込んだり、あるいはメモリへ値を書き込んだりする処理を伴う命令があれば、その命令に含まれるアドレスに関する記述を上記のように変換する。
【0055】
図4に示した命令のうちこれまでに変換方法を述べていない命令 (MV0 命令、ADD0命令、SHFT0命令 ) は、ルール(1)にも ルール(2)にも該当しないので、何も変更されない。
【0056】
次に、不要命令削除手段130について説明する。不要命令削除手段130は、文字列変換手段120の処理結果を引き取って、プログラムを解析し、不要な命令を削除する。
【0057】
文字列変換手段120によって変換されたプログラムは不必要な命令を含む場合がある。不要な命令はプログラムの実行時間やコードサイズを増加させるので好ましくない。そこで不要命令を削除する。ここでいう不要命令とは、文字列変換手段120によって挿入された命令であって、プログラムの実行結果に影響を与えない命令である。
【0058】
例えば、文字列変換手段120が、あるプログラムに加算命令R0=R0+R0(汎用レジスタR0と汎用レジスタR0の和を汎用レジスタR0へ格納する)を挿入し、その命令の直後に右1ビットシフト命令 R0=R0>>1 (汎用レジスタR0を右1ビットシフトして再び汎用レジスタ R0 へ格納する) を挿入したとする。そして、加算命令 R0=R0+R0の実行前も実行後も汎用レジスタR0の最上位ビットが0であることがわかっている場合、文字列変換手段120によって挿入された加算命令と直後の右1ビットシフト命令は不要である。なぜなら、加算命令R0=R0+R0の直後に右1ビットシフト命令R0=R0>>1を実行するとR0は加算命令R0=R0+R0を実行する前の値に戻るからである。
【0059】
あるいは、文字列変換手段120が、あるプログラムに右1ビットシフト命令R0=R0>>1を挿入し、その命令の直後に加算命令R0=R0+R0を挿入したとする。そして、右1ビットシフト命令R0=R0>>1の実行前に汎用レジスタR0の最下位ビットが0であることがわかっている場合、文字列変換手段2によって挿入された右1ビットシフト命令と直後の加算命令は不要である。なぜなら、右1ビットシフト命令R0=R0>>1の直後に加算命令R0=R0+R0を実行すると、R0右1ビットシフト命令R0=R0>>1を実行する前の値に戻るからである。
【0060】
不要な命令を削除することはプログラムを変換しながらでも可能である。例えば命令を変換する際に既に変換した命令との関係を調べれば、不要な命令かどうか判断することができる。あるいは、変換前にプログラムを解析しておき、不要な命令を挿入しないようにプログラムを変換することもできる。本発明の文字列変換システムはどちらの構成に対しても応用することが可能である。
【0061】
次に、出力手段140について説明する。出力手段140は、不要命令削除手段130によって削除されなかった命令を含む全ての文字列を出力する。
【0062】
次に、図2を参照して本発明にかかる文字列変換システムの第2の実施の形態について説明する。本実施の形態の文字列変換システム200は、文字列置換手段210と、文字列変換手段220と、不要命令削除手段230と、出力手段240と、記録媒体K2とから構成されている。記録媒体K2は、ディスク、半導体メモリ、その他の記録媒体であり、コンピュータを文字列変換システム200として機能させるためのプログラムが記録されている。このプログラムは、コンピュータによって読み取られ、コンピュータ上に、文字列置換手段210、文字列変換手段220、不要命令削除手段230、出力手段240を実現する。
【0063】
文字列置換手段210、不要命令削除手段230、出力手段240は、それぞれ図1に示した文字列置換手段110、不要命令削除手段130、出力手段140と同様の構成を有しているので、ここでは、文字列変換手段220についてのみ説明する。なお、本実施の形態の文字列変換システム200では、プロセッサがメモリからデータを読み込んだりメモリへデータを書き込んだりする際に使用するアドレスに関して、アドレスの一部または全てをシンボル文字列や数値で直接記述したり、アドレス専用レジスタにアドレスの一部または全てを格納しておくと仮定する。
【0064】
文字列変換手段220において、処理の対象となるプロセッサの命令はメモリからデータを読み込む処理を伴う命令と、メモリへデータを書き込む処理を伴う命令と、アドレス専用レジスタへ値を転送する命令と、アドレス専用レジスタに格納された値をアドレス専用レジスタ以外へ転送する命令である。これらの命令において、アドレスがどのように記述されているか、転送される値がどのように命令の中に記述されているか、値がどこへ転送されるのかなどによって処理内容が異なる。
【0065】
以下に処理内容を決定するルールを示す。
【0066】
ルール(3)
「メモリから値を読み込む処理を伴う命令やメモリへ値を書き込む処理を伴う命令において、アドレスの一部または全てがシンボル文字列や数値で記述されているなら、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。」
ルール(4)
「アドレス専用レジスタ Am へ値を転送する命令において、転送する値の一部または全てがシンボル文字列や数値で記述されているなら、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。」
ルール(5)
「アドレス専用レジスタAmへ値を転送する命令において、転送する値の一部または全てがアドレス専用レジスタ以外の場所に格納されているなら、アドレス専用レジスタAmをL倍する命令を当該命令の後のサイクルで実行されるように挿入する。または転送元の値をL倍する命令を当該命令の前のサイクルで実行されるよう挿入し、さらに転送元の値を1/L倍する命令を当該命令の後のサイクルで実行されるよう挿入する。」
ルール(6)
「アドレス専用レジスタAmに格納された値をアドレス専用レジスタ以外の場所へ転送する命令において、転送される値の一部または全てがアドレス専用レジスタAmに格納されている場合、転送後の値を1/L倍する命令を当該命令の後のサイクルで実行されるように挿入する。またはアドレス専用レジスタAmに格納された値を1/L倍する命令を当該命令の前のサイクルで実行されるよう挿入し さらにアドレス専用レジスタAmに格納された値をL倍する命令を当該命令の後のサイクルで実行されるよう挿入する。」
【0067】
文字列変換手段220は文字列置換手段221と、文字列置換手段222と、文字列挿入手段223と、文字列挿入手段224とを含んでいる。ルール(3)に該当する命令があれば、文字列置換手段221がルール(3)に記述された処理を実行する。ルール(4)に該当する命令があれば、文字列置換手段222がルール(4)に記述された処理を実行する。ルール(5)に該当する命令があれば、文字列挿入手段223がルール(5)に記述された処理を実行する。ルール(6)に該当する命令があれば、文字列挿入手段224がルール(6)に記述された処理を実行する。複数のルールに該当する命令があれば、該当する全てのルールに記述された処理が実行される。
【0068】
プロセッサWおよびプロセッサBの基本命令セット22,23(図5、図6)を使って、上記ルール(3)、(4)、(5)、(6) の具体例について説明する。図5、図6には変換の対象となる命令と変換に必要な命令が示されている。図5、図6に示した命令を参照するために、図5、図6の命令参照記号を使用する。命令の記述方法はプロセッサによって異なるし、命令が記述されるファイル形式によっても異なるが、ここでは図5、図6に示した記述例を使って説明する。
【0069】
命令LDST0の変換方法
命令LDST0は、シンボル文字列や数値によって記述されたアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(3)を適用する。命令LDST0においてアドレスの一部または全てを示すシンボル文字列や数値をL倍する記述へ変換する。つまり、
R0=*[label+K]

R0=*[(label+K)*L]
へ変換する。ここで、labelはリンカなど他のソフトウェアによってアドレスが自動的に割り当てられるシンボル文字列であり、Kは任意の定数を表すシンボル文字列または数値である。
【0070】
命令LDST5の変換方法
命令 LDST5 は、シンボル文字列や数値によって記述されたアドレスとアドレス専用レジスタの和が示すアドレスからデータを読み込む命令、あるいはそのアドレスへデータを書き込む命令である。従ってルール(3)を適用する。命令LDST5において、アドレス専用レジスタに格納されたアドレスは、アドレス専用レジスタへ転送された時点でバイトアドレスへ変換されているとみなし、アドレスの一部または全てを示すシンボル文字列や数値だけをL倍する記述へ変換する。例えばL=2の場合、
R0=*[A0+K]

R0=*[A0+(K)*L]
へ変換する。
【0071】
命令LDST7の変換方法
命令LDST7は、メモリから値を読み込み、それをアドレス専用レジスタAmへ転送する命令である。命令 LDST7 において、メモリから読み込んだ値のL倍の値がアドレス専用レジスタAmへ転送されるように変換する。さらにメモリのアドレスの一部または全てがシンボル文字列や数値で記述されていたら、それらをL倍する記述へ変換する。例えば命令LDST7においてL=2で、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む場合、ルール(3)およびルール(5)を適用する。例えば、
A0=*[label+K]

A0=*[(label+K)*2]
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令A0=A0<<1を使用してもよい。
【0072】
あるいは命令LDST7においてL=2で、アドレス専用レジスタに格納したアドレスを使ってメモリから値を読み込む場合、ルール(5)を適用する。例えば、
A0=*[A1]

A0=*[A1]
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令A0=A0<<1を使用してもよい。
【0073】
あるいは命令LDST7においてL=2で、アドレス専用レジスタに格納したアドレスと シンボル文字列や数値で記述されたアドレスとの和で表されるアドレスを使ってメモリから値を読み込む場合、ルール(3)とルール(5)を適用する。例えば、
A0=*[A1+K]

A0=*[A1+(K)*2]
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令 A0=A0<<1 を使用してもよい。
【0074】
命令LDST8の変換方法
命令LDST8は、アドレス専用レジスタAmに格納された値をメモリへ転送する命令である。命令LDST8において、アドレス専用レジスタに格納された値の1/L倍の値がメモリへ転送されるように変換する。さらにメモリのアドレスの一部または全てがシンボル文字列や数値で記述されていたら、それらをL倍する記述へ変換する。例えば命令LDST8においてL=2で、シンボル文字列や数値で記述されたアドレスを使ってメモリへ値を転送する場合、ルール(3)とルール(6)を適用する。例えば、
*[label+K]=A0

A0=A0>>1
*[(label+K)*2]=A0
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令 A0=A0<<1を使用してもよい。アドレス専用レジスタA0を1/2倍するために右1ビットシフト命令を使用したが、A0を1/2倍する他の命令を使用してもよい。
【0075】
あるいは命令LDST8においてL=2で、アドレス専用レジスタに格納したアドレスを使ってメモリへ値を転送する場合、ルール(6)を適用する。例えば、
*[A1]=A0

A0=A0>>1
*[A1]=A0
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令A0=A0<<1を使用してもよい。アドレス専用レジスタA0を1/2倍するために右1ビットシフト命令を使用したが、A0を1/2倍する他の命令を使用してもよい。
【0076】
あるいは命令LDST8においてL=2で、アドレス専用レジスタに格納したアドレスとシンボル文字列や数値で記述されたアドレスとの和で表されるアドレスを使ってメモリへ値を転送する場合、ルール(3)とルール(6)を適用する。例えば、
*[A1+K]=A0

A0=A0>>1
*[A1+(K)*2]=A0
A0=A0+A0
へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令 A0=A0+A0を使用したが、左シフト命令A0=A0<<1を使用してもよい。アドレス専用レジスタA0を1/2倍するために右1ビットシフト命令を使用したが、A0を1/2倍する他の命令を使用してもよい。
【0077】
命令MV1の変換方法
命令MV1はシンボル文字列や数値で記述された値をアドレス専用レジスタへ転送する命令である。従ってルール(4)を適用する。命令MV1において、命令実行後にアドレス専用レジスタがL倍の値をもつように変換する。つまり、
A0=K

A0=(K)*L
へ変換する。
【0078】
命令MV2の変換方法
命令MV2は汎用レジスタからアドレス専用レジスタへ値を転送する命令である。従ってルール(5)を適用する。命令MV2において、命令実行後にアドレス専用レジスタが汎用レジスタの L 倍の値をもつように変換する。例えばL=2の場合は、
A0=R0

A0=R0
A0=A0+A0
の二つの命令へ変換する。あるいは、
R0=R0+R0
A0=R0
R0=R0>>1
の三つの命令へ変換する。ここでは汎用レジスタR0を2倍するために加算命令 R0=R0+R0を使用したが、左シフト命令R0=R0<<1を使用してもよい。汎用レジスタR0を1/2倍するために右1ビットシフト命令を使用したが、R0を1/2倍する他の命令を使用してもよい。
【0079】
命令MV3の変換方法
命令MV3はアドレス専用レジスタから汎用レジスタへ値を転送する命令である。従ってルール(6)を適用する。命令MV3において、命令実行後に汎用レジスタがアドレス専用レジスタの1/L倍の値をもつように変換する。例えばL=2の場合は、
R0=A0

R0=A0
R0=R0>>1
の二つの命令へ変換する。あるいは、
A0=A0>>1
R0=A0
A0=A0+A0
の三つの命令へ変換する。ここではアドレス専用レジスタA0を2倍するために加算命令A0=A0+A0を使用したが、左シフト命令A0=A0<<1を使用してもよい。汎用レジスタR0を1/2倍するために右1ビットシフト命令を使用したが、R0を1/2倍する他の命令を使用してもよい。アドレス専用レジスタA0を1/2倍するために右1ビットシフト命令を使用したが、A0を1/2倍する他の命令を使用してもよい。
【0080】
命令ADD1の変換方法
命令ADD1は、汎用レジスタに格納された値と、メモリからロードした値とを加算してその結果を汎用レジスタへ転送する命令である。従ってルール(3)を適用する。命令ADD1において、例えばメモリからロードすべきデータのアドレスの一部または全てがシンボル文字列や数値で記述される場合、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える。例えば、シンボル文字列labelとシンボル文字列Kの和でアドレスが表される場合、
R0=R0+*[label+K]

R0=R0+*[(label+K)*L]
へ変換する。
【0081】
あるいは命令ADD1において、アドレス専用レジスタA0とシンボル文字列Kの和でアドレスが表される場合、そのシンボル文字列部分をL倍する記述へ置き換える。例えば、
R0=R0+*[A0+K]

R0=R0+*[A0+(K)*L]
へ変換する。
【0082】
図5、図6には記述されていない他の命令、例えば減算命令、乗算命令、除算命令、シフト命令、論理演算命令などにおいて、メモリから値を読み込んだり、あるいはメモリへ値を書き込んだりする処理を伴う命令があれば、その命令に含まれるアドレスに関する記述を上記のように変換する。
【0083】
図5及び図6に示した命令のうちこれまでに変換方法を述べていない命令 (LDST4命令、LDST6命令、ADD0命令、ADD2命令、MV0命令、SHFT0命令、SHFT1 命令) はルール(3)、(4)、(5)、(6) に該当しないので、何も変更されない。
【0084】
これまで述べてきた本発明の文字列変換システムは、プログラムのファイル形式に依存していない。つまり、どのようなファイル形式にも応用することができる。例えばプログラムがソースコードとして記述されていてもよいし、バイナリコードとして記述されていてもよい。入力となるプログラムを含む文字列がテキスト形式ならば、変換後のプログラムもテキスト形式で出力する。入力となるプログラムを含む文字列がバイナリ形式ならば、変換後のプログラムはテキスト形式あるいはバイナリ形式のどちらかで出力する。
【0085】
さらに本発明の文字列変換システムは、静的な変換はもとより動的な変換にも応用できる。静的な変換とは、プログラムを実行前に変換することを意味する。 動的な変換とは、プログラムを実行中に変換することを意味する。
【0086】
これまでは、特にL=2バイトのデータに対してひとつのアドレスを割り当てる ワードアドレス方式にもとづくプロセッサWから1バイトのデータに対してひとつのアドレスを割り当てる バイトアドレス方式にもとづくプロセッサBへプログラムを変換する場合についてだけ説明した。
【0087】
本発明の文字列変換システムはL=2だけでなく、Lが2よりも大きな整数の場合にも簡単に応用できる。また、2台のプロセッサが、共にワードアドレス方式に基づくものであっても、一つのアドレスを割り当てるバイト数の比Lが2以上の整数の場合は、本発明を適用することができる。
【0088】
また、これまではプロセッサWとプロセッサBが全く同一の命令セットをもっていて、アセンブリ言語も全く同じで、アドレス体系だけが異なる場合に、プロ セッサW用に記述されたプログラムをプロセッサB用のプログラムへ変換する方法についてだけ述べた。本発明の文字列変換システムはこのような場合だけでなく、プロセッサWとプロセッサBが異なる命令セットをもつ場合にも応用できる。
【0089】
例えば、まず本発明の文字列変換システムによりアドレス体系だけを変換してから、次に命令セットを変換する。その逆に、先に命令セットを変換してから、本発明の文字列変換システムによりアドレス体系を変換することも可能である。 あるいは、アドレス体系の変換と命令セットの変換を同時に行うことも考えられる。アドレス体系と命令セットを同時に変換する場合、本発明の文字列変換システム図1において、文字列変換手段2が命令セットを変換する機能を有することになる。つまり第1の実施の形態にかかる文字列変換システム100では文字列変換手段120が、第2の実施の形態にかかる文字列変換システム200では文字列変換手段220が命令セットを変換する手段を有することになる。
【0090】
さらに、より一般的な変換を行うために、変換元プロセッサ用に記述されたプログラムを仮想的なプロセッサ用のプログラムへ変換し、さらにそれを目的のプロセッサ用プログラムへ変換するという方法も考えられる。この場合、プログラムを二回変換することになるが、そのどちらかで本発明を使用する。二回の変換はどちらも命令セットの変換を必要とするので、そのうちのどちらかで、前述のように本発明の文字列変換システムと命令セット変換を組み合わせて使用する。
【0091】
【動作の説明】
まず、プロセッサWとプロセッサBとが全く同一の命令セットを持っていて、アセンブリ言語も全く同じで、アドレス体系だけが異なる場合に、プロセッサW用に記述されたプログラムをプロセッサB用のプログラムへ変換する場合の動作を図1の文字列変換システム100を用いて説明する。プロセッサWはLバイトのデータに対してひとつのアドレスを割り当てるワードアドレス方式にもとづくプロセッサでありここでは仮にL=2とする。プロセッサBは1バイトのデータに対してひとつのアドレスを割り当てるバイトアドレス方式に基づくプロセッサである。プロセッサWとプロセッサBは図3に示すように汎用レジスタとアドレス専用レジスタをもつと仮定する。さらに図4に示す基本命令セット21をもつと仮定する。
【0092】
図8は、プロセッサ W 用にアセンブリ言語で記述されたプログラムである。1行にひとつの命令が記述され、命令の終端にはセミコロン;が記述される。/*と*/で囲まれているのはコメントである。図8において、label1 というシンボル文字列はメモリ上のあるアドレスを示すラベルであり、実際のアドレスはリンカによって自動的に割り当てられるものとする。
【0093】
図8の変換元プログラムが入力されると、文字列変換システム100内の文字列置換手段110が、文字列置換処理を行う(図7、ステップS1)。文字列置換手段110は、ツールによって自動的にアドレスが割り当てられるシンボル文字列記述を参照する記述を、変換先プロセッサにおいてワードアドレスが参照されるように変換する。図8では、ツールによって自動的にアドレスが割り当てられるシンボル文字列はlabel1だけである。従って、文字列置換手段110によってlabel1が (label1/2)という記述へ変換される。文字列置換手段110による処理を終えたプログラムを図9に示す。
【0094】
次に文字列変換手段120がアドレス記述を含む命令の変換を行う(ステップS2)。文字列変換手段120は図9のプログラムを読み込んでアドレス記述を含む命令をひとつひとつ変換する。以下に各命令がどのように変換されるかを述べる。命令を参照するために、図9の命令参照記号を使用する。
● 転送命令move0とmove1では何も変更されない。
● ロード命令load0では、アドレスを示すシンボル文字列や数値が2倍される。
● ロード命令load1では、load1の前にアドレスを格納したR4を2倍する命令が挿入され、load1の後にR4を1/2 倍する命令が挿入される。
● ロード命令load2では、load2の前にアドレスを格納したR4を2倍する命令が挿入され、load2の後にR4を1/2倍する命令が挿入される。さらにアドレスを示すシンボル文字列や数値が2倍される。
● ロード命令load3では、load3の前にアドレスを格納したR4およびR5を 2倍する命令が挿入され、load3の後にR4およびR5を1/2 倍する命令が挿入される。
● 加算命令add0とadd1では、何も変換されない。
【0095】
図10に文字列変換手段120による処理を終えたプログラムを示す。 図10では、変換元プログラムには元々無く、変換によって追加された命令を字下げして示している。
【0096】
次に不要命令削除手段130が文字列変換手段120によって挿入された命令の中から不要な命令を削除する(ステップS3)。文字列変換手段120によって処理されたプログラム図10をよく見ると、変換によって追加された加算命令やシフト命令のうち、いくつかは不必要であることがわかる。例えば、シフト命令R4=R4>>1 (第8行目) の直後に、このシフト結果を利用した加算命令R4=R4+R4(第9行目) がある。これらはどちらも文字列変換手段120によって挿入された。第6行目で加算命令R4=R4+R4によって汎用レジスタR4の最下位ビットは0になっているので、第8行目と第9行目の二つの命令を実行しても、汎用レジスタR4は変化しない。従って、これらの命令を実行することは無意味である。同様なことが、シフト命令R4=R4>>1(第11行目) と加算命令R4=R4+R4 (第12行目)にも当てはまる。不要命令削除手段130はこうした命令を削除したプログラムを出力手段140へ渡す。
【0097】
そして、出力手段140は不要命令削除手段130から引き取ったプログラムを出力する(ステップS4)。出力手段140が出力した変換後プログラムを図11に示す。
【0098】
次に、プロセッサWとプロセッサBが全く同一の命令セットをもっていて、アセンブリ言語も全く同じで、アドレス体系だけが異なる場合に、プロセッサW用に記述されたプログラムをプロセッサBへ変換する場合の動作を図2の文字列変換システム200を用いて説明する。プロセッサWはLバイトのデータに対してひとつのアドレスを割り当てるワードアドレス方式にもとづくプロセッサであり、ここでは仮にL=2とする。プロセッサBは1バイトのデータに対してひとつのアドレスを割り当てるバイトアドレス方式に基づくプロセッサである。プロセッサWとプロセッサBは図3に示すように汎用レジスタとアドレス専用レジスタをもつと仮定する。さらに図6に示す基本命令セット22をもつと仮定する。
【0099】
図12は、プロセッサW用にアセンブリ言語で記述されたプログラムである。
1行にひとつの命令が記述され、命令の終端にはセミコロン;が記述される。/*と*/で囲まれているのはコメントである。図12において、label1というシンボル文字列はメモリ上のあるアドレスを示すラベルであり、実際のアドレスはリンカによって自動的に割り当てられるものとする。
【0100】
図12の変換元プログラムが入力されると、文字列変換システム200内の文字列置換手段210が、文字列置換処理を行う(図7、ステップS1)。文字列置換手段210は、ツールによって自動的にアドレスが割り当てられるシンボル文字列記述を参照する記述を、変換後プロセッサにおいてワードアドレスが参照されるように変換する。図12では、ツールによって自動的にアドレスが割り当てられるシンボル文字列はlabel1だけである。従って、文字列置換手段210によってlabel1が(label1/2) という記述へ変換される。文字列置換手段210による処理を終えたプログラムを図13に示す。
【0101】
次に文字列変換手段220がアドレス記述を含む命令の変換を行う(ステップS2)。文字列変換手段220は図13のプログラムを読み込んでアドレス記述を含む命令をひとつひとつ変換する。以下に各命令がどのように変換されるかを述べる。命令を参照するために、図13の命令参照記号を使用する。
● 転送命令move0とmove1では何も変更されない。
● 転送命令move2とmove3では、アドレス専用レジスタへ転送する数値が2 倍される。
● 転送命令move4とmove5では、アドレス専用レジスタを2倍する命令がそれぞれの命令の後へ挿入される。
● ロード命令load0では、アドレスを示すシンボル文字列や数値が2倍される。
● ロード命令load4では、何も変換されない。
● ロード命令load5では、アドレスを示すシンボル文字列や数値が2倍される。
● ロード命令load6では、何も変換されない。
● 加算命令add0とadd1では、何も変換されない。
● 加算命令add2では、アドレスを示すシンボル文字列や数値が2倍される。
● 転送命令move6では、move6の後に汎用レジスタR4の値を1/2 倍する命令が挿入される。
● 転送命令 move7では、move7の後に汎用レジスタR5の値を1/2倍する命令が挿入される。
【0102】
図14に文字列変換手段220による処理を終えたプログラムを示す。図14では、変換元プログラムには元々無く、変換によって追加された命令を字下げして示している。
【0103】
次に不要命令削除手段230が文字列変換手段220によって挿入された命令の中から不要な命令削除する(ステップS3)。ただし、文字列変換手段220によって処理されたプログラム図14にはたまたま不要な命令がないので、図14のプログラムをそのまま出力手段240へ渡す。
【0104】
そして、出力手段240は不要命令削除手段230から引き取ったプログラムを出力する(ステップS4)。文字列変換手段220によって処理されたプログラム図14にはたまたま不要な命令がなかったので、出力手段240が出力する変換後プログラムも図14と同じになる。
【0105】
次に、異なる命令セットをもつプロセッサW,B間でプログラムを変換する場合の動作を、図2の文字列変換システム200を使って説明する。プロセッサWはLバイトのデータに対してひとつのアドレスを割り当てるワードアドレス方式にもとづくプロセッサとする。ここでは仮にL=2とする。プロセッサBは1バイトのデータに対してひとつのアドレスを割り当てるバイトアドレス方式にもとづくプロセッサとする。プロセッサWとプロセッサBは互いに異なる命令セットをもっていて、アセンブリ言語も異なるとする。図5にプロセッサWの基本命令セット22を示す。図6にプロセッサBの基本命令セット23を示す。以上のような仮定のもとで、プロセッサW用に記述されたプログラムをプロセッサB用のプログラムへ変換する方法について説明する。
【0106】
プロセッサW用にアセンブリ言語で記述されたプログラムとして図12を使用する。既に説明したように、1行にひとつの命令が記述され、命令の終端にはセミコロン;が記述される。/*と*/で囲まれているのはコメントである。label1というシンボル文字列はメモリ上のあるアドレスを示すラベルであり、実際のアドレスはリンカ等の他のツールによって自動的に割り当てられるものとする。
【0107】
図12の変換元プログラムが入力されると、まず文字列置換手段210が文字列の置き換えを行う(図7、ステップS1)。文字列置換手段210は、他のツールによって自動的にアドレスが割り当てられるシンボル文字列記述を参照する記述を、全てワードアドレスが参照されるように変換する。図12では、他のツールによって自動的にアドレスが割り当てられるシンボル文字列はlabel1だけである。従って、文字列置換手段210によってlabel1が (label/2) という記述へ変換される。文字列置換手段210による処理を終えたプログラムを図13に示す。ここまでは、既に述べた命令セットが同一である場合の動作と同じである。
【0108】
次に文字列変換手段220がアドレス記述を含む命令の変換を行う。さらに命令セット変換も行う(ステップS2)。命令セットが異なる場合には、ステップS2で、アドレス記述の変換に加えて命令セットの変換も同時に行う。命令セット変換とはプログラムの入力文字列に含まれていた全てのプロセッサW用命令を対応するひとつ以上のプロセッサB用命令へ変換することである。文字列変換手段220は、図13のプログラムを読み込んで、アドレス記述を含む命令をひとつひとつ変換する。変換後の命令はプロセッサB用の命令である。さらにアドレス記述を含まない命令についてもプロセッサB用の命令へ変換する。以下に各命令がどのように変換されるかを述べる。
【0109】
● 転送命令R4=(label1/2)は命令セット変換によってプロセッサB用命令MV R4,(label1/2) へ変換される。
● 転送命令R5=4は命令セット変換によってプロセッサB用命令 MV R5,4 へ変換される。
● 転送命令A0=(label1/2)はアドレス専用レジスタへ転送される値が2倍される。さらに命令セット変換によってプロセッサB用命令MV A0,((label1/2))*2 へ変換される。
● 転送命令A1=4はアドレス専用レジスタへ転送される値が2倍される。さらに命令セット変換によってプロセッサB用命令MV A0,(4)*2 へ変換される。
● 転送命令A0=R4の直後のサイクルに、アドレス専用レジスタA1の値を2倍するプロセッサB用命令( ADD A0,A0,A0)が挿入される。さらに命令セット変換によって転送命令A0=R4はプロセッサB用命令MV A0,R4 へ変換される。
● 転送命令A1=R5の直後のサイクルに、アドレス専用レジスタA1の値を2倍するプロセッサB用命令(ADD A1,A1,A1)が挿入される。さらに命令セット変換によって転送命令A1=R4はプロセッサB用命令MV A1,R5へ変換される。
● ロード命令R0=*[(label1/2)+4] はアドレスを示すシンボル文字列や数値が2倍される。さらに命令セット変換によってプロセッサB用命令MV R0,*[((label1/2)+4)*2] へ変換される。
● ロード命令R1=*[A0] は命令セット変換によってプロセッサ B 用命令 MV
R1,*[A0] へ変換される。
● ロード命令R2=*[A0+4] はアドレスを示すシンボル文字列や数値が2倍される。さらに命令セット変換によってプロセッサB用命令MV R2,*[A0+(4)*2] へ変換される。
● ロード命令R3=*[A0+A1] は命令セット変換によってプロセッサB用命令 MV R3,*[A0+A1] へ変換される。
● 加算命令R4=R4+R5は命令セット変換によってプロセッサB用命令ADD R4,R4,R5へ変換される。
● 加算命令R5=R5+R3は命令セット変換によってプロセッサB用命令ADD R5,R5,R3へ変換される。
● 加算命令R5=R5+*[(label1/2)+4] はアドレスを示すシンボル文字列や数値が2倍される。さらに命令セット変換によってプロセッサB用命令ADD R5,R5,*[((label1/2)+4)*2]へ変換される。
● 転送命令R4=A0の直後のサイクルに、汎用レジスタR4を1/2倍するプロセッサB用命令(SHIFT_R R4,R4,1)が挿入される。さらに命令セット変換によって転送命令R4=A0はプロセッサB用命令MV R4,A0 へ変換される。
● 転送命令R5=A1の直後のサイクルに、汎用レジスタR5を1/2倍するプロセッサB用命令(SHIFT_R R5, R5, 1)が挿入される。さらに命令セット変換によって転送命令 R5=A1はプロセッサB用命令MV R5, A1へ変換される。
【0110】
図15に文字列変換手段220による処理を終えたプログラムを示す。
【0111】
次に不要命令削除手段230が文字列変換手段220によって挿入された命令の中から不要な命令削除する(ステップS3)。ただし、文字列変換手段220によって処理されたプログラム図15にはたまたま不要な命令がないので、図15のプログラムをそのまま出力手段240へ渡す。
【0112】
そして、出力手段240は不要命令削除手段230から引き取ったプログラムを出力する(ステップS3)。文字列変換手段220によって処理されたプログラム図15にはたまたま不要な命令がなかったので、出力手段240が出力する変換後プログラムも図15と同じになる。
【0113】
これまで述べた実施例では、プログラムのファイル形式について言及しなかった。なぜなら本発明はファイル形式によらず応用することができるからである。例えば、ファイル形式がバイナリ形式であったとしても、あるいはテキスト形式であったとしても、本発明はどちらにも応用することができる。バイナリ形式のプログラムを変換する場合、入力となるプログラムを含む文字列がバイナリ形式で与えられ、それを変換することになる。変換後のプログラムはバイナリ形式として出力してもよいし、テキスト形式で出力するようにしてもよい。
【0114】
また、これまで述べた実施例では、L=2バイトのデータに対してひとつのアドレスを割り当てるワードアドレス方式にもとづくプロセッサWから、1バイトのデータに対してひとつのアドレスを割り当てるバイトアドレス方式にもとづくプロセッサBへプログラムを変換する例を示した。これはLが2よりも大きな整数の場合にも簡単に応用できる。また、2台のプロセッサが、共にワードアドレス方式に基づくものであっても、一つのアドレスを割り当てるバイト数の比Lが2以上の整数の場合は、本発明を適用することができる。さらに本発明の文字列変換システムは、静的な変換はもとより動的な変換にも応用できる。静的な変換とは、プログラムを実行前に変換することを意味する。動的な変換とは、プログラムを実行中に変換することを意味する。
【0115】
【発明の効果】
以上説明したように、本発明の文字列変換システムは、変換元プロセッサが一つのアドレスを割り当てているデータのバイト数と、変換後プロセッサが一つのアドレスを割り当てているデータのバイト数との比にもとづいて、変換元プロセッサで動作可能な変換元プログラム中のアドレス記述を、変換後プロセッサが採用しているアドレス方式に合ったアドレス記述に変換する構成を有しているので、或るアドレス体系を持つ変換元プロセッサ用のプログラムを、自動的に他のアドレス体系を持つ変換後プロセッサ用のプログラムに変換することが可能になる。従って、アドレス記述を手作業で行っていた従来の技術に比較して、効率的に変換後プログラムを得ることが可能になる。また、本発明の文字列変換システムで作成した変換後プログラムを、変換後プロセッサで実行するようにすれば、エミュレーションを使用していた従来の技術に比較して、プログラムの実行速度を向上させることが可能になる。
【0116】
また、本発明の文字列変換システムは、プログラム中の不要命令を削除する不要命令削除手段を備えているので、実行効率の良いプログラムを作成することが可能になる。
【図面の簡単な説明】
【図1】本発明にかかる文字列変換システムの第1の実施の形態の構成例を示すブロック図である。
【図2】本発明にかかる文字列変換システムの第2の実施の形態の構成例を示すブロック図である。
【図3】プロセッサのレジスタ構成を示す図である。
【図4】プロセッサの基本命令セット21を示す図である。
【図5】プロセッサの基本命令セット22を示す図である。
【図6】プロセッサの基本命令セット23を示す図である。
【図7】文字列変換システムの処理例を示す流れ図である。
【図8】変換元プログラムの一例を示す図である。
【図9】文字列置換手段110による処理を終えたプログラムの一例を示す図である。
【図10】文字列変換手段120による処理を終えたプログラムの一例を示す図である。
【図11】出力手段140によって出力された変換後プログラムの一例を示す図である。
【図12】変換元プログラムの他の例を示す図である。
【図13】文字列置換手段210による処理を終えたプログラムの一例を示す図である。
【図14】文字列変換手段220による処理を終えたプログラムあるいは出力手段240によって出力された変換後プログラムの一例を示す図である。
【図15】文字列変換手段220による処理を終えたプログラムあるいは出力手段240によって出力された変換後プログラムの一例を示す図である。
【符号の説明】
100:文字列変換システム
110:文字列置換手段
120:文字列変換手段
121:文字列置換手段
122:文字列挿入手段
130:不要命令削除手段
140:出力手段
200:文字列変換システム
210:文字列置換手段
220:文字列変換手段
221:文字列置換手段
222:文字列置換手段
223:文字列挿入手段
224:文字列挿入手段
230:不要命令削除手段
240:出力手段
11 :プロセッサが計算用の入力データや計算結果等を格納する汎用レジスタ
12 :プロセッサがメモリ上のデータや命令の位置を示すアドレスを格納するアドレス専用レジスタ
21 :プロセッサの基本命令セット
22 :プロセッサの基本命令セット
23 :プロセッサの基本命令セット
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a technique for converting an instruction description of one processor into an instruction description of another processor.
[0002]
[Prior art]
The processor is a computer that can provide processing contents as a program composed of a plurality of instructions. The smallest program unit is an instruction. The instructions include addition, subtraction, and processing for reading data from and writing data to the memory connected to the processor. Usually, the instructions vary from processor to processor. Therefore, a program described by an instruction for a certain processor does not operate on another processor. In order to operate this, it is necessary to convert the instruction described in the program into the instruction of the target processor.
[0003]
There are roughly two types of conversion methods. One is conversion at the binary code level, and the other is conversion at the source code level. Regarding conversion at the binary code level, DAISY [References 1 and 2] from IBM (http://www.ibm.com), FX! 32 [Reference 3] from DEC, Transmeta (http: // www The Crusoe processor of [.transmeta.com] [Reference 4], Dynamite of [Transitive.com] (http://www.transitive.com) [Reference 5], etc. are known. With regard to source code level conversion, there are [Reference 6] and [Reference 7] as examples of source code conversion described in assembly language.
[0004]
[Reference 1]; K. Ebcioglu, E. Altman, M. Gschwind, and S. Sathaye, "Dynamic binary translation and optimization," IEEE Transactions on Computers, Vol. 50, Issue 6, pp. 529-548, Jun . 2001.
・ [Reference 2]; Http://oss.software.ibm.com/developerworks/opensource/daisy/
[Reference 3]; A. Chernoff, M. Herdeg, R. Hookway, C. Reeve, N. Rubin, T. Tye, SB Yadavalli, and J. Yates, "FX! 32 A Profile-Directed Binary Translator," IEEE Micro, vol. 18, no. 2, pp. 56-64, Mar. 1998.
[Reference 4]; Alexander Klaib, "The Technology Behind Crusoe Processors," Technical report, Transmeta Corp., Santa Clara, Calif. USA, Jan. 2000, available at http://www.transmeta.com.
・ [Reference 5]; "The Technology Behind Crusoe Processors," Product data sheet, Transitive Technologies Ltd., 2001, available at http://www.transitives.com.
[Reference 6]; MF Smith and BE Luff, "Automatic assembler source translation from the Z80 to the MC6809," IEEE Micro, Vol. 4, No 2, pp. 3-9, Apr. 1984.
・ [Reference 7]; Texas Instruments Europe, "TMS320C5x to TMS320C54x Translation Utility," Literature Number: BPRA075, Feb. 1998.
[0005]
IBM's DAISY is software that converts binary code for Intel's x86 architecture and IBM's PowerPC architecture into IBM's VLIW (very long instruction word) processor at runtime [References 1 and 2]. DEC FX! 32 is software that converts binary code for the x86 architecture to run on the DEC Alpha processor [Reference 3]. Despite the fact that Transmeta's Crusoe processor has a different instruction set than Intel's x86 architecture, Crusoe can convert x86 instructions to Crusoe instructions at program level at the binary level, so it is written for the x86 architecture. Can be executed [Reference 3]. Transitive provides software that converts binary code for one processor into binary code for another processor [5].
[0006]
On the other hand, in [Reference 6], source code written in assembly language for Z80 processor from Zilog (http://www.zilog.com) is used for MC6809 from Motorola (http://www.motorola.com). A technique for converting into source code written in an assembly language for a processor is described. [Reference 7] converts source code written in assembly language for TMS320C5x processor of Texas Instruments (http://www.ti.com) into source code written in assembly language for TMS320C54x processor of the company. The technology is described.
[0007]
The advantage of binary level translation is that it can be executed on another processor without making any changes to the binary code once created for one processor. Even if there is no original source code, only binary code is required. The converted binary code is interpreted by the processor that executes it. If the conversion is performed when the program is executed, the user is not involved in the conversion and does not need to be aware that the program is converted.
[0008]
On the other hand, the disadvantage of binary level conversion is that it is very difficult for the user to correct the converted binary code. This is because editing the converted binary code requires disassembling it, but the resulting assembly source code is very difficult to understand. If the user is not satisfied with the execution speed of the converted binary code, it is almost impossible to improve it.
[0009]
If the user wants to make the binary code run time as short as possible after conversion,
Binary level conversion is not suitable. A source code level conversion is more suitable. If the user has the source code of the source program, it can be recompiled for the target processor. If the source program is written in a high-level language such as C, recompiling to the target processor is very easy. When the conversion source program is described in the assembly language, the user can optimize it after the conversion as long as the source code can be converted into the source code described in the assembly language of the target processor.
[0010]
In the conventional code conversion techniques described so far, processors with the same address system are targeted. In general, a processor assigns one address for each byte (8 bits) of data. This is called a byte address system. Most of the conventional examples shown as references are technologies for converting codes between processors based on the byte address system. On the other hand, there is a processor that assigns an address for each data of a plurality of bytes. For example, a signal processor called TMS320C5x or TMS320C54x from Texas Instruments assigns an address every 2 bytes (16 bits, 1 word). This is generally called a word address system.
[0011]
Although code conversion is theoretically possible even between processors having different address systems, no technology related to such code conversion has been reported so far. For example, it is possible to convert a program written for a word address type processor into a program for a byte address type processor, but there is no report on such conversion. One of the reasons for not having a report example is that when a program is converted between processors having different address systems, it is difficult to convert an address description included in the program. Conventionally, all address descriptions included in the original program cannot be automatically and efficiently converted. Efficient code conversion between processors with different address systems is not possible because the post-conversion program execution time and code size are significantly degraded compared to the original program and address description conversion must be performed manually. It was.
[0012]
Conventionally, a technique called emulation has been used to convert a program between processors having different address systems. Emulation is a technique for executing a program written for one processor on another processor. For example, when a program for the processor A is executed by the processor B using emulation, a virtual processor A is first constructed on the processor B. Then, the virtual processor A executes a program for the processor A. Since emulation executes a program for another processor through a virtual processor, the execution speed of the program deteriorates. Obviously, in order to execute the program at high speed, it is better to convert the program and the processor A directly executes the program.
[0013]
[Problems to be solved by the invention]
Included in the original program when a program is converted from a processor based on a word address system that assigns one address to multi-byte data to a processor based on a byte address system that assigns one address to 1-byte data Since all address descriptions could not be automatically and efficiently converted, the post-conversion program execution time and code size were significantly deteriorated compared to the original program, and it was necessary to perform address description conversion manually.
[0014]
The present invention pays attention to this point, and an object thereof is to efficiently convert an address description in code conversion in two processors having different address systems. Specifically, from the conversion source program for the conversion source processor based on the address system in which one address is assigned to the first number of bytes of data, an address to which one address is assigned to the second number of bytes of data. An object of the present invention is to efficiently convert an address description with respect to an execution time and a code size of a post-conversion program in conversion to a post-conversion program for a post-conversion processor based on the system.
[0015]
[Means for Solving the Problems]
In order to achieve the above object, a character string conversion system (100 in FIG. 1) according to the present invention includes character string replacement means (110 in FIG. 1), character string replacement means (121 in FIG. 1), and character string insertion means. (122 in FIG. 1), unnecessary instruction deletion means (130 in FIG. 1), and output means (140 in FIG. 1).
[0016]
The conversion source program is input to the character string conversion system (100 in FIG. 1). The character string replacement means (110 in FIG. 1) finds a description referring to a symbol character string to which an address is automatically assigned by other software from the input source program, and the symbol character string is a branch instruction. If the symbol character string is not a symbol character string indicating the branch destination, the address assigned to the symbol character string is multiplied by 1 / L times [L = (number of bytes of data to which the conversion source processor assigns one address) / (Number of bytes to which the processor assigns one address after conversion), and an integer greater than or equal to 2)].
[0017]
The character string replacement means (121 in FIG. 1) reads from the memory using the address described by the symbol character string or numerical value in the program after the replacement by the first character string replacement means (110 in FIG. 1). If there is an instruction accompanied by a process for reading a value or an instruction accompanied by a process for writing a value to a memory using an address described in a symbol character string or a numerical value, the symbol character string or numerical value indicating the memory address is set to an L-fold address. Replace with the description to be.
[0018]
The character string insertion means (122 in FIG. 1) uses the address stored in the general-purpose register of the processor to store the value from the memory in the program that has been replaced by the first character string replacement means (110 in FIG. 1). If there is an instruction involving a read process or an instruction involving a process of writing a value to a memory using an address stored in a general-purpose register, an instruction to multiply the general-purpose register storing the address referred to by the instruction by L An instruction to be executed in a cycle is inserted, and an instruction for multiplying the general-purpose register by 1 / L is inserted to be executed in a cycle after the instruction.
[0019]
The unnecessary instruction deleting means (130 in FIG. 1) is an unnecessary instruction from all the character strings including the character strings processed by the character string replacing means (121 in FIG. 1) and the character string inserting means (122 in FIG. 1). Is deleted. The output means (140 in FIG. 1) outputs all character strings including instructions that have not been deleted by the unnecessary instruction deletion means (130 in FIG. 1).
[0020]
In order to achieve the above object, the character string conversion system (200 in FIG. 2) of the present invention has a first character string replacement unit (210 in FIG. 2) and a second character string replacement unit (in FIG. 2). 221), third character string replacement means (222 in FIG. 2), first character string insertion means (223 in FIG. 2), second character string insertion means (224 in FIG. 2), unnecessary Instruction deletion means (230 in FIG. 2) and output means (240 in FIG. 2) are provided.
[0021]
The character string replacing means (210 in FIG. 2) finds a description referring to a symbol character string to which an address is automatically assigned by other software from the inputted conversion source program, and the symbol character string is a branch instruction branch. If it is not the symbol character string indicating the destination, the symbol character string is replaced with a description that makes the address assigned to the symbol character string 1 / L times.
[0022]
The character string replacement means (221 in FIG. 2) reads a value from the memory using an address described by a symbol character string or a numerical value in the program that has been replaced by the character string replacement means (210 in FIG. 2). If there is an instruction that involves processing, or an instruction that involves writing a value to the memory using an address that is described by a symbol character string or a numerical value, a description that makes the symbol character string or numerical value indicating the memory address L times that address Replace with.
[0023]
The character string replacement means (222 in FIG. 2) is described by a symbol character string or a numerical value in the address dedicated register for storing the address in the program after the replacement by the character string replacement means (210 in FIG. 2). If there is an instruction for transferring the value, the symbol character string or numerical value is replaced with a description that uses an address that is L times the symbol character string or numerical value.
[0024]
The character string insertion means (223 in FIG. 2) receives the value from the location other than the address dedicated register for the address dedicated register for storing the address in the program after the replacement by the character string replacement means (210 in FIG. 2). If there is an instruction for transferring the instruction, an instruction for multiplying the value stored in the address dedicated register by L is inserted so as to be executed in a cycle subsequent to the instruction. Alternatively, an instruction for multiplying the transfer source value by L is inserted to be executed in the previous cycle of the instruction, and an instruction for multiplying the transfer source value by 1 / L is inserted to be executed in the cycle after the instruction. To do.
[0025]
The character string inserting means (224 in FIG. 2) sets the value from the address dedicated register for storing the address to a place other than the address dedicated register in the program after the replacement by the character string replacing means (210 in FIG. 2). If there is an instruction for transferring the instruction, an instruction for multiplying the value after the transfer by 1 / L is inserted so as to be executed in a cycle after the instruction. Alternatively, an instruction for multiplying the value stored in the address dedicated register by 1 / L is inserted so as to be executed in the previous cycle of the instruction, and an instruction for multiplying the value stored in the address dedicated register by L Insert to be executed in a later cycle of the instruction.
[0026]
The unnecessary instruction deleting means (230 in FIG. 2) searches for and deletes unnecessary instructions from the instructions inserted by the character string converting means (220 in FIG. 2). The output means (240 in FIG. 2) outputs all character strings including instructions that are not deleted by the unnecessary instruction deletion means (230 in FIG. 2).
[0027]
DETAILED DESCRIPTION OF THE INVENTION
Next, embodiments of the present invention will be described in detail with reference to the drawings.
[0028]
[Description of configuration]
In a processor program, a value representing an address is generally divided into a base address and an offset address. In general, the base address is referred to as a symbol character string. For example, the name of the array (symbol character string) is used to refer to the start address of the array on the memory. The offset address is described directly as a numerical value or as a symbol character string to which a numerical value is assigned. Alternatively, the offset address may be expressed as a difference between symbol character strings that are automatically given addresses as the names of the arrays.
[0029]
Hereinafter, an address system in which one address is assigned to data of L bytes (L is an integer of 2 or more) will be referred to as a word address system. A processor that uses a word address is assumed to be processor W, and a processor that uses a byte address is assumed to be processor B. In a program written for processor W, a tool such as a linker automatically assigns a word address to the symbol character string indicating the name of the array. In the source code written in assembly language for processor B, a tool such as a linker automatically assigns a byte address to a symbol character string indicating the name of the array.
[0030]
Assume that the processor W and the processor B have the same architecture except for the address system, and have the same instruction set. In this case, when the program in which the instruction of the processor W is described is interpreted as it is as a program for the processor B, only the symbol character string to which an address is automatically assigned by the linker or the like has a byte address, and other than that Numeric values indicating symbols and symbol character strings hold word addresses.
[0031]
Even if processor W and processor B have exactly the same instruction set, the address system is different, so in order to interpret a program in which the instructions of processor W are described as a program for processor B, the address description is converted. There is a need. If the processor W and the processor B have different instruction sets, in addition to converting individual instructions, it is also necessary to convert the address description.
[0032]
The present invention converts a program of one address system into a program of another address system (for example, a program in which an instruction of the processor W based on the word address system is described is converted into a program for the processor B based on the byte address system. Addresses in the program required for conversion, and when converting programs between word address type processors in which the number of bytes of data to which one address is assigned differs and the ratio is an integer of 2 or more A system that converts descriptions.
[0033]
First, we describe a system that converts address descriptions when processor W and processor B have exactly the same instruction set, the assembly language specifications are exactly the same, and only the address system is different.
[0034]
Referring to FIG. 1, a first embodiment of a character string conversion system 100 according to the present invention includes a character string replacement unit 110, a character string conversion unit 120, an unnecessary instruction deletion unit 130, an output unit 140, and a recording medium K1. Composed. The character string conversion unit 120 includes a character string replacement unit 121 and a character string insertion unit 122. The recording medium K1 is a disk, semiconductor memory, or other recording medium, and stores a program for causing the computer to function as the character string conversion system 100. This program is read by a computer and its operation is controlled to realize a character string replacement unit 110, a character string conversion unit 120, an unnecessary instruction deletion unit 130, and an output unit 140 on the computer.
[0035]
First, the character string replacement unit 110 will be described. When a symbol character string to which an address is automatically assigned by other software such as a linker is referred to in the program, the character string replacing unit 110 sets the address assigned to the symbol character string to an address that is 1 / L times the address. Convert to description. Here, L is the number of bytes indicating the minimum data width to which an address is assigned in the processor W. For example, L is 2 when one address is assigned to 2-byte data.
[0036]
For example, in the conversion source program, when a symbol character string label to which a word address is automatically assigned by other software is referenced, the post-conversion program converts label to (label / L). Alternatively, a function div (x, L) for multiplying x by 1 / L is defined, and label is converted to div (label, L). In the post-conversion program, label has a byte address, so (label / L) and div (x, L) indicate the word address in the source processor.
[0037]
However, the symbol character string used to indicate the branch destination of the program in the branch instruction is not subject to replacement. A branch instruction is an instruction for switching the flow of program execution.
[0038]
Next, the character string conversion unit 120 will be described. The character string conversion unit 120 converts an instruction including an address description in the program that has been processed by the character string replacement unit 110. An instruction including an address description is an instruction accompanied by a process for reading data from a memory, an instruction accompanied by a process for writing data to the memory, or the like.
[0039]
Hereinafter, the character string conversion unit 120 will be described in detail. In order to explain the operation of the character string conversion means 120, it is necessary to assume the architecture of the processor and the instruction set. FIG. 3 shows register configurations of the processor W and the processor B. Processor W and processor B have N general-purpose registers and M address-only registers. N and M are integers of 0 or more. Here, it will be referred to as general-purpose register Rn. n is a number from 0 to N-1. When N is 0, the general-purpose register Rn does not exist. Here, the address dedicated register is called Am. Any number from 0 to M-1 applies to m. When M is 0, it is assumed that the address dedicated register Am does not exist. The general-purpose register Rn is a place for storing a value used by the processor and a calculation result. The general-purpose register Rn can also store an address indicating the position of data or an instruction on the memory. On the other hand, the address dedicated register Am is a place for storing an address indicating the position of data or an instruction on the memory.
[0040]
In the character string conversion system 100 according to the present embodiment, a part or all of the memory address is a symbol character string or a numerical value with respect to an address used when the processor reads data from the memory or writes data to the memory. Assume that you write directly or store some or all of the memory addresses in general purpose registers.
[0041]
In the character string conversion unit 120, the processor instructions to be processed are an instruction accompanied by a process for reading data from the memory and an instruction accompanied by a process for writing data to the memory. In these instructions, processing contents differ depending on how addresses indicating data locations are described in the instructions. The rules for determining the processing contents are shown below.
[0042]
Rule (1)
“If part or all of the address is described by a symbol character string or a numerical value, replace the symbol character string or numerical value indicating the memory address with a description that uses an L-fold address.”
Rule (2)
“If part or all of the address is stored in general-purpose register Rn, insert an instruction to multiply the address stored in general-purpose register Rn by L so that it is executed in the previous cycle of the instruction. An instruction for multiplying the address stored in the register Rn by 1 / L is inserted so that it is executed in the cycle after the instruction. "
[0043]
The character string converting unit 120 includes a character string replacing unit 121 and a character string inserting unit 122. If there is an instruction corresponding to the rule (1), the character string replacing unit 121 executes the process described in the rule (1). If there is an instruction corresponding to the rule (2), the character string insertion means 122 executes the process described in the rule (2). If there is an instruction that corresponds to multiple rules, the processing described in all the applicable rules is executed.
[0044]
A specific example of the rules (1) and (2) will be described using the basic instruction set 21 (FIG. 4) of the processors W and B. FIG. 4 shows instructions to be converted and instructions necessary for the conversion. In order to refer to the instruction shown in FIG. 4, the instruction reference symbol of FIG. 4 is used. The instruction description method differs depending on the processor, and also differs depending on the file format in which the instruction is described. Here, description will be made using the description example shown in FIG.
[0045]
Instruction LDST0 conversion method
The instruction LDST0 is an instruction for reading data from an address described by a symbol character string or a numerical value, or an instruction for writing data to the address. Therefore, rule (1) is applied. In instruction LDST0, a symbol character string or a numerical value indicating a part or all of the address is converted into a description multiplied by L. For example,
R0 = * [label + K]
The
R0 = * [(label + K) * L]
Convert to Here, label is a symbol character string whose address is automatically assigned by other software such as a linker, and K is a symbol character string or a numerical value representing an arbitrary constant.
[0046]
Instruction LDST1 conversion method
The instruction LDST1 is an instruction for reading data from an address indicated by the general-purpose register or an instruction for writing data to the address. Therefore, rule (2) is applied. In instruction LDST1, insert an instruction that multiplies the general-purpose register that holds part or all of the addresses so that it is executed in the cycle preceding the instruction to be converted. In addition, insert an instruction that multiplies the general-purpose register holding part or all of the address by 1 / L so that it is executed in the cycle after the instruction to be converted. For example, if L = 2,
R0 = * [R4]
The
R4 = R4 + R4
R0 = * [R4]
R4 = R4 >> 1
Are converted into three instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used.
[0047]
Instruction LDST2 conversion method
The instruction LDST2 is an instruction for reading data from an address indicated by the sum of an address described by a symbol character string or a numerical value and a general-purpose register, or an instruction for writing data to the address. Therefore, rule (1) and rule (2) apply. In the instruction LDST2, a symbol character string or a numerical value indicating a part or all of the address is converted to a description multiplied by L. Further, an instruction for multiplying the general-purpose register holding a part or all of the addresses by L is inserted so as to be executed in the cycle before the conversion target instruction. Further, an instruction for multiplying the general-purpose register holding a part or all of the address by 1 / L is inserted so as to be executed in the cycle after the instruction to be converted. For example, if L = 2,
R0 = * [R4 + K]
The
R4 = R4 + R4
R0 = * [R4 + (K) * 2]
R4 = R4 >> 1
Are converted into three instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used.
[0048]
Instruction LDST3 conversion method
The instruction LDST3 is an instruction for reading data from an address indicated by the sum of a general register and another general register, or an instruction for writing data to the address. Therefore, rule (2) is applied. In the instruction LDST3, an instruction that multiplies each general-purpose register that holds part or all of the addresses by L is inserted so as to be executed in the cycle preceding the instruction to be converted. Further, an instruction that multiplies the general-purpose registers holding part or all of the addresses by 1 / L is inserted so that it is executed in the cycle after the conversion target instruction. For example, if L = 2,
R0 = * [R4 + R5]
The
R4 = R4 + R4
R5 = R5 + R5
R0 = * [R4 + R5]
R4 = R4 >> 1
R5 = R5 >> 1
Is converted into five instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Similarly, left shift instruction R5 = R5 instead of addition instruction R5 = R5 + R5 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used. Similarly, another instruction that halves R4 may be used instead of the right 1-bit shift instruction.
[0049]
Instruction ADD1 conversion method
The instruction ADD1 is an instruction for adding the value stored in the general-purpose register and the value loaded from the memory and transferring the result to the general-purpose register. In the instruction ADD1, for example, when a part or all of the address of data to be loaded from the memory is described by a symbol character string or a numerical value, the symbol character string or numerical value indicating the memory address is changed to an L-fold address. replace. Or in the instruction ADD1, for example, when part or all of the address of the data to be loaded from the memory is stored in the general-purpose register, the instruction that multiplies the address stored in the general-purpose register by L is executed in the cycle before the instruction to be converted In addition, an instruction for multiplying the address stored in the general-purpose register by 1 / L is inserted so that it is executed in the cycle after the instruction to be converted.
[0050]
In the instruction ADD1, rule (1) is applied when an address is described by a symbol character string or a numerical value, for example. For example,
R0 = R0 + * [label + K]
The
R0 = R0 + * [(label + K) * L]
Convert to Here, label is a symbol character string to which an address is automatically assigned by other software such as a linker, and K is a symbol character string or a numerical value representing an arbitrary constant.
[0051]
In the instruction ADD1, for example, when L = 2 and the address is stored in the general-purpose register R4, the rule (2) is applied. For example,
R0 = R0 + * [R4]
The
R4 = R4 + R4
R0 = R0 + * [R4]
R4 = R4 >> 1
Are converted into three instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used.
[0052]
In the instruction ADD1, for example, when L = 2 and the address is represented by the sum of the general-purpose register R4 and the symbol character string K, the rule (1) and the rule (2) are applied. For example,
R0 = R0 + * [R4 + K]
The
R4 = R4 + R4
R0 = R0 + * [R4 + (K) * 2]
R4 = R4 >> 1
Are converted into three instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used.
[0053]
In the instruction ADD1, for example, when L = 2 and the address is represented by the sum of the general register R4 and the general register R5, the rule (2) is applied. For example,
R0 = R0 + * [R4 + R5]
The
R4 = R4 + R4
R5 = R5 + R5
R0 = R0 + * [R4 + R5]
R4 = R4 >> 1
R5 = R5 >> 1
Is converted into five instructions. Here, the add instruction R4 = R4 + R4 was used to double the general-purpose register R4, but the left shift instruction R4 = R4 <<1 may be used. Similarly, left shift instruction R5 = R5 instead of addition instruction R5 = R5 + R5 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R4 by 1/2, other instructions that multiply R4 by 1/2 may be used. Similarly, another instruction that halves R4 may be used instead of the right 1-bit shift instruction.
[0054]
Other instructions not described in FIG. 4, such as subtraction instructions, multiplication instructions, division instructions, shift instructions, logical operation instructions, etc., instructions that involve processing to read a value from a memory or write a value to a memory If there is, the description about the address included in the instruction is converted as described above.
[0055]
Of the instructions shown in Fig. 4, instructions that have not been described so far (MV0 instruction, ADD0 instruction, SHFT0 instruction) do not correspond to rule (1) or rule (2), so nothing is changed. .
[0056]
Next, the unnecessary instruction deletion unit 130 will be described. The unnecessary command deletion unit 130 takes the processing result of the character string conversion unit 120, analyzes the program, and deletes unnecessary commands.
[0057]
The program converted by the character string conversion unit 120 may include unnecessary instructions. Unnecessary instructions are undesirable because they increase program execution time and code size. Therefore, unnecessary instructions are deleted. The unnecessary instruction here is an instruction inserted by the character string conversion unit 120 and does not affect the execution result of the program.
[0058]
For example, the character string conversion means 120 inserts an addition instruction R0 = R0 + R0 (stores the sum of the general-purpose register R0 and the general-purpose register R0 in the general-purpose register R0) into a program and shifts right by 1 bit immediately after the instruction. Assume that the instruction R0 = R0 >> 1 (the general register R0 is shifted to the right by 1 bit and stored in the general register R0 again) is inserted. When it is known that the most significant bit of the general-purpose register R0 is 0 before and after the execution of the addition instruction R0 = R0 + R0, the addition instruction inserted by the character string conversion unit 120 and the right 1 immediately after Bit shift instructions are not required. This is because when the right 1-bit shift instruction R0 = R0 >> 1 is executed immediately after the addition instruction R0 = R0 + R0, R0 returns to the value before the execution of the addition instruction R0 = R0 + R0.
[0059]
Alternatively, it is assumed that the character string conversion unit 120 inserts a right 1-bit shift instruction R0 = R0 >> 1 into a certain program and inserts an addition instruction R0 = R0 + R0 immediately after the instruction. If it is known that the least significant bit of the general register R0 is 0 before the execution of the right 1-bit shift instruction R0 = R0 >> 1, the right 1-bit shift instruction inserted by the character string conversion means 2 The immediately following addition instruction is unnecessary. This is because when the addition instruction R0 = R0 + R0 is executed immediately after the right 1-bit shift instruction R0 = R0 >> 1, the value before the execution of the R0 right 1-bit shift instruction R0 = R0 >> 1 is restored. .
[0060]
It is possible to delete unnecessary instructions while converting a program. For example, when an instruction is converted, it is possible to determine whether the instruction is an unnecessary instruction by examining the relationship with the already converted instruction. Alternatively, it is possible to analyze the program before conversion and convert the program so that unnecessary instructions are not inserted. The character string conversion system of the present invention can be applied to either configuration.
[0061]
Next, the output unit 140 will be described. The output unit 140 outputs all character strings including instructions that have not been deleted by the unnecessary command deletion unit 130.
[0062]
Next, a second embodiment of the character string conversion system according to the present invention will be described with reference to FIG. The character string conversion system 200 according to the present embodiment includes a character string replacement unit 210, a character string conversion unit 220, an unnecessary command deletion unit 230, an output unit 240, and a recording medium K2. The recording medium K2 is a disk, semiconductor memory, or other recording medium, and stores a program for causing the computer to function as the character string conversion system 200. This program is read by a computer, and a character string replacing unit 210, a character string converting unit 220, an unnecessary instruction deleting unit 230, and an output unit 240 are realized on the computer.
[0063]
The character string replacement unit 210, unnecessary command deletion unit 230, and output unit 240 have the same configuration as the character string replacement unit 110, unnecessary command deletion unit 130, and output unit 140 shown in FIG. Only the character string conversion unit 220 will be described. In the character string conversion system 200 according to the present embodiment, a part or all of the addresses are directly expressed as symbol character strings or numerical values with respect to addresses used when the processor reads data from the memory or writes data to the memory. It is assumed that a part or all of the address is stored in the address dedicated register.
[0064]
In the character string conversion means 220, the instructions of the processor to be processed are an instruction accompanied by a process for reading data from the memory, an instruction accompanied by a process for writing data to the memory, an instruction for transferring a value to the address dedicated register, and an address This instruction transfers the value stored in the dedicated register to other than the address dedicated register. In these instructions, the processing contents differ depending on how the address is described, how the transferred value is described in the instruction, where the value is transferred, and the like.
[0065]
The rules for determining the processing contents are shown below.
[0066]
Rule (3)
“If an instruction with a process for reading a value from a memory or an instruction with a process for writing a value to a memory has a part or all of the address described in a symbol character string or numerical value, a symbol character string indicating the address of the memory Replace with a description that makes the number an L times the address. "
Rule (4)
“If the instruction to transfer a value to the address-only register Am is part or all of the value to be transferred described in a symbol character string or a numerical value, the symbol character string or numerical value indicating the memory address is the L times the address. Replace with the description that
Rule (5)
“If an instruction that transfers a value to the address dedicated register Am is partially or entirely stored in a location other than the address dedicated register, the instruction that multiplies the address dedicated register Am by L Insert an instruction to be executed in a cycle, or insert an instruction to multiply the transfer source value by L to be executed in the previous cycle of the instruction, and further add an instruction to multiply the transfer source value by 1 / L To be executed in a later cycle. "
Rule (6)
“In the instruction to transfer the value stored in the address dedicated register Am to a location other than the address dedicated register, if part or all of the transferred value is stored in the address dedicated register Am, the value after transfer is set to 1. Insert an instruction to multiply / L to be executed in the cycle after the instruction, or execute an instruction to multiply the value stored in the address dedicated register Am by 1 / L in the cycle before the instruction. Insert an instruction that multiplies the value stored in the address-only register Am by L so that it is executed in the cycle after the instruction. "
[0067]
The character string conversion unit 220 includes a character string replacement unit 221, a character string replacement unit 222, a character string insertion unit 223, and a character string insertion unit 224. If there is an instruction corresponding to the rule (3), the character string replacement means 221 executes the process described in the rule (3). If there is an instruction corresponding to the rule (4), the character string replacement unit 222 executes the process described in the rule (4). If there is an instruction corresponding to the rule (5), the character string insertion means 223 executes the process described in the rule (5). If there is an instruction corresponding to the rule (6), the character string insertion means 224 executes the process described in the rule (6). If there is an instruction corresponding to a plurality of rules, the processing described in all the corresponding rules is executed.
[0068]
Specific examples of the rules (3), (4), (5), and (6) will be described using the basic instruction sets 22 and 23 (FIGS. 5 and 6) of the processor W and the processor B. 5 and 6 show instructions to be converted and instructions necessary for the conversion. In order to refer to the instructions shown in FIGS. 5 and 6, the instruction reference symbols of FIGS. 5 and 6 are used. Although the instruction description method differs depending on the processor and the file format in which the instruction is described, here, description will be made using the description examples shown in FIGS.
[0069]
Instruction LDST0 conversion method
The instruction LDST0 is an instruction for reading data from an address described by a symbol character string or a numerical value, or an instruction for writing data to the address. Therefore, rule (3) is applied. In the instruction LDST0, the symbol character string indicating a part or all of the address or the numerical value converted to a description multiplied by L is converted. That means
R0 = * [label + K]
The
R0 = * [(label + K) * L]
Convert to Here, label is a symbol character string to which an address is automatically assigned by other software such as a linker, and K is a symbol character string or a numerical value representing an arbitrary constant.
[0070]
Instruction LDST5 conversion method
The instruction LDST5 is an instruction for reading data from an address indicated by the sum of an address described by a symbol character string or a numerical value and an address dedicated register, or an instruction for writing data to the address. Therefore, rule (3) is applied. In instruction LDST5, the address stored in the address dedicated register is considered to have been converted to a byte address when it is transferred to the address dedicated register, and only the symbol character string or numerical value indicating part or all of the address is multiplied by L Convert to the description. For example, if L = 2,
R0 = * [A0 + K]
The
R0 = * [A0 + (K) * L]
Convert to
[0071]
Instruction LDST7 conversion method
The instruction LDST7 reads a value from the memory and transfers it to the address dedicated register Am. In the instruction LDST7, conversion is performed so that a value L times the value read from the memory is transferred to the address dedicated register Am. Furthermore, if part or all of the memory address is described by a symbol character string or numerical value, it is converted to a description that is multiplied by L. For example, when L = 2 in the instruction LDST7 and reading a value from the memory using an address described by a symbol character string or a numerical value, the rule (3) and the rule (5) are applied. For example,
A0 = * [label + K]
The
A0 = * [(label + K) * 2]
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used.
[0072]
Alternatively, when L = 2 in the instruction LDST7 and reading a value from the memory using the address stored in the address dedicated register, rule (5) is applied. For example,
A0 = * [A1]
The
A0 = * [A1]
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used.
[0073]
Or when L = 2 in instruction LDST7 and reading a value from memory using the address represented by the sum of the address stored in the address dedicated register and the address described by the symbol string or numerical value, the rule (3) Apply rule (5). For example,
A0 = * [A1 + K]
The
A0 = * [A1 + (K) * 2]
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used.
[0074]
Instruction LDST8 conversion method
The instruction LDST8 is an instruction for transferring the value stored in the address dedicated register Am to the memory. In the instruction LDST8, conversion is performed so that a value 1 / L times the value stored in the address dedicated register is transferred to the memory. Furthermore, if part or all of the memory address is described by a symbol character string or numerical value, it is converted to a description that is multiplied by L. For example, when L = 2 in the instruction LDST8 and a value is transferred to the memory using an address described by a symbol character string or a numerical value, the rule (3) and the rule (6) are applied. For example,
* [Label + K] = A0
The
A0 = A0 >> 1
* [(Label + K) * 2] = A0
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the address dedicated register A0 by 1/2, other instructions that multiply A0 by 1/2 may be used.
[0075]
Alternatively, when L = 2 in the instruction LDST8 and a value is transferred to the memory using the address stored in the address dedicated register, rule (6) is applied. For example,
* [A1] = A0
The
A0 = A0 >> 1
* [A1] = A0
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the address dedicated register A0 by 1/2, other instructions that multiply A0 by 1/2 may be used.
[0076]
Or, if L = 2 in the instruction LDST8 and the value is transferred to the memory using the address represented by the sum of the address stored in the address dedicated register and the address written in the symbol character string or numerical value, rule (3) And apply rule (6). For example,
* [A1 + K] = A0
The
A0 = A0 >> 1
* [A1 + (K) * 2] = A0
A0 = A0 + A0
Convert to Here, the add instruction A0 = A0 + A0 was used to double the address dedicated register A0, but the left shift instruction A0 = A0 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the address dedicated register A0 by 1/2, other instructions that multiply A0 by 1/2 may be used.
[0077]
Instruction MV1 conversion method
The instruction MV1 is an instruction for transferring a value described by a symbol character string or a numerical value to an address dedicated register. Therefore, rule (4) applies. In the instruction MV1, after the instruction is executed, the address dedicated register is converted so as to have a value of L times. That means
A0 = K
The
A0 = (K) * L
Convert to
[0078]
Instruction MV2 conversion method
The instruction MV2 is an instruction for transferring a value from the general-purpose register to the address dedicated register. Therefore, rule (5) applies. In instruction MV2, after the instruction is executed, the address dedicated register is converted to have a value L times that of the general-purpose register. For example, if L = 2,
A0 = R0
The
A0 = R0
A0 = A0 + A0
To two instructions. Or
R0 = R0 + R0
A0 = R0
R0 = R0 >> 1
Are converted into three instructions. Here, the add instruction R0 = R0 + R0 was used to double the general-purpose register R0, but the left shift instruction R0 = R0 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R0 by 1/2, other instructions that multiply R0 by 1/2 may be used.
[0079]
Instruction MV3 conversion method
The instruction MV3 is an instruction for transferring a value from the address dedicated register to the general purpose register. Therefore, rule (6) is applied. In the instruction MV3, after the instruction is executed, the general-purpose register is converted to have a value 1 / L times that of the address dedicated register. For example, if L = 2,
R0 = A0
The
R0 = A0
R0 = R0 >> 1
To two instructions. Or
A0 = A0 >> 1
R0 = A0
A0 = A0 + A0
Are converted into three instructions. Here, the add instruction A0 = A0 + A0 was used to double the address-only register A0, but the left shift instruction A0 = A0 <<1 may be used. Although the right 1-bit shift instruction is used to multiply the general-purpose register R0 by 1/2, other instructions that multiply R0 by 1/2 may be used. Although the right 1-bit shift instruction is used to multiply the address dedicated register A0 by 1/2, other instructions that multiply A0 by 1/2 may be used.
[0080]
Instruction ADD1 conversion method
The instruction ADD1 is an instruction for adding the value stored in the general-purpose register and the value loaded from the memory and transferring the result to the general-purpose register. Therefore, rule (3) is applied. In the instruction ADD1, for example, when a part or all of the address of data to be loaded from the memory is described by a symbol character string or a numerical value, the symbol character string or numerical value indicating the memory address is changed to an L-fold address. replace. For example, when the address is represented by the sum of the symbol character string label and the symbol character string K,
R0 = R0 + * [label + K]
The
R0 = R0 + * [(label + K) * L]
Convert to
[0081]
Alternatively, in the instruction ADD1, when the address is represented by the sum of the address dedicated register A0 and the symbol character string K, the symbol character string portion is replaced with a description multiplied by L. For example,
R0 = R0 + * [A0 + K]
The
R0 = R0 + * [A0 + (K) * L]
Convert to
[0082]
Processing to read a value from a memory or write a value to a memory in another instruction not described in FIGS. 5 and 6, such as a subtraction instruction, a multiplication instruction, a division instruction, a shift instruction, and a logical operation instruction If there is an instruction accompanied with, the description about the address included in the instruction is converted as described above.
[0083]
Of the instructions shown in FIG. 5 and FIG. 6, instructions that have not been described so far (LDST4 instruction, LDST6 instruction, ADD0 instruction, ADD2 instruction, MV0 instruction, SHFT0 instruction, SHFT1 instruction) are rules (3), ( Since it does not fall under 4), (5), (6), nothing is changed.
[0084]
The character string conversion system of the present invention described so far does not depend on the file format of the program. In other words, it can be applied to any file format. For example, the program may be described as source code or may be described as binary code. If the character string including the input program is in text format, the converted program is also output in text format. If the character string including the program to be input is in binary format, the converted program is output in either text format or binary format.
[0085]
Furthermore, the character string conversion system of the present invention can be applied to dynamic conversion as well as static conversion. Static conversion means converting a program before execution. Dynamic conversion means that a program is converted during execution.
[0086]
Up to now, the program has been converted from processor W based on the word address system, which assigns one address to L = 2 bytes of data, to processor B, based on the byte address system, which assigns one address to 1 byte of data. Only explained when to do.
[0087]
The character string conversion system according to the present invention can be easily applied not only to L = 2, but also when L is an integer larger than 2. Even if the two processors are both based on the word address system, the present invention can be applied when the ratio L of the number of bytes to which one address is allocated is an integer of 2 or more.
[0088]
In the past, when the processor W and the processor B have the same instruction set, the assembly language is exactly the same, and only the address system is different, the program written for the processor W is changed to the program for the processor B. Only the way to convert was mentioned. The character string conversion system of the present invention can be applied not only to such a case but also to a case where the processor W and the processor B have different instruction sets.
[0089]
For example, first, only the address system is converted by the character string conversion system of the present invention, and then the instruction set is converted. Conversely, it is also possible to convert the address system by the character string conversion system of the present invention after converting the instruction set first. Alternatively, it is conceivable to simultaneously convert the address system and the instruction set. When converting the address system and the instruction set at the same time, the character string conversion unit 2 in FIG. 1 of the present invention has a function of converting the instruction set. That is, in the character string conversion system 100 according to the first embodiment, the character string conversion means 120 has a means for converting the instruction set, and in the character string conversion system 200 according to the second embodiment, the character string conversion means 220 has an instruction set. It will be.
[0090]
Further, in order to perform more general conversion, a method of converting a program described for a conversion source processor into a program for a virtual processor and further converting it into a program for a target processor may be considered. In this case, the program is converted twice, and the present invention is used in either of them. Since both conversions require instruction set conversion, one of them uses the combination of the character string conversion system of the present invention and instruction set conversion as described above.
[0091]
[Description of operation]
First, if processor W and processor B have exactly the same instruction set, the assembly language is exactly the same, and only the address system is different, the program written for processor W is converted to a program for processor B The operation in this case will be described using the character string conversion system 100 of FIG. The processor W is a processor based on a word address system in which one address is assigned to L-byte data, and here, it is assumed that L = 2. The processor B is a processor based on a byte address system in which one address is assigned to 1-byte data. Assume that processor W and processor B have general purpose registers and address only registers as shown in FIG. Assume further that there is a basic instruction set 21 shown in FIG.
[0092]
FIG. 8 shows a program written in assembly language for the processor W. One instruction is described in one line, and a semicolon is described at the end of the instruction. Comments are enclosed in / * and * /. In FIG. 8, a symbol character string “label1” is a label indicating a certain address in the memory, and an actual address is automatically assigned by the linker.
[0093]
When the conversion source program of FIG. 8 is input, the character string replacement means 110 in the character string conversion system 100 performs a character string replacement process (FIG. 7, step S1). The character string replacement unit 110 converts a description that refers to a symbol character string description to which an address is automatically assigned by a tool so that a word address is referred to in a conversion destination processor. In FIG. 8, the only symbol character string to which an address is automatically assigned by the tool is label1. Therefore, label1 is converted into a description of (label1 / 2) by the character string replacement means 110. FIG. 9 shows a program that has been processed by the character string replacement unit 110.
[0094]
Next, the character string converter 120 converts an instruction including an address description (step S2). The character string conversion means 120 reads the program of FIG. 9 and converts each instruction including the address description one by one. The following describes how each instruction is converted. In order to refer to an instruction, the instruction reference symbol of FIG. 9 is used.
● Nothing is changed by the transfer instructions move0 and move1.
● In the load instruction load0, the symbol character string or numerical value indicating the address is doubled.
● In load instruction load1, an instruction that doubles R4 that stores the address is inserted before load1, and an instruction that doubles R4 is inserted after load1.
● In load instruction load2, an instruction that doubles R4 that stores the address is inserted before load2, and an instruction that doubles R4 is inserted after load2. Furthermore, the symbol character string and numerical value indicating the address are doubled.
● In load instruction load3, an instruction that doubles R4 and R5 that stored the address is inserted before load3, and an instruction that doubles R4 and R5 is inserted after load3.
● Addition instructions add0 and add1 do not convert anything.
[0095]
FIG. 10 shows a program that has been processed by the character string conversion means 120. In FIG. 10, the conversion source program does not originally exist, and the instruction added by the conversion is indented.
[0096]
Next, the unnecessary instruction deleting means 130 deletes unnecessary instructions from the instructions inserted by the character string converting means 120 (step S3). If the program FIG. 10 processed by the character string conversion means 120 is examined closely, it can be seen that some of the addition instructions and shift instructions added by the conversion are unnecessary. For example, immediately after the shift instruction R4 = R4 >> 1 (the eighth line), there is an addition instruction R4 = R4 + R4 (the ninth line) using the shift result. Both of these were inserted by the character string conversion means 120. In the sixth line, the least significant bit of the general register R4 is set to 0 by the addition instruction R4 = R4 + R4. Therefore, even if the two instructions in the eighth line and the ninth line are executed, the general register R4 Does not change. Therefore, it is meaningless to execute these instructions. The same applies to the shift instruction R4 = R4 >> 1 (11th line) and the addition instruction R4 = R4 + R4 (12th line). Unnecessary instruction deleting means 130 passes a program from which such instructions are deleted to output means 140.
[0097]
Then, the output unit 140 outputs the program taken from the unnecessary instruction deletion unit 130 (step S4). FIG. 11 shows the converted program output by the output means 140.
[0098]
Next, when processor W and processor B have exactly the same instruction set, the assembly language is exactly the same, and only the address system is different, the operation when converting the program written for processor W to processor B is as follows: This will be described using the character string conversion system 200 of FIG. The processor W is a processor based on a word address system in which one address is assigned to L-byte data, and it is assumed here that L = 2. The processor B is a processor based on a byte address system in which one address is assigned to 1-byte data. Assume that processor W and processor B have general purpose registers and address only registers as shown in FIG. Assume further that there is a basic instruction set 22 shown in FIG.
[0099]
FIG. 12 shows a program written in assembly language for the processor W.
One instruction is described in one line, and a semicolon is described at the end of the instruction. Comments are enclosed in / * and * /. In FIG. 12, a symbol character string “label1” is a label indicating a certain address in the memory, and an actual address is automatically assigned by the linker.
[0100]
When the conversion source program of FIG. 12 is input, the character string replacement means 210 in the character string conversion system 200 performs a character string replacement process (step S1 in FIG. 7). The character string replacing unit 210 converts a description that refers to a symbol character string description to which an address is automatically assigned by a tool so that a word address is referred to in the processor after conversion. In FIG. 12, the only symbol character string to which an address is automatically assigned by the tool is label1. Therefore, label1 is converted into a description of (label1 / 2) by the character string replacing means 210. FIG. 13 shows a program that has been processed by the character string replacement unit 210.
[0101]
Next, the character string conversion means 220 converts an instruction including an address description (step S2). The character string conversion means 220 reads the program of FIG. 13 and converts each instruction including the address description one by one. The following describes how each instruction is converted. In order to refer to the instruction, the instruction reference symbol of FIG. 13 is used.
● Nothing is changed by the transfer instructions move0 and move1.
● In transfer instructions move2 and move3, the value transferred to the address-only register is doubled.
● In transfer instructions move4 and move5, an instruction that doubles the address-only register is inserted after each instruction.
● In the load instruction load0, the symbol character string or numerical value indicating the address is doubled.
● Nothing is converted by the load instruction load4.
● In the load instruction load5, the symbol character string or numerical value indicating the address is doubled.
● Nothing is converted with the load instruction load6.
● Addition instructions add0 and add1 do not convert anything.
● Addition instruction add2 doubles the symbol character string and numerical value indicating the address.
● In transfer instruction move6, an instruction to halve the value of general-purpose register R4 is inserted after move6.
● Transfer instruction In move7, an instruction to halve the value of general-purpose register R5 is inserted after move7.
[0102]
FIG. 14 shows a program that has been processed by the character string conversion means 220. In FIG. 14, the conversion source program does not originally exist and the instruction added by the conversion is indented.
[0103]
Next, the unnecessary instruction deleting means 230 deletes unnecessary instructions from the instructions inserted by the character string converting means 220 (step S3). However, since the program processed by the character string converting means 220 does not happen to have an unnecessary instruction, the program shown in FIG. 14 is transferred to the output means 240 as it is.
[0104]
Then, the output unit 240 outputs the program taken from the unnecessary instruction deletion unit 230 (step S4). The program processed by the character string conversion means 220. Since there was no unnecessary command in the FIG. 14, the converted program output by the output means 240 is the same as that in FIG.
[0105]
Next, the operation when a program is converted between the processors W and B having different instruction sets will be described using the character string conversion system 200 of FIG. The processor W is a processor based on a word address system in which one address is assigned to L-byte data. Here, it is assumed that L = 2. The processor B is a processor based on a byte address system in which one address is assigned to 1-byte data. Assume that the processor W and the processor B have different instruction sets, and the assembly languages are also different. FIG. 5 shows a basic instruction set 22 of the processor W. FIG. 6 shows the basic instruction set 23 of the processor B. A method of converting a program written for the processor W into a program for the processor B under the above assumption will be described.
[0106]
FIG. 12 is used as a program written in assembly language for the processor W. As already explained, one instruction is described in one line, and a semicolon is described at the end of the instruction. Comments are enclosed in / * and * /. The symbol character string “label1” is a label indicating a certain address in the memory, and the actual address is automatically assigned by another tool such as a linker.
[0107]
When the conversion source program of FIG. 12 is input, the character string replacement unit 210 first replaces the character string (FIG. 7, step S1). The character string replacement unit 210 converts the description referring to the symbol character string description to which an address is automatically assigned by another tool so that all the word addresses are referred to. In FIG. 12, the only symbol character string to which an address is automatically assigned by another tool is label1. Therefore, label1 is converted into a description of (label / 2) by the character string replacement means 210. FIG. 13 shows a program that has been processed by the character string replacement unit 210. Up to this point, the operation is the same as when the instruction set already described is the same.
[0108]
Next, the character string converter 220 converts an instruction including an address description. Further, instruction set conversion is performed (step S2). If the instruction sets are different, in step S2, the instruction set conversion is simultaneously performed in addition to the address description conversion. The instruction set conversion is to convert all the instructions for the processor W included in the input character string of the program into one or more corresponding instructions for the processor B. The character string conversion unit 220 reads the program of FIG. 13 and converts each instruction including the address description one by one. The converted instruction is an instruction for processor B. Furthermore, instructions that do not include an address description are also converted into instructions for the processor B. The following describes how each instruction is converted.
[0109]
● Transfer instruction R4 = (label1 / 2) is converted to processor B instruction MVR4, (label1 / 2) by instruction set conversion.
● Transfer instruction R5 = 4 is converted to processor B instructions MV R5,4 by instruction set conversion.
● For transfer instruction A0 = (label1 / 2), the value transferred to the dedicated address register is doubled. Further, it is converted into an instruction MVA0 for processor B, ((label1 / 2)) * 2 by instruction set conversion.
● For transfer instruction A1 = 4, the value transferred to the address dedicated register is doubled. Furthermore, it is converted into the processor M instruction MVA0, (4) * 2 by instruction set conversion.
• The processor B instruction (ADD A0, A0, A0) that doubles the value of the address dedicated register A1 is inserted in the cycle immediately after the transfer instruction A0 = R4. Further, the transfer instruction A0 = R4 is converted into processor B instructions MVA0 and R4 by instruction set conversion.
• A processor B instruction (ADD A1, A1, A1) that doubles the value of the address dedicated register A1 is inserted in the cycle immediately after the transfer instruction A1 = R5. Further, the transfer instruction A1 = R4 is converted into processor B instructions MVA1 and R5 by instruction set conversion.
● The load instruction R0 = * [(label1 / 2) +4] doubles the symbol character string and numerical value indicating the address. Further, the instruction B is converted into an instruction M R0, * [(((label1 / 2) +4) * 2] for processor B by instruction set conversion.
● Load instruction R1 = * [A0] is instruction MV for processor B by instruction set conversion.
Converted to R1, * [A0].
● The load instruction R2 = * [A0 + 4] doubles the symbol character string and numerical value indicating the address. Furthermore, it is converted into an instruction M R2 for processor B, * [A0 + (4) * 2] by instruction set conversion.
● Load instruction R3 = * [A0 + A1] is converted to instruction MV R3, * [A0 + A1] for processor B by instruction set conversion.
● Addition instruction R4 = R4 + R5 is converted to processor B instruction ADD R4, R4, R5 by instruction set conversion.
● Addition instruction R5 = R5 + R3 is converted to processor B instruction ADD R5, R5, R3 by instruction set conversion.
● Addition instruction R5 = R5 + * [(label1 / 2) +4] doubles the symbol character string or numerical value indicating the address. Furthermore, it is converted into an instruction ADD R5, R5, * [(((label1 / 2) +4) * 2] for processor B by instruction set conversion.
• Processor B instructions (SHIFT_R R4, R4, 1) that halve general-purpose register R4 are inserted in the cycle immediately after transfer instruction R4 = A0. Further, the transfer instruction R4 = A0 is converted into the processor B instructions MVR4 and A0 by instruction set conversion.
● Processor B instructions (SHIFT_R R5, R5, 1) that halve general-purpose register R5 are inserted in the cycle immediately after transfer instruction R5 = A1. Further, the transfer instruction R5 = A1 is converted into the processor B instructions MVR5, A1 by instruction set conversion.
[0110]
FIG. 15 shows a program that has been processed by the character string conversion means 220.
[0111]
Next, the unnecessary instruction deleting means 230 deletes unnecessary instructions from the instructions inserted by the character string converting means 220 (step S3). However, since the program processed by the character string conversion unit 220 does not happen to have an unnecessary instruction, the program of FIG. 15 is transferred to the output unit 240 as it is.
[0112]
Then, the output unit 240 outputs the program taken from the unnecessary instruction deletion unit 230 (step S3). Program Processed by Character String Conversion Unit 220 Since there was no unnecessary instruction in FIG. 15, the converted program output by the output unit 240 is the same as that in FIG.
[0113]
In the embodiments described so far, the file format of the program has not been mentioned. This is because the present invention can be applied regardless of the file format. For example, even if the file format is a binary format or a text format, the present invention can be applied to both. When a binary format program is converted, a character string including the program to be input is given in the binary format and converted. The converted program may be output as a binary format or a text format.
[0114]
In the embodiments described so far, the processor W based on the word address system in which one address is assigned to L = 2 bytes of data and the byte address system in which one address is assigned to 1 byte of data. An example of converting a program to processor B is shown. This can easily be applied when L is an integer greater than 2. Even if the two processors are both based on the word address system, the present invention can be applied when the ratio L of the number of bytes to which one address is allocated is an integer of 2 or more. Furthermore, the character string conversion system of the present invention can be applied to dynamic conversion as well as static conversion. Static conversion means converting a program before execution. Dynamic conversion means that a program is converted during execution.
[0115]
【The invention's effect】
As described above, the character string conversion system according to the present invention has a ratio between the number of data bytes to which the conversion source processor assigns one address and the number of data bytes to which the converted processor assigns one address. Therefore, the address description in the conversion source program operable by the conversion source processor is converted into the address description suitable for the address system adopted by the processor after conversion. Can be automatically converted into a program for a converted processor having another address system. Therefore, it is possible to obtain a post-conversion program more efficiently than the conventional technique in which address description is manually performed. Also, if the post-conversion program created by the character string conversion system of the present invention is executed by the post-conversion processor, the execution speed of the program can be improved as compared with the conventional technique using emulation. Is possible.
[0116]
In addition, since the character string conversion system of the present invention includes unnecessary instruction deletion means for deleting unnecessary instructions in the program, it is possible to create a program with high execution efficiency.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration example of a first embodiment of a character string conversion system according to the present invention.
FIG. 2 is a block diagram showing a configuration example of a second embodiment of a character string conversion system according to the present invention.
FIG. 3 is a diagram illustrating a register configuration of a processor.
FIG. 4 is a diagram showing a basic instruction set 21 of a processor.
FIG. 5 is a diagram showing a basic instruction set 22 of a processor.
FIG. 6 is a diagram showing a basic instruction set 23 of a processor.
FIG. 7 is a flowchart showing a processing example of the character string conversion system.
FIG. 8 is a diagram illustrating an example of a conversion source program.
FIG. 9 is a diagram illustrating an example of a program that has been processed by the character string replacement unit 110;
FIG. 10 is a diagram illustrating an example of a program that has been processed by the character string conversion unit 120;
11 is a diagram showing an example of a post-conversion program output by the output unit 140. FIG.
FIG. 12 is a diagram showing another example of a conversion source program.
FIG. 13 is a diagram illustrating an example of a program that has been processed by the character string replacement unit 210;
14 is a diagram illustrating an example of a program that has been processed by the character string conversion unit 220 or a post-conversion program that has been output by the output unit 240. FIG.
15 is a diagram illustrating an example of a program that has been processed by the character string conversion unit 220 or a post-conversion program that has been output by the output unit 240. FIG.
[Explanation of symbols]
100: Character string conversion system
110: Character string replacement means
120: Character string conversion means
121: Character string replacement means
122: Character string insertion means
130: Unnecessary instruction deletion means
140: Output means
200: Character string conversion system
210: Character string replacement means
220: Character string conversion means
221: Character string replacement means
222: Character string replacement means
223: Character string insertion means
224: Character string insertion means
230: Unnecessary instruction deletion means
240: Output means
11: General-purpose register in which the processor stores input data and calculation results for calculation
12: Address dedicated register in which the processor stores an address indicating the position of data or an instruction in the memory
21: Basic instruction set of the processor
22: Basic instruction set of the processor
23: Processor basic instruction set

Claims (10)

第1のバイト数B1のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換元プロセッサで実行可能な変換元プログラムを、第2のバイト数B2のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換後プロセッサで実行可能な変換後プログラムに変換するアセンブラプログラムのためのアドレス記述変換システムであって、
前記変換元プログラムを入力とし、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を前記変換元プログラムの中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍(L=B1/B2であり、2以上の整数)する記述に置き換える第1のアドレス記述置換手段と、
該第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換え、レジスタに格納したアドレスを使ってメモリから値を読み込む処理を伴う命令I1あるいはレジスタに格納したアドレスを使ってメモリへ値を書き込む処理を伴う命令I2があれば、該命令I1およびI2が参照するアドレスをL倍する命令を該命令I1およびI2の前のサイクルで実行されるよう挿入し、さらに該命令I1およびI2が参照するアドレスを1/L倍する命令を該命令I1およびI2の後のサイクルで実行されるよう挿入するアドレス記述変換手段と、
アドレス記述変換手段で処理済みのプログラムを、前記変換後プログラムとして出力する出力手段とを備えたことを特徴とするアセンブラプログラムのためのアドレス記述変換システム
A conversion source program that can be executed by a conversion source processor that employs an address system in which one address is assigned to data of the first byte number B1, and one address for data of the second byte number B2. An address description conversion system for an assembler program that converts to a post-conversion program that can be executed by a post-conversion processor that employs an assigning address method,
A symbol character indicating the branch destination of a branch instruction is found in the conversion source program, with the conversion source program as an input and a reference to a symbol character string to which an address is automatically assigned by other software. If not a column, first address description replacement means for replacing the symbol character string with a description that multiplies the address assigned to the symbol character string by 1 / L (L = B1 / B2, an integer of 2 or more). ,
In the program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a numerical value that includes a process for reading a value from a memory using an address described by a symbol character string or a numerical value If there is an instruction that involves a process of writing a value to the memory using an address, the symbol character string or numerical value indicating the memory address is replaced with a description that uses an L-fold address, and the value stored in the register is used to store the value from the memory. If there is an instruction I1 accompanied by a process of reading the instruction I2 or an instruction I2 accompanied by a process of writing a value to the memory using the address stored in the register, the instruction that multiplies the address referenced by the instructions I1 and I2 by the instruction I1 and I2 Is inserted to be executed in the previous cycle, and the address referred to by the instructions I1 and I2 is multiplied by 1 / L. Address description conversion means for inserting to run in the cycle after the instruction I1 and I2 a decree,
An address description conversion system for an assembler program , comprising: output means for outputting a program processed by the address description conversion means as the post-conversion program.
請求項記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
前記アドレス記述変換手段が、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える第2のアドレス記述置換手段と、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、レジスタに格納したアドレスを使ってメモリから値を読み込む処理を伴う命令I3あるいはレジスタに格納したアドレスを使ってメモリへ値を書き込む処理を伴う命令I4があれば、該命令I3およびI4が参照するアドレスをL倍する命令を該命令I3およびI4の前のサイクルで実行されるよう挿入し、さらに該命令I3およびI4が参照するアドレスを1/L倍する命令を該命令I3およびI4の後のサイクルで実行されるよう挿入するアドレス変換命令挿入手段とを備えたことを特徴とするアセンブラプログラムのためのアドレス記述変換システム
The address description conversion system for an assembler program according to claim 1 ,
The address description conversion means comprises:
In the program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a value that includes a process of reading a value from a memory using an address described in a symbol character string or a numerical value A second address description replacement means for replacing a symbol character string or a numerical value indicating a memory address with a description of an L-fold address if there is an instruction involving a process of writing a value to the memory using an address ;
In the program that has been replaced by the first address description replacing means , the value is written to the memory using the instruction I3 that involves reading the value from the memory using the address stored in the register or the address stored in the register. If there is an instruction I4 with processing, an instruction to multiply the address referenced by the instructions I3 and I4 by L is inserted so as to be executed in the previous cycle of the instructions I3 and I4, and the instructions I3 and I4 refer to them. An address description conversion system for an assembler program, comprising: an address conversion instruction insertion means for inserting an instruction for multiplying an address by 1 / L so that the instruction is executed in a cycle after the instructions I3 and I4.
第1のバイト数B1のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換元プロセッサで実行可能な変換元プログラムを、第2のバイト数B2のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換後プロセッサで実行可能な変換後プログラムに変換するアセンブラプログラムのためのアドレス記述変換システムであって、
前記変換元プログラムを入力とし、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を前記変換元プログラムの中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍(L=B1/B2であり、2以上の整数)する記述に置き換える第1のアドレス記述置換手段と、
該第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換え、アドレスを格納するアドレス専用レジスタに対してシンボル文字列や数値で記述された値を転送する命令があれば、その値を示すシンボル文字列や数値をそのL倍の値にする記述へ置き換え、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令I5があれば、転送元の値をL倍する命令を該命令I5の前のサイクルで実行されるように挿入し、さらに転送元の値を1/L倍する命令を該命令I5の後のサイクルで実行されるよう挿入し、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令I6があれば、該アドレス専用レジスタに格納されたアドレスを1/L倍する命令を該命令I6の前のサイクルで実行されるように挿入し、さらに該アドレス専用レジスタに格納された値をL倍する命令を該命令I6の後のサイクルで実行されるよう挿入するアドレス記述変換手段と、
アドレス記述変換手段で処理済みのプログラムを、前記変換後プログラムとして出力する出力手段とを備えたことを特徴とするアセンブラプログラムのためのアドレス記述変換システム
A conversion source program that can be executed by a conversion source processor that employs an address system in which one address is assigned to data of the first byte number B1, and one address for data of the second byte number B2. An address description conversion system for an assembler program that converts to a post-conversion program that can be executed by a post-conversion processor that employs an assigning address method,
A symbol character indicating the branch destination of a branch instruction is found in the conversion source program, with the conversion source program as an input and a reference to a symbol character string to which an address is automatically assigned by other software. If not a column, first address description replacement means for replacing the symbol character string with a description that multiplies the address assigned to the symbol character string by 1 / L (L = B1 / B2, an integer of 2 or more). ,
In a program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a value that includes a process of reading a value from a memory using an address described in a symbol character string or a numerical value If there is an instruction that involves processing to write a value to the memory using an address, the symbol character string or numerical value indicating the memory address is replaced with a description that uses an L-fold address, and the address is stored in a dedicated address register. If there is an instruction that transfers a value described in a character string or a numerical value, the symbol character string or numerical value indicating the value is replaced with a description that is L times the value, and the address dedicated register that stores the address is dedicated to the address. If there is an instruction I5 that transfers a value from a place other than the register, an instruction that multiplies the transfer source value by L is sent in the cycle before the instruction I5. And an instruction for multiplying the value of the transfer source by 1 / L is inserted so that it is executed in the cycle after the instruction I5. If there is an instruction I6 for transferring a value to the instruction I6, an instruction for multiplying the address stored in the address dedicated register by 1 / L is inserted so as to be executed in the previous cycle of the instruction I6. An address description conversion means for inserting an instruction for multiplying the value stored in the register by L so that the instruction is executed in a cycle after the instruction I6;
An address description conversion system for an assembler program , comprising: output means for outputting a program processed by the address description conversion means as the post-conversion program.
請求項記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
前記アドレス記述変換手段が、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換える第2のアドレス記述置換手段と、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してシンボル文字列や数値で記述された値を転送する命令があれば、その値を示すシンボル文字列や数値をそのL倍の値にする記述へ置き換える第3のアドレス記述置換手段と、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令I7があれば、転送元の値をL倍する命令を該命令I7の前のサイクルで実行されるように挿入し、さらに転送元の値を1/L倍する命令を該命令I7の後のサイクルで実行されるよう挿入する第1のアドレス変換命令挿入手段と、
前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、第1のアドレス記述置換手段が出力した文字列において、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令I8があれば、該アドレス専用レジスタに格納されたアドレスを1/L倍する命令を該命令I8の前のサイクルで実行されるように挿入し、さらに該アドレス専用レジスタに格納された値をL倍する命令を該命令I8の後のサイクルで実行されるよう挿入する第2のアドレス変換命令挿入手段とから構成されることを特徴とするアセンブラプログラムのためのアドレス記述変換システム
The address description conversion system for an assembler program according to claim 3 ,
The address description conversion means comprises:
In the program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a value that includes a process of reading a value from a memory using an address described in a symbol character string or a numerical value A second address description replacement means for replacing a symbol character string or a numerical value indicating a memory address with a description of an L-fold address if there is an instruction involving a process of writing a value to the memory using an address ;
In the program that has been replaced by the first address description replacing means , if there is an instruction for transferring a value described by a symbol character string or a numerical value to an address dedicated register for storing an address, this value is indicated. A third address description replacement means for replacing a symbol character string or numerical value with a description of a value that is L times the symbol character string or numerical value;
In the program that has been replaced by the first address description replacing means , if there is an instruction I7 that transfers a value from a location other than the address dedicated register to the address dedicated register for storing the address, the transfer source value is set. An instruction for multiplying by L is inserted to be executed in the cycle before the instruction I7, and an instruction for multiplying the transfer source value by 1 / L is inserted to be executed in the cycle after the instruction I7. Address translation instruction insertion means ,
During said replacement is completed but the program in the first address description replacement unit, in the character string first address description replacing means has outputted, values for locations from the address-only register other than the address-only register for storing an address If there is an instruction I8 for transferring the instruction I8, an instruction for multiplying the address stored in the address dedicated register by 1 / L is inserted so as to be executed in the previous cycle of the instruction I8, and further stored in the address dedicated register. An address description conversion system for an assembler program, comprising: a second address conversion instruction insertion means for inserting an instruction for multiplying the obtained value by L to be executed in a cycle after the instruction I8.
請求項記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
第1のアドレス変換命令挿入手段が、前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令I9があれば、該アドレス専用レジスタに格納された値をL倍する命令を該命令I9の後のサイクルで実行されるよう挿入する構成を有することを特徴とするアセンブラプログラムのためのアドレス記述変換システム
5. An address description conversion system for an assembler program according to claim 4 ,
An instruction for transferring a value from a place other than the address dedicated register to the address dedicated register for storing the address in the program after the replacement by the first address description replacing means by the first address translation instruction inserting means If there is I9, an address description conversion for an assembler program characterized in that an instruction for multiplying the value stored in the address dedicated register by L is inserted so that it is executed in a cycle after the instruction I9 System .
請求項記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
前記第2のアドレス変換命令挿入手段が、前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令I10があれば、転送後の値を1/L倍する命令を該命令I10の後のサイクルで実行されるように挿入する構成を有することを特徴とするアセンブラプログラムのためのアドレス記述変換システム
5. An address description conversion system for an assembler program according to claim 4 ,
The second address translation instruction insertion means transfers a value from the address dedicated register for storing the address to a place other than the address dedicated register in the program after the replacement by the first address description replacing means. If there is an instruction I10, an address description conversion system for an assembler program having a configuration in which an instruction for multiplying the value after transfer by 1 / L is inserted so as to be executed in a cycle after the instruction I10 .
請求項記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
前記第1のアドレス変換命令挿入手段が、前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令I11があれば、該アドレス専用レジスタに格納された値をL倍する命令を該命令I11の後のサイクルで実行されるよう挿入する構成を有し、
前記第2のアドレス変換命令挿入手段が、前記第1のアドレス記述置換手段での置き換えが済んだプログラム中に、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令I12があれば、転送後の値を1/L倍する命令を該命令I12の後のサイクルで実行されるように挿入する構成を有することを特徴とするアセンブラプログラムのためのアドレス記述変換システム
5. An address description conversion system for an assembler program according to claim 4 ,
The first address translation instruction inserting means transfers a value from a place other than the address dedicated register to the address dedicated register for storing the address in the program after the replacement by the first address description replacing means. If there is an instruction I11, an instruction for multiplying the value stored in the dedicated address register by L is inserted so that it is executed in a cycle after the instruction I11.
The second address translation instruction inserting means transfers a value from the address dedicated register for storing the address to a place other than the address dedicated register in the program after the replacement by the first address description replacing means. If there is an instruction I12, an address description conversion system for an assembler program has a configuration in which an instruction for multiplying the value after transfer by 1 / L is inserted so as to be executed in a cycle after the instruction I12 .
請求項乃至の何れか1項に記載のアセンブラプログラムのためのアドレス記述変換システムにおいて、
前記アドレス記述変換手段によって挿入される命令の中から、不必要な命令を削除する不要命令削除手段を備えたことを特徴とするアセンブラプログラムのためのアドレス記述変換システム
The address description conversion system for an assembler program according to any one of claims 1 to 7 ,
An address description conversion system for an assembler program, comprising: unnecessary instruction deletion means for deleting unnecessary instructions from instructions inserted by the address description conversion means .
コンピュータを、第1のバイト数B1のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換元プロセッサで実行可能な変換元プログラムを、第2のバイト数B2のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換後プロセッサで実行可能な変換後プログラムに変換するアセンブラプログラムのためのアドレス記述変換システムとして機能させるためのプログラムであって、
前記コンピュータを、
前記変換元プログラムを入力とし、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を前記変換元プログラムの中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍(L=B1/B2であり、2以上の整数)する記述に置き換える第1のアドレス記述置換手段
該第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換え、レジスタに格納したアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはレジスタに格納したアドレスを使ってメモリへ値を書き込む処理を伴う命令I13があれば、該命令I13が参照するアドレスをL倍する命令を該命令I13の前のサイクルで実行されるよう挿入し、さらに該命令I13が参照するアドレスを1/L倍する命令を該命令I13の後のサイクルで実行されるよう挿入するアドレス記述変換手段
アドレス記述変換手段で処理済みのプログラムを前記変換後プログラムとして出力する出力手段として機能させるためのプログラム。
A conversion source program that can be executed by a conversion source processor that employs an address system in which one address is assigned to the first byte number B1 data is assigned to the second byte number B2 data. A program for functioning as an address description conversion system for an assembler program that converts to a post-conversion program that can be executed by a post-conversion processor adopting an address system that assigns two addresses,
The computer,
A symbol character indicating the branch destination of a branch instruction is found in the conversion source program, with the conversion source program as an input and a reference to a symbol character string to which an address is automatically assigned by other software. If not a column, first address description replacement means for replacing the symbol character string with a description that multiplies the address assigned to the symbol character string by 1 / L (L = B1 / B2, an integer of 2 or more);
In the program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a numerical value that includes a process for reading a value from a memory using an address described by a symbol character string or a numerical value If there is an instruction that involves a process of writing a value to the memory using an address, the symbol character string or numerical value indicating the memory address is replaced with a description that uses an L-fold address, and the value stored in the register is used to store the value from the memory. If there is an instruction involving the process of reading the instruction I13 or an instruction I13 involving the process of writing a value to the memory using the address stored in the register, an instruction for multiplying the address referred to by the instruction I13 by L is transmitted in the cycle preceding the instruction I13. An instruction to be executed is inserted, and an instruction for multiplying the address referred to by the instruction I13 by 1 / L is added to the support after the instruction I13. Address description conversion means for inserting to run on cycle,
A program for causing a program processed by the address description conversion means to function as an output means for outputting the program after the conversion.
コンピュータを、第1のバイト数B1のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換元プロセッサで実行可能な変換元プログラムを、第2のバイト数B2のデータに対して一つのアドレスを割り当てるアドレス方式を採用している変換後プロセッサで実行可能な変換後プログラムに変換するアセンブラプログラムのためのアドレス記述変換システムとして機能させるためのプログラムであって、
前記コンピュータを、
前記変換元プログラムを入力とし、他のソフトウェアによって自動的にアドレスが割り当てられるシンボル文字列を参照する記述を前記変換元プログラムの中から見つけ、そのシンボル文字列が分岐命令の分岐先を示すシンボル文字列でなければ、そのシンボル文字列を、そのシンボル文字列に割り当てられるアドレスを1/L倍(L=B1/B2であり、2以上の整数)する記述に置き換える第1のアドレス記述置換手段
該第1のアドレス記述置換手段での置き換えが済んだプログラム中に、シンボル文字列や数値で記述されたアドレスを使ってメモリから値を読み込む処理を伴う命令あるいはシンボル文字列や数値で記述されたアドレスを使ってメモリへ値を書き込む処理を伴う命令があれば、メモリのアドレスを示すシンボル文字列や数値をそのL倍のアドレスにする記述へ置き換え、アドレスを格納するアドレス専用レジスタに対してシンボル文字列や数値で記述された値を転送する命令があれば、その値を示すシンボル文字列や数値をそのL倍の値にする記述へ置き換え、アドレスを格納するアドレス専用レジスタに対してアドレス専用レジスタ以外の場所から値を転送する命令I14があれば、転送元の値をL倍する命令を該命令I14の前のサイクルで実行されるように挿入し、さらに転送元の値を1/L倍する命令を該命令I14の後のサイクルで実行されるよう挿入し、アドレスを格納するアドレス専用レジスタからアドレス専用レジスタ以外の場所に対して値を転送する命令I15があれば、該アドレス専用レジスタに格納されたアドレスを1/L倍する命令を該命令I15の前のサイクルで実行されるように挿入し、さらに該アドレス専用レジスタに格納された値をL倍する命令を該命令I15の後のサイクルで実行されるよう挿入するアドレス記述変換手段
アドレス記述変換手段で処理済みのプログラムを前記変換後プログラムとして出力する出力手段として機能させるためのプログラム。
A conversion source program that can be executed by a conversion source processor that employs an address system in which one address is assigned to the first byte number B1 data is assigned to the second byte number B2 data. A program for functioning as an address description conversion system for an assembler program that converts to a post-conversion program that can be executed by a post-conversion processor adopting an address system that assigns two addresses,
The computer,
A symbol character indicating the branch destination of a branch instruction is found in the conversion source program, with the conversion source program as an input and a reference to a symbol character string to which an address is automatically assigned by other software. If not a column, first address description replacement means for replacing the symbol character string with a description that multiplies the address assigned to the symbol character string by 1 / L (L = B1 / B2, an integer of 2 or more);
In a program that has been replaced by the first address description replacing means , an instruction or a symbol character string or a value that includes a process of reading a value from a memory using an address described in a symbol character string or a numerical value If there is an instruction that involves processing to write a value to the memory using an address, the symbol character string or numerical value indicating the memory address is replaced with a description that uses an L-fold address, and the address is stored in a dedicated address register. If there is an instruction that transfers a value described in a character string or a numerical value, the symbol character string or numerical value indicating the value is replaced with a description that is L times the value, and the address dedicated register that stores the address is dedicated to the address. If there is an instruction I14 that transfers a value from a place other than the register, the instruction that multiplies the transfer source value by L is the cycle before the instruction I14. And an instruction for multiplying the value of the transfer source by 1 / L is inserted so that it is executed in the cycle after the instruction I14. From the address dedicated register for storing the address to other than the address dedicated register If there is an instruction I15 for transferring a value to a location, an instruction for multiplying the address stored in the address dedicated register by 1 / L is inserted so as to be executed in the previous cycle of the instruction I15, and the address An address description conversion means for inserting an instruction for multiplying the value stored in the dedicated register by L so that the instruction is executed in a cycle after the instruction I15;
A program for causing a program processed by the address description conversion means to function as an output means for outputting the program after the conversion.
JP2002144512A 2002-05-20 2002-05-20 Address description conversion system and program for assembler program Expired - Fee Related JP4032822B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002144512A JP4032822B2 (en) 2002-05-20 2002-05-20 Address description conversion system and program for assembler program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002144512A JP4032822B2 (en) 2002-05-20 2002-05-20 Address description conversion system and program for assembler program

Publications (2)

Publication Number Publication Date
JP2003337708A JP2003337708A (en) 2003-11-28
JP4032822B2 true JP4032822B2 (en) 2008-01-16

Family

ID=29704165

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002144512A Expired - Fee Related JP4032822B2 (en) 2002-05-20 2002-05-20 Address description conversion system and program for assembler program

Country Status (1)

Country Link
JP (1) JP4032822B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100763177B1 (en) * 2005-04-21 2007-10-04 삼성전자주식회사 Method for executing Java virtual machine instructions, and apparatus for the same

Also Published As

Publication number Publication date
JP2003337708A (en) 2003-11-28

Similar Documents

Publication Publication Date Title
JP4573189B2 (en) Program code conversion method
JP2006338616A (en) Compiler device
JP5966509B2 (en) Program, code generation method, and information processing apparatus
US7574583B2 (en) Processing apparatus including dedicated issue slot for loading immediate value, and processing method therefor
JP3246438B2 (en) Variable target compilation processing method, its processing device, storage medium for its program, and storage medium for conversion table
US7299460B2 (en) Method and computer program for converting an assembly language program for one processor to another
US6308324B1 (en) Multi-stage profiler
US20080184213A1 (en) Compiler device, method, program and recording medium
US7120905B2 (en) System and method for transformation of assembly code for conditional execution
JP4032822B2 (en) Address description conversion system and program for assembler program
US20220261224A1 (en) Non-transitory computer-readable recording medium, function generation method, and information processing device
JPH11242599A (en) Computer program
US6941549B1 (en) Communicating between programs having different machine context organizations
CN114791811B (en) Assembler realization method based on meta-function template
JP3692884B2 (en) Program processing method and recording medium
Schwarz et al. Engineering an optimized instruction set architecture for AMIDAR processors
US11327758B2 (en) Non-transitory computer-readable recording medium, assembly instruction conversion method and information processing apparatus
JP7295466B2 (en) Class generation program and class generation method
Maria A Study on Determining the Link between the C Programming and Microprocessor.
Smith et al. Conditional Instructions and Optimizing Code
Hauswedell The Input/Output Module
Horton et al. Modules and Namespaces
JP2019191796A (en) High-level synthesis method, high-level synthesis program, and high-level synthesis apparatus
JP2004021441A (en) Program processing apparatus, program processing method and computer program
JP2023018581A (en) Conversion program and conversion method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050422

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070615

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070619

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070820

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: 20071002

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20071015

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

Free format text: PAYMENT UNTIL: 20101102

Year of fee payment: 3

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: 20111102

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20111102

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20121102

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20121102

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20131102

Year of fee payment: 6

LAPS Cancellation because of no payment of annual fees