JPH113272A - Stack overflow detector - Google Patents
Stack overflow detectorInfo
- Publication number
- JPH113272A JPH113272A JP15680297A JP15680297A JPH113272A JP H113272 A JPH113272 A JP H113272A JP 15680297 A JP15680297 A JP 15680297A JP 15680297 A JP15680297 A JP 15680297A JP H113272 A JPH113272 A JP H113272A
- Authority
- JP
- Japan
- Prior art keywords
- area
- stack
- display
- led
- display state
- 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)
Abstract
(57)【要約】
【課題】 スタックがオーバフローしたことを検出して
表示することができるスタックオーバフロー検出装置を
提供すること。
【解決手段】 RAMに設定されたスタック領域SRと
変数領域VRとの境界付近の斜線領域にLED表示用フ
ラグ領域を設定する。このLED表示用フラグ領域に対
してデータが書き込まれると、LEDを点灯させる。こ
れによりスタック領域SRがオーバフローしたことを検
出して表示することが可能となる。LEDの点灯によ
り、(a)の場合はスタック領域SRがデータで満たさ
れたことを示し、(b)の場合はデータの書き込まれて
いないスタック領域SRが残り少ないことを示し、
(c)の場合は既にスタック領域をオーバフローし、変
数領域に書き込まれていたプログラム変数等が失われた
可能性のあることを示している。
(57) [Problem] To provide a stack overflow detection device capable of detecting and displaying that a stack has overflowed. SOLUTION: An LED display flag area is set in a shaded area near a boundary between a stack area SR and a variable area VR set in a RAM. When data is written to the LED display flag area, the LED is turned on. This makes it possible to detect and display that the stack area SR has overflowed. By the lighting of the LED, (a) indicates that the stack area SR is filled with data, (b) indicates that the stack area SR to which no data is written is remaining,
The case (c) indicates that the stack area has already overflowed, and the program variables and the like written in the variable area may have been lost.
Description
【0001】[0001]
【発明の属する技術分野】この発明は、マイクロコンピ
ュータ(以下、「マイコン」と略称する)のメモリに割
り当てられるスタック領域に書き込まれるデータ量がス
タック領域をオーバフローすることを検出するスタック
オーバフロー検出装置に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a stack overflow detecting device for detecting that an amount of data written in a stack area allocated to a memory of a microcomputer (hereinafter referred to as "microcomputer") overflows the stack area. .
【0002】[0002]
【従来の技術】従来より、マイコンにおいて、所定の処
理プログラムを実行する際には、メモリの記憶領域の一
部に確保されたスタック領域に対して、関数やサブルー
チンを呼び出したときの戻りアドレス等を格納するよう
に構成されている。2. Description of the Related Art Conventionally, when a microcomputer executes a predetermined processing program, a return address when a function or a subroutine is called is stored in a stack area secured in a part of a storage area of a memory. Is configured to be stored.
【0003】図6は、メモリの記憶領域を示す説明図で
ある。図6において、プログラム領域PRは、マイコン
によって実行されるプログラムが格納される記憶領域で
あり、変数領域VRは、マイコンによって実行されてい
るプログラムの変数等を格納するために割り当てられて
いる記憶領域であり、スタック領域SRは、関数やサブ
ルーチンを呼び出したときの戻りアドレス等を格納する
ために割り当てられている記憶領域である。そして、ス
タック領域SRは、メモリのアドレスXから最後尾のア
ドレスFFFFまで割り当てられている。FIG. 6 is an explanatory diagram showing a storage area of a memory. In FIG. 6, a program area PR is a storage area in which a program executed by the microcomputer is stored, and a variable area VR is a storage area assigned to store variables of the program executed by the microcomputer. The stack area SR is a storage area allocated to store a return address when a function or a subroutine is called, and the like. The stack area SR is allocated from the memory address X to the last address FFFF.
【0004】このスタック領域SRに対して、マイコン
が、実行しているプログラムに基づいて他の関数やサブ
ルーチンを呼び出す度に、その戻りアドレス等をスタッ
ク領域SRの最後尾側から順次に書き込んでいく。ま
た、マイコンが、スタック領域SRから戻りアドレス等
を読み出す際には、最後にスタック領域SRに格納した
データから順に読み出していく。Each time the microcomputer calls another function or subroutine based on the program being executed, the return address and the like are sequentially written into the stack area SR from the tail end of the stack area SR. . When the microcomputer reads a return address or the like from the stack area SR, the microcomputer sequentially reads data from the data stored in the stack area SR.
【0005】このようなスタック操作において、スタッ
ク領域SRからデータが読み出される回数よりも、スタ
ック領域SRへのデータが書き込まれる回数の方が多い
場合には、スタック領域SRの使用率は次第に上昇す
る。そして、さらに書き込みが行われると、スタックの
オーバフローが起こり、アドレスXよりも先頭側の変数
領域VRやプログラム領域PRに対してデータが書き込
まれることとなる。In such a stack operation, when the number of times data is written to the stack area SR is greater than the number of times data is read from the stack area SR, the usage rate of the stack area SR gradually increases. . Then, when further writing is performed, a stack overflow occurs, and data is written to the variable area VR and the program area PR on the head side of the address X.
【0006】ところが、変数領域VRやプログラム領域
PRに対して関数やサブルーチンを呼び出したときの戻
りアドレス等を書き込むと、変数領域VRやプログラム
領域PRに格納している変数やプログラム等に対して上
書きすることとなり、変数領域VRやプログラム領域P
Rのデータを損失する。However, if a return address or the like when a function or subroutine is called is written in the variable area VR or the program area PR, the variable or program stored in the variable area VR or the program area PR is overwritten. And the variable area VR and the program area P
R data is lost.
【0007】そして、マイコンが変数領域VRやプログ
ラム領域PRの損失したデータを読み込んで処理を行う
と、そのデータは適切なデータではないため、プログラ
ムの暴走を招くことになる。When the microcomputer reads and processes the lost data in the variable area VR and the program area PR, the data is not appropriate data, and the program runs away.
【0008】このようなプログラムの暴走を防ぐために
は、予め十分な領域をスタック領域として設定しておけ
ば良いが、メモリの容量を増加することはコストアップ
を招くため好ましくない。従って、メモリの記憶領域の
効率的な使用が望まれている。In order to prevent such a program runaway, it is sufficient to set a sufficient area as a stack area in advance, but increasing the memory capacity is not preferable because it increases the cost. Therefore, efficient use of the storage area of the memory is desired.
【0009】[0009]
【発明が解決しようとする課題】マイコンのソフトウェ
ア開発の段階において、どの程度の領域がスタック領域
として適切であるのかを判断して、スタック領域を設定
する必要がある。In the stage of software development of a microcomputer, it is necessary to determine a suitable area as a stack area and set the stack area.
【0010】しかし、従来においては、スタックがオー
バフローしたこと自体を知ることは困難であり、プログ
ラムが暴走するまでスタックがオーバフローしたことを
知ることが困難であった。However, conventionally, it is difficult to know that the stack has overflowed, and it is difficult to know that the stack has overflowed until the program runs away.
【0011】従って、プログラムの暴走の原因がスタッ
クのオーバフローであることを確認するまでに、ある程
度の時間が必要となる。これにより、スタック領域の適
切化に対して時間が掛かることとなり、効率的なソフト
ウェア開発ができないという問題がある。Therefore, it takes a certain amount of time to confirm that the cause of the program runaway is the stack overflow. As a result, it takes time to optimize the stack area, and there is a problem that efficient software development cannot be performed.
【0012】この発明は、上記課題に鑑みてなされたも
のであって、スタックがオーバフローしたことを検出し
て表示することができるスタックオーバフロー検出装置
を提供することを目的とする。The present invention has been made in view of the above problems, and has as its object to provide a stack overflow detection device capable of detecting and displaying that a stack has overflowed.
【0013】[0013]
【課題を解決するための手段】上記目的を達成するため
に、請求項1に記載の発明は、読み出し/書き込み可能
な記憶手段(13)と、記憶手段(13)に対してアク
セスして所定の処理を実行する演算処理手段(11)
と、演算処理手段(11)によって表示状態が制御され
る表示手段(20)とを備える装置であって、記憶手段
(13)の記憶領域内に設定されたスタック領域と変数
領域との境界付近に表示状態変更領域を設けるととも
に、演算処理手段(11)が表示状態変更領域の監視を
行い、表示状態変更領域の記憶状態の変更に応答して演
算処理手段(11)が表示手段(20)の表示状態を変
更することを特徴としている。According to a first aspect of the present invention, there is provided a storage means (13) which is readable / writable, and which has a predetermined access to the storage means (13). Arithmetic processing means (11) for executing the above processing
And a display means (20) whose display state is controlled by the arithmetic processing means (11), wherein the display area (20) is provided near a boundary between a stack area and a variable area set in a storage area of the storage means (13). And a processing unit (11) monitors the display state change area, and in response to a change in the storage state of the display state change area, the calculation processing unit (11) displays the display state (20). The display state is changed.
【0014】請求項2に記載の発明は、請求項1に記載
の装置において、演算処理手段(11)が行う表示状態
変更領域の監視は、所定の時間ごとに定期的に行われる
ことを特徴としている。According to a second aspect of the present invention, in the device according to the first aspect, the monitoring of the display state change area performed by the arithmetic processing means (11) is periodically performed at predetermined time intervals. And
【0015】請求項3に記載の発明は、請求項1または
2に記載の装置において、表示状態変更領域はスタック
領域内に設けることを特徴としている。According to a third aspect of the present invention, in the device according to the first or second aspect, the display state change area is provided in the stack area.
【0016】請求項4に記載の発明は、請求項3に記載
の装置において、表示状態変更領域は変数領域に隣接す
る領域に設けることを特徴としている。According to a fourth aspect of the present invention, in the device according to the third aspect, the display state change area is provided in an area adjacent to the variable area.
【0017】請求項5に記載の発明は、請求項1または
2に記載の装置において、表示状態変更領域は変数領域
内に設けることを特徴としている。According to a fifth aspect of the present invention, in the device according to the first or second aspect, the display state change area is provided in a variable area.
【0018】[0018]
【作用】上記構成において、請求項1に記載の発明は、
表示状態変更領域についての記憶状態が変化してたこと
を視覚的に認識することができるように、表示状態変更
領域の記憶状態の変更に応答して演算処理手段(11)
が表示手段(20)の表示状態を変更する。In the above construction, the invention according to claim 1 is
Arithmetic processing means (11) in response to a change in the storage state of the display state change area so that the storage state of the display state change area can be visually recognized as being changed;
Changes the display state of the display means (20).
【0019】請求項2に記載の発明は、リアルタイムに
表示手段(20)による表示を行うことができるよう
に、演算処理手段(11)が行う表示状態変更領域の監
視を定期的に行うように動作する。According to a second aspect of the present invention, the display state change area is periodically monitored by the arithmetic processing means (11) so that the display means (20) can perform display in real time. Operate.
【0020】請求項3に記載の発明は、データの書き込
まれていないスタック領域が残り少ないことを知らせる
ように、表示手段(20)による表示が行われる。According to the third aspect of the present invention, the display is performed by the display means (20) so as to notify that the stack area where no data is written is remaining.
【0021】請求項4に記載の発明によれば、スタック
領域がデータで満たされたことを知らせるように、表示
手段(20)による表示が行われる。According to the fourth aspect of the present invention, the display by the display means (20) is performed so as to notify that the stack area is filled with the data.
【0022】請求項5に記載の発明によれば、既にスタ
ック領域をオーバフローし、変数領域に書き込まれてい
たプログラム変数等が失われた可能性のあることを知ら
せるように、表示手段(20)による表示が行われる。According to the fifth aspect of the present invention, the display means (20) informs that there is a possibility that the program variable or the like which has already overflowed the stack area and has been written in the variable area may be lost. Is displayed.
【0023】[0023]
【発明の実施の形態】図1は、この発明の実施の形態で
あるスタックオーバフロー検出装置の構成を示す概略図
である。図1に示すように、マイコン10の内部には、
プログラムを実行して演算処理を行う演算処理部11
と、プログラム等を予め記憶させておく読み出し専用の
メモリであるROM(Read Only Memory)12と、演算
処理部11がプログラムを実行する際に一時的にデータ
を格納するメモリであるRAM(Random Access Memor
y)13と、マイコン10の外部機構とデータの受渡を
行うI/Oポート14とが設けられている。FIG. 1 is a schematic diagram showing a configuration of a stack overflow detection device according to an embodiment of the present invention. As shown in FIG. 1, inside the microcomputer 10,
Arithmetic processing unit 11 for executing arithmetic processing by executing a program
A ROM (Read Only Memory) 12 which is a read-only memory for storing programs and the like in advance, and a RAM (Random Access Memory) which is a memory for temporarily storing data when the arithmetic processing unit 11 executes the program. Memor
y) 13 and an I / O port 14 for exchanging data with an external mechanism of the microcomputer 10 are provided.
【0024】また、I/Oポート14から得られる出力
のうち少なくとも1つの出力は、LED表示部20に導
かれている。このLED表示部20は複数設けられても
良い。そしてLED表示部20は、マイコン10からの
出力信号に基づいてLED(Light Emitting Diode)2
1を発光させることが可能なように構成されている。At least one of the outputs obtained from the I / O port 14 is led to the LED display unit 20. A plurality of LED display units 20 may be provided. Then, the LED display unit 20 outputs an LED (Light Emitting Diode) 2 based on an output signal from the microcomputer 10.
1 is configured to emit light.
【0025】そして、マイコン10やLED21は、少
なくとも1枚の基板に実装されて制御基板となる。この
制御基板は、製品として完成したときは製品全体を統括
的に制御するように機能する。そして、LED21は製
品の動作状況等を示すための表示機構として機能する。
例えば、製品が空気調和機であり、この制御基板が空気
調和機の各機構部を統括的に制御するものである場合、
LED21は当該空気調和機の動作状況に応じた点灯を
する。そして、LED表示部20が複数設けられている
場合には、その点灯パターンによって動作状況を詳細に
知ることができる。The microcomputer 10 and the LED 21 are mounted on at least one board to serve as a control board. This control board functions so as to control the entire product when completed as a product. The LED 21 functions as a display mechanism for indicating the operation status of the product and the like.
For example, when the product is an air conditioner, and the control board controls each mechanism of the air conditioner,
The LED 21 lights up according to the operation state of the air conditioner. When a plurality of LED display units 20 are provided, the operating state can be known in detail by the lighting pattern.
【0026】このような制御基板は、マイコン10のソ
フトウェア開発の段階においても使用される。そしてこ
の実施の形態においては、ソフトウェア開発段階では、
LED21を特別にスタック領域がオーバフローしたこ
とを開発者に知らせるための表示手段として機能させ
る。Such a control board is also used at the stage of software development of the microcomputer 10. And in this embodiment, at the software development stage,
The LED 21 functions as display means for notifying the developer that the stack area has overflowed.
【0027】一方、マイコン10において、RAM13
の記憶領域の一部をスタック領域として予め設定してお
く。そして、RAM13の記憶領域のスタック領域とそ
れ以外の記憶領域である変数領域との境界付近にLED
表示用フラグ領域を予め設定する。そして演算処理部1
1が定期的にLED表示用フラグ領域に対してデータが
書き込まれたか否かを検出し、データが書き込まれてい
た場合にはLED表示部20に対してLED21を発光
させるような信号を出力するように構成されている。On the other hand, in the microcomputer 10, the RAM 13
Is set in advance as a stack area. The LED is located near the boundary between the stack area of the storage area of the RAM 13 and the variable area which is the other storage area.
A display flag area is set in advance. And arithmetic processing unit 1
1 periodically detects whether or not data has been written to the LED display flag area, and if the data has been written, outputs a signal to the LED display unit 20 to cause the LED 21 to emit light. It is configured as follows.
【0028】図2は、この実施の形態におけるRAM1
3に設定されたスタック領域と変数領域との境界付近に
設定されたLED表示用フラグ領域を示す図である。な
お、図2においては、RAM13のアドレスXからアド
レスFFFFまでがスタック領域SRとして設定されて
おり、スタック領域SRよりも先頭側に変数領域VRが
設定されており、さらに、変数領域VRよりも先頭側に
プログラム領域PRが設定されている。そして、図2
(a)〜(c)に示す各斜線部分がLED表示用フラグ
領域である。FIG. 2 shows a RAM 1 according to this embodiment.
FIG. 9 is a diagram showing an LED display flag area set near a boundary between a stack area and a variable area set to 3; In FIG. 2, the area from the address X to the address FFFF of the RAM 13 is set as the stack area SR, the variable area VR is set at the head side of the stack area SR, and the head area is set at the top of the variable area VR. A program area PR is set on the side. And FIG.
Each shaded portion shown in (a) to (c) is an LED display flag area.
【0029】まず、図2(a)では、スタック領域SR
として設定されている先頭アドレスXがLED表示用フ
ラグ領域として設定されている。そして、このLED表
示用フラグ領域に対してデータが書き込まれたときに
は、スタック領域SRの全てにデータが書き込まれた状
態となる。従って、図2(a)に示すようにLED表示
用フラグ領域を設定した場合、LED21が点灯する
と、スタック領域がデータで満たされたことが判る。First, in FIG. 2A, the stack region SR
Is set as the LED display flag area. Then, when data is written to the LED display flag area, data is written to all of the stack areas SR. Therefore, when the LED display flag area is set as shown in FIG. 2A, when the LED 21 is turned on, it is understood that the stack area is filled with data.
【0030】次に、図2(b)では、スタック領域SR
として設定されている先頭アドレスXよりも最後尾側に
LED表示用フラグ領域が設定されている。そして、こ
のLED表示用フラグ領域に対してデータが書き込まれ
たときには、スタック領域SRの多くの領域に対してデ
ータが書き込まれた状態となり、データの書き込まれて
いないスタック領域が残り少ない状態である。従って、
図2(b)に示すようにLED表示用フラグ領域を設定
した場合、LED21が点灯すると、データの書き込ま
れていないスタック領域が残り少ないことが判る。Next, in FIG. 2B, the stack region SR
The flag area for LED display is set at the tail end side from the start address X set as (1). When data is written in the LED display flag area, data is written in many areas of the stack area SR, and the stack area in which no data is written remains small. Therefore,
When the LED display flag area is set as shown in FIG. 2B, when the LED 21 is turned on, it can be seen that the stack area where no data is written remains small.
【0031】さらに、図2(c)では、スタック領域S
Rとして設定されている先頭アドレスXよりも先頭側の
変数領域VRにLED表示用フラグ領域が設定されてい
る。そして、このLED表示用フラグ領域に対してデー
タが書き込まれたときには、既にスタック領域SRをオ
ーバフローした状態となる。従って、図2(c)に示す
ようにLED表示用フラグ領域を設定した場合、LED
21が点灯すると、既にスタック領域SRをオーバフロ
ーし、変数領域VRに書き込まれていたプログラム変数
等が失われた可能性のあることが判る。Further, in FIG. 2C, the stack area S
An LED display flag area is set in the variable area VR on the head side of the head address X set as R. Then, when data is written to the LED display flag area, the stack area SR has already overflowed. Therefore, when the LED display flag area is set as shown in FIG.
When 21 is turned on, it is found that the stack area SR has already overflowed and the program variables and the like written in the variable area VR may have been lost.
【0032】ここで、この実施の形態のスタックオーバ
フロー検出装置は、本来製品に使用される制御基板を使
用しているため、製品の動作状況等を表示するためのL
ED表示部20を、ソフトウェア開発段階においては、
特別にスタック領域がオーバフローしたことを開発者に
知らせるための表示手段として機能させることができる
ので、ソフトウェア開発段階のためだけの表示機構を設
ける必要がなく、効率的なソフトウェア開発ができるよ
うになる。さらに、LED21を点灯させるためのプロ
グラムについても製品の動作状況等を表示するためのプ
ログラムを流用することができるので、ソフトウェア開
発段階のためだけの表示プログラムを作成する必要がな
いとともに、プログラムを記憶しておくROM12の記
憶容量も増加させる必要がなく効率的な開発を行うこと
が可能となる。Here, since the stack overflow detection device of this embodiment uses a control board which is originally used for a product, an L for displaying the operation status of the product is used.
In the software development stage, the ED display unit 20 is
Since it can function as a display unit for notifying the developer that the stack area has overflowed specially, there is no need to provide a display mechanism only for the software development stage, thereby enabling efficient software development. . Furthermore, since a program for displaying the operating status of the product can be used for the program for turning on the LED 21, it is not necessary to create a display program only for the software development stage, and the program is stored. It is not necessary to increase the storage capacity of the ROM 12 to be stored, and efficient development can be performed.
【0033】このようなマイコンの処理についてフロー
チャートを参照しつつ説明する。The processing of such a microcomputer will be described with reference to a flowchart.
【0034】図3は、この実施の形態におけるマイコン
4の演算処理部11で行われる処理のフローチャートで
ある。まず、ステップS1において処理が開始されると
スタートアップ処理が行われる。このスタートアップ処
理は、マイコン10の内部のハードウェア機構(例え
ば、I/Oポート14等)の初期設定を行うための処理
である。次に、ステップS2においてデータや変数等の
初期化が行われる。初期化が終了するとステップS3に
おいて割込処理が許可される。その後演算処理部11
は、ステップS4に示す無限ループに入る。そして、ス
テップS4に示す無限ループの処理の途中に種々の割込
処理が行われる。割込処理には、処理の種類に応じて優
先レベルが設定されており、割込処理の実行中に優先レ
ベルの高い割込処理をさらに割り込ませることもある。
このように割込処理が行われる際には、その割込処理が
終了したときの戻りアドレスをスタック領域に順次格納
していく。例えば、制御基板が空気調和機についての制
御を行うためのものである場合は、上記の割込処理の中
に熱交換処理や除霜処理等の処理が含まれる。FIG. 3 is a flowchart of a process performed by the arithmetic processing unit 11 of the microcomputer 4 according to this embodiment. First, when the process is started in step S1, a startup process is performed. The start-up process is a process for performing initial setting of a hardware mechanism (for example, the I / O port 14 and the like) inside the microcomputer 10. Next, in step S2, initialization of data, variables, and the like is performed. When the initialization is completed, the interrupt processing is permitted in step S3. After that, the arithmetic processing unit 11
Enters an infinite loop shown in step S4. Then, various types of interrupt processing are performed during the processing of the infinite loop shown in step S4. A priority level is set in the interrupt process according to the type of the process, and an interrupt process with a higher priority level may be further interrupted during execution of the interrupt process.
When the interrupt processing is performed as described above, the return address when the interrupt processing is completed is sequentially stored in the stack area. For example, when the control board is for controlling the air conditioner, the above-described interrupt processing includes processing such as heat exchange processing and defrosting processing.
【0035】そして、LED21を点灯させるための処
理についても割込処理として実行される。図4は、この
実施の形態におけるLEDの点灯を確定する処理のフロ
ーチャートである。この処理は、例えば10msという
ような一定の時間間隔ごとに割込を発生させて実行され
る処理である。ステップS11では、LED表示用とし
て設定されているフラグ領域に全てについて、データが
セットされているか否かについて検出を行う。このと
き、LED表示用として設定されているフラグ領域とし
て、図2に示したLED表示用フラグ領域を追加設定し
ておくだけで、スタック領域がオーバフローする直前ま
たは直後にであることを認識することができる。そして
ステップS12では、検出したデータに基づいてLED
の点灯パターンを確定する。そしてステップS13で
は、確定したLED点灯パターンに応じて表示用変数を
所定の記憶領域(例えば、変数領域VR)にセットす
る。これでLEDの点灯を確定するための割込処理は終
了する。そしてこの処理は、10msというような一定
の時間間隔ごとに割込を発生させて実行される処理であ
るため、リアルタイムにLEDを点灯させるべきか否か
を検出することができる。The process for turning on the LED 21 is also executed as an interrupt process. FIG. 4 is a flowchart of a process for determining the lighting of the LED in this embodiment. This processing is executed by generating an interrupt at regular time intervals such as 10 ms. In step S11, it is detected whether or not data is set in all of the flag areas set for LED display. At this time, by simply setting the LED display flag area shown in FIG. 2 as the flag area set for the LED display, it is possible to recognize that the stack area is immediately before or immediately after the overflow. Can be. In step S12, based on the detected data, LED
Confirm the lighting pattern of. In step S13, a display variable is set in a predetermined storage area (for example, a variable area VR) according to the determined LED lighting pattern. This completes the interrupt process for determining the lighting of the LED. Since this process is a process executed by generating an interrupt at regular time intervals such as 10 ms, it is possible to detect in real time whether or not the LED should be turned on.
【0036】図5は、この実施の形態におけるLEDを
点灯させる処理のフローチャートである。この処理につ
いても、例えば1msというような一定の時間間隔ごと
に割込を発生させて実行される処理である。ステップS
21では、図4の処理でセットされた表示用変数を読み
出す。そして、ステップS22においては、読み出した
表示用変数の示すLED点灯パターンに応じてI/Oポ
ート14よりLED21を点灯させるための出力を行
う。以上でLEDを点灯させるための割込処理は終了す
る。FIG. 5 is a flowchart of a process for turning on an LED in this embodiment. This process is also a process executed by generating an interrupt at regular time intervals such as 1 ms. Step S
At 21, the display variables set in the processing of FIG. 4 are read. In step S22, an output for lighting the LED 21 is performed from the I / O port 14 according to the LED lighting pattern indicated by the read display variable. Thus, the interrupt processing for lighting the LED ends.
【0037】このように図3,4,5に示したフローチ
ャートの処理は、実際の製品についても必要な処理であ
る。そして、先述のように図4に示すステップS11に
おいてデータがセットされているか否かを検出する領域
として図2に示したLED表示用フラグ領域を追加する
だけで、開発者はスタック領域がオーバフローする直前
または直後にであることを認識することができる。従っ
て、プログラムが暴走するまで待つことなくリアルタイ
ムで効率良くスタックがオーバフローしたことを認識す
ることができる。また、開発段階専用のプログログラム
を作成する必要がないため、ROM12の容量を増加さ
せる必要がないとともに、ソフトウェア開発の効率の向
上を図ることが可能となる。The processes in the flowcharts shown in FIGS. 3, 4 and 5 are necessary processes for an actual product. Then, as described above, by simply adding the LED display flag area shown in FIG. 2 as an area for detecting whether or not data is set in step S11 shown in FIG. 4, the developer overflows the stack area. It can be recognized immediately before or immediately after. Therefore, it is possible to efficiently recognize that the stack has overflowed in real time without waiting for the program to run away. Further, since it is not necessary to create a program dedicated to the development stage, it is not necessary to increase the capacity of the ROM 12, and it is possible to improve the efficiency of software development.
【0038】ところで、スタックがオーバフローしたこ
とを表示するための表示手段は、LEDによる表示に限
らず、視覚的に認識することができるものであれば良い
ことは言うまでもない。By the way, it goes without saying that the display means for displaying that the stack has overflowed is not limited to the LED display, but may be any means that can be visually recognized.
【0039】また、RAM13に設定されたスタック領
域SRと変数領域VRとプログラム領域PRとの位置関
係は、図2に示した位置関係以外に、RAM13の先頭
アドレス側から変数領域VR、スタック領域SR、プロ
グラム領域PRと順で設定される場合もあるが、このよ
うな場合であってもスタック領域SRと変数領域VRと
の境界付近にLED表示用フラグ領域を設定しておけ
ば、スタックがオーバフローしたことを認識することが
できる。The positional relationship between the stack area SR, the variable area VR, and the program area PR set in the RAM 13 is not limited to the positional relationship shown in FIG. , The program area PR may be set in this order, but even in such a case, if an LED display flag area is set near the boundary between the stack area SR and the variable area VR, the stack overflows. You can recognize that you have done.
【0040】[0040]
【発明の効果】以上説明したように、請求項1に記載の
発明によれば、記憶手段(13)の記憶領域内に設定さ
れたスタック領域と変数領域との境界付近に表示状態変
更領域を設けるとともに、演算処理手段(11)が表示
状態変更領域の監視を行い、表示状態変更領域の記憶状
態の変更に応答して演算処理手段(11)が表示手段
(20)の表示状態を変更するため、プログラムが暴走
するまで待つことなくリアルタイムで効率良くスタック
がオーバフローしたことを認識することができる。ま
た、開発段階専用のプログログラムを作成する必要がな
いため、ROMの容量を増加させる必要がないととも
に、ソフトウェア開発の効率の向上を図ることが可能と
なる。As described above, according to the first aspect of the present invention, the display state change area is provided near the boundary between the stack area and the variable area set in the storage area of the storage means (13). At the same time, the arithmetic processing means (11) monitors the display state change area, and the arithmetic processing means (11) changes the display state of the display means (20) in response to the change of the storage state of the display state change area. Therefore, it is possible to efficiently recognize that the stack has overflowed in real time without waiting for the program to run away. Further, since it is not necessary to create a program dedicated to the development stage, it is not necessary to increase the capacity of the ROM, and it is possible to improve the efficiency of software development.
【0041】請求項2に記載の発明によれば、演算処理
手段(11)が行う表示状態変更領域の監視は、所定の
時間ごとに定期的に行われるため、リアルタイムに表示
手段(20)による表示を行うべきか否かを検出するこ
とができる。According to the second aspect of the present invention, the monitoring of the display state change area performed by the arithmetic processing means (11) is periodically performed at predetermined time intervals. It is possible to detect whether or not to perform display.
【0042】請求項3に記載の発明によれば、表示状態
変更領域はスタック領域内に設けるため、表示手段(2
0)による表示が行われると、データの書き込まれてい
ないスタック領域が残り少ないことが判る。According to the third aspect of the present invention, since the display state change area is provided in the stack area, the display means (2)
When the display according to 0) is performed, it can be seen that the stack area in which no data is written remains small.
【0043】請求項4に記載の発明によれば、表示状態
変更領域は変数領域に隣接する領域に設けるため、表示
手段(20)による表示が行われると、スタック領域が
データで満たされたことが判る。According to the fourth aspect of the present invention, since the display state change area is provided in the area adjacent to the variable area, when the display is performed by the display means (20), the stack area is filled with data. I understand.
【0044】請求項5に記載の発明によれば、表示状態
変更領域は変数領域内に設けるため、表示手段(20)
による表示が行われると、既にスタック領域をオーバフ
ローし、変数領域に書き込まれていたプログラム変数等
が失われた可能性のあることが判る。According to the fifth aspect of the present invention, since the display state change area is provided in the variable area, the display means (20)
Is displayed, it is found that the stack area has already overflowed, and the program variables and the like written in the variable area may have been lost.
【図1】この発明の実施の形態であるスタックオーバフ
ロー検出装置の構成を示す概略図である。FIG. 1 is a schematic diagram showing a configuration of a stack overflow detection device according to an embodiment of the present invention.
【図2】この発明の実施の形態においてRAMに設定さ
れたスタック領域と変数領域との境界付近に設定された
LED表示用フラグ領域を示す図である。FIG. 2 is a diagram showing an LED display flag area set near a boundary between a stack area and a variable area set in a RAM according to the embodiment of the present invention;
【図3】この実施の形態におけるマイコンの演算処理部
における処理のフローチャートである。FIG. 3 is a flowchart of a process in an arithmetic processing unit of the microcomputer according to the embodiment.
【図4】この実施の形態におけるLEDの点灯を確定す
る処理のフローチャートである。FIG. 4 is a flowchart of a process for determining lighting of an LED according to the embodiment.
【図5】この実施の形態におけるLEDを点灯させる処
理のフローチャートである。FIG. 5 is a flowchart of a process for turning on an LED according to the embodiment.
【図6】メモリの記憶領域を示す説明図である。FIG. 6 is an explanatory diagram showing a storage area of a memory.
10 マイコン、11 演算処理部、12 ROM、1
3 RAM、14 I/Oポート、20 LED表示
部、21 LED、VR 変数領域、SR スタック領
域10 microcomputer, 11 arithmetic processing unit, 12 ROM, 1
3 RAM, 14 I / O port, 20 LED display, 21 LED, VR variable area, SR stack area
Claims (5)
3)と、 前記記憶手段(13)に対してアクセスして所定の処理
を実行する演算処理手段(11)と、 前記演算処理手段(11)によって表示状態が制御され
る表示手段(20)と、を備える装置であって、 前記記憶手段(13)の記憶領域内に設定されたスタッ
ク領域と変数領域との境界付近に表示状態変更領域を設
けるとともに、 前記演算処理手段(11)が前記表示状態変更領域の監
視を行い、前記表示状態変更領域の記憶状態の変更に応
答して前記演算処理手段(11)が前記表示手段(2
0)の表示状態を変更することを特徴とするスタックオ
ーバフロー検出装置。A readable / writable storage means (1)
3), an arithmetic processing means (11) for accessing the storage means (13) and executing a predetermined process, and a display means (20) whose display state is controlled by the arithmetic processing means (11). A display state change area is provided near a boundary between a stack area and a variable area set in a storage area of the storage means (13), and the arithmetic processing means (11) provides the display state change area. A state change area is monitored, and in response to a change in the storage state of the display state change area, the arithmetic processing means (11) causes the display means (2
A stack overflow detection device, wherein the display state of 0) is changed.
の監視は、所定の時間ごとに定期的に行われることを特
徴とするスタックオーバフロー検出装置。2. The apparatus according to claim 1, wherein the monitoring of the display state change area performed by the arithmetic processing means (11) is performed periodically at predetermined time intervals. apparatus.
て、 前記表示状態変更領域は前記スタック領域内に設けるこ
とを特徴とするスタックオーバフロー検出装置。3. The stack overflow detecting device according to claim 1, wherein the display state change area is provided in the stack area.
設けることを特徴とするスタックオーバフロー検出装
置。4. The device according to claim 3, wherein the display state change area is provided in an area adjacent to the variable area.
て、 前記表示状態変更領域は前記変数領域内に設けることを
特徴とするスタックオーバフロー検出装置。5. The stack overflow detection device according to claim 1, wherein the display state change area is provided in the variable area.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP15680297A JPH113272A (en) | 1997-06-13 | 1997-06-13 | Stack overflow detector |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP15680297A JPH113272A (en) | 1997-06-13 | 1997-06-13 | Stack overflow detector |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH113272A true JPH113272A (en) | 1999-01-06 |
Family
ID=15635651
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP15680297A Pending JPH113272A (en) | 1997-06-13 | 1997-06-13 | Stack overflow detector |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH113272A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP5079326B2 (en) * | 2004-03-26 | 2012-11-21 | 三菱電機株式会社 | Elevator control device |
| CN116627852A (en) * | 2023-07-24 | 2023-08-22 | 苏州萨沙迈半导体有限公司 | Method and device for detecting stack overflow and computing equipment |
-
1997
- 1997-06-13 JP JP15680297A patent/JPH113272A/en active Pending
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP5079326B2 (en) * | 2004-03-26 | 2012-11-21 | 三菱電機株式会社 | Elevator control device |
| CN116627852A (en) * | 2023-07-24 | 2023-08-22 | 苏州萨沙迈半导体有限公司 | Method and device for detecting stack overflow and computing equipment |
| CN116627852B (en) * | 2023-07-24 | 2023-10-03 | 苏州萨沙迈半导体有限公司 | Method and device for detecting stack overflow and computing equipment |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP0486304B1 (en) | Initialising computer systems | |
| KR900016842A (en) | Programmable controller | |
| JP2002175183A (en) | Semiconductor integrated circuit | |
| EP0622732A1 (en) | Microcomputer | |
| US5951684A (en) | Method of booting a computer system with identifying a CD-ROM disk drive of the system and a method of loading a device driver | |
| US5968159A (en) | Interrupt system with fast response time | |
| CN113849229A (en) | Server starting method and device, electronic equipment and readable storage medium | |
| CN117806924A (en) | A control method, device, server and medium for an indicating device | |
| JPH113272A (en) | Stack overflow detector | |
| JP2004338883A (en) | Elevator control device | |
| JP2000076081A (en) | Task manager and program recording medium | |
| JPH0766368B2 (en) | Boot processor determination method | |
| JP3310481B2 (en) | Test mode execution device | |
| KR960003652B1 (en) | How to support indivisible cycle using bus monitor | |
| JPH0916220A (en) | Input / output display | |
| JPH02161523A (en) | Resident module correcting system | |
| JPH08249018A (en) | Multiprocessor arithmetic device and programmable controller having the device | |
| JP4408504B2 (en) | GAME DEVICE AND ALLOCATION METHOD | |
| JP2880658B2 (en) | Runaway detection device for multitask program | |
| JP2005071141A (en) | Method and device for managing stack and stack management program | |
| JPH11272490A (en) | Diagnostic control system | |
| JPH11306040A (en) | Emulator trace device | |
| JP4422926B2 (en) | Image forming apparatus | |
| JPS5815833B2 (en) | Vending machine malfunction display device | |
| US20020073260A1 (en) | Method for preventing processes between processors from conflicting in a multiprocessor based computer |