JPS6057439A - Stack overflow detector - Google Patents

Stack overflow detector

Info

Publication number
JPS6057439A
JPS6057439A JP58166411A JP16641183A JPS6057439A JP S6057439 A JPS6057439 A JP S6057439A JP 58166411 A JP58166411 A JP 58166411A JP 16641183 A JP16641183 A JP 16641183A JP S6057439 A JPS6057439 A JP S6057439A
Authority
JP
Japan
Prior art keywords
stack
value
upper limit
lower limit
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.)
Pending
Application number
JP58166411A
Other languages
Japanese (ja)
Inventor
Yoshio Nakano
中埜 善夫
Makoto Ando
誠 安藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP58166411A priority Critical patent/JPS6057439A/en
Publication of JPS6057439A publication Critical patent/JPS6057439A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • G06F9/30054Unconditional branch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • G06F9/3012Organisation of register space, e.g. banked or distributed register file
    • G06F9/30134Register stacks; shift registers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline, look ahead
    • G06F9/3861Recovery, e.g. branch miss-prediction, exception handling

Abstract

PURPOSE:To detect a stack overflow by providing a function to identify the writing to a data area from the writing in a stack area. CONSTITUTION:An upper limit comparator 22 compares the value A delivered to an address bus 12 with the value Au of an upper limit register 20 while a signal is delivered to a stack operation detecting signal line 25. Then an overflow signal 1 is delivered when A>Au is satisfied. While a lower limit comparator 23 compares the value A delivered to the bus 12 with the value Al of a lower limit register 21 and delivers an underflow signal 1 with A<Al. Therefore, 1 is delivered to a stack overflow detecting signal line 30 from an OR gate 26 when A>Au or A<Al is satisfied with the value A of a subject address of a stack operation instruction. Thus a stack overflow can be detected.

Description

【発明の詳細な説明】 産業上の利用分野 この発明祉、マイクロプロセッサなどを応用した計算機
システムにおけるスタックあふれ検出装置に関するもの
である。
DETAILED DESCRIPTION OF THE INVENTION Field of Industrial Application This invention relates to a stack overflow detection device in a computer system using a microprocessor or the like.

従来例の構成とその問題点 近年マイクロプロセッサの急速な発展に伴い、安価に計
算機システムを構築できるようになった。
Conventional configurations and their problems With the rapid development of microprocessors in recent years, it has become possible to construct computer systems at low cost.

マイクロプロセッサ応用製品の特徴は、従来ハードウェ
アで実現していた機能をソフトウェアで実現するもので
、同一のハードウェアであっても搭載するソフトウェア
な変えれば外見上具なった製品としてMth fr:さ
せることができる点にある。したがって、適正なハード
ウェアの開発とともに適正なソフトウェアの開発が必要
になり、各種のソフトウェア開発ソールが開発されてい
る。
A feature of microprocessor-based products is that they use software to perform functions that were conventionally achieved using hardware. Even if the hardware is the same, if you change the installed software, the product will look like a different product. It is possible to do so. Therefore, it is necessary to develop appropriate software as well as appropriate hardware, and various software development soles have been developed.

マイクロプロセッサのアーキテ°クチ丁の一つにスタッ
クという概念があ夛、内部レジスタの一時退避および復
旧、副プログラムへの分岐時の主プログラムへの戻り番
地の記憶などに用いられており、記憶装置内の番地とは
無関係にデータの読み書きができる特長を持つ。
The concept of stack is one of the architectural features of microprocessors, and is used to temporarily save and restore internal registers, and to store the return address to the main program when branching to a subprogram. It has the feature that data can be read and written regardless of the address within.

このスタック領域は物理的には有限であり、スタックポ
インタというものが演算処理装置内に設けられ、これが
記憶装置へ読み書きする番地を管理している。
This stack area is physically limited, and a stack pointer is provided in the arithmetic processing unit, which manages addresses for reading and writing from and to the storage device.

しかし、開発途中のプログラムではスタック領域のサイ
ズ以上に多くのデータを格納したシ、格納されたデータ
数以上におおぐデータを取出したりすることによるプロ
グラムの暴走などの障害が生じやすく、シかも原因の追
求が困難であり、スタックあふれ検出装置というものが
必要となってきている。
However, programs that are in the middle of development are prone to problems such as program runaways due to storing more data than the size of the stack area or retrieving more data than the stored data. It is difficult to pursue this, and a stack overflow detection device has become necessary.

