JP2006202268A - Cpu - Google Patents
Cpu Download PDFInfo
- Publication number
- JP2006202268A JP2006202268A JP2005351013A JP2005351013A JP2006202268A JP 2006202268 A JP2006202268 A JP 2006202268A JP 2005351013 A JP2005351013 A JP 2005351013A JP 2005351013 A JP2005351013 A JP 2005351013A JP 2006202268 A JP2006202268 A JP 2006202268A
- Authority
- JP
- Japan
- Prior art keywords
- stack area
- stack
- address
- register
- area
- 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.)
- Granted
Links
Images
Landscapes
- Executing Machine-Instructions (AREA)
Abstract
Description
本発明は、スタックポインタ制御回路を備えたCPU、およびCPUにおけるスタック領域制御方法に関する。特に、スタックポインタレジスタを有するCPUにおいて、プログラムの実行時にスタック領域が当初想定したメモリ領域を越えてデータやプログラムコードを破壊し、プログラムが予期せぬ動作をしてしまうという不具合を防止する技術に関する。 The present invention relates to a CPU including a stack pointer control circuit and a stack area control method in the CPU. In particular, in a CPU having a stack pointer register, the present invention relates to a technique for preventing a problem that a program or a program operates unexpectedly by destroying data or program code beyond the memory area initially assumed when the program is executed. .
CPU(Central Processing Unit)には、外部からの割込要求信号の入力や内部での例外事象等の割込要因の発生に応じて、現在実行中の処理を中断して割込処理に移行し、割込処理の終了後に再び元の処理に復帰する割込機能が備えられている。 In response to the input of an external interrupt request signal or the occurrence of an interrupt factor such as an internal exception event, the CPU (Central Processing Unit) interrupts the currently executing process and proceeds to interrupt processing. An interrupt function for returning to the original process again after completion of the interrupt process is provided.
一般的に割込みは、その機能を実現するための処理である割込ルーチン処理と、その割込ルーチン処理に先だって元の処理の実行時の各種レジスタの値をスタック領域(後入れ先出し方式のメモリ領域)に退避する処理を行う割込入力処理と、割込ルーチン処理の終了後に割込入力処理で退避した各種レジスタの値をスタック領域から元のレジスタに復元して前の処理に復帰する割込終了処理から構成される。このように割込入力処理で各種レジスタの値をスタック領域に退避し,割込終了処理でスタック領域に退避されている値を元のレジスタに復元することで,割込ルーチンでレジスタの値を書き換えたとしても、割込前の処理に復帰する時点で、レジスタの値は割込前のレジスタの値に復元される。すなわち、割込の前後でレジスタの値が変わらないようにすることができ、元の処理を正常に継続することができる。ここで、スタック領域にデータを格納することをプッシュ動作といい、データを取り出すことをポップ動作という。 Generally, an interrupt is an interrupt routine that is a process for realizing the function, and various register values at the time of execution of the original process prior to the interrupt routine process are stored in the stack area (last-in-first-out memory Interrupt input processing that performs processing to save to (area), and interrupt processing that restores the values of various registers saved in the interrupt input processing from the stack area to the original register after the completion of interrupt routine processing and returns to the previous processing. Consists of a process to finish loading. In this way, the values of various registers are saved in the stack area by interrupt input processing, and the values saved in the stack area by the interrupt end processing are restored to the original registers. Even if the value is rewritten, the value of the register is restored to the value of the register before the interrupt when returning to the process before the interrupt. That is, the register value can be kept unchanged before and after the interrupt, and the original process can be continued normally. Here, storing data in the stack area is called a push operation, and taking out data is called a pop operation.
一般的にCPUには、現在のスタック領域の先頭アドレスを格納するスタックポインタレジスタ(以下、スタックポインタと記す)が備えられており、CPUの起動後にソフトウエアによりスタックポインタに初期値となるメモリアドレスを設定してスタック領域を使用する。 In general, a CPU is provided with a stack pointer register (hereinafter referred to as a stack pointer) that stores the start address of the current stack area, and a memory address that becomes an initial value in the stack pointer by software after the CPU is started. To use the stack area.
CPUの一例として、現在でも組込み用途に用いられることの多いZ80CPUのレジスタ構造を図8に示す(例えば、非特許文献1参照)。Z80CPUにはレジスタ群として、アキュムレータとして用いられるA,A’ やフラグレジスタF,F’ 、汎用レジスタとして用いられるBからLと、補助レジスタとして用いられるB’からL’と、専用レジスタとして用いられるスタックポインタ(SP)やプログラムカウンタ(PC)等が備わっている。 As an example of the CPU, FIG. 8 shows a register structure of the Z80 CPU that is often used for embedded applications even now (see, for example, Non-Patent Document 1). In Z80CPU, A, A ′ and flag registers F and F ′ used as accumulators, B to L used as general purpose registers, B ′ to L ′ used as auxiliary registers, and dedicated registers are used as a register group. A stack pointer (SP), a program counter (PC), and the like are provided.
通常、スタック領域を実現するためのメモリ領域は1つであり、物理的に複数には分離されない。そのため、時として、図9に示すように、実際のプログラム実行時に、割込みやサブルーチンが重なること等によって当初想定したメモリ領域を越えてスタック領域がメモリを消費してしまうことがある。このような場合、もともと所定のメモリ領域に保持されているプログラムコード、変数などのデータが書き換わってしまうこととなり、プログラムが予期せぬ動作をしてしまうという不具合が発生することがあった。 Usually, there is one memory area for realizing the stack area, and it is not physically separated into a plurality. Therefore, as shown in FIG. 9, sometimes the stack area consumes memory beyond the originally assumed memory area due to overlap of interrupts and subroutines during actual program execution. In such a case, data such as program codes and variables that are originally held in a predetermined memory area are rewritten, which may cause a problem that the program operates unexpectedly.
このような不具合に対処するために、例えば、特許文献1には、スタックエリアの上限アドレスを格納するレジスタと、該レジスタに格納されたアドレスと記憶回路をアクセスするときのアドレスとを比較し、記憶回路をアクセスするアドレスの値が該レジスタの値より小さいときにCPUに割込信号を出力するコンパレータとを備え、当該割込みによって実行されるサブルーチンによって実行中のプログラムにスタックの異常使用を認識させて、プログラムの実行を停止してプログラムの破壊を未然に防ぐという技術が開示されている。 In order to deal with such problems, for example, Patent Document 1 compares a register that stores the upper limit address of the stack area with an address stored in the register and an address when accessing the storage circuit. A comparator that outputs an interrupt signal to the CPU when the value of the address for accessing the memory circuit is smaller than the value of the register, and allows the program being executed to recognize the abnormal use of the stack by a subroutine executed by the interrupt Thus, a technique is disclosed in which execution of a program is stopped to prevent destruction of the program.
また、特許文献2には、CPUにより、割込処理を起動し、スタックポインタの値を汎用レジスタに設定する処理を実行し、主メモリ上の空きエリアのアドレスをスタックポインタに設定する処理を実行するという技術が開示されている。
しかしながら、上記特許文献1に記載の技術では、プログラムの実行を停止することによりプログラムの破壊を防止するだけであって、スタック領域が当初想定した領域を越えても正常に動作させるという技術内容ではない。 However, the technique described in Patent Document 1 only prevents the program from being destroyed by stopping the execution of the program, and the technical content is that the stack area can be operated normally even if it exceeds the initially assumed area. Absent.
一方、特許文献2に記載の技術では、プロセル空間の破壊を防ぎ、システムを継続して実行することを可能としている。しかし、これを実現するためにCPUによるソフトウエア処理が必要であり、処理速度が低下するという問題があった。
On the other hand, in the technique described in
本発明は,上記事情に鑑み、スタック領域が当初想定したメモリ領域を越えてメモリ領域を消費してしまう恐れのある場合であってもプログラムの実行を停止することなく、正常な動作を継続することのできるCPUおよび当該CPUを用いたスタック領域制御方法を提供することを目的とする。特に、ソフトウエアの負担増大による処理速度低下を抑制しながら、正常な動作を継続することのできるCPUおよびスタック領域制御方法を提供することを目的とする In view of the above circumstances, the present invention continues normal operation without stopping execution of a program even if the stack area may consume the memory area beyond the initially assumed memory area. It is an object of the present invention to provide a CPU capable of performing the above and a stack area control method using the CPU. In particular, it is an object of the present invention to provide a CPU and a stack area control method capable of continuing normal operation while suppressing a reduction in processing speed due to an increase in software load.
上記目的を達成する本発明のCPUは、現在のスタック領域の先頭アドレスを格納するスタックポインタレジスタと、第1スタック領域の終端アドレスを設定するスタック終端レジスタと、第2スタック領域の開始アドレスを設定する第2スタック領域開始レジスタと、前記スタックポインタレジスタのアドレスが前記スタック終端レジスタに設定されているアドレスに到達した次のプッシュ動作において、該スタックポインタレジスタのアドレスを前記第2スタック領域開始レジスタに設定されているアドレスに置換え、また前記スタックポインタレジスタのアドレスが前記第2スタック領域開始レジスタに設定されているアドレスに到達した次のポップ動作において、該スタックポインタレジスタのアドレスを前記スタック終端レジスタに設定されているアドレスに置換えるスタックポインタ制御回路とを備えたことを特徴とする。 The CPU of the present invention that achieves the above object sets the stack pointer register for storing the start address of the current stack area, the stack end register for setting the end address of the first stack area, and the start address of the second stack area In the next push operation when the address of the second stack area start register and the address of the stack pointer register reach the address set in the stack end register, the address of the stack pointer register is stored in the second stack area start register. In the next pop operation when the stack pointer register address reaches the address set in the second stack area start register, the stack pointer register address is replaced with the stack end register. Characterized in that a stack pointer control circuit to replace has been set to address.
スタックポインタ制御回路を備えることにより、スタック領域が当初想定した領域を越えてメモリ領域を消費し、データを破壊する恐れのある場合にも、ソフトウエアの負担増大を抑えながら、正常な動作を継続することができる。 By providing a stack pointer control circuit, normal operation continues while restraining an increase in software load even if the stack area consumes memory area beyond the originally assumed area and data may be destroyed. can do.
ここで、前記スタックポインタレジスタのアドレスが前記第1スタック領域の終端アドレス又は当該終端アドレスよりも所定値だけ第1スタック領域内のアドレスに到達した時に、内部割込要求信号を発生するスタック終端判定回路をさらに備え、前記内部割込要求信号により移行する割込ルーチンにおいて、前記第2スタック領域を動的に確保し、該確保された第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに設定することが好ましい。スタック終端判定回路を備え、第2スタック領域を動的に確保するため、メモリ領域の有効活用が可能である。 Here, when the address of the stack pointer register reaches the end address of the first stack area or an address in the first stack area by a predetermined value from the end address, a stack end determination that generates an internal interrupt request signal A second stack area is dynamically allocated in the interrupt routine that is shifted by the internal interrupt request signal, and a start address of the reserved second stack area is assigned to the second stack area start register It is preferable to set to. Since the stack end determination circuit is provided and the second stack area is dynamically secured, the memory area can be effectively used.
ここで、前記スタック終端判定回路は、プッシュ動作時とポップ動作時では、異なる内部割込要求信号を発生するものであることが好ましい。 Here, it is preferable that the stack end determination circuit generates different internal interrupt request signals during a push operation and a pop operation.
また、前記スタック終端判定回路が、前記第2スタック領域が確保されているか否かを示す値を記憶する第2スタック領域イネーブルフラグを備え、該イネーブルフラグの値を参照して前記内部割込要求信号を発生することが好ましい。これにより、第2スタック領域が確保されているか否かに応じた処理を行うことが可能になる。 The stack end determination circuit includes a second stack area enable flag for storing a value indicating whether or not the second stack area is secured, and refers to the value of the enable flag to determine the internal interrupt request. It is preferable to generate a signal. This makes it possible to perform processing according to whether or not the second stack area is secured.
もしくは、該イネーブルフラグは、前記内部割込要求信号により移行した割込ルーチンから読み出し可能であることが好ましい。これにより、割込ルーチン移行後に、第2スタック領域が確保されているか否かによって異なる処理を行うことが可能になる。 Alternatively, it is preferable that the enable flag can be read from an interrupt routine that has been shifted by the internal interrupt request signal. This makes it possible to perform different processing depending on whether or not the second stack area is secured after the transition to the interrupt routine.
さらに、前記第2スタック領域開始レジスタが、前記内部割込信号により移行した割込ルーチンにおいて書き込み可能であって、該割込ルーチンが前記第2スタック領域を動的に確保した時には該確保した第2スタック領域の開始アドレスが書き込まれ、割込ルーチンが前記第2スタック領域を解放したときには無効な値が書き込まれ、かつ、前記スタック終端判定回路が、前記第2スタック領域への書き込みを検知して前記第2スタック領域イネーブルフラグの設定を行う、イネーブルフラグ制御回路をさらに含むことが好ましい。イネーブルフラグ制御回路を備えることにより、ソフトウエアの負担を増大させることなく、第2スタック領域イネーブルフラグ値の適切な設定が可能となる。 Further, the second stack area start register is writable in the interrupt routine shifted by the internal interrupt signal, and when the interrupt routine dynamically secures the second stack area, The start address of the two stack areas is written, an invalid value is written when the interrupt routine releases the second stack area, and the stack end judgment circuit detects writing to the second stack area. It is preferable to further include an enable flag control circuit for setting the second stack area enable flag. By providing the enable flag control circuit, it is possible to appropriately set the second stack area enable flag value without increasing the software load.
上記目的を達成する本発明のスタック領域制御方法は、現在のスタック領域の先頭アドレスを格納するスタックポインタレジスタと、第1スタック領域の終端アドレスを設定するスタック終端レジスタと、第2スタック領域の開始アドレスを設定する第2スタック領域開始レジスタと、前記スタックポインタレジスタのアドレスが前記第1スタック領域の終端アドレス又は当該終端アドレスよりも所定値だけ第1スタック領域内のアドレスに到達した時に、内部割込要求信号を発生するスタック終端判定回路とを備えたCPUにおけるスタック領域制御方法であって、前記内部割込要求信号により割込ルーチンに移行し、該割込ルーチンにおいて前記第2スタック領域を動的に確保し、該確保された第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに設定することを特徴とする。 The stack area control method of the present invention that achieves the above object includes a stack pointer register that stores the start address of the current stack area, a stack end register that sets the end address of the first stack area, and the start of the second stack area When the address of the second stack area start register for setting the address and the address of the stack pointer register reaches the end address of the first stack area or an address in the first stack area by a predetermined value from the end address, an internal allocation is performed. A stack area control method in a CPU having a stack end determination circuit for generating an interrupt request signal, wherein the process proceeds to an interrupt routine in response to the internal interrupt request signal, and the second stack area is activated in the interrupt routine. And reserve the start address of the reserved second stack area. And setting the stack area start register.
確保された第2スタック領域の開始アドレスが第2スタック領域開始レジスタに設定されることにより、CPUは、ソフトウエアの負担増大を抑えながら、第2スタック領域を利用することができる。 By setting the reserved start address of the second stack area in the second stack area start register, the CPU can use the second stack area while suppressing an increase in software load.
ここで、前記CPUのプッシュ動作時には、前記割込ルーチンにおいて、前記第2スタック領域の動的確保および前記第2スタック領域開始レジスタへの第2スタック領域開始アドレスの設定を行い、前記CPUのポップ動作時には、前記割込ルーチンにおいて、前記プッシュ時割込ルーチンで確保された第2スタック領域を解放することが好ましい。ポップ時割込ルーチンにて第2スタック領域を解放することにより、メモリ領域のさらに有効な活用が可能である。 Here, during the CPU push operation, in the interrupt routine, the second stack area is dynamically secured and the second stack area start address is set in the second stack area start register, and the CPU pops. In operation, the interrupt routine preferably releases the second stack area secured by the push-time interrupt routine. The memory area can be used more effectively by releasing the second stack area in the pop-up interrupt routine.
また、前記スタック終端判定回路が、前記第2スタック領域が確保されているか否かを示す値を記憶する第2スタック領域イネーブルフラグを備え、前記割込ルーチンにおいて、前記イネーブルフラグの値を読み出し、該イネーブルフラグの値に応じて異なる処理を行うことが好ましい。 The stack end determination circuit includes a second stack area enable flag for storing a value indicating whether or not the second stack area is secured, and reads the value of the enable flag in the interrupt routine. It is preferable to perform different processing depending on the value of the enable flag.
さらに、前記スタック終端判定回路が、前記第2スタック領域が確保されているか否かを示す値を記憶する第2スタック領域イネーブルフラグを備えるとともに、前記第2スタック領域開始レジスタへの書き込みを検知して該イネーブルフラグの設定を行う、イネーブルフラグ制御回路を含み、前記割込ルーチンにおいて、前記第2スタック領域を動的に確保した時には該確保した第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに書き込み、前記第2スタック領域を解放したときには前記第2スタック領域開始レジスタに無効な値を書き込むことが好ましい。これにより、スタック終端判定回路が、ソフトウエアの負担増大を抑えながら、第2スタック領域イネーブルフラグの値の管理を行うことが可能になる。 Further, the stack end determination circuit includes a second stack area enable flag for storing a value indicating whether or not the second stack area is secured, and detects writing to the second stack area start register. Including an enable flag control circuit for setting the enable flag, and when the second stack area is dynamically secured in the interrupt routine, the start address of the secured second stack area is set to the second stack area. It is preferable to write an invalid value to the second stack area start register when writing to the start register and releasing the second stack area. As a result, the stack end determination circuit can manage the value of the second stack area enable flag while suppressing an increase in software load.
本発明によるCPUは、スタックポインタ制御回路を備えるので、スタック領域が当初想定した領域を越えてメモリ領域を消費し、データを破壊する恐れのある場合にも、ソフトウエアの負担増大を抑えながら、正常な動作を継続することができる。 Since the CPU according to the present invention includes the stack pointer control circuit, even when the stack area consumes the memory area beyond the initially assumed area and the data may be destroyed, the increase in software load is suppressed, Normal operation can be continued.
以下に添付の図面に示す好適実施形態に基づいて本発明のCPUおよび当該CPUを用いたスタック領域制御方法を詳細に説明する。 Hereinafter, a CPU and a stack area control method using the CPU according to the present invention will be described in detail based on preferred embodiments shown in the accompanying drawings.
図1は、本発明の一実施形態のCPUの構成を示すブロック図である。図1に示すCPU1には、割込コントロール部10、制御部20、ALU(算術論理ユニット)30、レジスタ群40、スタック終端判定回路50が備えられている。レジスタ群40は、本発明に直接には関係しない複数のレジスタを表すレジスタ群400と、スタックポインタ(以下、SPとも記す)401と、第1スタック領域(以下、当初のスタック領域を第1スタック領域という)の終端アドレスを保持するためのスタック終端レジスタ(以下、SPE1レジスタと記す)402と、第2スタック領域の開始アドレスを保持するための第2スタック領域開始レジスタ(以下、SPS2レジスタと記す)403とを備えている。
FIG. 1 is a block diagram showing a configuration of a CPU according to an embodiment of the present invention. The CPU 1 shown in FIG. 1 includes an
また、制御部20は、本発明のスタックポインタ制御回路22を備えている。スタックポインタ制御回路22は、スタックポインタのアドレスがSPE1レジスタに設定されているアドレスに到達したときにスタックポインタのアドレスをSPS2レジスタに設定されているアドレスに置換え、スタックポインタのアドレスがSPS2レジスタに設定されているアドレスに到達したときにスタックポインタのアドレスをSPE1レジスタに設定されているアドレスに置換えるようにスタックポインタを制御する。
The
さらに、スタック終端判定回路50は、第2スタック領域イネーブルフラグ52を備えている。第2スタック領域イネーブルフラグ(以下、SP2ENBフラグと記す)には、第2スタック領域が確保されているか否かを示す値が記憶される。例えば、SP2ENB=Hは第2スタック領域が確保されていることを、SP2ENB=Lは第2スタック領域が確保されていない(もしくは、いったん確保された後に解放された)ことを示す。
Further, the stack
なお、図1に示すブロック図には本発明に直接には関係しない回路ブロックの記載は省略している。 In the block diagram shown in FIG. 1, description of circuit blocks not directly related to the present invention is omitted.
(実施例1)
図1に示したCPUの動作の第1の例を説明する。
Example 1
A first example of the operation of the CPU shown in FIG. 1 will be described.
CPU1の起動後にソフトウエアにより、スタックポインタに第1スタック領域の開始アドレスとなる初期値が設定されて、スタック領域の使用を開始する。一例として、図3に示されるように、アドレスFFFFh(16進表示、以下同様)〜FF00hの範囲を第1スタック領域に設定し、FFFFhに近い(アドレス値の大きい)側を開始側とし、FF00hに近い(アドレス値の小さい)側を終端側とした場合を考える。すると、SP401の初期値としてはFFFEhが設定される。そして、スタック領域が成長するに従い、スタックポインタ制御回路22の制御により、SP401はFFFCh、FFFAh、…の順に値が変化する。
After the CPU 1 is activated, the software sets an initial value to be the start address of the first stack area in the stack pointer, and starts using the stack area. As an example, as shown in FIG. 3, the range from address FFFFh (hexadecimal display, the same applies hereinafter) to FF00h is set in the first stack area, the side closer to FFFFh (address value is larger) is set as the start side, Let us consider a case where the side closer to (the address value is smaller) is the end side. Then, FFFEh is set as the initial value of
すなわち、ここでは、一度に2アドレス分のスタック領域を使用し、SP401の値が2つずつ変化する場合を想定する。そして、2つのアドレスの内の終端に近い(値が小さい)方をSP401の値とした。例えば、第1スタック領域の最初のFFFFh、FFFEhの2つのアドレスを使用する際には、SP401の値をFFFEhとした。
That is, here, it is assumed that the stack area for two addresses is used at a time and the value of
本発明のCPU1では、第1スタック領域の終端アドレスを保持するためのSPE1レジスタ402を備えている。これを利用して、スタックポインタ制御回路22は、第1スタック領域がどこで終了するのかを知り、スタック領域の利用を適切に制御することができる。
The CPU 1 of the present invention includes an
スタックポインタ制御回路22の動作機構を図2を用いて説明する。図2はスタックポインタ(SP)制御回路22の1例の回路ブロック図である。SP制御回路22は、−2/+2加減算器221と、切替器222と、比較器223とを備えている。また、プッシュ動作であるかポップ動作であるかを指示する制御信号が、制御部20により比較器223に供給される。ここで例えば、SPE1レジスタ402にはFF00hが、SPS2レジスタ403にはF0FEhが設定されているとする。
The operation mechanism of the stack
−2/+2加減算器221は、プッシュ動作時にはSPの値を2だけ減算し、ポップ動作時にはSPの値を2だけ加算するものである。比較器223は、SPの値が1つのスタック領域内で変わる場合には、−2/+2加算器221の出力が切替器222から出力されるように切替器222を選択する。
The −2 / + 2 adder /
比較器223は、プッシュ動作時にはSPE1レジスタ402に設定されたアドレスとSP401のアドレスとを比較する。そして、SP401のアドレスがSPE1レジスタ402に設定された終端アドレス(即ち、FF00h)と等しい比較結果が得られたときに、切替器222へ、SPS2レジスタに設定されたアドレスを出力するように選択信号を出力する。すなわち、それ以前の動作によって第1スタック領域の終端アドレスまで利用された次のプッシュ動作においては、切替器222から第2スタック領域の開始アドレスがSP401に供給され、クロックに同期して取り込まれる。これにより、SP401のアドレスが第2スタック領域に移り、第2スタック領域が利用される。
The comparator 223 compares the address set in the SPE1 register 402 with the address of the
反対に、スタックがポップされる方向では、SP401の値がF0FEhとなった後、次の値はF100hではなくFF00hとなり、第1スタック領域にSP401のアドレスが移ることになる。このために、比較器223は、SPS2レジスタ403に設定されたアドレスとSP401のアドレスを比較する。そして、両者が等しい比較結果が得られたときに、切替器222へ、SPE1レジスタのアドレスを出力するように選択信号を出力する。すなわち、それ以前の動作によって第2スタック領域の開始アドレスまで利用された次のポップ動作においては、切替器222から第1スタック領域の終端アドレスがSP401に供給され、クロックに同期して取り込まれる。
On the contrary, in the direction in which the stack is popped, after the value of SP401 becomes F0FEh, the next value becomes FF00h instead of F100h, and the address of SP401 moves to the first stack area. For this purpose, the comparator 223 compares the address set in the SPS2 register 403 with the address of SP401. When the comparison result is the same between the two, a selection signal is output to the
図2に示したスタックポインタ制御回路22は、CPU1内のハードウエアとして構成されるものである。そして、このスタックポインタ制御回路22が、やはりハードウエアとして構成されるSPE1レジスタ402およびSPS2レジスタ403を利用して、スタックポインタの制御を行う。従って、特許文献2の場合とは異なり、ソフトウエアによる処理を必要とせず、第1および第2スタック領域の利用を実現しながら高速処理を可能とすることができる。
The stack
次に、スタック終端判定回路50の動作について説明する。スタック終端判定回路は、SP401の値が第1スタック領域の終端に達したときに、第2スタック領域を確保し、もしくは解放するための、内部割込信号を発生する。
Next, the operation of the stack
最も単純には、SP401の値がSPE1レジスタ402に設定された終端アドレスに到達した時に、第1スタック領域の終端に達したと判断をする。しかし現実には、終端アドレスよりも所定値だけ第1スタック領域内のアドレスに到達した時に、第1スタック領域の終端に達したと判断し、第2スタック領域の確保を行うための内部割込信号を発生することが好ましい。例えば、SP=FF04hからSP=FF02hになった時に、スタック終端判定回路50は第1スタック領域の終端に達したと判定する。そして、スタック終端判定回路50は、内部割込要求信号を発生し、割込コントロール部10に出力する。割込コントロール部10は当該内部割込要求信号に応答して、割込信号を制御部20に出力する。その結果、CPU1は割込動作を行い、現在のプログラムカウンタ(PC)の値を第1スタック領域のアドレスFF01h、FF00hに保存し、特定アドレスへジャンプする。
Most simply, when the value of
特定アドレスには、動的にメモリ領域を確保する命令又は関数、例えばC言語のmalloc( )に準じた命令が配置される。この命令の実行により、第2スタック領域の開始アドレスが得られる。この値をSPS2レジスタ403に設定する。
An instruction or function that dynamically allocates a memory area, for example, an instruction conforming to C language malloc () is arranged at the specific address. By executing this instruction, the start address of the second stack area is obtained. This value is set in the
1例として、図3に示すように、メモリアドレスF0FFh〜F000hの範囲が第2スタック領域として確保できたとする。そして、前述のように、一度に使用する2つのアドレスの終端に近い(値が小さい)方のアドレスをSP401の値にすることを想定して、SPS2に設定する終端アドレスはF0FEhとする。 As an example, as shown in FIG. 3, it is assumed that the range of memory addresses F0FFh to F000h can be secured as the second stack area. As described above, assuming that the address closer to the end of the two addresses used at a time (smaller value) is set to the value of SP401, the end address set in SPS2 is set to F0FEh.
その後、アドレスFF01h、FF00hに保存しておいたPCの値を取り出し、実行中であった元のプログラムに戻る。戻った後、スタックがF002hからさらに成長し、FF00hとなった後のプッシュ動作では、スタックポインタ制御回路22の制御により、SP401の値はFEFEhではなく、SPS2レジスタに保存しておいたF0FEhがロードされる。その後、メモリアドレスF0FFhからF000hの第2スタック領域が使用される。
Thereafter, the PC value stored in the addresses FF01h and FF00h is taken out, and the original program being executed is returned to. After the return, the stack grows further from F002h, and in the push operation after becoming FF00h, the value of SP401 is not FEFEh but F0FEh stored in the SPS2 register is loaded by the control of the stack
さらに、ポップ動作によって第2スタック領域から第1スタック領域に戻り、SP=FF02hからSP=FF04hになるところで、スタック終端判定回路50は第1スタック領域の終端に達したと判断する。この時、スタック終端判定回路50は、プッシュ時とは異なる内部割込要求信号を発生し、割込コントロール部10に伝達する。
Further, when the pop operation returns from the second stack area to the first stack area and SP = FF02h changes to SP = FF04h, the stack
今回はメモリアドレスがFF02h→FF04hのポップ動作の場合なので、先の特定アドレスとは別の特定アドレスにジャンプする。当該特定アドレスから始まる割込みルーチンには、先に動的に確保したメモリ領域を解放する命令を配置する。そうすることによって第2スタック領域として確保していたメモリ領域を、ユーザが再びスタック領域以外の目的で使用することが可能となる。その後、スタックは再び第1スタック領域においてデータの受け渡しを行うこととなる。 Since this time is the case of a pop operation in which the memory address is FF02h → FF04h, a jump is made to a specific address different from the previous specific address. In the interrupt routine starting from the specific address, an instruction for releasing the memory area dynamically allocated first is arranged. As a result, the memory area reserved as the second stack area can be used again by the user for purposes other than the stack area. Thereafter, the stack transfers data again in the first stack area.
このように、第2スタック領域を、必要となったときに動的に確保し、かつ、不要となったときに解放することにより、メモリ領域を有効に利用することが可能になる。本実施例では、第2スタック領域の確保および解放には、ソフトウエア処理(内部割込ルーチン)を利用している。しかし、確保した第2スタック領域の開始アドレスはハードウエアとして構成されたSPS2レジスタ403に書き込まれる。従って、確保された第2スタック領域をスタックポインタ制御回路22が利用する際には、ソフトウエア処理を必要としない。
As described above, the memory area can be effectively used by securing the second stack area dynamically when it becomes necessary and releasing it when it becomes unnecessary. In this embodiment, software processing (internal interrupt routine) is used for securing and releasing the second stack area. However, the secured start address of the second stack area is written into the
本実施例において、スタック終端判定回路50は、プッシュ動作時とポップ動作時とでは、異なる内部割込要求信号を発生する。具体的には、プッシュ動作時には第2スタック領域を確保する割込ルーチンを要求する要求信号を発生し、ポップ動作時には、確保した第2スタック領域を解放する割込ルーチンを要求する要求信号を発生する。
In this embodiment, the stack
すなわち、本実施例においては、プッシュ動作において第1スタック領域の終端への到達を検出した場合には必ず第2スタック領域を確保し、ポップ動作時において第1スタック領域の終端への到達を検出した場合には必ず第2スタック領域を解放する。この場合には、図1に示した第2スタック領域イネーブル(SP2ENB)フラグ52は省略することができる。
That is, in this embodiment, the second stack area is always secured when the end of the first stack area is detected in the push operation, and the end of the first stack area is detected during the pop operation. If this happens, the second stack area is always released. In this case, the second stack area enable (SP2ENB)
(実施例2)
図1に示したCPUの動作の第2の例を説明する。本実施例においては、スタック終端判定回路50が、プッシュ動作時とポップ動作時とで異なるとともに、第2スタック領域が確保されているか否かによって異なる内部割込要求信号を発生する。それ以外の動作、例えば、スタックポインタ制御回路22の動作は、第1の実施例の場合と同様である。
(Example 2)
A second example of the operation of the CPU shown in FIG. 1 will be described. In this embodiment, the stack
図4は、第2スタック領域イネーブル(SP2ENB)フラグ52を利用して行う、本実施例におけるスタック終端判定回路50の動作の一例を示すフロー図である。
FIG. 4 is a flowchart showing an example of the operation of the stack
図4のフロー図において、スタック終端判定回路50は、SP401の変化を監視する(ST11)。そして、FF04h→FF02hの変化、すなわち、プッシュ動作における第1スタック領域の終端への到達を検出した時(ST12)には、さらに、SP2ENBフラグ52の値を参照する(ST13)。そして、第2スタック領域が確保されていないことを示すSP2ENB=Lの値が得られた場合には、スタック終端判定回路50は、第1の内部割込要求信号INT1を発生する(ST14)。この、第1の内部割込要求信号INT1を受けて、割込コントロール部10は、第1の内部割込ルーチンに移行するための信号を、制御部20に出力する。これによって、第2スタック領域を確保する第1の内部割込ルーチンが、CPU1において起動される(ST15)。その後、スタック終端判定回路50は、SP401の監視を継続する。一方、第2スタック領域が確保されていることを示すSP2ENB=Hの値が得られた場合には、スタック終端判定回路50は内部割込要求信号を発生しない。
In the flowchart of FIG. 4, the stack
これに対して、スタック終端判定回路50がFF02h→FF04hの変化、すなわち、ポップ動作における第1スタック領域の終端への到達を検出した時(ST16)にも、SP2ENBフラグ52の値を参照する(ST17)。そして、SP2ENB=Hであれば、スタック終端判定回路50は、第2の内部割込要求信号INT2を発生する(ST18)。この、第2の内部割込要求信号INT2を受けて、割込コントロール部10は、第2の内部割込ルーチンに移行するための信号を、制御部20に出力する。これによって、それ以前の動作によって確保された第2スタック領域を解放する、第2の内部割込ルーチンが、CPU1において起動される(ST19)。その後、スタック終端判定回路50は、SP401の監視を継続する。一方、SP2ENB=Lであれば、スタック終端判定回路50は内部割込要求信号を発生しない。
On the other hand, when the stack
ここで、図4に示された処理の内、第1の内部割込ルーチンST15および第2の内部割込ルーチンST19は、ソフトウエアによって実装される。しかし、それ以外の、第1の内部割込要求信号INT1発生もしくは第2の内部割込要求信号INT2発生までの処理は、全て、スタック終端判定回路50内のハードウエアによって実行される。従って、本実施例において、ソフトウエアの負担の増大を抑えながら、高速に、第2スタック領域の確保および解放を実施することができる。
Here, in the processing shown in FIG. 4, the first internal interrupt routine ST15 and the second internal interrupt routine ST19 are implemented by software. However, all other processing up to the generation of the first internal interrupt request signal INT1 or the generation of the second internal interrupt request signal INT2 is executed by the hardware in the stack
例えば、ポップ動作における第1スタック領域の終端への到達を検出し、第2の内部割込ルーチンに移行したとしても、第2の内部割込ルーチン内での判断によって、第2スタック領域の解放を行わないことも可能である。具体的には、第2のスタック領域によるメモリ資源圧迫の程度や、高い処理速度を要求される特定処理を完了した後か否か等を判断し、その判断結果によっては、第2スタック領域の解放を行わないことが考えられる。 For example, even if the arrival of the end of the first stack area in the pop operation is detected and the process proceeds to the second internal interrupt routine, the second stack area is released according to the determination in the second internal interrupt routine. It is also possible not to perform. Specifically, it determines the degree of memory resource pressure by the second stack area, whether or not it is after completion of a specific process that requires a high processing speed, and depending on the determination result, It is possible not to release.
このように、第2スタック領域の解放を行わなかった場合、次に、プッシュ動作においてSP401が第1スタック領域の端部に達したことが検出された時には、あらためて第2スタック領域の確保を行う必要が無い。このように、プッシュ動作もしくはポップ動作において第1スタック領域の終端への到達が検出されても、第2スタック領域の確保もしくは解放を行う必要があるとは限らない場合、図4に示されたようなフローにより、第2スタック領域が確保されているか否かによって異なる内部割込要求信号を発生することが必要である。ここで、図4のフローの実施のためには、スタック終端判定回路50が、SP2ENBフラグ52の値を制御するためのSP2ENBフラグ制御回路54(図6参照)を含むことが好ましい。
As described above, when the second stack area is not released, when it is detected that the
図5は、イネーブルフラグ制御回路がSP2ENBフラグ52の値を制御するためのフローの1例を示す。ここで、第1の内部割込ルーチンによって第2のスタック領域の確保が行われる場合には、例えばmalloc( )に準じた命令の実行によって第2のスタック領域が確保されるとともに、確保した第2スタック領域の開始アドレスをSPS2レジスタ403に書き込むものとする。さらに、第2の内部割込ルーチンによって第2のスタック領域の解放を行う場合には、例えば、free( )に準じた命令の実行によって第2のスタック領域の解放を行うとともに、SPS2レジスタ403に、それ自身は意味のない、ダミーデータを書き込むものとする。
FIG. 5 shows an example of a flow for the enable flag control circuit to control the value of the
図5に示したフローにおいて、スタック終端判定回路50は、SPS2レジスタ403への書き込みを監視する(ST21)。そして、SPS2への書き込みが検出された時(ST22)には、SP2ENBフラグ52の値を参照し(ST23)、SP2ENBフラグ52の値がHであればLを書き込み(ST24)、LであればHを書き込む(ST25)。
In the flow shown in FIG. 5, the stack
図6には、図5のフローによる制御を行うための、SP2ENBフラグ制御回路54の1例を示す。図6のSP2ENBフラグ制御回路54において、SP2ENBフラグ52は、フリップフロップによって実現されている。SP2ENBフラグ52のD入力端子には、XORゲート56の出力が接続され、XORゲート56の一方の入力端子には入力信号INが、他方の入力端子にはSP2ENBフラグ52のQ出力端子が接続されている。入力信号INには、SPS2レジスタ403の書き込み信号が供給されている。一方、SP2ENBフラグ52のQ出力端子からは、制御部20およびスタック終端判定回路50内の内部割込信号発生回路(図示しない)に出力信号OUTが供給されている。
FIG. 6 shows an example of the SP2ENB
図6に示されたSP2ENBフラグ制御回路54において、XORゲート56の一方の入力端子にSPS2レジスタ403書き込み信号(1クロック幅)が供給されることによって、SPS2レジスタ403への書き込みが監視される。すなわち、Hレベルの信号がXORゲート一方の入力端子に供給された時に、SPS2レジスタ403への書き込みが検出される。そして、XORゲート56の他の入力端子に、SP2ENDフラグ52のQ出力が供給されることによって、現在のSP2ENBフラグ52の値を反転した信号が、XORゲート56の出力端子からSP2ENBフラグ52のD入力端子に供給される。この信号が、クロック信号CKに同期してSP2ENBフラグ52に書き込まれる。
In the SP2ENB
本実施例においては、スタック終端判定回路50が、第2スタック領域が確保されているか否かによって異なる内部割込要求信号を発生する。従って、第2スタック領域の確保および解放を、より柔軟に行うことが可能である。本実施例においてはさらに、図5のフローによるSP2ENBフラグ52の制御は、図6に例示された制御回路54のように、スタック終端判定回路50内のハードウエアによって実施される。従って、本実施例においては、ソフトウエア(内部割込ルーチン)の負担を増大させることなく、SP2ENBフラグ52の値の制御を行うことができる。
In this embodiment, the stack
(実施例3)
スタック判定回路50の動作のさらに他の例を記す。
(Example 3)
Still another example of the operation of the
実施例2においては、図4に示したフローによって、スタック終端判定回路50が、SP2ENBフラグ=Lである時には第1の内部割込要求信号INT1を発生し、SP2ENBフラグ=Hである時には第2の内部割込要求信号INT2を発生した。すなわち、スタック終端判定回路50が、SP2ENBフラグの値に応じて異なる内部割込要求信号を発生した。そして、第1の内部割込要求信号INT1および第2の内部割込要求信号INT2を受けて、割込コントロール部10は、第1の内部割込ルーチンに移行するための割込信号、および、第2の内部割込ルーチンに移行するための割込信号を制御部20に出力した。
In the second embodiment, according to the flow shown in FIG. 4, the stack
しかし、スタック終端判定回路50が発生する内部割込要求信号は同一とし、内部割込ルーチンに移行した後で、ソフトウエア処理によって、異なる処理を行うことも可能である。
However, the internal interrupt request signals generated by the stack
図7には、この場合の処理フローの1例を示す。図7のフローにおいて、スタック終端判定回路50は、SP401の変化を監視する(ST31)。そして、FF04h→FF02hの変化、すなわち、プッシュ動作における第1スタック領域の終端への到達を検出した時(ST32)には、さらに、SP2ENBフラグ52の値を参照する(ST33)。そして、SP2ENB=Lであれば、スタック終端判定回路50は、第1の内部割込要求信号INT1を発生する(ST34)。一方、SP2ENB=Hであれば、スタック終端判定回路50は内部割込要求信号を発生しない。
FIG. 7 shows an example of the processing flow in this case. In the flow of FIG. 7, the stack
また、スタック終端判定回路50がFF02h→FF04hの変化、すなわち、ポップ動作における第1スタック領域の終端への到達を検出した時(ST35)にも、さらに、SP2ENBプラグ52の値を参照する(ST36)。そして、SP2ENB=Hであれば、スタック終端判定回路50は、第2の内部割込要求信号INT2を発生する(ST37)。一方、SP2ENB=Lであれば、スタック終端判定回路50は内部割込要求信号を発生しない。
Further, when the stack
そして、INT1とINT2とのORをとり、内部割込要求信号INTを発生し(ST38)、制御部20に出力する。これによって、CPU1は、内部割込ルーチンに移行する(ST40)。この内部割込ルーチンの中で、SP2ENBフラグ52を読み出し、その値を調べる(ST41)。SP2ENB=Lである場合には、第2スタック領域を確保し(ST42)、SPS2レジスタへ第2スタック領域の開始アドレスを書き込み(ST43)。内部割込ルーチンを終える。
Then, the OR of INT1 and INT2 is taken to generate an internal interrupt request signal INT (ST38) and output to the
一方、ST41においてSP2ENB=Hであった場合には、それ以前の動作によって確保された第2スタック領域の解放が可能か否かを確認し(ST44)、否であれば、処理的には何も行わない。第2スタック領域の解放が可である場合には、第2スタック領域の解放を行い(ST45)、SPS2レジスタへダミーの書き込みを行い(ST46)、内部割込ルーチンを終える。 On the other hand, if SP2ENB = H in ST41, it is confirmed whether or not the second stack area secured by the previous operation can be released (ST44). Also do not. If the second stack area can be released, the second stack area is released (ST45), a dummy is written to the SPS2 register (ST46), and the internal interrupt routine is terminated.
なお、本実施例においても、図5に示されたフローにより、SPS2レジスタへの書き込みを検知したSP2ENBフラグ52の設定が行われる。
Also in this embodiment, the
図7に示したフローにおいては、ソフトウエア(内部割込ルーチンST40)がSP2ENBフラグ52の値を調べ、それに応じて異なる処理を行う。このため、図4に示したフローに比較して、より柔軟なスタック領域管理が可能である。しかも、内部割込要求信号INT発生まではハードウエアで処理されており、特許文献2に示された技術に比較すると、ソフトウエアの負担は小さく、高速処理が可能である。
In the flow shown in FIG. 7, the software (internal interrupt routine ST40) checks the value of the
なお、図7のフローを実現するためには、内部割込ルーチンからSP2ENBフラグが読み出し可能とすることが必要である。例えば、他の汎用レジスタと同様に、図示しないデータバスからSP2ENBフラグを読み出すことを可能とする機能が必要となる。 In order to realize the flow of FIG. 7, it is necessary to be able to read the SP2ENB flag from the internal interrupt routine. For example, like other general-purpose registers, a function that enables reading of the SP2ENB flag from a data bus (not shown) is required.
以上、本発明の実施形態について詳細に説明した。本発明が上記の具体例には限定されず、さまざまな変形、改良が可能であることは言うまでもない。 The embodiment of the present invention has been described in detail above. It goes without saying that the present invention is not limited to the specific examples described above, and various modifications and improvements are possible.
例えば、上記の実施形態では、スタック終端判定回路50は、レジスタSPE1に保持されているアドレス(FF00h)より2だけ大きいアドレス(FF02h)とスタックポインタSP401の値とを比較し、内部割込要求信号を発生する。すなわち、プログラムカウンタの返り値を保存するための2バイト分のアドレスを考慮して、スタックポインタのアドレスが(SPE1+4)から(SPE1+2)への遷移、または(SPE1+2)から(SPE1+4)への遷移が生じた際に割込要求信号を出力する。しかし、この際の増分するバイト数は2には限らず、CPUのサポートする命令の取り扱いデータ長に依存する。
For example, in the above embodiment, the stack
また、上記の実施形態では、一度に2つのアドレスのスタック領域を使用し、その内の終端に近い(値が小さい)方のアドレスをSP401の値とした。これに合わせて、SPE1レジスタ402には、第1スタック領域の実際の終端のアドレスFF00hをそのまま、第1スタック領域の終端アドレスとして設定した。一方、SPS2レジスタ403には、第2スタック領域の実際の開始アドレスF0FFhから1を減じたF0FEhを、第2スタック領域の開始アドレスとして設定した。
In the above embodiment, the stack area of two addresses is used at one time, and the address closer to the end (smaller value) is used as the
このように、スタックポインタ制御回路22における制御において利用するための、SPE1レジスタ402への第1スタック領域の終端アドレスの設定、および、SPS2レジスタ403への第2スタック領域の開始アドレスの設定は、スタック領域の利用形態およびSP401の設定に応じて適切に行われる。その設定が、上記の実施形態の場合に限定されないことは言うまでもない。
Thus, the setting of the end address of the first stack area in the
また、上記の実施形態では、図3に示すように、スタックのプッシュ方向がアドレスの減少する方向としているが、スタックのポップ方向がアドレスの減少する方向に用いるものであっても良い。さらに上記の実施形態では動的に確保した第2スタック領域の終端アドレスについては考慮しなかったが、第2スタック領域の終端アドレスを設定するためのレジスタを設けて、スタックポインタの値が当該アドレスを超える恐れのある場合には、第3スタック領域を確保するようにすることも可能である。 In the above embodiment, as shown in FIG. 3, the stack push direction is the direction in which the address decreases, but the stack pop direction may be used in the direction in which the address decreases. Furthermore, in the above embodiment, the end address of the second stack area that is dynamically secured is not considered. However, a register for setting the end address of the second stack area is provided, and the value of the stack pointer is set to the address. It is also possible to secure the third stack area when there is a risk of exceeding the threshold.
また、上述の実施形態においては、内部割込ルーチンにて、メモリ領域を動的に確保する命令又は解放する命令を配置することにより、第2スタック領域として用いるメモリ領域を動的に確保し、その開始アドレスの値をSPS2レジスタ403に設定していた。しかし、動的にメモリ領域を確保する機構を前提とするのではなく、リセット後に、SPS2レジスタに第2スタック領域の開始アドレスを設定してしまうアーキテクチャも可能である。この場合は、ハードウエア構成上,実現容易という意味で有利である。
In the above-described embodiment, the memory area used as the second stack area is dynamically secured by arranging an instruction for dynamically securing the memory area or an instruction for releasing the memory area in the internal interrupt routine. The value of the start address was set in the
以上のように、本発明によれば、実際のプログラムの実行時に、当初想定したメモリ領域を越えてスタック領域がメモリを消費してしまう恐れのある場合にも、プログラムを停止させることなくデータ破壊を回避し、プログラムが予期せぬ動作をしてしまうという不具合を防止することができる。さらに、このようなスタック領域の管理を、ソフトウエアの負担増大を抑えながら実現し、処理速度の低下を抑えることができる。 As described above, according to the present invention, when an actual program is executed, even if there is a possibility that the stack area may consume memory beyond the initially assumed memory area, the data is destroyed without stopping the program. Can be avoided, and the problem that the program operates unexpectedly can be prevented. Further, such management of the stack area can be realized while suppressing an increase in software load, and a reduction in processing speed can be suppressed.
1 CPU
10 割込みコントロール部
20 制御部
22 スタックポインタ制御回路
221 −2/+2加減算器
222 切替器
223 比較器
30 ALU
40、400 レジスタ群
401 スタックポインタレジスタ
402 第1スタック領域終端アドレスレジスタ
403 第2スタック領域開始アドレスレジスタ
50 スタック終端判定回路
52 第2スタック領域イネーブルフラグ
54 イネーブルフラグ制御回路
1 CPU
10 interrupt
40, 400
402 First stack area end address register 403 Second stack area start
Claims (10)
第1スタック領域の終端アドレスを設定するスタック終端レジスタと、
第2スタック領域の開始アドレスを設定する第2スタック領域開始レジスタと、
前記スタックポインタレジスタのアドレスが前記スタック終端レジスタに設定されているアドレスに到達した次のプッシュ動作において、該スタックポインタレジスタのアドレスを前記第2スタック領域開始レジスタに設定されているアドレスに置換え、また前記スタックポインタレジスタのアドレスが前記第2スタック領域開始レジスタに設定されているアドレスに到達した次のポップ動作において、該スタックポインタレジスタのアドレスを前記スタック終端レジスタに設定されているアドレスに置換えるスタックポインタ制御回路とを備えたことを特徴とするCPU。 A stack pointer register that stores the start address of the current stack area;
A stack end register for setting the end address of the first stack area;
A second stack area start register for setting a start address of the second stack area;
In the next push operation when the address of the stack pointer register reaches the address set in the stack end register, the address of the stack pointer register is replaced with the address set in the second stack area start register, and A stack that replaces the address of the stack pointer register with the address set in the stack end register in the next pop operation when the address of the stack pointer register reaches the address set in the second stack area start register A CPU comprising a pointer control circuit.
前記内部割込要求信号により移行する割込ルーチンにおいて、前記第2スタック領域を動的に確保し、該確保された第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに設定することを特徴とする請求項1記載のCPU。 A stack end determination circuit for generating an internal interrupt request signal when the address of the stack pointer register reaches the end address of the first stack area or an address in the first stack area by a predetermined value from the end address; Prepared,
In the interrupt routine to be shifted by the internal interrupt request signal, dynamically securing the second stack area and setting a start address of the secured second stack area in the second stack area start register. The CPU according to claim 1, wherein
かつ、
前記スタック終端判定回路が、前記第2スタック領域開始レジスタへの書き込みを検知して前記イネーブルフラグの設定を行う、イネーブルフラグ制御回路をさらに含むことを特徴とする請求項4または5記載のCPU。 The second stack area start register is writable in the interrupt routine shifted by the internal interrupt signal, and the second stack area secured when the interrupt routine dynamically secures the second stack area. The start address of the area is written, and an invalid value is written when the interrupt routine releases the second stack area,
And,
6. The CPU according to claim 4, further comprising an enable flag control circuit for detecting the write to the second stack area start register and setting the enable flag.
前記内部割込要求信号により割込ルーチンに移行し、該割込ルーチンにおいて前記第2スタック領域を動的に確保し、該確保された第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに設定することを特徴とするスタック領域制御方法。 A stack pointer register for storing the start address of the current stack area, a stack end register for setting the end address of the first stack area, a second stack area start register for setting the start address of the second stack area, and the stack A stack end determination circuit for generating an internal interrupt request signal when the address of the pointer register reaches the end address of the first stack area or an address in the first stack area by a predetermined value from the end address. A stack area control method in a CPU,
In response to the internal interrupt request signal, the process proceeds to an interrupt routine, in which the second stack area is dynamically secured, and the start address of the secured second stack area is assigned to the second stack area start register. A stack area control method, characterized in that:
前記CPUのポップ動作時には、前記割込ルーチンにおいて、前記プッシュ時割込ルーチンで確保された第2スタック領域を解放することを特徴とする請求項7記載のスタック領域制御方法。 During the push operation of the CPU, in the interrupt routine, dynamically securing the second stack area and setting the second stack area start address in the second stack area start register,
8. The stack area control method according to claim 7, wherein, during the pop operation of the CPU, the second stack area secured in the push-time interrupt routine is released in the interrupt routine.
前記割込ルーチンにおいて、前記イネーブルフラグの値を読み出し、該イネーブルフラグの値に応じて異なる処理を行うことを特徴とする請求項7記載のスタック領域制御方法。 The stack end determination circuit includes a second stack area enable flag for storing a value indicating whether or not the second stack area is secured;
8. The stack area control method according to claim 7, wherein in the interrupt routine, the value of the enable flag is read and different processing is performed according to the value of the enable flag.
前記割込ルーチンにおいて、前記第2スタック領域を動的に確保した時には該確保した第2スタック領域の開始アドレスを前記第2スタック領域開始レジスタに書き込み、前記第2スタック領域を解放したときには前記第2スタック領域開始レジスタに無効な値を書き込むことを特徴とする請求項7または9記載のスタック領域制御方法。 The stack end determination circuit includes a second stack area enable flag for storing a value indicating whether or not the second stack area is secured, and detects writing to the second stack area start register to Including an enable flag control circuit for setting the enable flag;
In the interrupt routine, when the second stack area is dynamically secured, the start address of the secured second stack area is written to the second stack area start register, and when the second stack area is released, the second stack area is released. 10. The stack area control method according to claim 7, wherein an invalid value is written to the two stack area start register.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005351013A JP4813882B2 (en) | 2004-12-24 | 2005-12-05 | CPU |
Applications Claiming Priority (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2004372393 | 2004-12-24 | ||
JP2004372393 | 2004-12-24 | ||
JP2005351013A JP4813882B2 (en) | 2004-12-24 | 2005-12-05 | CPU |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2006202268A true JP2006202268A (en) | 2006-08-03 |
JP4813882B2 JP4813882B2 (en) | 2011-11-09 |
Family
ID=36960182
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005351013A Expired - Fee Related JP4813882B2 (en) | 2004-12-24 | 2005-12-05 | CPU |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4813882B2 (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009540438A (en) * | 2006-06-06 | 2009-11-19 | クゥアルコム・インコーポレイテッド | Processor core stack expansion |
JP2010134748A (en) * | 2008-12-05 | 2010-06-17 | Fuji Xerox Co Ltd | Image processing apparatus |
JP2010134747A (en) * | 2008-12-05 | 2010-06-17 | Fuji Xerox Co Ltd | Image processing apparatus |
JP2010224908A (en) * | 2009-03-24 | 2010-10-07 | Fujitsu Semiconductor Ltd | Information processor and data restoration method |
JP2016135285A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
JP2016135284A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
JP2016135286A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS5933552A (en) * | 1982-08-18 | 1984-02-23 | Toshiba Corp | Data processor |
JPH0228721A (en) * | 1988-03-23 | 1990-01-30 | Du Pont Pixel Syst Ltd | Processing system |
JPH0293730A (en) * | 1988-09-29 | 1990-04-04 | Fuji Xerox Co Ltd | Information processor |
JPH02304624A (en) * | 1989-05-19 | 1990-12-18 | Hitachi Ltd | Information processor |
JPH04157530A (en) * | 1990-10-22 | 1992-05-29 | Nec Corp | Microprocessor |
-
2005
- 2005-12-05 JP JP2005351013A patent/JP4813882B2/en not_active Expired - Fee Related
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS5933552A (en) * | 1982-08-18 | 1984-02-23 | Toshiba Corp | Data processor |
JPH0228721A (en) * | 1988-03-23 | 1990-01-30 | Du Pont Pixel Syst Ltd | Processing system |
JPH0293730A (en) * | 1988-09-29 | 1990-04-04 | Fuji Xerox Co Ltd | Information processor |
JPH02304624A (en) * | 1989-05-19 | 1990-12-18 | Hitachi Ltd | Information processor |
JPH04157530A (en) * | 1990-10-22 | 1992-05-29 | Nec Corp | Microprocessor |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009540438A (en) * | 2006-06-06 | 2009-11-19 | クゥアルコム・インコーポレイテッド | Processor core stack expansion |
JP2010134748A (en) * | 2008-12-05 | 2010-06-17 | Fuji Xerox Co Ltd | Image processing apparatus |
JP2010134747A (en) * | 2008-12-05 | 2010-06-17 | Fuji Xerox Co Ltd | Image processing apparatus |
JP2010224908A (en) * | 2009-03-24 | 2010-10-07 | Fujitsu Semiconductor Ltd | Information processor and data restoration method |
JP2016135285A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
JP2016135284A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
JP2016135286A (en) * | 2016-03-18 | 2016-07-28 | 株式会社ソフイア | Game machine |
Also Published As
Publication number | Publication date |
---|---|
JP4813882B2 (en) | 2011-11-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4813882B2 (en) | CPU | |
JP4422136B2 (en) | Storage device and activation method | |
TWI436199B (en) | Method and controller for power management | |
KR20070108060A (en) | System executing a fast boot wake-up | |
KR0138697B1 (en) | Microcomputer | |
JP2004178016A (en) | Cpu, information processor having it, and control method for cpu | |
JP5621912B2 (en) | Information processing apparatus and information processing apparatus control method | |
JP2004046324A (en) | Information processor with standby mode, and standby mode starting method and standby mode canceling method for the same | |
JP2009157542A (en) | Information processing apparatus and method of updating stack pointer | |
US6038631A (en) | Data processing system and method using virtual storage system | |
JP3202497B2 (en) | Information processing device | |
US6738898B1 (en) | Information processor, method for saving/loading data, and information recorded | |
JP5578811B2 (en) | Information processing apparatus, information processing apparatus control method, and program | |
KR20080057688A (en) | Method for booting operating system using of non volatile memory | |
JP2009230479A (en) | Microprocessor | |
TWI843444B (en) | Electronic device and operation method thereof | |
JP4334312B2 (en) | Start-up time reduction computing device and data loading method | |
JP2005209178A (en) | Memory protection unit, memory protection method, and memory protection program | |
JP2006243810A (en) | Microcomputer system | |
US5778207A (en) | Assisting operating-system interrupts using application-based processing | |
JP2007094497A (en) | Information processor and information processing method | |
JP2001051854A (en) | Information management system | |
JPS63298654A (en) | Microcomputer | |
JP4876459B2 (en) | Multiprocessor system, multiprocessor system activation method, and portable terminal | |
EP1104899A2 (en) | Data processing apparatus and method of controlling the same |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A821 Effective date: 20080220 |
|
RD02 | Notification of acceptance of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7422 Effective date: 20080220 |
|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20080325 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20100614 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20100629 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20100826 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110510 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20110706 |
|
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: 20110823 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20110825 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 4813882 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140902 Year of fee payment: 3 |
|
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 |
|
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 |