JP3678330B2 - Microprocessor - Google Patents

Microprocessor Download PDF

Info

Publication number
JP3678330B2
JP3678330B2 JP25051998A JP25051998A JP3678330B2 JP 3678330 B2 JP3678330 B2 JP 3678330B2 JP 25051998 A JP25051998 A JP 25051998A JP 25051998 A JP25051998 A JP 25051998A JP 3678330 B2 JP3678330 B2 JP 3678330B2
Authority
JP
Japan
Prior art keywords
address
stack
stack area
branch instruction
circuit
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
JP25051998A
Other languages
Japanese (ja)
Other versions
JPH11327904A (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.)
Kawasaki Microelectronics Inc
Original Assignee
Kawasaki Microelectronics Inc
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 Kawasaki Microelectronics Inc filed Critical Kawasaki Microelectronics Inc
Priority to JP25051998A priority Critical patent/JP3678330B2/en
Publication of JPH11327904A publication Critical patent/JPH11327904A/en
Application granted granted Critical
Publication of JP3678330B2 publication Critical patent/JP3678330B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、命令を取り込んで実行するマイクロプロセッサに関する。
【0002】
【従来の技術】
近年のLSI技術の発達によって、メモリの大容量化が進んでおり、それに伴って、広いアドレス空間を取り扱うことができる新型マイクロプロセッサが開発されている。このような新型マイクロプロセッサは、狭いアドレス空間のみを取り扱うことができる旧型マイクロプロセッサ用に開発された、過去の資産であるソフトウェアを利用することができるように、いわゆる互換性が確保されていることが望まれている。また、当然ながら、広いアドレス空間を自由に利用することができるように、いわゆる拡張性を持つことも望まれている。
【0003】
このような要請の下、従来の新型マイクロプロセッサには、旧型マイクロプロセッサ用のソフトウェアで使用されている、狭いアドレス空間を前提とする旧命令と、新たに、旧命令と対応するように定義された、広いアドレス空間を前提とする新命令が用意されており、コール命令やリスタート命令といった、スタックに戻りアドレスを積むとともに分岐先アドレスに分岐する分岐命令については、スタックに、狭いアドレス空間に対応する、語長が短い戻りアドレスが積まれる旧分岐命令と、スタックに、広いアドレス空間に対応する、語長が長い戻りアドレスが積まれる新分岐命令が用意されている。
【0004】
このような旧分岐命令による分岐が行われた場合には、その分岐後に分岐先から分岐元へ戻る際には、語長が短い戻りアドレスに基づいて分岐元へ戻らなければならない。このため、旧分岐命令の実行後、正常にプログラムが進行するためには、分岐先と分岐元との位置関係が、所定の限定条件を満たしている必要があり、通常は、プログラマによって、この限定条件を満たす位置で旧分岐命令が実行されるようにプログラムが設計される。
【0005】
【発明が解決しようとする課題】
しかし、旧分岐命令は、プログラム上の、プログラマによって予定された位置で実行されるだけでなく、旧分岐命令を前提として設計された周辺回路により、プログラム上の、プログラマが予測不可能な位置で実行される場合もある。
【0006】
例えば、割り込み回路によって旧分岐命令が割り込まれて優先的に実行される場合や、デバッグ装置によって、プログラム上の命令が旧分岐命令に書き換えられる場合等には、割り込みが発生する位置や、命令が書き換えられる位置は、プログラマには予測ができない。このため、プログラムの正常な進行が保証されないという問題がある。
【0007】
しかも、このような、旧分岐命令を前提として設計された周辺回路を、新分岐命令を前提として設計変更することは、困難である場合や不可能である場合がある。
【0008】
本発明は、上記事情に鑑み、プログラム上の、プログラマが予測不可能な位置で旧分岐命令が実行される場合であっても、プログラムを正常に進行することができるマイクロプロセッサを提供することを目的とする。
【0009】
【課題を解決するための手段】
上記目的を達成する本発明の第1のマイクロプロセッサは、データが積まれるスタック領域と、複数の命令が格納されたプログラム領域とを有するメモリに接続され、命令を順次取り込んで実行するマイクロプロセッサにおいて、
スタック領域に戻りアドレスを積んで、プログラム領域上の分岐先アドレスに分岐する分岐命令を実行する分岐命令実行回路と、
分岐先アドレスに格納された命令が所定のスタック構築命令であるか否かを判定する判定回路とを備え、
分岐命令実行回路が、判定回路により、分岐先アドレスに格納された命令が所定のスタック構築命令であると判定されたか否かに応じて、スタック領域に、それぞれ、相対的に語長が長い戻りアドレスもしくは相対的に語長が短い戻りアドレスを積むものであることを特徴とする。
【0010】
本発明の第1のマイクロプロセッサは、上記メモリが、それぞれに上記プログラム領域および上記スタック領域の両方が設けられてなる2つのアドレス空間部分からなるアドレス空間を有するものであり、
上記分岐命令実行回路が、上記判定回路により、上記分岐先アドレスに格納された命令が所定のスタック構築命令であると判定されたか否かに応じて、それぞれ、相対的に語長が長い戻りアドレスを、スタック構築命令が存在するアドレス空間部分に設けられたスタック領域に積み、あるいは相対的に語長が短い戻りアドレスを、上記分岐命令が存在するアドレス空間部分に設けられたスタック領域に積むものであることが好適である。
【0011】
上記目的を達成する本発明の第2のマイクロプロセッサは、データが積まれるスタック領域と、複数の命令が格納されたプログラム領域とを有するメモリに接続され、命令を順次取り込んで実行するマイクロプロセッサにおいて、
スタック領域に戻りアドレスを積んで分岐先アドレスに分岐する分岐命令を実行する分岐命令実行回路と、
分岐命令実行回路によりスタック領域に積まれた戻りアドレスを再構築するスタック構築命令を実行するスタック構築命令実行回路とを備え、
分岐命令実行回路が、相対的に語長が短い戻りアドレスを前記スタック領域に積むとともに、相対的に語長が長い戻りアドレスを保存しておくものであって、スタック構築命令実行回路が、スタック領域に積まれた相対的に語長が短い戻りアドレスを、分岐命令実行回路によって保存された相対的に語長が長い戻りアドレスに変更するものであることを特徴とする。
【0012】
ここで、「相対的に語長が長い戻りアドレスを保存しておく」とは、保存する場所を限定するものではなく、分岐命令実行回路内部に保存しても良く、マイクロプロセッサ内にレジスタ等を設けて、このレジスタ等に保存しても良く、スタック領域に保存しても良い。また、相対的に語長が長い戻りアドレス全体を保存しても良く、相対的に語長が短い戻りアドレスを越える部分のみを保存しても良い。
【0013】
本発明の第2のマイクロプロセッサは、上記メモリが、それぞれに上記プログラム領域および上記スタック領域の両方が設けられてなる2つのアドレス空間部分からなるアドレス空間を有するものであり、
上記分岐命令実行回路が、相対的に語長が短い戻りアドレスを上記分岐命令が存在するアドレス空間部分に設けられたスタック領域に積み上記分岐命令が存在するアドレス空間部分を2つのアドレス空間部分の中から特定する空間部分情報を保存するとともに、相対的に語長が長い戻りアドレスを保存しておくものであり、
上記スタック構築命令実行回路が、分岐命令実行回路によって保存された空間部分情報により特定されるアドレス空間部分に設けられたスタック領域に積まれた相対的に語長が短い戻りアドレスを読み出して、上記スタック構築命令が存在するアドレス空間部分に設けられたスタック領域に、分岐命令実行回路によって保存された相対的に語長が長い戻りアドレスを積むものであることが好適である。
【0014】
本発明の第1および第2のマイクロプロセッサは、上記分岐命令を受け付け、受け付けた分岐命令を上記分岐命令実行回路に優先的に実行させる割り込み受付回路を備えたものであることが望ましい。
【0015】
この割り込み受付回路は、戻りアドレスが適切にスタック領域に積まれるまで分岐命令の受け付けを禁止する回路が付された回路であっても良い。
【0016】
【発明の実施の形態】
以下、本発明の実施形態について説明する。
【0017】
図1は、本発明のマイクロプロセッサの第1実施形態を示す図である。
【0018】
このマイクロプロセッサ10は、24ビットのアドレス空間を取り扱うことができ、16ビットのアドレス空間を前提とした旧型マイクロプロセッサとの互換性を有する。また、このマイクロプロセッサ10は、割り込み回路20およびメモリ30に、バス40を介して接続されており、メモリ30は、24ビットのアドレス空間を有し、このアドレス空間上に、プログラムが格納されるプログラム領域31と、データが積まれるスタック領域32を有する。
【0019】
このマイクロプロセッサ10には、スタック領域32に、16ビットの戻りアドレスを積んで分岐アドレスに分岐する旧分岐命令と、スタック領域32に積まれた16ビットの戻りアドレスを、24ビットの戻りアドレスに変更するスタック構築命令が用意されており、割り込み回路20は、必要に応じて、マイクロプロセッサ10に対して論理「1」の割り込み要求信号を出力すると共に、マイクロプロセッサ10にバス40を介して旧分岐命令を出力する。
【0020】
また、このマイクロプロセッサ10には、バス制御回路11と、割り込み受付回路12が備えられており、バス制御回路11によって、バス40を介したデータ入出力が制御される。割り込み受付回路12にはANDゲート121が接続されており、このANDゲート121には、割り込み回路20からの割り込み要求信号が入力される。また、割り込み受付回路12は、ANDゲート121からの論理「1」の信号の入力を受けて、バス制御回路11に対して、割り込み回路20からのデータの受取りを、メモリからのデータの読込みよりも優先して行うように指示する。
【0021】
また、このマイクロプロセッサ10には、フェッチ・解読回路13と、プログラムカウンタ14が備えられており、フェッチ・解読回路13によって、バス40およびバス制御回路11を介して、プログラム領域31から命令がフェッチされ、あるいは割り込み回路20からの命令が取り込まれる。その後、フェッチ・解読回路13によって、命令が解読され、マイクロプロセッサの各部へ各部の動作を指示する信号が送られる。フェッチ・解読回路13は、旧分岐命令を解読すると、その解読後、分岐先アドレスに格納されている命令をフェッチするまで、論理「0」の割り込み禁止信号をANDゲート121へ出力する。この結果、ANDゲート121の出力は、割り込み要求信号と割り込み禁止信号との論理和である論理「0」の信号となり、この出力が割り込み受付回路12に入力されて割り込みが禁止される。プログラムカウンタ14のカウント値は、フェッチ・解読回路13によって命令がフェッチされる度に、プログラム領域31上の、フェッチされた命令が格納されていたアドレスの次のアドレスを示す値に更新される。
【0022】
また、このマイクロプロセッサ10には、旧分岐命令実行回路15と、レジスタ16が備えられており、フェッチ・解読回路13によって旧分岐命令が解読されると、旧分岐命令実行回路15によって、プログラムカウンタ14のカウント値に基づいて戻りアドレスが認識され、バス40およびバス制御回路11を介して、スタック領域32に16ビットの戻りアドレスが、後述する図2に示すように積まれるとともに、レジスタ16に24ビットの戻りアドレスが格納される。その後、旧分岐命令実行回路15によって、プログラムカウンタ14のカウント値が、分岐先アドレスを示すカウント値に更新され、フェッチ・解読回路13によって、プログラムカウンタ14のカウント値に基づいて、バス40およびバス制御回路11を介して、プログラム領域31上の分岐先アドレスから命令がフェッチされる。
【0023】
フェッチ・解読回路13には、判定回路131が備えられており、判定回路131によって、フェッチ・解読回路13が旧分岐命令の次にフェッチした命令がスタック構築命令であるか否かが判定される。
【0024】
また、このマイクロプロセッサ10には、スタック構築命令実行回路17が備えられており、このスタック構築命令実行回路17は、判定回路131による、フェッチ・解読回路13が旧分岐命令の次にフェッチした命令がスタック構築命令であるとの判定結果を受けて、バス40およびバス制御回路11を介して、スタック領域32から16ビットの戻りアドレスを取り出し、レジスタ16に格納されている24ビットの戻りアドレスを取り込んで、バス40およびバス制御回路11を介して、スタック領域32に、24ビットの戻りアドレスを積む。これによって、スタック領域32に積まれた戻りアドレスの再構築が行われることとなる。
【0025】
図2は、第1実施形態のマイクロプロセッサによってスタック領域に構築されるデータ構造を示す図である。
【0026】
スタック領域32には、図の上方から下方へと向かってデータが積まれる。また、スタック領域32には、図1に示すマイクロプロセッサ10によって戻りアドレスが積まれる前に、分岐先で利用されるパラメータD10が積まれている。
【0027】
図2(A)には、図1に示す旧分岐命令実行回路15によって戻りアドレスが積まれる場合に構築されるデータ構造が示されており、パラメータD10の次に、戻りアドレスの、第8ビットから第15ビットまでの8ビット分D20が積まれ、次に、戻りアドレスの、第0ビットから第7ビットまでの8ビット分D30が積まれる。
【0028】
図2(B)には、図1に示すスタック構築命令実行回路17によって戻りアドレスが積み直される場合に構築されるデータ構造が示されており、パラメータD10の次に、戻りアドレスの、第16ビットから第23ビットまでの8ビット分D40が積まれ、次に、戻りアドレスの、第8ビットから第15ビットまでの8ビット分D50が積まれ、次に、戻りアドレスの、第0ビットから第7ビットまでの8ビット分D60が積まれる。
【0029】
これらのデータ構造は、最終的には、分岐先にスタック構築命令が存在するか否かに応じて、マイクロプロセッサによって選択されることとなるが、旧分岐命令によってプログラムが分岐される分岐先は、プログラム上の、分岐が発生する位置に関わらず、プログラマによって予め予定された位置である。従って、プログラマは、割り込み発生時等に予定されている分岐先にスタック構築命令を書き込むことによって、マイクロプロセッサに、24ビットの戻りアドレスをスタックさせることができ、これによって、旧分岐命令の実行位置に関わらず、プログラムの正常な進行が保証される。
【0030】
なお、第1実施形態では、レジスタに24ビットの戻りアドレスが格納されるが、本発明のマイクロプロセッサは、相対的に語長が長い戻りアドレスのうちの、相対的に短い語長の戻りアドレスを越える部分のみを保存するものであってもよい。
【0031】
以下、本発明のマイクロプロセッサの他の実施形態について説明するが、図1に示す回路等と同様の回路等については、同一の符号を付して重複説明を省略する。
【0032】
図3は、本発明のマイクロプロセッサの第2実施形態を示す図である。
【0033】
このマイクロプロセッサ50には、スタック領域32に戻りアドレスを積んで分岐先に分岐する旧分岐命令と、一種の標識であるスタック構築命令が用意されている。
【0034】
また、このマイクロプロセッサ50には、プリフェッチ回路51が備えられており、プリフェッチ回路51によって、フェッチ・解読回路13で解読された命令の実行中に、その命令の次に実行される命令が、プログラムカウンタ14のカウント値に基づいて、バス40およびバス制御回路11を介して取り込まれ、実行中の命令の実行が終了すると、プリフェッチ回路51に取り込まれている命令がフェッチ・解読回路13に送られる。
【0035】
また、フェッチ・解読回路13には、判定回路132が備えられており、判定回路132は、フェッチ・解読回路13によって旧分岐命令が解読されると、プリフェッチ回路51に取り込まれている、次に実行すべき命令がスタック構築命令であるか否かを判定する。
【0036】
また、マイクロプロセッサ50には、旧分岐命令実行回路52が備えられており、旧分岐命令実行回路52は、フェッチ・解読回路13によって旧分岐命令が解読されると、プログラムカウンタ14のカウント値に基づいて戻りアドレスを認識する。また、この旧分岐命令実行回路52は、判定回路132によって、プリフェッチ回路51に取り込まれている命令がスタック構築命令であると判定されると、バス40およびバス制御回路11を介して、スタック領域32に、24ビットの戻りアドレスを積み、スタック構築命令でないと判定されると、16ビットの戻りアドレスを積む。その後、旧分岐命令実行回路52は、プログラムカウンタ14のカウント値を、分岐先アドレスを示す値に更新する。
【0037】
上述した各動作の結果、第1実施形態同様に、分岐先アドレスに格納されている命令がスタック構築命令であるか否かに応じて、それぞれ、24ビットの戻りアドレスあるいは16ビットの戻りアドレスがスタック領域32に積まれることとなり、プログラムの正常な進行が保証される。
【0038】
なお、第2実施形態では、判定回路がフェッチ・解読回路内に備えられているが、本発明にいう判定回路は、フェッチ・解読回路とは独立の回路であっても良い。
【0039】
図4は、本発明のマイクロプロセッサの第3実施形態を示す図である。
【0040】
図1に示すマイクロプロセッサ10同様に、図4に示すマイクロプロセッサ60には、スタック領域32に、16ビットの戻りアドレスを積んで分岐アドレスに分岐する旧分岐命令と、スタック領域32に積まれた16ビットの戻りアドレスを、24ビットの戻りアドレスに変更するスタック構築命令が用意されている。但し、本実施形態における、スタック領域32に戻りアドレスを積む順序は、以下で説明するように、第1実施形態および第2実施形態における順序とは逆の順序となっている。
【0041】
このマイクロプロセッサ60には、スタックポインタ61が備えられており、スタックポインタ61は、スタック領域32上の、スタック領域32に積まれているデータのうちの、最後に積まれたデータが積まれているアドレスを示しており、スタックポインタ61が示すアドレスに基づいて、バス40およびバス制御回路11を介した、スタック領域32へのアクセスが行われるとともに、スタック領域32へのアクセスが行われる度に、スタックポインタ61が示すアドレスが更新される。
【0042】
また、このマイクロプロセッサ60には、旧分岐命令実行回路62が備えられており、旧分岐命令実行回路62は、フェッチ・解読回路13によって旧分岐命令が解読されると、プログラムカウンタ14のカウント値に基づいて戻りアドレスを認識し、24ビットの戻りアドレスを、8ビット分ずつ、第1実施形態および第2実施形態とは逆に、下位側から順にスタック領域32に積み、その後、スタックポインタ61が示すアドレスを1アドレス戻す。これによって、後述する図5に示すように、スタック領域32には、実質的に16ビットの戻りアドレスが積まれることとなる。その後、この旧分岐命令実行回路62は、プログラムカウンタ14のカウント値を、分岐先アドレスを示す値に更新する。
【0043】
また、このマイクロプロセッサ60には、スタック構築命令実行回路63が備えられており、判定回路131による、分岐先アドレスに格納されている命令がスタック構築命令であるとの判定結果を受けて、スタック構築命令実行回路63によって、スタックポインタ61が示すアドレスが1アドレス進められる。これによって、後述する図5に示すように、実質的に、スタック領域32に積まれた16ビットの戻りアドレスが、24ビットの戻りアドレスに変更されることとなる。
【0044】
図5は、第3実施形態のマイクロプロセッサによってスタック領域に積まれたデータの構造を示す図である。
【0045】
図2に示すスタック領域同様に、図5に示すスタック領域32には、図の上方から下方へとデータが積まれ、第1実施形態および第2実施形態とは逆順で積まれる戻りアドレスの前にはパラメータD10が積まれている。
【0046】
図5(A)には、図4に示す旧分岐命令実行回路62によって戻りアドレスが積まれた後のデータ構造が示されており、スタック領域32には、図の上方から順に、戻りアドレスの、第0ビットから第7ビットまでの8ビット分D70と、戻りアドレスの、第8ビットから第15ビットまでの8ビット分D80と、戻りアドレスの、第16ビットから第23ビットまでの8ビット分D90が積まれており、スタックポインタは、図5(A)に矢印で示すように、戻りアドレスの、第8ビットから第15ビットまでの8ビット分D80が積まれているアドレスを示す。このため、スタックポインタが示すアドレスよりも先のアドレスに積まれている、戻りアドレスの、第16ビットから第23ビットまでの8ビット分D90は、いわば無視されて、スタック領域32は、実質的に、16ビットの戻りアドレスが積まれた状態となる。
【0047】
図5(B)には、図4に示すスタック構築命令実行回路63によりスタック構築命令が実行された後のデータ構造が示されている。上述したように、スタック構築命令実行回路63は、スタックポインタを操作するだけの回路であるので、スタック領域32に積まれているデータは、図5(A)同様である。また、スタックポインタは、図5(B)に矢印で示すように、戻りアドレスの、第16ビットから第23ビットまでの8ビット分D90が積まれているアドレスを示す。つまり、スタックポインタが示すアドレスが、図5(A)に矢印で示された位置から、図5(B)に矢印で示された位置へと移動することとなり、実質的に、16ビットの戻りアドレスが24ビットの戻りアドレスに変更されることとなる。
【0048】
結局、第1実施形態および第2実施形態同様に、第3実施形態でも、分岐先アドレスに格納されている命令がスタック構築命令であるか否かに応じて、それぞれ、24ビットの戻りアドレスあるいは16ビットの戻りアドレスがスタック領域32に積まれることとなり、プログラムの正常な進行が保証される。
【0049】
なお、第1実施形態および第3実施形態においてスタック構築命令実行回路は、分岐先アドレスにスタック構築命令が格納されていた場合にのみ、戻りアドレスの再構築を行うものであるが、本発明にいうスタック構築命令実行回路は、スタック構築命令の格納場所に関わらず、戻りアドレスの再構築が行われるものであってもよい。
【0050】
ところで、上記では、メモリが有するアドレス空間上にスタック領域とプログラム領域が1つずつ設けられている実施形態について説明したが、狭いアドレス空間を前提とした旧型マイクロプロセッサとの互換性を有し広いアドレス空間を取り扱うことができる新型マイクロプロセッサが開発される場合には、スタック領域とプログラム領域が2つずつ設けられることが多い。つまり、新型マイクロプロセッサが取り扱うことができる広いアドレス空間のうち、旧型マイクロプロセッサが前提としている狭いアドレス空間に対応するアドレス空間部分(以下このアドレス空間部分のことを「従来空間部分」と称する)にスタック領域とプログラム領域が設けられるとともに、新型マイクロプロセッサが取り扱うことができる広いアドレス空間のうち従来空間部分を除くアドレス空間部分(以下このアドレス空間部分のことを「拡張空間部分」と称し、従来空間部分と拡張空間部分とを総称して「アドレス空間部分」と称する)にもスタック領域とプログラム領域が設けられる。
【0051】
しかし、スタック領域が従来空間部分および拡張空間部分それぞれに設けられる場合には、スタック構築命令が用意されていても、戻りアドレスの再構築等が正常に行われずに、プログラムの進行に以上が生じる場合がある。
【0052】
そこで、以下では、スタック領域が従来空間部分および拡張空間部分それぞれに設けられ、かつ、プログラムの正常な進行が保証されるように工夫が施された実施形態について説明する。
【0053】
図6は、本発明のマイクロプロセッサの第4実施形態を示す図である。
【0054】
この図6に示す回路等のうち、図1に示す回路等と同様の回路等については、同一の符号を付して重複説明を省略する。
【0055】
この図6には、24ビットのアドレス空間を有するメモリ35が示されており、このメモリ35のアドレス空間のうち、16進数表示でアドレス「000000」からアドレス「00FFFF」までが従来空間部分36であり、16進数表示でアドレス「010000」からアドレス「FFFFFF」までが拡張空間部分37である。また、スタック領域およびプログラム領域の両方が従来空間部分36および拡張空間部分37それぞれに設けられている。
【0056】
マイクロプロセッサ70には、アドレス空間のページ(24ビットのアドレスの上位8ビット分)を示すページレジスタ71が備えられており、スタック領域へのアクセスを伴う命令が実行された場合には、ページレジスタ71の値は、拡張空間部分37に設けられたスタック領域が設けられているページを示しているものとする。
【0057】
マイクロプロセッサ70は、スタック領域へのアクセスを伴う従来の命令のうち旧分岐命令を除く命令が実行される場合には、原則としてその命令が格納されているアドレスが属する方のアドレス空間部分に設けられたスタック領域へのアクセスを行う。また、マイクロプロセッサ70には、拡張空間部分37に設けられたスタック領域へ、命令が配置されている場所にかかわらずアクセス可能な新命令が用意されている。
【0058】
フェッチ・解読回路13で旧分岐命令が解読されると、旧分岐命令実行回路15によって、プログラムカウンタ14の値が示すアドレスが属する方のアドレス空間部分に設けられているスタック領域に16ビットの戻りアドレスが積まれ、レジスタ16に24ビットの戻りアドレスが保存され、プログラムカウンタ14の値が分岐先アドレスを示す値に更新される。
【0059】
また、マイクロプロセッサ70には、空間選択レジスタ72が備えられており、旧分岐命令実行回路15によって16ビットの戻りアドレスが積まれたスタック領域が設けられている方のアドレス空間部分が従来空間部分36であると空間選択レジスタ72の値が値「0」に設定され、拡張空間部分37であると空間選択レジスタ72の値が値「1」に設定される。
【0060】
バス制御回路11には、選択器111が備えられており、選択器111は、従来空間部分36に相当するページを示す16進数の値「00」およびページレジスタ71が示す値のうちのいずれかの値を、空間選択レジスタ72の値に応じて選択する。選択器111によって選択された値は、スタック構築命令実行回路17が16ビットの戻りアドレスをスタック領域から取り出す際に、バス制御回路11によって、16ビットの戻りアドレスが積まれている方のスタック領域が設けられているページ(アドレスの上位8ビット分)を示すものとして用いられる。
【0061】
この結果、空間選択レジスタ72の値が示す方のスタック領域から16ビットの戻りアドレスが正常に取り出されて戻りアドレスの再構築が正常に行われ、これによって正常なプログラム進行が保証される。なお、本実施形態では、割込発生時の分岐先アドレスは必ず従来空間部分36に属しており、これに対し、スタック構築命令実行回路17は24ビットの戻りアドレスを拡張空間部分37に設けられているスタック領域に積む。そして、分岐先から分岐元へ戻るときには新命令が用いられて、拡張空間部分37に設けられているスタック領域へのアクセスが行われることによってプログラムが正常に進行する。
【0062】
図7は、本発明のマイクロプロセッサの第5実施形態を示す図である。
【0063】
この図7に示す回路等のうち、図3および図6に示す回路等と同様の回路等については、同一の符号を付して重複説明を省略する。
【0064】
この図7に示すマイクロプロセッサ80には、空間判定回路81が備えられており、フェッチ・解読回路13で旧分岐命令が解読されると、空間判定回路81によって、プログラムカウンタ14が示す戻りアドレスが属しているアドレス空間部分が従来空間部分であるか拡張空間部分であるかが判定され、従来空間部分であると判定されると空間判定回路81から値「0」が出力され、拡張空間部分であると判定されると値「1」が出力される。また、上述したように、フェッチ・解読回路13によって旧分岐命令が解読されると、判定回路132は、プリフェッチ回路51に取り込まれている、次に実行すべき命令がスタック構築命令であるか否かを判定する。スタック構築命令であると判定されると判定回路132から値「1」が出力され、スタック構築命令でないと判定されると値「0」が出力される。
【0065】
フェッチ・解読回路13で旧分岐命令が解読されると、上述したように、旧分岐命令実行回路52によって、判定回路132による判定結果に応じたビット数の戻りアドレスがスタック領域に積まれる。また、旧分岐命令実行回路52によって戻りアドレスが積まれるスタック領域は、以下説明するように、メモリ35に設けられた2つのスタック領域の中からバス制御回路11によって選択される。
【0066】
バス制御回路11には、NORゲート112と、選択器113が備えられており、NORゲート112には判定回路132の出力と空間判定回路81の出力が入力される。従って、NORゲート112からは、次に実行すべき命令がスタック構築命令でなく、かつ、戻りアドレスが属しているアドレス空間部分が従来空間部分である場合にだけ、値「1」が出力され、それ以外の場合には値「0」が出力される。
【0067】
NORゲート112の出力は選択器113に入力され、選択器113によって、従来空間部分36に相当するページを示す16進数の値「00」およびページレジスタ71が示す値のうちのいずれかの値が、NORゲート112の出力に応じて選択される。図6に示す選択器111によって選択された値が、戻りアドレスをスタック領域から取り出す際に用いられるのに対して、選択器113によって選択された値は、旧分岐命令実行回路52によって戻りアドレスがスタック領域に積まれる際に、バス制御回路11によるスタック領域の選択に用いられる。
【0068】
このように、適切なビット数の戻りアドレスが適切な方のスタック領域に積まれ、これによってプログラムの正常な進行が保証されることとなる。
【0069】
【発明の効果】
以上説明したように、本発明のマイクロプロセッサによれば、プログラム上の、プログラマが予測不可能な位置で旧分岐命令が実行される場合であっても、プログラムを正常に進行することができる。
【図面の簡単な説明】
【図1】本発明のマイクロプロセッサの第1実施形態を示す図である。
【図2】第1実施形態のマイクロプロセッサによってスタック領域に構築されるデータ構造を示す図である。
【図3】本発明のマイクロプロセッサの第2実施形態を示す図である。
【図4】本発明のマイクロプロセッサの第3実施形態を示す図である。
【図5】第3実施形態のマイクロプロセッサによってスタック領域に積まれたデータの構造を示す図である。
【図6】本発明のマイクロプロセッサの第4実施形態を示す図である。
【図7】本発明のマイクロプロセッサの第5実施形態を示す図である。
【符号の説明】
10,50,60,70,80 マイクロプロセッサ
11 バス制御回路
12 割り込み受付回路
14 プログラムカウンタ
15,52,62 旧分岐命令実行回路
16 レジスタ
17,63 スタック構築命令実行回路
20 割り込み回路
30,35 メモリ
31 プログラム領域
32 スタック領域
36 従来空間部分
37 拡張空間部分
40 バス
51 プリフェッチ回路
61 スタックポインタ
71 ページレジスタ
72 空間選択レジスタ
81 空間判定回路
111,113 選択器
112 NORゲート
121 ANDゲート
131,132 判定回路
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a microprocessor that fetches and executes instructions.
[0002]
[Prior art]
With the recent development of LSI technology, the capacity of memory has been increased, and accordingly, a new type microprocessor capable of handling a wide address space has been developed. These new microprocessors must be compatible so that software that is a legacy asset developed for older microprocessors that can handle only a narrow address space can be used. Is desired. Of course, it is also desired to have a so-called extensibility so that a wide address space can be freely used.
[0003]
Under such a demand, the conventional new microprocessor is defined to correspond to the old instruction that is used in the software for the old microprocessor based on the narrow address space and the old instruction. In addition, new instructions are provided on the premise of a wide address space. Branch instructions such as call instructions and restart instructions that accumulate return addresses on the stack and branch to branch destination addresses are stored in a narrow address space on the stack. A corresponding old branch instruction in which a return address having a short word length is stacked and a new branch instruction in which a return address having a long word length corresponding to a wide address space is stacked are prepared on the stack.
[0004]
When such a branch by an old branch instruction is performed, when returning from the branch destination to the branch source after the branch, it is necessary to return to the branch source based on a return address having a short word length. For this reason, in order for the program to proceed normally after execution of the old branch instruction, the positional relationship between the branch destination and the branch source must satisfy a predetermined limiting condition. The program is designed so that the old branch instruction is executed at a position that satisfies the limiting condition.
[0005]
[Problems to be solved by the invention]
However, the old branch instruction is not only executed at the position planned by the programmer on the program, but the peripheral circuit designed on the assumption of the old branch instruction is used at a position on the program where the programmer cannot predict. May be executed.
[0006]
For example, when an old branch instruction is interrupted and executed preferentially by an interrupt circuit, or when an instruction on a program is rewritten to an old branch instruction by a debugging device, the location where the interrupt occurs or the instruction The position where the rewriting is performed cannot be predicted by the programmer. For this reason, there is a problem that normal progress of the program is not guaranteed.
[0007]
Moreover, it may be difficult or impossible to change the design of a peripheral circuit designed on the assumption of the old branch instruction on the basis of the new branch instruction.
[0008]
SUMMARY OF THE INVENTION In view of the above circumstances, the present invention provides a microprocessor that allows a program to proceed normally even when an old branch instruction is executed at a position on the program where the programmer cannot predict. Objective.
[0009]
[Means for Solving the Problems]
A first microprocessor of the present invention that achieves the above object is a microprocessor that is connected to a memory having a stack area in which data is stacked and a program area in which a plurality of instructions are stored, and sequentially fetches and executes instructions. ,
A branch instruction execution circuit that executes a branch instruction that branches to a branch destination address in the program area by accumulating a return address in the stack area;
A determination circuit that determines whether or not the instruction stored in the branch destination address is a predetermined stack construction instruction;
The branch instruction execution circuit returns a relatively long word length to the stack area depending on whether the determination circuit determines that the instruction stored at the branch destination address is a predetermined stack construction instruction. The address or the return address having a relatively short word length is stacked.
[0010]
In the first microprocessor of the present invention, the memory has an address space composed of two address space portions each provided with both the program area and the stack area.
A return address having a relatively long word length depending on whether the branch instruction execution circuit determines that the instruction stored in the branch destination address is a predetermined stack construction instruction by the determination circuit. Are stacked in the stack area provided in the address space portion where the stack construction instruction exists, or the return address having a relatively short word length is stacked in the stack area provided in the address space portion where the branch instruction exists. Is preferred.
[0011]
The second microprocessor of the present invention that achieves the above object is a microprocessor that is connected to a memory having a stack area in which data is stacked and a program area in which a plurality of instructions are stored, and sequentially fetches and executes instructions. ,
A branch instruction execution circuit that executes a branch instruction that loads a return address in the stack area and branches to a branch destination address;
A stack construction instruction execution circuit for executing a stack construction instruction for reconstructing the return address stacked in the stack area by the branch instruction execution circuit;
A branch instruction execution circuit accumulates a return address having a relatively short word length in the stack area, and stores a return address having a relatively long word length. A return address having a relatively short word length accumulated in the area is changed to a return address having a relatively long word length stored by the branch instruction execution circuit.
[0012]
Here, “save the return address having a relatively long word length” does not limit the storage location, and may be stored in the branch instruction execution circuit, and may be stored in a register in the microprocessor. May be stored in this register or the like, or may be stored in the stack area. Further, the entire return address having a relatively long word length may be stored, or only a portion exceeding the return address having a relatively short word length may be stored.
[0013]
In the second microprocessor of the present invention, the memory has an address space composed of two address space portions each provided with both the program area and the stack area.
The branch instruction execution circuit stacks a return address having a relatively short word length on a stack area provided in the address space part where the branch instruction exists, and converts the address space part where the branch instruction exists into two address space parts. In addition to storing the spatial part information specified from inside, the return address having a relatively long word length is stored,
The stack construction instruction execution circuit reads a return address having a relatively short word length loaded in a stack area provided in an address space portion specified by the space portion information stored by the branch instruction execution circuit, and It is preferable that the return area having a relatively long word length stored by the branch instruction execution circuit is stacked in the stack area provided in the address space portion where the stack construction instruction exists.
[0014]
It is desirable that the first and second microprocessors of the present invention include an interrupt acceptance circuit that accepts the branch instruction and causes the branch instruction execution circuit to preferentially execute the accepted branch instruction.
[0015]
This interrupt acceptance circuit may be a circuit provided with a circuit that prohibits acceptance of branch instructions until the return address is appropriately stacked in the stack area.
[0016]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described.
[0017]
FIG. 1 is a diagram showing a first embodiment of a microprocessor of the present invention.
[0018]
The microprocessor 10 can handle a 24-bit address space, and is compatible with an old microprocessor based on a 16-bit address space. The microprocessor 10 is connected to the interrupt circuit 20 and the memory 30 via the bus 40. The memory 30 has a 24-bit address space, and a program is stored in the address space. It has a program area 31 and a stack area 32 where data is stacked.
[0019]
In this microprocessor 10, the stack area 32 is loaded with a 16-bit return address and branched to a branch address, and the 16-bit return address accumulated in the stack area 32 is converted into a 24-bit return address. A stack construction instruction to be changed is prepared, and the interrupt circuit 20 outputs an interrupt request signal of logic “1” to the microprocessor 10 as necessary, and also sends an old request to the microprocessor 10 via the bus 40. A branch instruction is output.
[0020]
The microprocessor 10 includes a bus control circuit 11 and an interrupt reception circuit 12, and data input / output via the bus 40 is controlled by the bus control circuit 11. An AND gate 121 is connected to the interrupt reception circuit 12, and an interrupt request signal from the interrupt circuit 20 is input to the AND gate 121. The interrupt reception circuit 12 receives a logic “1” signal from the AND gate 121 and receives data from the interrupt circuit 20 to the bus control circuit 11 by reading data from the memory. Is also given priority.
[0021]
Further, the microprocessor 10 is provided with a fetch / decryption circuit 13 and a program counter 14. The fetch / decode circuit 13 fetches an instruction from the program area 31 via the bus 40 and the bus control circuit 11. Alternatively, an instruction from the interrupt circuit 20 is fetched. Thereafter, the fetch / decode circuit 13 decodes the instruction and sends a signal instructing the operation of each part to each part of the microprocessor. When the old branch instruction is decoded, the fetch / decode circuit 13 outputs an interrupt disable signal of logic “0” to the AND gate 121 until the instruction stored in the branch destination address is fetched after the decoding. As a result, the output of the AND gate 121 becomes a logic “0” signal that is the logical sum of the interrupt request signal and the interrupt prohibition signal, and this output is input to the interrupt reception circuit 12 to prohibit the interrupt. Each time an instruction is fetched by the fetch / decryption circuit 13, the count value of the program counter 14 is updated to a value indicating the next address on the program area 31 where the fetched instruction is stored.
[0022]
The microprocessor 10 includes an old branch instruction execution circuit 15 and a register 16. When the old branch instruction is decoded by the fetch / decode circuit 13, the old branch instruction execution circuit 15 The return address is recognized based on the count value of 14, and a 16-bit return address is stacked in the stack area 32 via the bus 40 and the bus control circuit 11 as shown in FIG. A 24-bit return address is stored. Thereafter, the old branch instruction execution circuit 15 updates the count value of the program counter 14 to the count value indicating the branch destination address, and the fetch / decryption circuit 13 determines the bus 40 and the bus based on the count value of the program counter 14. An instruction is fetched from the branch destination address on the program area 31 via the control circuit 11.
[0023]
The fetch / decryption circuit 13 includes a determination circuit 131. The determination circuit 131 determines whether the instruction fetched after the old branch instruction by the fetch / decryption circuit 13 is a stack construction instruction. .
[0024]
Further, the microprocessor 10 is provided with a stack construction instruction execution circuit 17. The stack construction instruction execution circuit 17 is an instruction fetched by the determination circuit 131 after the old branch instruction by the fetch / decoding circuit 13. Is received from the stack area 32 through the bus 40 and the bus control circuit 11, and the 24-bit return address stored in the register 16 is obtained. Then, a 24-bit return address is loaded in the stack area 32 via the bus 40 and the bus control circuit 11. As a result, the return address stacked in the stack area 32 is reconstructed.
[0025]
FIG. 2 is a diagram illustrating a data structure constructed in the stack area by the microprocessor according to the first embodiment.
[0026]
Data is stacked in the stack area 32 from the top to the bottom of the figure. The stack area 32 is loaded with a parameter D10 used at a branch destination before the return address is loaded by the microprocessor 10 shown in FIG.
[0027]
FIG. 2A shows a data structure that is constructed when the return address is stacked by the old branch instruction execution circuit 15 shown in FIG. 1, and the eighth bit of the return address is next to the parameter D10. 8 bits D20 from the 15th bit to the 15th bit are stacked, and then, 8 bits D30 from the 0th bit to the 7th bit of the return address are stacked.
[0028]
FIG. 2B shows a data structure that is constructed when the return address is restacked by the stack construction instruction execution circuit 17 shown in FIG. 1, and the 16th of the return address is next to the parameter D10. 8 bits D40 from the bit to the 23rd bit are stacked, then 8 bits D50 from the 8th bit to the 15th bit of the return address are stacked, and then from the 0th bit of the return address D60 for 8 bits up to the 7th bit is stacked.
[0029]
These data structures are ultimately selected by the microprocessor depending on whether or not a stack construction instruction exists at the branch destination, but the branch destination where the program is branched by the old branch instruction is Regardless of the position where the branch occurs on the program, the position is predetermined by the programmer. Therefore, the programmer can stack the 24-bit return address in the microprocessor by writing the stack construction instruction to the branch destination that is scheduled when an interrupt occurs or the like. Regardless, the normal progress of the program is guaranteed.
[0030]
In the first embodiment, a 24-bit return address is stored in the register. However, the microprocessor of the present invention has a return address with a relatively short word length among return addresses with a relatively long word length. Only the part exceeding the limit may be stored.
[0031]
Hereinafter, other embodiments of the microprocessor of the present invention will be described. Circuits similar to those shown in FIG. 1 are denoted by the same reference numerals, and redundant description will be omitted.
[0032]
FIG. 3 is a diagram showing a second embodiment of the microprocessor of the present invention.
[0033]
The microprocessor 50 is provided with an old branch instruction that loads the return address into the stack area 32 and branches to a branch destination, and a stack construction instruction that is a kind of indicator.
[0034]
The microprocessor 50 is provided with a prefetch circuit 51. During execution of an instruction decoded by the fetch / decryption circuit 13 by the prefetch circuit 51, an instruction to be executed next to the instruction is a program. Based on the count value of the counter 14, the instruction fetched through the bus 40 and the bus control circuit 11 and the execution of the currently executed instruction is completed, and the instruction fetched into the prefetch circuit 51 is sent to the fetch / decryption circuit 13. .
[0035]
Further, the fetch / decryption circuit 13 is provided with a determination circuit 132. When the old branch instruction is decrypted by the fetch / decryption circuit 13, the determination circuit 132 is fetched into the prefetch circuit 51. It is determined whether the instruction to be executed is a stack construction instruction.
[0036]
Further, the microprocessor 50 is provided with an old branch instruction execution circuit 52. When the old branch instruction is decoded by the fetch / decryption circuit 13, the old branch instruction execution circuit 52 sets the count value of the program counter 14. Based on this, the return address is recognized. When the determination circuit 132 determines that the instruction fetched by the prefetch circuit 51 is a stack construction instruction, the old branch instruction execution circuit 52 passes through the stack area via the bus 40 and the bus control circuit 11. A 24-bit return address is stacked in 32, and if it is determined that the instruction is not a stack construction instruction, a 16-bit return address is stacked. Thereafter, the old branch instruction execution circuit 52 updates the count value of the program counter 14 to a value indicating the branch destination address.
[0037]
As a result of each operation described above, as in the first embodiment, a 24-bit return address or a 16-bit return address is obtained depending on whether the instruction stored in the branch destination address is a stack construction instruction, respectively. The program is stacked in the stack area 32, and the normal progress of the program is guaranteed.
[0038]
In the second embodiment, the determination circuit is provided in the fetch / decryption circuit. However, the determination circuit according to the present invention may be a circuit independent of the fetch / decryption circuit.
[0039]
FIG. 4 is a diagram showing a third embodiment of the microprocessor of the present invention.
[0040]
Similar to the microprocessor 10 shown in FIG. 1, the microprocessor 60 shown in FIG. 4 has the stack area 32 loaded with a 16-bit return address and branched to a branch address and the stack area 32. A stack construction instruction for changing a 16-bit return address to a 24-bit return address is prepared. However, the order in which the return addresses are stacked in the stack area 32 in the present embodiment is the reverse of the order in the first and second embodiments, as will be described below.
[0041]
The microprocessor 60 is provided with a stack pointer 61. The stack pointer 61 is obtained by stacking the last stacked data among the data stacked in the stack area 32 on the stack area 32. The stack area 32 is accessed via the bus 40 and the bus control circuit 11 on the basis of the address indicated by the stack pointer 61, and whenever the stack area 32 is accessed. The address indicated by the stack pointer 61 is updated.
[0042]
The microprocessor 60 includes an old branch instruction execution circuit 62. When the old branch instruction is decoded by the fetch / decryption circuit 13, the old branch instruction execution circuit 62 counts the count value of the program counter 14. The return address is recognized based on the above, and the 24-bit return address is stacked on the stack area 32 in order from the lower side, in the opposite direction to the first and second embodiments, and then the stack pointer 61 1 address is returned. As a result, as shown in FIG. 5 to be described later, a 16-bit return address is substantially stacked in the stack area 32. Thereafter, the old branch instruction execution circuit 62 updates the count value of the program counter 14 to a value indicating the branch destination address.
[0043]
Further, the microprocessor 60 is provided with a stack construction instruction execution circuit 63. Upon receiving a determination result by the determination circuit 131 that the instruction stored in the branch destination address is a stack construction instruction, the stack 60 The address indicated by the stack pointer 61 is advanced by one address by the construction instruction execution circuit 63. As a result, as shown in FIG. 5 to be described later, the 16-bit return address stacked in the stack area 32 is substantially changed to a 24-bit return address.
[0044]
FIG. 5 is a diagram showing the structure of data stacked in the stack area by the microprocessor of the third embodiment.
[0045]
Like the stack area shown in FIG. 2, the stack area 32 shown in FIG. 5 is loaded with data from the top to the bottom of the figure, and before the return address that is stacked in the reverse order of the first and second embodiments. Is loaded with a parameter D10.
[0046]
FIG. 5A shows the data structure after the return address is stacked by the old branch instruction execution circuit 62 shown in FIG. 4. The stack area 32 has the return address in order from the top of the figure. 8 bits D70 from the 0th bit to the 7th bit, 8 bits D80 from the 8th bit to the 15th bit of the return address, and 8 bits from the 16th bit to the 23rd bit of the return address As shown by the arrow in FIG. 5A, the stack pointer indicates an address where 8 bits D80 from the 8th bit to the 15th bit of the return address are stacked. For this reason, the 8-bit D90 from the 16th bit to the 23rd bit of the return address, which is stacked at the address earlier than the address indicated by the stack pointer, is ignored, so to speak, the stack area 32 is substantially In addition, a 16-bit return address is stacked.
[0047]
FIG. 5B shows a data structure after the stack construction instruction is executed by the stack construction instruction execution circuit 63 shown in FIG. As described above, since the stack construction instruction execution circuit 63 is a circuit that only operates the stack pointer, the data loaded in the stack area 32 is the same as that shown in FIG. Further, the stack pointer indicates an address in which D90 of 8 bits from the 16th bit to the 23rd bit of the return address is stacked, as indicated by an arrow in FIG. That is, the address indicated by the stack pointer moves from the position indicated by the arrow in FIG. 5A to the position indicated by the arrow in FIG. The address is changed to a 24-bit return address.
[0048]
Eventually, as in the first and second embodiments, in the third embodiment, a 24-bit return address or an instruction stored in the branch destination address depends on whether or not the instruction stored in the branch destination address is a stack construction instruction, respectively. A 16-bit return address is stacked in the stack area 32, and normal progress of the program is guaranteed.
[0049]
In the first and third embodiments, the stack construction instruction execution circuit reconstructs the return address only when the stack construction instruction is stored in the branch destination address. The stack construction instruction execution circuit may be one in which the return address is reconstructed regardless of the storage location of the stack construction instruction.
[0050]
In the above description, the embodiment in which one stack area and one program area are provided in the address space of the memory has been described. However, the embodiment has a wide compatibility with old microprocessors based on a narrow address space. When a new microprocessor capable of handling an address space is developed, two stack areas and two program areas are often provided. That is, of the wide address space that can be handled by the new microprocessor, the address space portion corresponding to the narrow address space assumed by the old microprocessor (hereinafter, this address space portion is referred to as the “conventional space portion”). A stack area and a program area are provided, and the address space portion excluding the conventional space portion of the wide address space that can be handled by the new microprocessor (hereinafter, this address space portion is referred to as the “extended space portion”). The stack area and the program area are also provided in the “address space portion”.
[0051]
However, when the stack area is provided in each of the conventional space portion and the extended space portion, even if the stack construction instruction is prepared, the return address is not reconstructed normally and the program progresses as described above. There is a case.
[0052]
Therefore, in the following, an embodiment will be described in which stack areas are provided in each of the conventional space portion and the extended space portion and the device is devised so as to ensure normal progress of the program.
[0053]
FIG. 6 is a diagram showing a fourth embodiment of the microprocessor of the present invention.
[0054]
Among the circuits shown in FIG. 6 and the like, the same circuits and the like as those shown in FIG.
[0055]
FIG. 6 shows a memory 35 having a 24-bit address space. Of the address space of this memory 35, addresses “000000” to “00FFFF” in hexadecimal notation are the conventional space portion 36. There is an extended space portion 37 from the address “010000” to the address “FFFFFF” in hexadecimal notation. Both the stack area and the program area are provided in the conventional space portion 36 and the extended space portion 37, respectively.
[0056]
The microprocessor 70 is provided with a page register 71 indicating a page of the address space (the upper 8 bits of the 24-bit address). When an instruction involving access to the stack area is executed, the page register A value of 71 indicates a page in which a stack area provided in the extended space portion 37 is provided.
[0057]
When an instruction other than the old branch instruction is executed among conventional instructions that accompany access to the stack area, the microprocessor 70 is provided in the address space portion to which the address storing the instruction belongs as a rule. Access the specified stack area. Further, the microprocessor 70 is provided with a new instruction that can access the stack area provided in the expansion space portion 37 regardless of the place where the instruction is arranged.
[0058]
When the old branch instruction is decoded by the fetch / decryption circuit 13, the old branch instruction execution circuit 15 returns 16 bits to the stack area provided in the address space portion to which the address indicated by the value of the program counter 14 belongs. The addresses are stacked, a 24-bit return address is stored in the register 16, and the value of the program counter 14 is updated to a value indicating the branch destination address.
[0059]
Further, the microprocessor 70 is provided with a space selection register 72, and the address space portion where the stack area where the 16-bit return address is stacked by the old branch instruction execution circuit 15 is provided is the conventional space portion. If it is 36, the value of the space selection register 72 is set to the value “0”, and if it is the extended space portion 37, the value of the space selection register 72 is set to the value “1”.
[0060]
The bus control circuit 11 is provided with a selector 111, which is one of a hexadecimal value “00” indicating a page corresponding to the conventional space portion 36 and a value indicated by the page register 71. Is selected according to the value of the space selection register 72. The value selected by the selector 111 is the stack area on which the 16-bit return address is stacked by the bus control circuit 11 when the stack construction instruction execution circuit 17 extracts the 16-bit return address from the stack area. Is used to indicate the page (the upper 8 bits of the address).
[0061]
As a result, a 16-bit return address is normally extracted from the stack area indicated by the value of the space selection register 72, and the return address is normally reconstructed, thereby ensuring normal program progress. In this embodiment, the branch destination address at the time of occurrence of an interrupt always belongs to the conventional space portion 36. On the other hand, the stack construction instruction execution circuit 17 is provided with a 24-bit return address in the extended space portion 37. Stack the stack area. Then, when returning from the branch destination to the branch source, a new instruction is used to access the stack area provided in the extended space portion 37, so that the program proceeds normally.
[0062]
FIG. 7 is a diagram showing a fifth embodiment of the microprocessor of the present invention.
[0063]
Among the circuits shown in FIG. 7 and the like, circuits and the like similar to those shown in FIGS. 3 and 6 are denoted by the same reference numerals, and redundant description is omitted.
[0064]
The microprocessor 80 shown in FIG. 7 includes a space determination circuit 81. When the old branch instruction is decoded by the fetch / decryption circuit 13, the space determination circuit 81 generates a return address indicated by the program counter 14. It is determined whether the address space portion to which it belongs is a conventional space portion or an extended space portion. If it is determined that the address space portion is a conventional space portion, the value “0” is output from the space determination circuit 81 and If it is determined that there is, the value “1” is output. Further, as described above, when the old branch instruction is decoded by the fetch / decryption circuit 13, the determination circuit 132 determines whether the instruction to be executed next, which is fetched by the prefetch circuit 51, is a stack construction instruction. Determine whether. When it is determined that the instruction is a stack construction instruction, the value “1” is output from the determination circuit 132, and when it is determined that the instruction is not a stack construction instruction, a value “0” is output.
[0065]
When the old branch instruction is decoded by the fetch / decryption circuit 13, as described above, the old branch instruction execution circuit 52 accumulates the return address of the number of bits corresponding to the determination result by the determination circuit 132 in the stack area. The stack area where the return address is stacked by the old branch instruction execution circuit 52 is selected by the bus control circuit 11 from two stack areas provided in the memory 35, as will be described below.
[0066]
The bus control circuit 11 includes a NOR gate 112 and a selector 113, and the output of the determination circuit 132 and the output of the space determination circuit 81 are input to the NOR gate 112. Therefore, the value “1” is output from the NOR gate 112 only when the next instruction to be executed is not a stack construction instruction and the address space part to which the return address belongs is the conventional space part, Otherwise, the value “0” is output.
[0067]
The output of the NOR gate 112 is input to the selector 113, and the selector 113 selects one of the hexadecimal value “00” indicating the page corresponding to the conventional space portion 36 and the value indicated by the page register 71. , Selected according to the output of the NOR gate 112. The value selected by the selector 111 shown in FIG. 6 is used when the return address is taken out from the stack area, whereas the value selected by the selector 113 has the return address set by the old branch instruction execution circuit 52. When stacked in the stack area, it is used for selection of the stack area by the bus control circuit 11.
[0068]
In this way, a return address having an appropriate number of bits is stacked in the appropriate stack area, thereby ensuring the normal progress of the program.
[0069]
【The invention's effect】
As described above, according to the microprocessor of the present invention, the program can proceed normally even when the old branch instruction is executed at a position on the program where the programmer cannot predict.
[Brief description of the drawings]
FIG. 1 is a diagram showing a first embodiment of a microprocessor according to the present invention.
FIG. 2 is a diagram showing a data structure constructed in a stack area by the microprocessor of the first embodiment.
FIG. 3 is a diagram showing a second embodiment of the microprocessor of the present invention.
FIG. 4 is a diagram showing a third embodiment of the microprocessor of the present invention.
FIG. 5 is a diagram illustrating a structure of data stacked in a stack area by the microprocessor according to the third embodiment.
FIG. 6 is a diagram showing a fourth embodiment of the microprocessor of the present invention.
FIG. 7 is a diagram showing a fifth embodiment of the microprocessor of the present invention.
[Explanation of symbols]
10, 50, 60, 70, 80 Microprocessor
11 Bus control circuit
12 Interrupt acceptance circuit
14 Program counter
15, 52, 62 Old branch instruction execution circuit
16 registers
17, 63 Stack construction instruction execution circuit
20 Interrupt circuit
30,35 memory
31 Program area
32 Stack area
36 Conventional space
37 Extended space
40 bus
51 Prefetch circuit
61 Stack pointer
71 page register
72 Space Select Register
81 Spatial determination circuit
111,113 selector
112 NOR gate
121 AND gate
131,132 judgment circuit