ここで、記憶装置の利用形態を模式化すると一般的に第
1図のようになる。1はプログツム領域、2はデータ領
域、3はスタック領域、4は空き領域である。プログツ
ム領域1は通常、読出し専用であり、データ領域2.ス
タック領域3はともに読み書きの両方が可能である。
Here, the usage pattern of a storage device is generally shown in FIG. 1. 1 is a program area, 2 is a data area, 3 is a stack area, and 4 is a free area. Program area 1 is typically read-only, data area 2. The stack area 3 can be both read and written.

プログツム領域1または空き領域4へのデータの格納。Storing data in program area 1 or free area 4.

およびデータ領域2.スタック領域3゜空き領域4から
の命令の読込みは異常処理となる。
and data area 2. Reading an instruction from the stack area 3° free area 4 is an abnormal process.

演算処理装置が命令の読込みザイクル、命令の実行サイ
クルのいずれの状態にあるかを示す信号線を用いると、
命令の読込みサイケVでのアドレス母線の値よりデータ
領域2.スタック領域3゜空き領域4へのアクセスを検
出することができ、同様に命令の実行サイクルでのプロ
グラム領域1へのデータの格納を検出することができる
By using a signal line that indicates whether the arithmetic processing unit is in an instruction read cycle or an instruction execution cycle,
Data area 2. It is possible to detect an access to the stack area 3 and the free area 4, and similarly, it is possible to detect the storage of data to the program area 1 in an instruction execution cycle.

しかし、データ領域2への読み書きとスタック領域3へ
の読み書きとを外部から区別することができないので、
スタックオーバーフローによるデータ領域2内のデータ
の破壊を防ぐことができず、異常動作の原因追求に多く
の労力を費していた。
However, since reading and writing to data area 2 and reading and writing to stack area 3 cannot be distinguished from the outside,
It was not possible to prevent the data in the data area 2 from being destroyed due to stack overflow, and a lot of effort was spent searching for the cause of the abnormal operation.

また、記憶装置の利用形態が第2図のようになって論る
場合は、スタックのアンダーフローによる不当データの
取り出しや不当番地へのプログラムの復帰を防ぐことが
できないという問題点を有していた。
Furthermore, if the storage device usage pattern is as shown in Figure 2, there is a problem in that it is not possible to prevent the extraction of invalid data or the return of a program to an invalid address due to stack underflow. Ta.

発明の目的 この発明は上記従来の問題点を解決するもので、データ
領域への読み書きとスタック領域への読み書きを識別す
る機能を設けることによりスタックのあぶれを検知でき
るスタックあふれ検出装置を提供することを目的とする
Purpose of the Invention The present invention solves the above-mentioned conventional problems, and provides a stack overflow detection device that can detect stack overflow by providing a function to distinguish between reading and writing to a data area and reading and writing to a stack area. With the goal.

発明の構成 この発明のスタックあふれ検出装置はスタック領域の上
限を規定する上限レジスタと、スタック領域の下限を規
定する下限レジスタと、アドレス母線の値Aと上限レジ
スタのIfAuとを比較する上限比較器と、アドレス母
線の値Aと下限レジスタの値A2とを比較する下限比較
器と、スタック操作命令であることを検出する制御部を
備え、スタックあふれによるプログラムの異寓を検出す
ることのできるものである。
Structure of the Invention The stack overflow detection device of the present invention includes an upper limit register that defines the upper limit of the stack area, a lower limit register that defines the lower limit of the stack area, and an upper limit comparator that compares the value A of the address bus with IfAu of the upper limit register. , a lower limit comparator that compares the value A of the address bus line with the value A2 of the lower limit register, and a control unit that detects that it is a stack manipulation instruction, and can detect program variations due to stack overflow. It is.

実施例の説明 第3図はこの発明の一実施例を示すグロック図である。Description of examples FIG. 3 is a clock diagram showing an embodiment of the present invention.

