JPS6148738B2 - - Google Patents
Info
- Publication number
- JPS6148738B2 JPS6148738B2 JP56096272A JP9627281A JPS6148738B2 JP S6148738 B2 JPS6148738 B2 JP S6148738B2 JP 56096272 A JP56096272 A JP 56096272A JP 9627281 A JP9627281 A JP 9627281A JP S6148738 B2 JPS6148738 B2 JP S6148738B2
- Authority
- JP
- Japan
- Prior art keywords
- address
- program
- stack
- data
- content
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
- G06F9/4484—Executing subprograms
- G06F9/4486—Formation of subprogram jump address
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Executing Machine-Instructions (AREA)
Description
【発明の詳細な説明】
本発明は、レジスタフアイルとしても使用可能
なアドレススタツクを有する情報処理装置のプロ
グラムの制御方式に関するものである。DETAILED DESCRIPTION OF THE INVENTION The present invention relates to a program control method for an information processing apparatus having an address stack that can also be used as a register file.
一般に小型の情報処理装置では、割込み用或い
はサブルーチン用のアドレススタツクをプログラ
ムが一時的にデータを保持するレジスタフアイル
としても使用することがある。この様な場合に、
ポツプアツプとプツシユダウンが1対1に対応し
て使用されないと、すなわちネスト構造の深さの
把握に誤まりがあると、プログラムは暴走する。
この影響は、複数プログラムが同じスタツクを共
有している場合にはミスを生じたプログラムだけ
にとどまらない。 Generally, in small-sized information processing devices, an address stack for interrupts or subroutines is sometimes used as a register file in which a program temporarily holds data. In such a case,
If pop-up and push-down are not used in a one-to-one correspondence, that is, if the depth of the nesting structure is incorrectly grasped, the program will run out of control.
This effect is not limited to the program that made the mistake if multiple programs share the same stack.
第1図および第2図を参照してこのプログラム
暴走の一例を説明する。第1図は後入れ先出し方
式のそしてレジスタフアイルとしても使用される
アドレススタツクSTKとスタツクポインタSPを
示す図で、アドレスまたはデータは、ポインタ
SPの値n−1,n,n+1,……で区別される
各エントリENTに記憶される。ポインタSPはス
タツクSTKへ書込みがなされる毎に+1され
(プツシユダウン)、スタツクから読取りがなされ
る毎に−1される(ポツプアツプ)。第2図はプ
ログラムAの実行中にサブルーチンコールがあ
り、次のアドレスaに移行する前にプログラムB
を実行することになつた場合を例としたものであ
る。図示しないアドレスカウンタを+1しながら
(必らずしも+1ではないが、こゝでは簡略化し
てこのようにいう)プログラムAを格納している
メモリをアクセスし、該メモリ内のプログラムA
の各命令を次々と読出し、デコードして実行し、
アドレスがa−1まで進んだときコール命令が読
出され、プログラムBへとぶことになつたとする
と、プログラムAへの復帰のため該プログラムA
の次アドレスaをスタツクSTKに書込み、アド
レスカウンタへはプログラムBの先頭アドレスを
書込み、該アドレスでメモリをアクセスして該プ
ログラムBを読出し、同様にアドレスカウンタを
逐次+1して該プログラムの実行に入る。このプ
ログラムBはスタツクSTKをレジスタフアイル
として使用し、ポインタ値n,n+1,n+2の
エントリENTにそれぞれデータb,c,dを一
時記憶させていつたとする。このデータb,c,
dがプログラムBのその後の実行過程で逐次全部
読出されればポインタSPの値はn−1に戻つて
いるので、こゝでプログラムBのサブルーチン復
帰命令が読出され実行されれば、アドレスカウン
タには、エントリnを指すスタツクポインタの指
示によりスタツクSTKからアドレスaが読出さ
れ、これがアドレスカウンタにリストアされてプ
ログラムAはアドレスaから処理を再開できる
(破線で示す)。しかし、プログラムBの作成ミス
等によつてネスト(又はスタツク)の深さを誤解
し、例えばデータdを読み出しただけで処理終
了、サブルーチン復帰とすると、スタツクポイン
タSPが指す値n+2のエントリのデータCをア
ドレスとして復帰するため、プログラムはデータ
C相当のアドレスへとぶ(該当するものがあれ
ば)ことになり、プログラムAの処理再開ができ
ないことは勿論、全く予期しないプログラムが実
行されまたはプログラム実行は停止される。つま
りプログラム暴走が起る。 An example of this program runaway will be explained with reference to FIGS. 1 and 2. Figure 1 shows the address stack STK and stack pointer SP, which are of a last-in-first-out type and are also used as register files.
It is stored in each entry ENT distinguished by SP values n-1, n, n+1, . . . . Pointer SP is incremented by one (pushdown) each time a write is made to the stack STK, and decremented by one (popup) each time a read is made from the stack. In Figure 2, there is a subroutine call during the execution of program A, and before moving to the next address a, program B
This is an example of a case where it is decided to carry out the following. The memory storing program A is accessed while an address counter (not shown) is incremented (not necessarily +1, but it is simply referred to as such here), and the program A in the memory is accessed.
Read each instruction one after another, decode and execute it,
If the call instruction is read when the address advances to a-1 and jumps to program B, then program A is used to return to program A.
Write the next address a to the stack STK, write the start address of program B to the address counter, access the memory at that address to read the program B, and similarly increment the address counter by 1 to start executing the program. enter. Assume that program B uses stack STK as a register file and temporarily stores data b, c, and d in entries ENT with pointer values n, n+1, and n+2, respectively. This data b, c,
If d is read out in its entirety in the subsequent execution process of program B, the value of pointer SP will have returned to n-1, so if program B's subroutine return instruction is read out and executed now, the address counter will be updated. Address a is read from the stack STK by the instruction of the stack pointer pointing to entry n, and this is restored to the address counter, allowing program A to resume processing from address a (indicated by a broken line). However, if the depth of the nest (or stack) is misunderstood due to a mistake in the creation of program B, for example, if the process ends and the subroutine returns after just reading data d, the entry with the value n+2 pointed to by the stack pointer SP In order to return with data C as the address, the program will jump to the address corresponding to data C (if applicable), and of course it will not be possible to resume processing of program A, and a completely unexpected program will be executed or the program Execution is halted. In other words, a program runaway occurs.
本発明はかゝるA,Bマルチプログラムの処理
装置において、あるプログラム上記例ではBがア
ドレススタツクをレジスタフアイルとして使用し
た際に犯したネスト深さの誤りによる悪影響を他
のプログラムAが受けないようにし、誤りはそれ
をしたプログラムBだけに留める様にするもので
あり、その特徴とする所はアドレスのスタツクお
よびデータのスタツクとして共用され複数のエン
トリを備える後入れ先出し方式の記憶装置と、該
記憶装置の各エントリの内容がアドレスかデータ
かを表示する手段と、プログラムからの指示によ
り該記憶装置から読み出された内容をアドレスと
してサブルーチン復帰する手段とを有し、サブル
ーチン復帰時には前記表示手段によりアドレスと
表示された内容のみを有効として該内容のアドレ
スへ復帰する点にある。 The present invention provides such an A, B multi-program processing device in which, in the above example, another program A is adversely affected by a nesting depth error made when program B uses an address stack as a register file. It is designed to prevent errors from occurring and to limit the error to only the program B that made the error.It is characterized by a last-in, first-out storage device that is shared as an address stack and a data stack and has multiple entries. , means for displaying whether the content of each entry in the storage device is an address or data, and means for returning to the subroutine using the content read from the storage device as an address according to instructions from a program, and when returning to the subroutine, the above-mentioned The point is that only the content displayed as an address by the display means is valid and the return is made to the address of the content.
以下、第3図および第4図を参照して本発明の
一実施例を説明する。本発明ではスタツクSTK
内の各エントリENTに当該エントリは現在アド
レスを記憶しているかデータを記憶しているかを
表示する手段を設ける。第3図の例ではこれをア
ドレス/データ識別フラグFで実現している。本
例ではF=0であれば対応するエントリENT内
の内容(第3図ではa)はアドレスであり、また
F=1であれば対応するエントリENT内の内容
(同b〜d)はデータであることを示す。このフ
ラグFを参照すれば、第4図に示すように第2図
と同様の過程でサブルーチン復帰命令が発生した
とき、スタツクポインタSPの値をF=0のとこ
ろ(n−1)まで戻すことができるので、確実に
アドレスaを読出すことができる。従つて、プロ
グラムの暴走は防止され、プログラムAの実行継
続は何ら障害なく行なわれる。 Hereinafter, one embodiment of the present invention will be described with reference to FIGS. 3 and 4. In the present invention, stack STK
For each entry ENT in ENT, a means is provided for displaying whether the entry currently stores an address or data. In the example shown in FIG. 3, this is realized by the address/data identification flag F. In this example, if F=0, the content in the corresponding entry ENT (a in Figure 3) is an address, and if F=1, the content in the corresponding entry ENT (b to d in the same figure) is data. . Referring to this flag F, as shown in Figure 4, when a subroutine return instruction occurs in the same process as in Figure 2, the value of the stack pointer SP is returned to F = 0 (n-1). Therefore, address a can be reliably read. Therefore, runaway of the program is prevented, and program A continues to be executed without any trouble.
以上述べたように本発明によれば、マルチプロ
グラムで同一のスタツクをアドレスおよびデータ
記憶用に使用する処理装置において、ネストの深
さ誤認によりスタツク内のデータがアドレスと間
違えられプログラム暴走が生じるのを防止できる
利点がある。なお実施例ではマルチプログラムは
A,B2つの例を挙げたが、これはA,B,C,
D……など多数になる場合もある。この場合アド
レススタツクには戻り先のアドレスが多数個入い
り、それらの間にデータが詰ることになる(その
ようなケースが有り得る)が、このような場合で
も本発明を適用すればデータを読出すことなく確
実にアドレスへ戻ることができプログラム暴走阻
止に有効である。 As described above, according to the present invention, in a processing device that uses the same stack for storing addresses and data in multiple programs, data in the stack is mistaken for an address due to misjudgment of the nesting depth, resulting in a program runaway. It has the advantage of preventing In addition, in the example, two multi-programs A and B were given, but this example includes A, B, C,
There may be many such as D... In this case, the address stack will contain a large number of return destination addresses, and data will be jammed between them (such cases may occur), but even in such cases, if the present invention is applied, data can be saved. It is possible to reliably return to the address without reading, which is effective in preventing program runaway.
第1図は従来のアドレスおよびデータ兼用のス
タツクの説明図、第2図は同スタツクをマルチプ
ログラムで共用する際の動作説明図、第3図およ
び第4図は本発明の一実施例を示す図で、第3図
はスタツクの説明図、第4図は動作説明図であ
る。
図中、STKはスタツク、ENTはエントリ、F
はアドレス/データ識別フラグである。
Fig. 1 is an explanatory diagram of a conventional stack for both address and data, Fig. 2 is an explanatory diagram of the operation when the same stack is shared by multiple programs, and Figs. 3 and 4 show an embodiment of the present invention. 3 is an explanatory diagram of the stack, and FIG. 4 is an explanatory diagram of the operation. In the diagram, STK is stack, ENT is entry, F
is an address/data identification flag.
Claims (1)
として共用され複数のエントリを備える後入れ先
出し方式の記憶装置と、該記憶装置の各エントリ
の内容がアドレスかデータかを表示する手段と、
プログラムからの指示により該記憶装置から読み
出された内容をアドレスとしてサブルーチン復帰
する手段とを有し、サブルーチン復帰時には前記
表示手段によりアドレスと表示された内容まで戻
つて該内容のアドレスへ復帰することを特徴とす
るサブルーチン制御方式。1. A last-in, first-out storage device that is shared as an address stack and a data stack and includes a plurality of entries; and means for displaying whether the content of each entry in the storage device is an address or data;
and means for returning to the subroutine using the content read from the storage device as an address according to instructions from the program, and when returning from the subroutine, the display means returns to the content displayed as an address and returns to the address of the content. A subroutine control method featuring:
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP56096272A JPS57211646A (en) | 1981-06-22 | 1981-06-22 | Subroutine controlling system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP56096272A JPS57211646A (en) | 1981-06-22 | 1981-06-22 | Subroutine controlling system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPS57211646A JPS57211646A (en) | 1982-12-25 |
| JPS6148738B2 true JPS6148738B2 (en) | 1986-10-25 |
Family
ID=14160504
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP56096272A Granted JPS57211646A (en) | 1981-06-22 | 1981-06-22 | Subroutine controlling system |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPS57211646A (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS63150732A (en) * | 1986-12-16 | 1988-06-23 | Fujitsu Ltd | Program running supervisory equipment |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS539701B2 (en) * | 1972-09-14 | 1978-04-07 | ||
| JPS5259537A (en) * | 1975-11-11 | 1977-05-17 | Mitsubishi Electric Corp | Data processor |
| JPS5495144A (en) * | 1978-01-13 | 1979-07-27 | Hitachi Ltd | Malfunction detection system in data processing unit |
| JPS5584090A (en) * | 1978-12-19 | 1980-06-24 | Nec Corp | Stack control system for logic control unit |
-
1981
- 1981-06-22 JP JP56096272A patent/JPS57211646A/en active Granted
Also Published As
| Publication number | Publication date |
|---|---|
| JPS57211646A (en) | 1982-12-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US6578094B1 (en) | Method for preventing buffer overflow attacks | |
| EP0213843A2 (en) | Digital processor control | |
| US5261101A (en) | Method for calling and returning from subroutine that is invoked by either a near call or a far call | |
| EP0144779B1 (en) | Parallel processing computer | |
| US4942524A (en) | Software trap system which saves previous content of software trap handling pointer in a stack upon execution of a trap | |
| JPS6148738B2 (en) | ||
| US5481705A (en) | Method for executing a program with branch-to modifying instructions | |
| JP2000029690A (en) | Method and device for data processing | |
| JPS62254237A (en) | Inter-printer type branch instruction executing system | |
| KR950000552B1 (en) | Microprocessor | |
| JPH0324695B2 (en) | ||
| JPH0610793B2 (en) | Program runaway detection method | |
| JPH0484224A (en) | Stack area protection circuit | |
| JPS60214046A (en) | Control system for abnormal end processing | |
| JPS58151656A (en) | Data processing device | |
| KR960029969A (en) | A data processor having a pipeline processing function | |
| US5430868A (en) | Shared memory with benign failure modes | |
| JPS6337439B2 (en) | ||
| JPS59123935A (en) | Stack device | |
| JP2847863B2 (en) | Microprocessor interrupt control method | |
| JPS62221035A (en) | Microprogram control system | |
| JPH05127895A (en) | Write protection system for general-purpose register | |
| JPS62108333A (en) | Semiconductor device | |
| JPH0724030B2 (en) | Debug device | |
| JPS6161417B2 (en) |