Claims (5)

データが積まれるスタック領域と、複数の命令が格納されたプログラム領域とを有するメモリに接続され、命令を順次取り込んで実行するマイクロプロセッサにおいて、
前記スタック領域に戻りアドレスを積んで、前記プログラム領域上の分岐先アドレスに分岐する分岐命令を実行する分岐命令実行回路と、
前記分岐先アドレスに格納された命令が所定のスタック構築命令であるか否かを判定する判定回路とを備え、
前記分岐命令実行回路が、前記判定回路により、前記分岐先アドレスに格納された命令が所定のスタック構築命令であると判定されたか否かに応じて、前記スタック領域に、それぞれ、相対的に語長が長い戻りアドレスもしくは相対的に語長が短い戻りアドレスを積むものであることを特徴とするマイクロプロセッサ。
In a microprocessor connected to a memory having a stack area where data is stacked and a program area where a plurality of instructions are stored, and sequentially fetching and executing instructions,
A branch instruction execution circuit that loads a return address in the stack area and executes a branch instruction that branches to a branch destination address on the program area;
A determination circuit for determining whether or not the instruction stored in the branch destination address is a predetermined stack construction instruction,
The branch instruction execution circuit is relatively worded in the stack area depending on whether or not the determination circuit determines that the instruction stored in the branch destination address is a predetermined stack construction instruction. A microprocessor characterized by accumulating return addresses having a long length or return addresses having a relatively short word length.
前記メモリが、それぞれに前記プログラム領域および前記スタック領域の両方が設けられてなる2つのアドレス空間部分からなるアドレス空間を有するものであり、
前記分岐命令実行回路が、前記判定回路により、前記分岐先アドレスに格納された命令が所定のスタック構築命令であると判定されたか否かに応じて、それぞれ、相対的に語長が長い戻りアドレスを、該スタック構築命令が存在するアドレス空間部分に設けられたスタック領域に積み、あるいは相対的に語長が短い戻りアドレスを、前記分岐命令が存在するアドレス空間部分に設けられたスタック領域に積むものであることを特徴とする請求項1記載のマイクロプロセッサ。
The memory has an address space composed of two address space portions each provided with both the program area and the stack area;
The branch instruction execution circuit has a relatively long return address according to whether or not the determination circuit determines that the instruction stored in the branch destination address is a predetermined stack construction instruction. Are stacked in the stack area provided in the address space portion where the stack construction instruction exists, or the return address having a relatively short word length is stacked in the stack area provided in the address space portion where the branch instruction exists. 2. The microprocessor according to claim 1, wherein the microprocessor is a memory.
データが積まれるスタック領域と、複数の命令が格納されたプログラム領域とを有するメモリに接続され、命令を順次取り込んで実行するマイクロプロセッサにおいて、
前記スタック領域に戻りアドレスを積んで分岐先アドレスに分岐する分岐命令を実行する分岐命令実行回路と、
前記分岐命令実行回路によりスタック領域に積まれた戻りアドレスを再構築するスタック構築命令を実行するスタック構築命令実行回路とを備え、
前記分岐命令実行回路が、相対的に語長が短い戻りアドレスを前記スタック領域に積むとともに、相対的に語長が長い戻りアドレスを保存しておくものであって、
前記スタック構築命令実行回路が、前記スタック領域に積まれた相対的に語長が短い戻りアドレスを、前記分岐命令実行回路によって保存された相対的に語長が長い戻りアドレスに変更するものであることを特徴とするマイクロプロセッサ。
In a microprocessor connected to a memory having a stack area where data is stacked and a program area where a plurality of instructions are stored, and sequentially fetching and executing instructions,
A branch instruction execution circuit for executing a branch instruction for branching to a branch destination address by accumulating a return address in the stack area;
A stack construction instruction execution circuit for executing a stack construction instruction for reconstructing a return address stacked in the stack area by the branch instruction execution circuit;
The branch instruction execution circuit accumulates a return address having a relatively short word length in the stack area, and stores a return address having a relatively long word length,
The stack construction instruction execution circuit changes a return address with a relatively short word length accumulated in the stack area to a return address with a relatively long word length stored by the branch instruction execution circuit. A microprocessor characterized by that.
前記メモリが、それぞれに前記プログラム領域および前記スタック領域の両方が設けられてなる2つのアドレス空間部分からなるアドレス空間を有するものであり、
前記分岐命令実行回路が、相対的に語長が短い戻りアドレスを前記分岐命令が存在するアドレス空間部分に設けられたスタック領域に積み前記分岐命令が存在するアドレス空間部分を前記2つのアドレス空間部分の中から特定する空間部分情報を保存するとともに、相対的に語長が長い戻りアドレスを保存しておくものであり、
前記スタック構築命令実行回路が、前記分岐命令実行回路によって保存された空間部分情報により特定されるアドレス空間部分に設けられたスタック領域に積まれた相対的に語長が短い戻りアドレスを読み出して、前記スタック構築命令が存在するアドレス空間部分に設けられたスタック領域に、前記分岐命令実行回路によって保存された相対的に語長が長い戻りアドレスを積むものであることを特徴とする請求項3記載のマイクロプロセッサ。
The memory has an address space composed of two address space portions each provided with both the program area and the stack area;
The branch instruction execution circuit stacks a return address having a relatively short word length in a stack area provided in an address space part where the branch instruction exists, and the address space part where the branch instruction exists exists in the two address space parts. In addition to storing the spatial part information specified from within, the return address having a relatively long word length is stored,
The stack construction instruction execution circuit reads a return address having a relatively short word length stacked in a stack area provided in an address space portion specified by the space portion information stored by the branch instruction execution circuit, 4. The micro of claim 3, wherein a stack area provided in an address space where the stack construction instruction exists is loaded with a return address having a relatively long word length stored by the branch instruction execution circuit. Processor.
前記分岐命令を受け付け、受け付けた分岐命令を前記分岐命令実行回路に優先的に実行させる割り込み受付回路を備えたことを特徴とする請求項1または3記載のマイクロプロセッサ。4. The microprocessor according to claim 1, further comprising an interrupt acceptance circuit that accepts the branch instruction and causes the branch instruction execution circuit to preferentially execute the accepted branch instruction.
JP25051998A 1998-03-20 1998-09-04 Microprocessor Expired - Fee Related JP3678330B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP25051998A JP3678330B2 (en) 1998-03-20 1998-09-04 Microprocessor

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP10-72094 1998-03-20
JP7209498 1998-03-20
JP25051998A JP3678330B2 (en) 1998-03-20 1998-09-04 Microprocessor