第3図において、1oは演算処理装置、11は主記憶装
置、12はアドレス母線、13はデータ母線、14は割
込要求線、15は割込み応答サイクル表示信号(割込サ
イクル信号)線、16は命令フェッチサイクル表示信号
(フェッチサイクル信号)線、17は演算処理装置動作
信号(クロック信号)線、20はスタック領域上限規定
レジスタ(上限レジスタ)、21はスタック領域下限規
定レジスタ(下限レジスタ)、22は上限比較器、23
は下限比較器、24は制御部、25はスタック操作検出
信号線、30はスタックあふれ検出信号線である。
In FIG. 3, 1o is an arithmetic processing unit, 11 is a main storage device, 12 is an address bus line, 13 is a data bus line, 14 is an interrupt request line, 15 is an interrupt response cycle display signal (interrupt cycle signal) line, and 16 is a is an instruction fetch cycle display signal (fetch cycle signal) line, 17 is an arithmetic processing unit operation signal (clock signal) line, 20 is a stack area upper limit regulation register (upper limit register), 21 is a stack area lower limit regulation register (lower limit register), 22 is an upper limit comparator, 23
24 is a lower limit comparator, 24 is a control unit, 25 is a stack operation detection signal line, and 30 is a stack overflow detection signal line.

以上のように構成された本実施例のスタックあふれ検出
装置について、以下その動作を説明する。
The operation of the stack overflow detection device of this embodiment configured as described above will be described below.

演算処理袋[10は主記憶装置11から逐次命令を読み
込み、処理を実行する。このときスタック操作に関する
命令として、PUSH(スタックへのデータの退避) 
、 POP (スタックからのデータの復旧) 、 C
ALL (副プログラムへの分岐とともに主プログラム
への戻り番地をスタックに退避)。
The arithmetic processing bag [10 reads instructions sequentially from the main memory 11 and executes the processing. At this time, as a command related to stack operation, PUSH (saving data to stack)
, POP (recovery of data from stack), C
ALL (branch to the subprogram and save the return address to the main program on the stack).

RET (主プログラムへの戻り番地をスタックがら取
出して副プログラムから復帰)などがある。上限レジス
タ20.下限レジスタ21にはそれぞれ予め図示しない
手段で、スタック領域の上限値Au。
RET (retrieve the return address to the main program from the stack and return from the subprogram), etc. Upper limit register 20. The upper limit value Au of the stack area is stored in each lower limit register 21 in advance by means not shown in the figures.

スタッタ領域の下限値Alが格納されている。The lower limit value Al of the stutter area is stored.

制御部24は、プエッチサイクル信号線16に1が出力
されているときにデータ母線13の値を読み込むことに
より演算処理装置10の読み込んだ命令を知シ、スタッ
ク操作命令CPUSH,POP、CALL。
The control unit 24 reads the value of the data bus 13 when 1 is output to the fetch cycle signal line 16, and thereby learns the instructions read by the arithmetic processing unit 10, and issues the stack operation instructions CPUSH, POP, and CALL.

RETなど)かどうかを判定する。スタック操作命令で
あることを検出すると、命令によってその後の何マシン
サイクル目にスタックに対する読み書きが行われるかが
規定されているだめ、クロック信号線17より該当マシ
ンサイクルを検出しスタック操作検出信号線25に信号
1を出力する。また、スタック操作検出信号線25に1
が出力されているときは、アドレス母IfA12にはス
タック操作の対象となる番地値Aが出力されている。
RET, etc.). When a stack manipulation command is detected, the relevant machine cycle is detected from the clock signal line 17 and the stack manipulation detection signal line 25 is determined, since the command specifies the number of machine cycles after which reading and writing to the stack will be performed. Outputs signal 1 to In addition, 1 is connected to the stack operation detection signal line 25.
is being output, the address value A to be subjected to the stack operation is being output to the address mother IfA12.

上限比較器22は、スタック操作検出信号m25に信号
1が出力されているときに、アドレス母線12に出力さ
れている値Aと上限レジスタ2oの値〜とを比較し、A
’>Auであるとオーバーフロー信号lを出力する機能
を持つ。下限比較器23は、同様にアドレス母線12に
出方されている値Aと下限レジスタ21の値Atとを比
較し、A <Azであるとアンダー70−信号1を出力
する機能を持つ。
The upper limit comparator 22 compares the value A output to the address bus 12 with the value ~ of the upper limit register 2o when the signal 1 is output as the stack operation detection signal m25, and
'> Au, it has a function of outputting an overflow signal l. The lower limit comparator 23 similarly compares the value A output on the address bus 12 with the value At of the lower limit register 21, and has the function of outputting an under 70-signal 1 if A<Az.

したがって、上述の機能によυ、スタック操作命令の対
象となる番地値AがA>AuまたはA <Azであるど
、オア・ゲート26によりスタックあふれ検出信Jij
−1i130に1が出力され、スタックあふれ全検出す
ることができる。
Therefore, according to the above function, if the address value A targeted by the stack manipulation instruction is A>Au or A<Az, the OR gate 26 generates the stack overflow detection signal Jij.
1 is output to -1i 130, and all stack overflows can be detected.

また、演算処理装置10に対して割込要求が生じてデー
タをスタック領域に退避させるときも、制御部24が割
込サイクル信号紗15にょシスタックへのデータ退避動
作を検出し、演算処理装置10に規定されたタイミング
に従って、データ格納番地の値Aを上限レジスタ20の
値A□、下限レジスタ21の値Atと比較することによ
り同様にスタックあぶれを検出することができる。
Further, when an interrupt request is issued to the arithmetic processing unit 10 and data is saved to the stack area, the control unit 24 detects the data saving operation to the stack area using the interrupt cycle signal gauze 15, and the arithmetic processing unit 10 Stack overflow can be similarly detected by comparing the value A of the data storage address with the value A□ of the upper limit register 20 and the value At of the lower limit register 21 according to the timing defined in .

発明の効果 この発明のスタックあふれ検出IAfitによれば、ス
タックのあふれを検出することができるため、スタック
あふれに起因する異常処理の検出が容易になるという効
果がある。
Effects of the Invention According to the stack overflow detection IAfit of the present invention, since stack overflow can be detected, abnormal processing caused by stack overflow can be easily detected.

【図面の簡単な説明】 第1図、第2図は夫々主記憶装置の利用形態を示す模式
図、第3図はこの発明の実施例におけるスタックあふれ
検出装置のブロック図である。 3・・・スタック領域、10・・・演算処理装置、12
・・・アドレス母線、13・・・データ母線、14・・
・割込要求m、20・・・上限レジスタ、21・・・下
限レジスタ、22・・・上限比較器、23・・・下限比
較器、24・・・制御部、25・・・スタック操作検出
信号線、3゜・・・スタックあふれ検出信号線 第1図 第2図 第3図
BRIEF DESCRIPTION OF THE DRAWINGS FIGS. 1 and 2 are schematic diagrams showing how the main memory is used, respectively, and FIG. 3 is a block diagram of a stack overflow detection device in an embodiment of the present invention. 3... Stack area, 10... Arithmetic processing unit, 12
...Address bus, 13...Data bus, 14...
- Interrupt request m, 20... Upper limit register, 21... Lower limit register, 22... Upper limit comparator, 23... Lower limit comparator, 24... Control unit, 25... Stack operation detection Signal line, 3°...Stack overflow detection signal line Figure 1 Figure 2 Figure 3

Claims (1)

【特許請求の範囲】[Claims] (1) スタック領域の上限を規定する上限レジスタと
、前記スタック領域の下限を規定する下限レジスタと、
演算処理装置が読み込む命令を解読して前記命令が前記
スタック領域へのデータの読み書き命令(スタック操作
命令)であることを検出する制御部と、前記制御部によ
って制御され前記演算処理装置が前記スタック操作命令
実行時にアドレス母線に出力する値Aと前記上限レジス
タの値Auとを比較してA>Auか否かを検出する上限
比較器と、前記制御部によって制御され前記アドレス母
線の[Aと前記下限レジスタの値Atとを比較しA<A
tか否かを検出する下限比較器とを備えたスタックあふ
れ検出装置。 (21前記制御部が、演算処理装置の割込み要求受付は
時に内部レジスタをスタック領域に退避格納する動作を
検出して前記上限比較器および下限比較器を制御する機
能を有するものである特許請求の範囲第(1)項記載の
スタックあふれ検出装置。
(1) an upper limit register that defines the upper limit of the stack area; a lower limit register that defines the lower limit of the stack area;
a control unit that decodes an instruction read by the arithmetic processing unit and detects that the instruction is an instruction to read/write data to the stack area (stack manipulation instruction); an upper limit comparator that compares the value A output to the address bus when an operation command is executed with the value Au of the upper limit register to detect whether A>Au; Compare the value At of the lower limit register and find that A<A
A stack overflow detection device comprising a lower limit comparator for detecting whether or not t. (21) The control unit has a function of controlling the upper limit comparator and the lower limit comparator by detecting an operation of saving and storing an internal register in a stack area when accepting an interrupt request of the arithmetic processing unit. Stack overflow detection device according to scope (1).
JP58166411A 1983-09-08 1983-09-08 Stack overflow detector Pending JPS6057439A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP58166411A JPS6057439A (en) 1983-09-08 1983-09-08 Stack overflow detector

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP58166411A JPS6057439A (en) 1983-09-08 1983-09-08 Stack overflow detector

Publications (1)

Publication Number Publication Date
JPS6057439A true JPS6057439A (en) 1985-04-03

Family

ID=15830920

Family Applications (1)

Application Number Title Priority Date Filing Date
JP58166411A Pending JPS6057439A (en) 1983-09-08 1983-09-08 Stack overflow detector

Country Status (1)

Country Link
JP (1) JPS6057439A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS622327A (en) * 1985-06-28 1987-01-08 Fujitsu Ltd Stack-over prevention and controlling system
EP3330848A3 (en) * 2016-12-01 2018-07-18 Cisco Technology, Inc. Detection of stack overflow in a multithreaded processor

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS573156A (en) * 1980-06-04 1982-01-08 Yokogawa Hokushin Electric Corp Central processing device
JPS57200984A (en) * 1981-06-03 1982-12-09 Fujitsu Ltd Information stack system
JPS5873099A (en) * 1981-10-23 1983-05-02 Canon Inc Data processor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS573156A (en) * 1980-06-04 1982-01-08 Yokogawa Hokushin Electric Corp Central processing device
JPS57200984A (en) * 1981-06-03 1982-12-09 Fujitsu Ltd Information stack system
JPS5873099A (en) * 1981-10-23 1983-05-02 Canon Inc Data processor

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS622327A (en) * 1985-06-28 1987-01-08 Fujitsu Ltd Stack-over prevention and controlling system
EP3330848A3 (en) * 2016-12-01 2018-07-18 Cisco Technology, Inc. Detection of stack overflow in a multithreaded processor
US10649786B2 (en) 2016-12-01 2020-05-12 Cisco Technology, Inc. Reduced stack usage in a multithreaded processor

Similar Documents

Publication Publication Date Title
RU2137182C1 (en) Execution of data processing instruction
JPH07271403A (en) Inactive system memory updating system
US5003458A (en) Suspended instruction restart processing system based on a checkpoint microprogram address
US5146569A (en) System for storing restart address of microprogram, determining the validity, and using valid restart address to resume execution upon removal of suspension
EP1125199A1 (en) Method of debugging a program thread
JPS6057439A (en) Stack overflow detector
JPH08255476A (en) Apparatus and method for memory extended stack in data-processing system
KR890003322B1 (en) Data processing system
JP2562838B2 (en) Processor and store buffer control method
JPS59172044A (en) Instruction control system
JPH01125633A (en) System for debugging multi-processing system
JPH059815B2 (en)
JP3762597B2 (en) Computer and its control method
JPS59112494A (en) Memory testing system
JP2665173B2 (en) Processor trap circuit
JPH0795288B2 (en) Microcomputer
JPH0258648B2 (en)
JPH0330022A (en) Information processor
JPH0149975B2 (en)
JPH0333939A (en) Microprocessor
JPS6115235A (en) Central processor
JPH04364531A (en) Microprocessor
JPH059814B2 (en)
JPH03263226A (en) Control system for data processor
JPH03233741A (en) Microprocessor processing device