JPH07334376A - Microprocessor and multitask management method - Google Patents
Microprocessor and multitask management methodInfo
- Publication number
- JPH07334376A JPH07334376A JP6131716A JP13171694A JPH07334376A JP H07334376 A JPH07334376 A JP H07334376A JP 6131716 A JP6131716 A JP 6131716A JP 13171694 A JP13171694 A JP 13171694A JP H07334376 A JPH07334376 A JP H07334376A
- Authority
- JP
- Japan
- Prior art keywords
- register
- stack
- stack pointer
- given
- 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.)
- Pending
Links
Landscapes
- Executing Machine-Instructions (AREA)
- Debugging And Monitoring (AREA)
Abstract
(57)【要約】
【目的】 プログラム開発時においてスタック操作によ
る問題点が発生するか否かを容易にチェックすることが
できる技術を提供する。
【構成】 SPレジスタ9に格納されている値、即ち現
状のスタックポインタの値は信号線19を介して、SP
Pレジスタ15に格納されている値は信号線20を介し
て、それぞれSP比較回路17に与えられる。SP比較
回路17はSPレジスタ9に格納されていた値がSPP
レジスタ15に格納されていた値よりも小さい場合には
信号線21を“H”にし、それ以外の場合には信号線2
1を“L”に設定する。信号線21が“L”から“H”
になったときに、SPPレジスタ15にはSPレジスタ
9に格納されていた値が与えられる。
【効果】 SPPレジスタ15には常にスタックポイン
タの最小値が格納されることになる。
(57) [Summary] [Purpose] To provide a technology that can easily check whether a problem due to stack operation occurs during program development. [Structure] The value stored in the SP register 9, that is, the current value of the stack pointer is sent to the SP via the signal line 19.
The value stored in the P register 15 is given to the SP comparison circuit 17 via the signal line 20. In the SP comparison circuit 17, the value stored in the SP register 9 is SPP.
If the value is smaller than the value stored in the register 15, the signal line 21 is set to "H", otherwise, the signal line 2 is set.
Set 1 to "L". Signal line 21 is "L" to "H"
Then, the value stored in the SP register 9 is given to the SPP register 15. [Effect] The minimum value of the stack pointer is always stored in the SPP register 15.
Description
【0001】[0001]
【産業上の利用分野】この発明はマイクロプロセッサに
関し、特にスタックサイズを考慮してプログラム開発を
行うことができるマイクロプロセッサ、及びこのマイク
ロプロセッサのマルチタスク管理方法に関するものであ
る。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a microprocessor, and more particularly to a microprocessor capable of developing a program in consideration of the stack size and a multitask management method for the microprocessor.
【0002】[0002]
【従来の技術】一般にマイクロプロセッサによって実行
されるプログラムでは、記憶領域においてデータを一時
的に積み上げておく「スタック」という概念が導入され
る。スタックは通常、主記憶装置の所定の領域に割り当
てられる。2. Description of the Related Art Generally, in a program executed by a microprocessor, a concept of "stack" for temporarily stacking data in a storage area is introduced. The stack is usually allocated in a predetermined area of the main storage device.
【0003】例えばサブルーチンが呼び出される場合に
は、そのサブルーチンの実行が終了した後に戻るべき場
所を示す戻り番地がスタックに保存される。あるいはま
た、割り込みが発生した場合にマイクロプロセッサの内
部レジスタの値を一時的に保存しておくのに用いられ
る。さらには一時変数の変数格納領域としても用いられ
る。For example, when a subroutine is called, a return address indicating a place to return to after the execution of the subroutine is completed is stored in the stack. Alternatively, it is used to temporarily store the value of the internal register of the microprocessor when an interrupt occurs. It is also used as a variable storage area for temporary variables.
【0004】図8はスタックが記憶領域500に割り当
てられる様子を示すアドレスの概念図である。図8にお
いて、上側は記憶領域500の高アドレス側に、下側は
低アドレス側に、それぞれ対応している。通常、記憶領
域500においては、プログラムの命令やデータを格納
するプログラム領域100と、スタックが割り当てられ
るスタック領域200とが設定されている。スタック領
域200はスタック最上位アドレス200uとスタック
最下位アドレス200dとに挟まれた領域となってお
り、またここではプログラム領域100の最上位のアド
レスはスタック最下位アドレス200dに一致してい
る。FIG. 8 is a conceptual diagram of addresses showing how the stack is allocated to the storage area 500. In FIG. 8, the upper side corresponds to the high address side of the storage area 500, and the lower side corresponds to the low address side. Normally, in the storage area 500, a program area 100 for storing instructions and data of programs and a stack area 200 to which a stack is allocated are set. The stack area 200 is an area sandwiched between the stack uppermost address 200u and the stack lowermost address 200d, and the uppermost address of the program area 100 here matches the stack lowermost address 200d.
【0005】スタック領域200においてデータが積み
上げられてゆく場合、高アドレス側から低アドレス側へ
と順に積み上げられて行く。図においては白抜きの矢印
でその積み上げられる方向が示されている。When the data is stacked in the stack area 200, the data is sequentially stacked from the high address side to the low address side. In the figure, the outline arrow indicates the stacking direction.
【0006】スタックの一番上(低アドレス)に新たに
データを積み上げることはスタックプッシュと呼ばれ、
一番新しくスタックプッシュされたデータがあるアドレ
スをスタックポインタと呼ぶ。図においてスタックポイ
ンタは参照符号SPで示されている。スタックプッシュ
される度にスタックポインタSPは小さな(低い)アド
レスを示すことになる。Stacking new data on the top (low address) of the stack is called stack push.
The address at which the most recently pushed data is on the stack is called the stack pointer. In the figure, the stack pointer is indicated by reference sign SP. Each time the stack is pushed, the stack pointer SP indicates a small (low) address.
【0007】一方、スタックにおいて積み上げられたデ
ータの一番上からデータを取り出すことはスタックポッ
プと呼ばれ、スタックポップされる度にスタックポイン
タSPは大きな(高い)アドレスを示すことになる。On the other hand, taking out the data from the top of the data stacked in the stack is called stack pop, and the stack pointer SP indicates a large (high) address each time the stack is popped.
【0008】スタック領域200は少なくとも、実行す
るプログラムが使用するスタックの大きさ(スタックサ
イズ)だけ確保しておく必要がある。It is necessary to secure at least the stack area 200 by the size of the stack used by the program to be executed (stack size).
【0009】スタックそのものはソフトウェア上の概念
であり、効率よくスタックを割り当てて機能させるた
め、マイクロプロセッサにはスタック操作のための様々
な命令が備えられている。そして更に、スタック操作の
ためのこれらの命令を実現するために、様々なハードウ
ェアも備えられている。The stack itself is a software concept, and in order to efficiently allocate and operate the stack, the microprocessor is provided with various instructions for stack operation. In addition, various hardware is also provided to implement these instructions for stack manipulation.
【0010】図9はかかるソフトウェア、ハードウェア
を備えたマイクロプロセッサの構成の概略を示すブロッ
ク図である。命令フェッチ部4はデータバス3を介し、
図示されない主記憶装置から命令を読み込む。読み込ま
れた命令は命令デコード部5において解析され、その結
果が命令実行部6に与えられる。命令実行部6はこの命
令に基づいた様々な処理を行う。上述の「スタック操作
のための様々な命令が備えられている」とは、命令に対
応するデータ自身は外部の主記憶装置に存在していて
も、これをデコードして解析する機能や、その命令を実
行する機能を有することを指している。FIG. 9 is a block diagram showing the outline of the configuration of a microprocessor provided with such software and hardware. The instruction fetch unit 4 receives data via the data bus 3.
An instruction is read from a main memory device (not shown). The read instruction is analyzed by the instruction decoding unit 5, and the result is given to the instruction executing unit 6. The instruction execution unit 6 performs various processes based on this instruction. The above-mentioned "provided with various instructions for stack operation" means that even if the data itself corresponding to the instruction exists in the external main storage device, the function to decode and analyze it, Refers to having the function of executing instructions.
【0011】命令実行部6により、プログラムカウンタ
7、汎用レジスタ8、スタックポインタレジスタ(SP
レジスタ)9が制御される。プログラムカウンタ7には
実行される命令のアドレスが格納される。SPレジスタ
9にはスタックポインタが格納される。The instruction execution unit 6 controls the program counter 7, general-purpose register 8, stack pointer register (SP
Register 9 is controlled. The program counter 7 stores the address of the instruction to be executed. A stack pointer is stored in the SP register 9.
【0012】図10はスタックプッシュ命令を行う場合
の処理を示すフローチャートである。スタックプッシュ
命令が実行される場合には、積み上げるべきデータの大
きさだけSPレジスタ9の値が減少される(ステップS
11)。そして主記憶装置において、SPレジスタ9の
更新された値で示されるアドレス(スタックポインタ)
に対し、積み上げるべきデータが格納される(ステップ
S12)。勿論マイクロプロセッサはスタックポップ命
令をも備えている。FIG. 10 is a flow chart showing the processing when a stack push instruction is executed. When the stack push instruction is executed, the value of the SP register 9 is decreased by the size of the data to be stacked (step S
11). Then, in the main storage device, the address (stack pointer) indicated by the updated value of the SP register 9
On the other hand, the data to be accumulated is stored (step S12). Of course, the microprocessor also has a stack pop instruction.
【0013】また、スタックを使用する他の命令の例と
して、サブルーチンコール命令と、リターンサブルーチ
ン命令とがある。サブルーチンコール命令は、「サブル
ーチンの実行が終わった後で次に実行する命令」のアド
レスをスタックプッシュしてからサブルーチンに実行を
移す命令である。また、リターンサブルーチン命令は、
スタックから戻り先のアドレスをスタックポップし、そ
の番地に実行を移すことによってサブルーチンを呼び出
した元のアドレスに戻る命令である。Further, examples of other instructions using the stack include a subroutine call instruction and a return subroutine instruction. The subroutine call instruction is an instruction to move the execution to the subroutine after stack-pushing the address of the "instruction to be executed next after the execution of the subroutine". The return subroutine instruction is
This is an instruction to return to the original address that called the subroutine by stack-popping the return address from the stack and moving execution to that address.
【0014】この他、マイクロプロセッサ内部に汎用レ
ジスタ8が複数設けられ、一つの命令でスタックにセー
ブ、リストアする命令などがある。こうしてマイクロプ
ロセッサにスタックを操作するハードウェアや命令を備
えることで、スタック操作は高速化され、また簡単化さ
れていく。In addition, a plurality of general-purpose registers 8 are provided inside the microprocessor, and there are instructions for saving and restoring on the stack with one instruction. By providing the microprocessor with hardware and instructions for manipulating the stack in this way, stack manipulation becomes faster and easier.
【0015】また、マイクロプロセッサは通常、更に割
り込みスタックポインタレジスタ(SPIレジスタ)1
0を備えている。そして、SPIレジスタ10には、割
り込みルーチン実行中のスタックポインタが格納され
る。このように最近のマイクロプロセッサでは、割り込
みルーチン実行中とそうでない時とで、使用するスタッ
ク領域を自動的に変更し、それぞれのスタックポインタ
を格納するレジスタを別々に有するのが通常である。Further, the microprocessor usually further includes an interrupt stack pointer register (SPI register) 1
It has 0. The SPI register 10 stores the stack pointer during execution of the interrupt routine. As described above, in recent microprocessors, the stack area to be used is automatically changed during the execution of the interrupt routine and when it is not, and the registers for storing the respective stack pointers are usually provided separately.
【0016】[0016]
【発明が解決しようとする課題】しかし、実行しようと
するプログラムが使用するスタック領域200のサイズ
の見積が誤っていると、スタックがスタック領域200
をオーバーフローし、プログラムが暴走する危険性があ
る。通常、スタック領域200を主記憶装置のどの領域
にどれだけのサイズで設定するかはプログラム開発者が
計算して決定するため、スタックがオーバーフローする
ことはしばしば生じる問題である。However, if the size of the stack area 200 used by the program to be executed is erroneously estimated, the stack becomes the stack area 200.
There is a risk that the program will run out of control. In general, a stack overflow is a problem that often occurs because a program developer determines by calculation which size and size of the stack area 200 is set in which area of the main storage device.
【0017】図11はスタックがオーバーフローする様
子を示すアドレスの概念図である。スタックがスタック
領域200を越えて積まれ、スタックポインタSPはス
タック最下位アドレス200dよりも低いアドレスにな
っている。このため、プログラム領域100の高アドレ
ス側の領域100aにおいてもスタックが積まれ、領域
100aにおいて予め記憶されていたデータが破壊され
てしまう。この様な事態に陥った場合、破壊された領域
100aを対象としてプログラムが実行されると、もは
や正常な動作は行われないという問題点があった。FIG. 11 is a conceptual diagram of addresses showing how the stack overflows. The stack is stacked over the stack area 200, and the stack pointer SP has an address lower than the stack lowest address 200d. Therefore, the stack is stacked even in the area 100a on the high address side of the program area 100, and the data stored in advance in the area 100a is destroyed. In such a case, there is a problem that when the program is executed for the destroyed area 100a, the normal operation is no longer performed.
【0018】スタック領域の設定ミスによるこのような
問題点は、その原因を特定するのが困難である。という
のも、スタックのオーバーフローが生じた時に直ちにプ
ログラムが暴走するわけではなく、スタックによって破
壊された領域100aにプログラムの実行が及んだ時点
で初めて動作不良が発生するためである。この時には既
にスタックポインタは最初に設定したスタック領域20
0内に戻ってしまっているため、スタックによって領域
100aのデータが破壊されたかどうかを直ちに特定す
ることができない。It is difficult to identify the cause of such a problem due to the setting error of the stack area. This is because the program does not run out of control immediately when the stack overflows, but a malfunction occurs only when the program is executed in the area 100a destroyed by the stack. At this time, the stack pointer has already been set to the stack area 20 that was initially set.
Since it has returned to 0, it is not possible to immediately determine whether the data in the area 100a has been destroyed by the stack.
【0019】また逆に、スタックの使用が間違っていた
りすると、スタック最上位アドレス200uよりも高ア
ドレス側に対してスタックポップを行ってしまう、スタ
ックアンダーフローを生じさせるという問題点もある。On the other hand, if the stack is used incorrectly, there is a problem that a stack underflow occurs which causes a stack pop to a higher address side than the stack uppermost address 200u.
【0020】これらのような、スタック操作に起因する
問題点を防ぐには、プログラムが使用するスタックのス
タックサイズを正確に把握する必要がある。そしてスタ
ックサイズを正確に把握できれば確保すべきスタック領
域200は最小限度に抑えることができるので、主記憶
装置の記憶領域を節約することができる。In order to prevent such problems caused by stack operations, it is necessary to accurately grasp the stack size of the stack used by the program. If the stack size can be accurately grasped, the stack area 200 to be secured can be minimized, so that the storage area of the main storage device can be saved.
【0021】しかし、プログラムが使用するスタックサ
イズを算定することは可能であるものの、高級言語でプ
ログラムを既述する場合にはその算定は面倒な場合があ
る。また、初級プログラマーがスタックという概念を知
らずにプログラミングすれば、その算定は不可能であ
る。However, although it is possible to calculate the stack size used by the program, the calculation may be troublesome when the program is already described in a high-level language. In addition, if the beginner programmers program without knowing the concept of stack, the calculation is impossible.
【0022】そこで、実際にプログラムを実行させてス
タックサイズを調べる方法が考えられている。従来で
は、適当なタイミングでスタックポインタの値をチェッ
クすることにより、スタックにおいて必要なサイズが求
められていた。しかしそのタイミングにおいてスタック
ポインタがピーク値をとるとは限らず、プログラム領域
100の破壊という問題点を完全に払拭することはでき
ない。Therefore, a method of actually executing a program to check the stack size has been considered. Conventionally, the size required in the stack has been obtained by checking the value of the stack pointer at an appropriate timing. However, the stack pointer does not always take the peak value at that timing, and the problem of destruction of the program area 100 cannot be completely eliminated.
【0023】この発明は以上のような問題点を解消する
ためになされたもので、プログラムが使用するスタック
サイズを正確に知ることができるマイクロプロセッサを
提供し、プログラム開発時においてスタック操作による
問題点が発生するか否かを容易にチェックすることがで
きる技術を提供することを目的としている。The present invention has been made to solve the above problems, and provides a microprocessor capable of accurately knowing the stack size used by a program, and problems caused by stack operation during program development. It is an object of the present invention to provide a technique capable of easily checking whether or not a problem occurs.
【0024】[0024]
【課題を解決するための手段】この発明のうち請求項1
にかかるものは、スタック操作を行うマイクロプロセッ
サであって、(a)スタックの現状のスタックポインタ
を格納するスタックポインタレジスタと、(b)スタッ
クポインタピークレジスタと、(c)(c−1)前記ス
タックポインタレジスタの格納するデータが与えられる
第1入力端と、(c−2)前記スタックポインタピーク
レジスタの格納するデータが与えられる第2入力端と、
(c−3)前記第1入力端に与えられたデータと、前記
第2入力端に与えられたデータとを比較し、所定の大小
関係に基づいて前記スタックポインタピークレジスタの
格納するデータを更新する出力端とを有する比較器と、
(d)前記スタックポインタピークレジスタに対して所
定の値を格納する命令を解析する、命令解析部とを備え
るマイクロプロセッサである。[Means for Solving the Problems] Claim 1 of the present invention
Is a microprocessor that performs stack operations, and includes (a) a stack pointer register that stores the current stack pointer of the stack, (b) a stack pointer peak register, and (c) (c-1). A first input end to which the data stored in the stack pointer register is given, and (c-2) a second input end to which the data stored in the stack pointer peak register is given,
(C-3) The data given to the first input end is compared with the data given to the second input end, and the data stored in the stack pointer peak register is updated based on a predetermined magnitude relation. A comparator having an output terminal for
(D) A microprocessor including an instruction analysis unit that analyzes an instruction that stores a predetermined value in the stack pointer peak register.
【0025】この発明のうち請求項2にかかるものは、
請求項1記載のマイクロプロセッサであって、前記所定
の大小関係とは、前記第1入力端に与えられたデータが
前記第2入力端に与えられたデータよりも小さい場合
に、前記スタックポインタピークレジスタの値を、前記
第1入力端に与えられたデータに更新することを示す。According to claim 2 of the present invention,
2. The microprocessor according to claim 1, wherein the predetermined magnitude relationship is the stack pointer peak when the data given to the first input end is smaller than the data given to the second input end. It indicates that the value of the register is updated to the data given to the first input terminal.
【0026】この発明のうち請求項3にかかるものは、
請求項1記載のマイクロプロセッサであって、前記所定
の大小関係とは、前記第1入力端に与えられたデータが
前記第2入力端に与えられたデータよりも大きい場合
に、前記スタックポインタピークレジスタの値を、前記
第1入力端に与えられたデータに更新することを示す。According to claim 3 of the present invention,
2. The microprocessor according to claim 1, wherein the predetermined magnitude relationship is the stack pointer peak when the data given to the first input end is larger than the data given to the second input end. It indicates that the value of the register is updated to the data given to the first input terminal.
【0027】この発明のうち請求項4にかかるものは、
複数のスタックモードの制御を行うマイクロプロセッサ
であって、(a)前記複数のスタックモードのそれぞれ
に対応して設けられ、各スタックモードの現状のスタッ
クポインタをそれぞれ格納する複数のスタックポインタ
レジスタと、(b)前記複数のスタックポインタレジス
タに対応して設けられたスタックポンタピークレジスタ
と、(c)前記複数のスタックポインタレジスタに対応
して設けられ、その各々が、(c−1)対応する前記ス
タックポインタレジスタの格納するデータが与えられる
第1入力端と、(c−2)対応する前記スタックポイン
タピークレジスタの格納するデータが与えられる第2入
力端と、(c−3)前記第1入力端に与えられたデータ
と、前記第2入力端に与えられたデータとを比較し、所
定の大小関係に基づいて前記スタックポインタピークレ
ジスタの格納するデータを更新する出力端とを有する複
数の比較器とを備える。According to claim 4 of the present invention,
A microprocessor for controlling a plurality of stack modes, comprising: (a) a plurality of stack pointer registers provided corresponding to each of the plurality of stack modes, each storing a current stack pointer of each stack mode; (B) a stack pointer peak register provided corresponding to the plurality of stack pointer registers; and (c) provided corresponding to the plurality of stack pointer registers, each of which corresponds to (c-1). A first input end to which the data stored in the stack pointer register is given, (c-2) a second input end to which the corresponding data stored in the stack pointer peak register is given, and (c-3) the first input The data given to the end and the data given to the second input end are compared, and based on a predetermined magnitude relationship. There comprises a plurality of comparators and an output end for updating the data stored in said stack pointer peak register.
【0028】この発明のうち請求項5にかかるものは、
請求項1記載のマイクロプロセッサにおいて複数のタス
クを時分割で実行させるマルチタスク管理方法であっ
て、(e)一の前記タスクを中断し、前記スタックポイ
ンタピークレジスタ及び前記スタックポインタレジスタ
の値を前記一のタスクのコンテキストとしてセーブする
工程と、(f)他の前記タスクを開始させ、中断させる
工程と、(g)前記一のタスクのコンテキストをリスト
アする工程と、(h)前記一のタスクを、前記一のタス
クのコンテキストに基づいて開始させる工程とを備え
る。According to claim 5 of the present invention,
2. A multi-task management method for executing a plurality of tasks in a time-division manner in a microprocessor according to claim 1, wherein (e) one of the tasks is suspended, and the values of the stack pointer peak register and the stack pointer register are Saving as a context of one task; (f) starting and suspending the other task; (g) restoring the context of the one task; and (h) the one task. , Starting based on the context of the one task.
【0029】[0029]
【作用】この発明のうち請求項1にかかるマイクロプロ
セッサにおいては、プログラムを実行した際に変動する
スタックポインタのピーク値がスタックポインタピーク
レジスタに格納される。In the microprocessor according to the first aspect of the present invention, the peak value of the stack pointer which changes when the program is executed is stored in the stack pointer peak register.
【0030】この発明のうち請求項2にかかるマイクロ
プロセッサにおいては、プログラム実行中にとりえたス
タックポインタの最小ピーク値がスタックポインタピー
クレジスタに格納される。In the microprocessor according to the second aspect of the present invention, the minimum peak value of the stack pointer acquired during program execution is stored in the stack pointer peak register.
【0031】この発明のうち請求項3にかかるマイクロ
プロセッサにおいては、プログラム実行中にとりえたス
タックポインタの最大ピーク値がスタックポインタピー
クレジスタに格納される。In the microprocessor according to claim 3 of the present invention, the maximum peak value of the stack pointer acquired during the execution of the program is stored in the stack pointer peak register.
【0032】この発明のうち請求項4にかかるマイクロ
プロセッサにおいては、複数のスタック毎にスタックポ
インタのピーク値がスタックポインタピークレジスタに
格納される。In the microprocessor according to the fourth aspect of the present invention, the peak value of the stack pointer is stored in the stack pointer peak register for each of a plurality of stacks.
【0033】この発明のうち請求項5にかかるマルチタ
スク管理方法においては、タスクの中断・再開に際し
て、タスクのコンテキストとしてスタックポインタレジ
スタの値、スタックポインタピークレジスタの値がセー
ブ、リストアされる。In the multitask management method according to claim 5 of the present invention, the value of the stack pointer register and the value of the stack pointer peak register are saved and restored as the context of the task when the task is suspended / resumed.
【0034】[0034]
第1実施例:図1はこの発明の第1実施例にかかるマイ
クロプロセッサ11の構造を示すブロック図である。マ
イクロプロセッサ11は、図9に示された従来のマイク
ロプロセッサ1と同様に、命令フェッチ部4、命令デコ
ード部5、命令実行部6、プログラムカウンタ7、汎用
レジスタ8、SPレジスタ9を備えている。しかし、更
に追加してスタックポインタ比較回路(SP比較回路)
17、スタックポインタピークレジスタ(SPPレジス
タ)15が設けられている。First Embodiment: FIG. 1 is a block diagram showing the structure of a microprocessor 11 according to a first embodiment of the present invention. The microprocessor 11 includes an instruction fetch unit 4, an instruction decode unit 5, an instruction execution unit 6, a program counter 7, a general-purpose register 8 and an SP register 9, like the conventional microprocessor 1 shown in FIG. . However, a stack pointer comparison circuit (SP comparison circuit) is additionally added.
17, a stack pointer peak register (SPP register) 15 is provided.
【0035】SPPレジスタ15はSPレジスタ9と同
様に、ソフトウェア命令に基づき、命令実行部6によっ
て、信号線14を介してその値を設定することができ
る。Like the SP register 9, the SPP register 15 can be set by the instruction executing section 6 via the signal line 14 based on a software instruction.
【0036】SPレジスタ9に格納されている値、即ち
現状のスタックポインタの値は信号線19を介して、S
PPレジスタ15に格納されている値は信号線20を介
して、それぞれSP比較回路17に与えられる。SP比
較回路17は通常用いられる大小比較器で構成され、S
Pレジスタ9に格納されていた値が、SPPレジスタ1
5に格納されていた値よりも小さい場合には信号線21
を“H”にし、それ以外の場合には信号線21を“L”
に設定する。The value stored in the SP register 9, that is, the current value of the stack pointer is S through the signal line 19.
The values stored in the PP register 15 are given to the SP comparison circuits 17 via the signal lines 20, respectively. The SP comparison circuit 17 is composed of a commonly used size comparator, and S
The value stored in the P register 9 is changed to the SPP register 1
If it is smaller than the value stored in 5, the signal line 21
Is set to "H", otherwise, the signal line 21 is set to "L".
Set to.
【0037】SPPレジスタ15は一種のラッチ回路で
構成されており、SPレジスタ9に格納されていた値が
信号線22を介して与えられている。そして信号線21
が“L”から“H”になったときに、SPPレジスタ1
5にはSPレジスタ9に格納されていた値が与えられ
る。即ちSPPレジスタ15は現状のスタックポインタ
の値を用いて更新される。この様な動作によって、SP
Pレジスタ15には常にスタックポインタの最小値が格
納されることになる。The SPP register 15 is composed of a kind of latch circuit, and the value stored in the SP register 9 is given through the signal line 22. And the signal line 21
Goes from "L" to "H", the SPP register 1
The value stored in the SP register 9 is given to 5. That is, the SPP register 15 is updated using the current stack pointer value. By such operation, SP
The minimum value of the stack pointer is always stored in the P register 15.
【0038】図2は、この実施例においてスタックプッ
シュ命令を実行する場合の手順を示すフローチャートで
ある。図10において示された従来のスタックプッシュ
命令を実行する場合と比較して、ステップS11,S1
2の間にステップS13,S14が介在した構成となっ
ている。ステップS13ではSPレジスタ9に格納され
ていた値が、SPPレジスタ15に格納されていた値よ
りも小さいか否かが判断され、“Y”の場合にはステッ
プS14において、SPレジスタ9に格納されていた値
がSPPレジスタ15に与えられる。FIG. 2 is a flow chart showing the procedure for executing the stack push instruction in this embodiment. Compared with the case of executing the conventional stack push instruction shown in FIG. 10, steps S11 and S1 are performed.
Steps S13 and S14 are interposed between the two. In step S13, it is determined whether or not the value stored in the SP register 9 is smaller than the value stored in the SPP register 15. If "Y", the value is stored in the SP register 9 in step S14. The existing value is given to the SPP register 15.
【0039】第1実施例にかかるマイクロプロセッサで
はこの様に動作するので、一時的にせよ、スタックポイ
ンタが到達したアドレスの最小値がSPPレジスタ15
に格納されている。従って、プログラムの開発時(特に
デバッグ時)に、スタック領域を何処まで使用したか、
スタックオーバーフローが生じなかったか否かを確実に
把握することができる。Since the microprocessor according to the first embodiment operates in this way, the minimum value of the address reached by the stack pointer is the SPP register 15 even if temporarily.
It is stored in. Therefore, when developing a program (especially when debugging), how much stack area was used,
It is possible to reliably know whether or not a stack overflow has occurred.
【0040】図3はこの把握の様子を示すフローチャー
トである。ステップS15において、デバッグすべきプ
ログラムの実行に先だって、SPレジスタ9、SPPレ
ジスタ15にそれぞれスタック最上位アドレス200u
を初期値として与える。かかる初期値を与えるのは、ス
タックプッシュが実行され、スタックの積み上げが為さ
れたときには、必ずスタックポインタが低アドレス側に
移動するためである。FIG. 3 is a flow chart showing how this is grasped. In step S15, the stack top address 200u is set in the SP register 9 and the SPP register 15, respectively, prior to execution of the program to be debugged.
Is given as an initial value. The reason why such an initial value is given is that the stack pointer always moves to the low address side when stack push is executed and stacks are stacked.
【0041】ステップS16においてデバッグすべきプ
ログラムが実行される。この実行によってスタックポイ
ンタは様々に移動するが、その最小のアドレスはSPP
レジスタ15において格納されている。従ってステップ
S17において、SPPレジスタ15に格納された値を
読み出すことにより、スタックポインタがプログラム実
行中にたとえ一時的にせよ何処まで移動したかをチェッ
クすることができる。In step S16, the program to be debugged is executed. This execution moves the stack pointer variously, but the smallest address is the SPP.
It is stored in the register 15. Therefore, in step S17, by reading the value stored in the SPP register 15, it is possible to check where the stack pointer has moved, even temporarily during the program execution.
【0042】勿論、SPPレジスタ15にはスタック最
上位アドレス200uを初期値としてセットするのみな
らず、スタック最上位アドレス200uよりも高アドレ
ス側であれば、他の任意の値をセットすることができ
る。この場合、SPPレジスタ15には自動的にその時
のスタックポインタの値がコピーされることになる。Of course, not only the stack top address 200u is set as the initial value in the SPP register 15, but any other value can be set as long as it is on the side of a higher address than the stack top address 200u. . In this case, the stack pointer value at that time is automatically copied to the SPP register 15.
【0043】一方、SP比較回路17が、SPレジスタ
9に格納されていた値が、SPPレジスタ15に格納さ
れていた値よりも大きい場合には信号線21を“H”に
し、それ以外の場合には信号線21を“L”に設定する
様に動作するものを用いれば、SPPレジスタ15には
常にスタックポインタの最大値が格納されることにな
る。よって、上記の動作と同様にしてスタックアンダー
フローを検出することができる。On the other hand, the SP comparison circuit 17 sets the signal line 21 to "H" when the value stored in the SP register 9 is larger than the value stored in the SPP register 15, and otherwise. If the one that operates so as to set the signal line 21 to "L" is used, the maximum value of the stack pointer is always stored in the SPP register 15. Therefore, the stack underflow can be detected in the same manner as the above operation.
【0044】勿論、SP比較回路17が、複数の動作モ
ードを有するようにしておき、必要に応じてスタックオ
ーバーフローとスタックアンダーフローの何れかを選択
して検出することもできる。Of course, the SP comparison circuit 17 can be made to have a plurality of operation modes, and either stack overflow or stack underflow can be selected and detected as required.
【0045】なお、デバッグすべきプログラムの実行に
先だって、モニタプログラムを実行させる場合がある。
しかし、この発明ではスタックポインタピークレジスタ
に予め所定の値を格納する命令を実行することができる
ので、プログラム開発時においてモニタプログラムが前
もって実行されスタックポインタピークレジスタに既に
何らかの値が格納されていても、新たにスタックポイン
タピークレジスタの値を初期化する事ができる。従っ
て、スタックが必要とする領域の検出は、モニタプログ
ラムの実行によって誤ることはない。The monitor program may be executed prior to the execution of the program to be debugged.
However, according to the present invention, the instruction for storing a predetermined value in the stack pointer peak register in advance can be executed. Therefore, even if the monitor program is executed in advance at the time of program development and some value is already stored in the stack pointer peak register. , The value of the stack pointer peak register can be newly initialized. Therefore, the detection of the area required by the stack will not be mistaken by the execution of the monitor program.
【0046】第2実施例:図4は第2実施例にかかるマ
イクロプロセッサ11aの構成を示すブロック図であ
る。Second Embodiment: FIG. 4 is a block diagram showing the arrangement of a microprocessor 11a according to the second embodiment.
【0047】第1実施例におけるSP比較回路17に対
応してSP比較回路17a,17bが、SPPレジスタ
15に対応してSPPレジスタ15a,15bが、それ
ぞれ設けられている。SPレジスタ9、SP比較回路1
7a、SPPレジスタ15aの接続関係と、SPレジス
タ9、SP比較回路17b、SPPレジスタ15bの接
続関係とは、共に第1実施例で示されたSPレジスタ
9、SP比較回路17、SPPレジスタ15の接続関係
と同様である。SP comparison circuits 17a and 17b are provided corresponding to the SP comparison circuit 17 in the first embodiment, and SPP registers 15a and 15b are provided corresponding to the SPP register 15. SP register 9, SP comparison circuit 1
7a and the SPP register 15a and the SP register 9, the SP comparison circuit 17b, and the SPP register 15b are connected by the SP register 9, the SP comparison circuit 17, and the SPP register 15 shown in the first embodiment. It is similar to the connection relationship.
【0048】SPレジスタ9に格納されていた値が、S
PPレジスタ15に格納されていた値よりも小さい場合
には、SP比較回路17aはSPPレジスタ15aをし
てSPレジスタ9に格納されていた値を格納せしめる。The value stored in the SP register 9 is S
If the value is smaller than the value stored in the PP register 15, the SP comparison circuit 17a causes the SPP register 15a to store the value stored in the SP register 9.
【0049】一方、SPレジスタ9に格納されていた値
が、SPPレジスタ15に格納されていた値よりも大き
い場合には、SP比較回路17bはSPPレジスタ15
bをしてSPレジスタ9に格納されていた値を格納せし
める。On the other hand, when the value stored in the SP register 9 is larger than the value stored in the SPP register 15, the SP comparison circuit 17b causes the SPP register 15 to operate.
The value stored in the SP register 9 is stored by executing b.
【0050】第2実施例は以上の様に構成され、機能す
るので、スタックポインタの最大値及び最小値をチェッ
クすることができ、スタックオーバーフロー、スタック
アンダーフローの何れをも検出することができる。Since the second embodiment is constructed and functions as described above, it is possible to check the maximum value and the minimum value of the stack pointer, and it is possible to detect both stack overflow and stack underflow.
【0051】第3実施例:図5は第2実施例にかかるマ
イクロプロセッサ11bの構成を示すブロック図であ
る。Third Embodiment: FIG. 5 is a block diagram showing the configuration of the microprocessor 11b according to the second embodiment.
【0052】マイクロプロセッサ11bは、第1実施例
に示されたマイクロプロセッサ11に追加して、SPI
レジスタ10、割り込みスタックポインタ比較回路(S
PI比較回路)18、割り込みスタックポインタピーク
レジスタ(SPIPレジスタ)16を設けた構成を有し
ている。The microprocessor 11b is added to the microprocessor 11 shown in the first embodiment to add SPI.
Register 10, interrupt stack pointer comparison circuit (S
A PI comparator circuit 18 and an interrupt stack pointer peak register (SPIP register) 16 are provided.
【0053】割り込みルーチン実行時においてもスタッ
クを使用し、複数のスタックモードを持つマイクロプロ
セッサでは、それぞれのスタックモード毎にスタックポ
インタレジスタを有している。そこで、この様な場合に
本発明を適用したのが、第3実施例である。The stack is used even when the interrupt routine is executed, and a microprocessor having a plurality of stack modes has a stack pointer register for each stack mode. Therefore, the third embodiment applies the present invention in such a case.
【0054】SPIレジスタ10、SPI比較回路1
8、SPIPレジスタ16の接続関係は、第1実施例で
示されたSPレジスタ9、SP比較回路17、SPPレ
ジスタ15の接続関係と同様である。従って、割り込み
ルーチンにおいてもスタックポインタの最大値若しくは
最小値であるピーク値をチェックすることができる。SPI register 10, SPI comparison circuit 1
8. The connection relationship of the SPIP register 16 is the same as the connection relationship of the SP register 9, the SP comparison circuit 17, and the SPP register 15 shown in the first embodiment. Therefore, the peak value which is the maximum value or the minimum value of the stack pointer can be checked also in the interrupt routine.
【0055】第4実施例:マイクロプロセッサにおい
て、複数のタスクを実行させるマルチタスクオペレーシ
ョンシステム(マルチタスクOS)が稼働される場合が
ある。マルチタスクOSは、その上で複数のプログラム
(タスク)を同時に動作させるソフトウェアである。
「同時に」とはいえ、通常のマイクロプロセッサは一度
に一つの処理しかできないために、複数のタスクは時分
割で実行される。Fourth Embodiment: In a microprocessor, a multitask operation system (multitask OS) for executing a plurality of tasks may be operated. The multi-task OS is software that causes a plurality of programs (tasks) to operate at the same time.
Although "simultaneously", multiple tasks are performed in a time-sharing manner, as a typical microprocessor can only do one operation at a time.
【0056】図6はこのようなタスクの切り替えの手順
を示すフローチャートである。簡単の為に2つのタスク
を切り替える場合について説明するが、更に多くのタス
クを切り替える場合についても同様に行われる。便宜
上、図9に示された従来のマイクロプロセッサ1を参照
して説明する。FIG. 6 is a flow chart showing the procedure of such task switching. For simplicity, the case of switching two tasks will be described, but the same applies to the case of switching more tasks. For convenience, description will be given with reference to the conventional microprocessor 1 shown in FIG.
【0057】第1のタスクが実行されており、これが中
断される(ステップS20)。タスクを時分割で切り替
える際に、直前まで実行していた第1のタスクのコンテ
キスト(タスクの状態を示す情報)として、マイクロプ
ロセッサの内部レジスタの値を主記憶装置にセーブする
(ステップS21,S22,S23)。そして第2のタ
スクの実行が開始される(ステップS25)。この際、
後述する内部レジスタの値のリストアが、第2のタスク
に関しても行われる(ステップS24)。The first task is being executed and is interrupted (step S20). When switching tasks in a time-sharing manner, the value of the internal register of the microprocessor is saved in the main storage device as the context of the first task (information indicating the state of the task) that was executed immediately before (steps S21 and S22). , S23). Then, the execution of the second task is started (step S25). On this occasion,
The value of the internal register, which will be described later, is also restored for the second task (step S24).
【0058】この後、第2のタスクの実行が終了した
後、ステップS21,S22,S23と同様のセーブ
が、第2のタスクに関して行われる(ステップS2
6)。次に第1のタスクに関して主記憶装置にセーブさ
れていた内部レジスタの値をリストアし(ステップS2
7,S28,S29)、再度第1のタスクが続行される
(ステップS30)。なお、ステップS24におけるリ
ストアは、ステップS27,S28,S29に対応して
いる。After this, after the execution of the second task is completed, the same saving as in steps S21, S22, and S23 is performed for the second task (step S2).
6). Next, the value of the internal register saved in the main memory for the first task is restored (step S2
7, S28, S29), and the first task is continued again (step S30). The restoration in step S24 corresponds to steps S27, S28, and S29.
【0059】このようにセーブ、リストアされる内部レ
ジスタのデータは、それぞれのタスクにおけるコンテキ
ストに対応しており、タスクが切り替わって、中断、再
開しても同一タスクに関しては連続した処理が可能とな
る。The data of the internal register that is saved and restored in this way corresponds to the context in each task, and even if the task is switched and interrupted or restarted, continuous processing can be performed for the same task. .
【0060】本発明をマルチタスクOSにおいて適用す
る場合には、コンテキストとしてスタックポインタをも
セーブ、リストアする。When the present invention is applied to a multitask OS, the stack pointer is also saved and restored as the context.
【0061】図7は、本発明をマルチタスクOSに適用
した場合の手順を示すフローチャートである。図6に示
されたフローチャートに対し、ステップS22とステッ
プS23との間にステップS31を、ステップS27と
ステップS28の間にステップS34を、それぞれ追加
し、ステップS24をステップS32に、ステップS2
6をステップS33に、それぞれ置換した構成を有して
いる。FIG. 7 is a flow chart showing the procedure when the present invention is applied to a multitasking OS. In the flowchart shown in FIG. 6, step S31 is added between step S22 and step S23, step S34 is added between step S27 and step S28, step S24 is added to step S32, and step S2 is added.
6 has been replaced by step S33.
【0062】ステップS31において、第1のタスクに
関してSPPレジスタ15の値が、プログラムカウンタ
7の値及び汎用レジスタ8の値並びにSPレジスタ9の
値と同様、コンテキストの一つとしてセーブされる。ま
た、ステップS34においては第1のタスクに関してS
PPレジスタ15の値がコンテキストの一つとしてリス
トアされる。In step S31, the value of the SPP register 15 for the first task is saved as one of the contexts, like the value of the program counter 7, the value of the general register 8 and the value of the SP register 9. Further, in step S34, the first task S
The value of the PP register 15 is restored as one of the contexts.
【0063】ステップS32においては第2のタスクに
関するリストアが行われるが、これはステップS27,
S34,S28,S29に対応している。また、ステッ
プS33においては第2のタスクに関するセーブが行わ
れるが、これはステップS21,S22,S31,S2
3に対応している。In step S32, the restoration related to the second task is performed.
It corresponds to S34, S28, and S29. In addition, in step S33, a save related to the second task is performed, which is performed in steps S21, S22, S31, S2.
It corresponds to 3.
【0064】以上のように、第4実施例においては、タ
スクが時分割で実行されていても、各タスク毎にスタッ
ク領域の最大値・最小値を得ることができる。勿論、中
断・再開されることにより、時間的には不連続であって
も、同一タスクに関する限り、スタックが一時的にせよ
最大値・最小値を採った場合にはその値が最後までSP
Pレジスタ15に格納される。従って、各タスク毎にス
タックオーバーフロー、スタックアンダーフローを容易
に検出することができる。As described above, in the fourth embodiment, the maximum value and the minimum value of the stack area can be obtained for each task even if the tasks are executed in a time division manner. Of course, even if they are discontinuous in time due to being interrupted / resumed, as long as the stack takes a maximum / minimum value even if it is the same task, that value will be SP until the end.
It is stored in the P register 15. Therefore, stack overflow and stack underflow can be easily detected for each task.
【0065】[0065]
【発明の効果】この発明のうち請求項1にかかるマイク
ロプロセッサにおいては、スタックポインタピークレジ
スタにおいてスタックポインタのピーク値が格納される
ので、プログラムの途中でたとえ一時的にせよ、スタッ
クとして使用する領域の最大サイズが検出できる。この
ため、プログラムを開発する際にスタック領域の設定に
おいてスタックサイズを考慮することが容易となる。In the microprocessor according to claim 1 of the present invention, since the peak value of the stack pointer is stored in the stack pointer peak register, the area used as a stack, even temporarily during the program, is used. The maximum size of can be detected. Therefore, it becomes easy to consider the stack size in setting the stack area when developing the program.
【0066】しかも、スタックポインタピークレジスタ
に予め所定の値を格納する命令を実行することができる
ので、プログラム開発時においてモニタプログラムが前
もって実行され、スタックポインタピークレジスタに既
に何らかの値が格納されていても、新たにスタックポイ
ンタピークレジスタの値を初期化する事ができる。従っ
て、スタックが必要とする領域の検出は、モニタプログ
ラムの実行によって誤ることはない。Moreover, since the instruction for storing a predetermined value in the stack pointer peak register in advance can be executed, the monitor program is executed in advance at the time of program development, and some value is already stored in the stack pointer peak register. Also, the value of the stack pointer peak register can be newly initialized. Therefore, the detection of the area required by the stack will not be mistaken by the execution of the monitor program.
【0067】この発明のうち請求項2にかかるマイクロ
プロセッサにおいては、スタックオーバーフローが生じ
ないようにプログラムを開発することが容易となる。In the microprocessor according to the second aspect of the present invention, it becomes easy to develop a program so that stack overflow does not occur.
【0068】この発明のうち請求項3にかかるマイクロ
プロセッサにおいては、スタックアンダーフローが生じ
ないようにプログラムを開発することが容易となる。In the microprocessor according to the third aspect of the present invention, it becomes easy to develop the program so that the stack underflow does not occur.
【0069】この発明のうち請求項4にかかるマイクロ
プロセッサにおいては、複数のスタック毎にスタックが
必要とする領域が検出できる。In the microprocessor according to the fourth aspect of the present invention, the area required by the stack can be detected for each of the plurality of stacks.
【0070】この発明のうち請求項5にかかるマルチタ
スク管理方法においては、マルチタスクを実行しつつ、
スタックポインタのピーク値が検出できる。In the multitask management method according to claim 5 of the present invention, while executing multitask,
The peak value of the stack pointer can be detected.
【図1】 この発明の第1実施例を示すブロック図であ
る。FIG. 1 is a block diagram showing a first embodiment of the present invention.
【図2】 この発明の第1実施例の動作を示すフローチ
ャートである。FIG. 2 is a flowchart showing the operation of the first embodiment of the present invention.
【図3】 この発明の第1実施例の動作を示すフローチ
ャートである。FIG. 3 is a flowchart showing the operation of the first embodiment of the present invention.
【図4】 この発明の第2実施例を示すブロック図であ
る。FIG. 4 is a block diagram showing a second embodiment of the present invention.
【図5】 この発明の第3実施例を示すブロック図であ
る。FIG. 5 is a block diagram showing a third embodiment of the present invention.
【図6】 この発明の第4実施例の前提を示すフローチ
ャートである。FIG. 6 is a flowchart showing the premise of the fourth embodiment of the present invention.
【図7】 この発明の第4実施例の動作を示すフローチ
ャートである。FIG. 7 is a flowchart showing the operation of the fourth embodiment of the present invention.
【図8】 従来の技術を示すアドレスの概念図である。FIG. 8 is a conceptual diagram of an address showing a conventional technique.
【図9】 従来の技術を示すブロック図である。FIG. 9 is a block diagram showing a conventional technique.
【図10】 従来の技術を示すフローチャートである。FIG. 10 is a flowchart showing a conventional technique.
【図11】 樹来の技術の問題点を示す、アドレスの概
念図である。FIG. 11 is a conceptual diagram of an address showing a problem of Jira technology.
5 命令デコード部、6 命令実行部、9 SPレジス
タ、10 SPIレジスタ、15,15a,15b S
PPレジスタ、16 SPIPレジスタ、17,17
a,17b SP比較回路、18 SPI比較回路。5 instruction decode section, 6 instruction execution section, 9 SP register, 10 SPI register, 15, 15a, 15b S
PP register, 16 SPIP register, 17, 17
a, 17b SP comparison circuit, 18 SPI comparison circuit.
Claims (5)
であって、 (a)スタックの現状のスタックポインタを格納するス
タックポインタレジスタと、 (b)スタックポインタピークレジスタと、 (c)(c−1)前記スタックポインタレジスタの格納
するデータが与えられる第1入力端と、(c−2)前記
スタックポインタピークレジスタの格納するデータが与
えられる第2入力端と、(c−3)前記第1入力端に与
えられたデータと、前記第2入力端に与えられたデータ
とを比較し、所定の大小関係に基づいて前記スタックポ
インタピークレジスタの格納するデータを更新する出力
端とを有する比較器と、 (d)前記スタックポインタピークレジスタに対して所
定の値を格納する命令を解析する、命令解析部とを備え
るマイクロプロセッサ。1. A microprocessor for performing stack operations, comprising: (a) a stack pointer register for storing a current stack pointer of a stack; (b) a stack pointer peak register; and (c) (c-1), A first input end to which the data stored in the stack pointer register is given; (c-2) a second input end to which the data stored in the stack pointer peak register is given; and (c-3) to the first input end. A comparator having an output end for comparing the given data with the data given to the second input end and updating the data stored in the stack pointer peak register based on a predetermined magnitude relationship; d) A microprocessor including an instruction analysis unit that analyzes an instruction for storing a predetermined value in the stack pointer peak register. Support.
端に与えられたデータが前記第2入力端に与えられたデ
ータよりも小さい場合に、前記スタックポインタピーク
レジスタの値を、前記第1入力端に与えられたデータに
更新することを示す、請求項1記載のマイクロプロセッ
サ。2. The predetermined magnitude relation means that when the data given to the first input end is smaller than the data given to the second input end, the value of the stack pointer peak register is 2. The microprocessor according to claim 1, which indicates to update to the data given to the first input terminal.
端に与えられたデータが前記第2入力端に与えられたデ
ータよりも大きい場合に、前記スタックポインタピーク
レジスタの値を、前記第1入力端に与えられたデータに
更新することを示す、請求項1記載のマイクロプロセッ
サ。3. The predetermined magnitude relationship means that when the data given to the first input end is larger than the data given to the second input end, the value of the stack pointer peak register is 2. The microprocessor according to claim 1, which indicates to update to the data given to the first input terminal.
クロプロセッサであって、 (a)前記複数のスタックモードのそれぞれに対応して
設けられ、各スタックモードの現状のスタックポインタ
をそれぞれ格納する複数のスタックポインタレジスタ
と、 (b)前記複数のスタックポインタレジスタに対応して
設けられたスタックポンタピークレジスタと、 (c)前記複数のスタックポインタレジスタに対応して
設けられ、その各々が、(c−1)対応する前記スタッ
クポインタレジスタの格納するデータが与えられる第1
入力端と、(c−2)対応する前記スタックポインタピ
ークレジスタの格納するデータが与えられる第2入力端
と、(c−3)前記第1入力端に与えられたデータと、
前記第2入力端に与えられたデータとを比較し、所定の
大小関係に基づいて前記スタックポインタピークレジス
タの格納するデータを更新する出力端とを有する複数の
比較器とを備えるマイクロプロセッサ。4. A microprocessor for controlling a plurality of stack modes, comprising: (a) a plurality of microprocessors provided corresponding to each of the plurality of stack modes, each storing a current stack pointer of each stack mode. A stack pointer register, (b) a stack pointer peak register provided corresponding to the plurality of stack pointer registers, and (c) provided corresponding to the plurality of stack pointer registers, each of which is (c- 1) The first to which the data stored in the corresponding stack pointer register is given
An input end, (c-2) a second input end to which the data stored in the corresponding stack pointer peak register is given, and (c-3) data given to the first input end,
A plurality of comparators each having an output end for comparing the data supplied to the second input end and updating the data stored in the stack pointer peak register based on a predetermined magnitude relation.
いて複数のタスクを時分割で実行させるマルチタスク管
理方法であって、 (e)一の前記タスクを中断し、前記スタックポインタ
ピークレジスタ及び前記スタックポインタレジスタの値
を前記一のタスクのコンテキストとしてセーブする工程
と、 (f)他の前記タスクを開始させ、中断させる工程と、 (g)前記一のタスクのコンテキストをリストアする工
程と、 (h)前記一のタスクを、前記一のタスクのコンテキス
トに基づいて開始させる工程とを備えるマルチタスク管
理方法。5. A multi-task management method for causing a plurality of tasks to be executed in a time-division manner in a microprocessor according to claim 1, wherein (e) one of the tasks is suspended, the stack pointer peak register and the stack pointer. Saving the value of the register as the context of the one task; (f) starting and suspending the other task; (g) restoring the context of the one task; (h) Starting the one task based on the context of the one task.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP6131716A JPH07334376A (en) | 1994-06-14 | 1994-06-14 | Microprocessor and multitask management method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP6131716A JPH07334376A (en) | 1994-06-14 | 1994-06-14 | Microprocessor and multitask management method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH07334376A true JPH07334376A (en) | 1995-12-22 |
Family
ID=15064535
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP6131716A Pending JPH07334376A (en) | 1994-06-14 | 1994-06-14 | Microprocessor and multitask management method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH07334376A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112948000A (en) * | 2021-03-17 | 2021-06-11 | 星汉智能科技股份有限公司 | Stack space statistical method, device and medium |
-
1994
- 1994-06-14 JP JP6131716A patent/JPH07334376A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112948000A (en) * | 2021-03-17 | 2021-06-11 | 星汉智能科技股份有限公司 | Stack space statistical method, device and medium |
| CN112948000B (en) * | 2021-03-17 | 2023-03-03 | 星汉智能科技股份有限公司 | Stack space statistical method, device and medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US6799236B1 (en) | Methods and apparatus for executing code while avoiding interference | |
| US20100017581A1 (en) | Low overhead atomic memory operations | |
| JP2010522932A (en) | Bookmarks and configuration files for the installation sequence | |
| JPH07191865A (en) | Interblock analysis method in operating system | |
| JP2005050208A (en) | Memory management method and task control device in multitask system | |
| US6957367B2 (en) | System and method for controlling activity of temporary files in a computer system | |
| JPH10214203A (en) | Information processor | |
| JPH07334376A (en) | Microprocessor and multitask management method | |
| US20060026388A1 (en) | Computer executing instructions having embedded synchronization points | |
| JP2000020352A (en) | Stack overflow detection method and stack underflow detection method | |
| JPH0895798A (en) | Data processing device | |
| JPH04266141A (en) | Stack overflow detection system | |
| JP2552738B2 (en) | Data processing device | |
| JPS6376028A (en) | Method for controlling execution of instruction step in virtual computer system | |
| KR960014825B1 (en) | Information processing system | |
| JPH08249206A (en) | Calculator with stack area destruction detection function | |
| JPH05165652A (en) | Task switching control method | |
| JP3120841B2 (en) | In-circuit emulator | |
| CN119025070A (en) | Floating point operation support method, device, program file formation method and related equipment | |
| JP2002116926A (en) | Program processor and program processing method | |
| JPH11110250A (en) | Software execution mode switching method | |
| JPH0816431A (en) | Debugging process system for user program | |
| JPH0784786A (en) | Program execution control method | |
| JP3039450B2 (en) | Stack area switching method and method, and storage medium storing stack area switching program | |
| JPH07134656A (en) | Interrupt control method and multitasking system for realizing the same |