Publications (2)

Publication Number Publication Date
JPH11327904A JPH11327904A (en) 1999-11-30
JP3678330B2 true JP3678330B2 (en) 2005-08-03

Family

ID=26413232

Family Applications (1)

Application Number Title Priority Date Filing Date
JP25051998A Expired - Fee Related JP3678330B2 (en) 1998-03-20 1998-09-04 Microprocessor

Country Status (1)

Country Link
JP (1) JP3678330B2 (en)

Also Published As

Publication number Publication date
JPH11327904A (en) 1999-11-30

Similar Documents

Publication Publication Date Title
US6408385B1 (en) Data processor
KR100260353B1 (en) Processor for executing instruction codes of two different lengths and device for inputting the instruction codes
US4274138A (en) Stored program control system with switching between instruction word systems
US4937738A (en) Data processing system which selectively bypasses a cache memory in fetching information based upon bit information of an instruction
US5522053A (en) Branch target and next instruction address calculation in a pipeline processor
US6178492B1 (en) Data processor capable of executing two instructions having operand interference at high speed in parallel
EP0697651A2 (en) Microprocessor having register file
KR101913968B1 (en) Micro computer
US8789169B2 (en) Microcomputer having a protection function in a register
US6385714B1 (en) Data processing apparatus
JP3678330B2 (en) Microprocessor
US5404471A (en) Method and apparatus for switching address generation modes in CPU having plural address generation modes
JP2004206389A (en) Risc type cpu, compiler, microcomputer, and auxiliary arithmetic unit
US20040044848A1 (en) Instruction cache, and microprocessor and method of designing the same
JPH04104350A (en) Micro processor
US20050289297A1 (en) Processor and semiconductor device
JP3583918B2 (en) Microprocessor
JPS6051947A (en) Instruction prefetching system in virtual storage computer
US7206894B2 (en) Microcomputer application system, microcomputer, signal processing system and signal processing LSI
US6243798B1 (en) Computer system for allowing a two word jump instruction to be executed in the same number of cycles as a single word jump instruction
US6961844B1 (en) System and method for extracting instruction boundaries in a fetched cacheline, given an arbitrary offset within the cacheline
JP2004103012A (en) Cache structure for enhancing operating speed of processor and processor having cache management method
JPH09505428A (en) Microcontroller with page address mode
JPS62236034A (en) Microcomputer
JP3476314B2 (en) Microprocessor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20040123

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20050425

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20050506

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

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20090520

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20100520

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20110520

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20110520

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20120520

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20130520

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20140520

Year of fee payment: 9

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R360 Written notification for declining of transfer of rights

Free format text: JAPANESE INTERMEDIATE CODE: R360

R360 Written notification for declining of transfer of rights

Free format text: JAPANESE INTERMEDIATE CODE: R360

R371 Transfer withdrawn

Free format text: JAPANESE INTERMEDIATE CODE: R371

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees