JP2500804B2 - calculator - Google Patents

calculator

Info

Publication number
JP2500804B2
JP2500804B2 JP61197588A JP19758886A JP2500804B2 JP 2500804 B2 JP2500804 B2 JP 2500804B2 JP 61197588 A JP61197588 A JP 61197588A JP 19758886 A JP19758886 A JP 19758886A JP 2500804 B2 JP2500804 B2 JP 2500804B2
Authority
JP
Japan
Prior art keywords
stack
software trap
program
generation instruction
software
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 - Lifetime
Application number
JP61197588A
Other languages
Japanese (ja)
Other versions
JPS6353650A (en
Inventor
泰浩 布村
秀夫 坪田
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP61197588A priority Critical patent/JP2500804B2/en
Publication of JPS6353650A publication Critical patent/JPS6353650A/en
Application granted granted Critical
Publication of JP2500804B2 publication Critical patent/JP2500804B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime 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/46Multiprogramming arrangements
    • G06F9/461Saving or restoring of program or task context

Description

【発明の詳細な説明】 〔産業上の利用分野〕 この発明は、トラツプ機能を備えた計算機に関し、特
に、ソフトウエア・トラツプの処理方式の改良に関する
ものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a computer having a trap function, and more particularly to improvement of a software trap processing system.

〔従来の技術〕[Conventional technology]

計算機で処理されるプログラムの制御を他のプログラ
ムあるいはルーチンに移す方法として、サブルーチン呼
び出し、割込み、トラツプがある。このうちトラツプ
は、命令実行の直接的かつ即時的結果として内部発生す
る割込み要求であり、メモリー管理による例外条件の検
出、違法オペレーシヨンや未定義命令の実行、演算結果
のオーバーフローやゼロ除算、デバツグ時のブレークポ
イントやプログラムのトレースの実行、ソフトウエア・
トラツプ発生命令の実行により発生する。このうち、ソ
フトウエア・トラツプ発生命令はプログラムで故意にト
ラツプを発生させトラツプ処理プログラムを呼び出すも
ので、サブルーチン呼び出しと良く似た性質のものであ
る。
As a method of transferring the control of the program processed by the computer to another program or routine, there are a subroutine call, an interrupt, and a trap. Of these, traps are interrupt requests that are internally generated as a direct and immediate result of instruction execution. They include detection of exceptional conditions by memory management, execution of illegal operations and undefined instructions, overflow of operation results, division by zero, and debugging. Breakpoints and program trace execution, software
It is generated by executing the trap generation instruction. Of these, the software trap generation instruction is for intentionally generating a trap in a program to call a trap processing program, and has a property similar to that of a subroutine call.

ソフトウエア・トラツプ発生命令は、プログラム実行
環境を変えて、特に、システムに用意されているサービ
ス・プログラムを呼び出す場合に用いられる。例えば、
米国インテル社の16ビツトマイクロプロセツサiAPX86の
INT命令、米国モトローラ社の16ビツトマイクロプロセ
ツサMC68000のTRAP命令、あるいは米国ナシヨナル・セ
ミコンダクタ社の32ビツトマイクロプロセツサNS32032
のSVC命令がこのソフトウエア・トラツプ発生命令に当
たる。
The software trap generation instruction is used when the program execution environment is changed, and particularly when a service program prepared in the system is called. For example,
Intel Intel 16-bit microprocessor iAPX86
INT instruction, TRAP instruction of Motorola's 16-bit microprocessor MC68000, or US National Semiconductor's 32-bit microprocessor NS32032
SVC instruction corresponds to this software trap generation instruction.

サブルーチン呼び出し、割込み、および、トラツプに
よるプログラムの呼び出し制御は、ラストイン・フアー
ストアウト形式でデータを蓄積するスタツク機構と良く
マツチする。現在実行中のプログラムからサブルーチン
が呼び出されたり、割込み、トラツプにより別のプログ
ラムに制御が移されたりする時には、戻りアドレスおよ
び必要な情報をスタツクに保存し、サブルーチンあるい
は割込みやトラツプ処理の終了時にスタツクに保存され
ている情報を復元し、さらに戻りアドレスを復元して、
そのアドレスの命令から実行を再開する。このような機
構によれば、最後に保存された情報が最初に復元される
ので、プログラムが入れ子で呼び出された場合において
も、あるルーチンやプログラムの処理が終了すれば必ず
呼び出し元に制御が戻される。現在の計算機の大部分は
このスタツク機構を用いて上述のような制御を行つてい
る。
Control of program call by subroutine call, interrupt, and trap matches well with the stack mechanism that accumulates data in the last-in / first-out format. When a subroutine is called from the program currently being executed, or when control is transferred to another program due to an interrupt or trap, the return address and necessary information are saved in the stack, and the stack is stored at the end of the subroutine or interrupt or trap processing. To restore the information stored in
Execution resumes from the instruction at that address. With such a mechanism, the last saved information is restored first, so even if a program is called in a nested manner, control is always returned to the caller when the processing of a routine or program ends. Be done. Most of the current computers use this stack mechanism to perform the above-mentioned control.

第4図はこのような呼び出し制御をスタツク機構によ
り行う従来の計算機のブロツク図である。(7)は主記
憶装置、(3)は実行する命令が格納されている主記憶
装置内のアドレスを保持するプログラム・カウンタ、
(2)は主記憶装置(7)にラストイン・フアーストア
ウト形式で蓄積されているデータの最上位位置を示すス
タツク・ポインタ、(4)は少なくとも1つ以上の汎用
または専用のレジスタ、(5)は計算機の制御フラグや
状態フラグを含む制御レジスタおよび、(6b)は制御手
段である。主記憶装置(7)には、ラストイン・フアー
ストアウト形式でデータを蓄積するためのスタツク領域
(8)が設けられ、この領域に蓄積されているデータの
最上位位置をスタツクポインタ(2)が指している。ま
た、制御手段(6b)は、プログラム・カウンタ(3)の
示す主記憶装置(7)上の位置から取り出した命令を解
釈し命令の実行制御を行うとともに、前記プログラム・
カウンタ(3)、スタツク・ポインタ(2)、レジスタ
(4)、制御レジスタ(5)および、主記憶装置(7)
との間のデータ授受制御を行うものである。
FIG. 4 is a block diagram of a conventional computer that performs such call control by a stack mechanism. (7) is a main memory, (3) is a program counter for holding an address in the main memory in which an instruction to be executed is stored,
(2) is a stack pointer indicating the highest position of the data stored in the main memory (7) in the last-in-first-out format, (4) is at least one or more general-purpose or dedicated registers, ( 5) is a control register including a control flag and a status flag of the computer, and (6b) is a control means. The main storage device (7) is provided with a stack area (8) for storing data in the last-in / first-out format, and the stack pointer (2) is set to the highest position of the data stored in this area. ) Is pointing. The control means (6b) interprets the instruction fetched from the position on the main storage device (7) indicated by the program counter (3) and controls the execution of the instruction, and
Counter (3), stack pointer (2), register (4), control register (5) and main memory (7)
The data transfer control between the device and the device is performed.

次に、このような計算機におけるソフトウエア・トラ
ツプ発生命令実行毎の動作について説明する。第5図は
前記計算機のソフトウエア・トラツプ発生命令実行前後
の主記憶装置内のスタツクの状態図である。ソフトウエ
ア・トラツプ発生命令実行直前には、スタツク・ポイン
タ(2)は、スタツク位置〔S0〕を保持し、矢印(9)
で示されるように、これまでのプログラムの実行によつ
てスタツク領域(8)内に蓄積されたデータの最上位位
置を指している。ソフトウエア・トラツプ発生命令が実
行されると、必要な情報がスタツク領域のスタツク位置
〔S0+1〕からスタツク位置〔S1b〕の間に保存され、
スタツク・ポインタ(2)の内容が、矢印(10b)で示
されるように、スタツク位置〔S1b〕に更新される。次
いで、それぞれの計算機あるいはオペレーテイング・シ
ステムにより決められている特定のプログラムの先頭ア
ドレスがプログラム・カウンタ(3)に格納される。従
つて、次の命令はこのプログラム・カウンタ(3)に格
納された主記憶装置のアドレスから取り出され実行され
る。以上述べた制御は制御手段(6b)が行う。
Next, the operation for each execution of the software trap generation instruction in such a computer will be described. FIG. 5 is a state diagram of the stack in the main memory before and after the execution of the software trap generation instruction of the computer. Immediately before the execution of the software trap generation instruction, the stack pointer (2) holds the stack position [S0], and the arrow (9)
As shown by, indicates the highest position of the data accumulated in the stack area (8) by the execution of the program up to now. When the software trap generation instruction is executed, the necessary information is saved between the stack position [S0 + 1] and the stack position [S1b] in the stack area.
The contents of the stack pointer (2) are updated to the stack position [S1b] as indicated by the arrow (10b). Then, the start address of a specific program determined by each computer or operating system is stored in the program counter (3). Therefore, the next instruction is fetched from the main memory address stored in the program counter (3) and executed. The control described above is performed by the control means (6b).

スタツク位置〔S0+1〕からスタツク位置〔S1b〕の
間に保存される情報は、プログラム・カウンタ(3)の
内容(戻りアドレス)の他、制御レジスタ(5)の内
容、汎用または専用レジスタ(4)の内容、主記憶装置
内の特定のデータ等が考えられる。例えば、モトローラ
社のMC68000では、戻りアドレス、および、制御レジス
タの内容が保存される。
Information stored between the stack position [S0 + 1] and the stack position [S1b] includes the contents of the program counter (3) (return address), the contents of the control register (5), the general-purpose or dedicated register (4). , The specific data in the main memory, and so on. For example, the Motorola MC68000 saves the return address and the contents of the control register.

このような計算機においては、スタツクはプログラム
やサブルーチンを呼び出すごとに動的に成長してゆく。
例えば、プログラムAがソフトウエア・トラツプ発生命
令によりシステム・プログラムSを呼び出し、呼び出さ
れたシステム・プログラムSがサブルーチンBを呼び出
した場合、スタツクの変化は第6図のようになる。スタ
ツク・ポインタ(2)は、ソフトウエア・トラツプ発生
命令実行直前には、実線の矢印(30)のようにスタツク
位置〔SP0〕を指しているが、ソフトウエア・トラツプ
発生命令実行により戻りアドレスを含む情報がスタツク
の一番上である領域(21b)に保存されると、破線の矢
印(31b)のようにスタツク位置〔SP1b〕を指すように
なる。また、プログラムSの実行時に何等かの目的のた
めに領域(22)が使用されるとすると、システム・プロ
グラムSからサブルーチンBを呼び出す直前には、スタ
ツク・ポインタは破線の矢印(32)のようになり、スタ
ツク位置〔SP2〕を指す。次いで、サブルーチンBを呼
び出すと、戻りアドレスを含む情報がスタツクの一番上
である領域(23)に保存され、スタツク・ポインタは破
線の矢印(33)のようにスタツク位置〔SP3〕を指すよ
うになる。
In such a computer, the stack grows dynamically every time a program or subroutine is called.
For example, when the program A calls the system program S by a software trap generation instruction and the called system program S calls the subroutine B, the stack changes as shown in FIG. The stack pointer (2) points to the stack position [SP0] as indicated by the solid arrow (30) immediately before the execution of the software trap generation instruction, but the return address is set by the execution of the software trap generation instruction. When the contained information is stored in the area (21b) which is the top of the stack, the stack position [SP1b] is pointed to as shown by the broken arrow (31b). Further, if the area (22) is used for some purpose when the program S is executed, the stack pointer is indicated by a broken arrow (32) immediately before the subroutine B is called from the system program S. And indicates the stack position [SP2]. Then, when subroutine B is called, the information including the return address is stored in the area (23) at the top of the stack, and the stack pointer points to the stack position [SP3] as indicated by the broken arrow (33). become.

この例において、サブルーチンBの実行が、ソフトウ
エア・トラツプ発生命令によつて(21b)の領域に退避
されたプログラムAの情報によつて制御されるとする。
例えば、(21b)の領域に割込み許可の識別情報が含ま
れており、サブルーチンBの実行中に発生した割込み要
求に対し割込みの許可をこの識別情報によつて決定する
ような場合が考えられる。このような場合の処理には次
の2通りの方法が考えられる。
In this example, it is assumed that the execution of the subroutine B is controlled by the information of the program A saved in the area (21b) by the software trap generation instruction.
For example, it is conceivable that the area (21b) contains identification information for permitting interrupts, and the permission for interrupts for interrupt requests generated during the execution of the subroutine B is determined based on this identification information. The following two methods can be considered for processing in such a case.

一つは、ソフトウエア・トラツプ発生命令によつて
(21b)の領域に退避された情報から識別情報を参照す
るという方法である。
One is a method of referring to the identification information from the information saved in the area (21b) by the software trap generation instruction.

それには、まず、サブルーチン呼び出しやトラツプお
よび割込み時に、以前のサブルーチン呼び出しやトラツ
プおよび割込み時に保存した情報の記憶場所を示すスタ
ツク位置を、戻りアドレスとともに保存する必要があ
る。そして、サブレーチンBから領域(21b)の識別情
報を参照する時には、領域(23)に退避された情報か
ら、領域(21b)を示すスタツク位置を知り、その結果
によつて目的とする識別情報を参照する、という手続き
をとらなければならない。
To do so, first, at the time of subroutine call, trap and interrupt, it is necessary to save the stack position indicating the storage location of the information saved at the time of the previous subroutine call, trap and interrupt together with the return address. Then, when the identification information of the area (21b) is referred from the subretin B, the stack position indicating the area (21b) is known from the information saved in the area (23), and the target identification information is obtained from the result. You must take the procedure of referencing.

もう一つは、サブルーチンBで用いられる識別情報を
それぞれの呼び出しの際にパラメータとして引き渡すと
いう方法である。そのためには、システム・プログラム
SからサブルーチンBを呼び出す際に、領域(21b)の
中の識別情報を領域(23)にコピーするという手続きを
とらねばならない。この場合、サブルーチンBからの識
別情報の参照は領域(23)にある元の識別情報のコピー
を参照する。
The other is a method of passing the identification information used in the subroutine B as a parameter at the time of each call. For that purpose, when the subroutine B is called from the system program S, a procedure of copying the identification information in the area (21b) to the area (23) must be taken. In this case, the reference of the identification information from the subroutine B refers to the copy of the original identification information in the area (23).

この例のように呼び出しの段数が少ない場合は識別情
報参照のための余分な手続きは余り問題にならないが、
何段階にも入れ子で呼ばれているサブルーチンや再帰的
に呼び出されているサブルーチンから識別情報を参照す
る場合等は、この余分な手続きは処理の効率を大きく低
下させるものである。また、後者の方法では、識別情報
参照時の効率は前者に比べてよいが、呼び出しごとに識
別情報をコピーするため、コピーのための無駄な記憶領
域を必要とする。この無駄は、識別情報のサイズが大き
くなつたり、呼び出しの入れ子の段数が大きくなるにつ
れて増加する。
When the number of stages of calls is small as in this example, the extra procedure for referring to the identification information does not become a problem,
When referring to the identification information from a subroutine called in a nested manner or a subroutine called recursively in any number of stages, this extra procedure greatly reduces the processing efficiency. Further, in the latter method, the efficiency at the time of referring to the identification information is better than that in the former method, but since the identification information is copied for each call, an unnecessary storage area for copying is required. This waste increases as the size of the identification information increases and the number of nesting stages of the call increases.

〔発明が解決しようとする問題点〕[Problems to be solved by the invention]

従来の技術では、ソフトウエア・トラツプ発生命令に
より直接的または間接的に呼び出されたプログラムやサ
ブルーチンを実行する際、ソフトウエア・トラツプ発生
時に主記憶装置に退避された呼び出し側プログラムの情
報を参照するのは非常に困難であり、割込み許可等の細
かい制御が複雑な処理となつてしまう、という問題点が
ある。
In the prior art, when executing a program or subroutine called directly or indirectly by a software trap generation instruction, the information of the calling program saved in the main memory when the software trap occurs is referred to. Is very difficult, and there is a problem that fine control such as interrupt permission is complicated processing.

この発明は、上記のような問題点を解消するためにな
されたもので、ソフトウエア・トラツプ発生命令により
直接的または間接的に呼び出されたプログラムやサブル
ーチンを実行する際に、ソフトウエア・トラツプ発生時
に主記憶装置に退避された呼び出し側プログラムの情報
を容易に参照することができる計算機を得ることを目的
とする。
The present invention has been made to solve the above problems, and when a program or subroutine called directly or indirectly by a software trap generation instruction is executed, a software trap generation occurs. It is an object of the present invention to obtain a computer that can easily refer to the information of the calling program saved in the main storage device at times.

〔問題点を解決するための手段〕[Means for solving problems]

この発明にかかる計算機は、ソフトウェア・トラップ
発生命令を含むプログラム呼び出しが発生した時にレジ
スタに保持されているデータを一時格納する後入れ先出
し方式のスタックメモリと、プログラム呼び出し時に、
呼び出し側のプログラムに復帰させるための戻りアドレ
スを含むデータが退避されている前記スタックメモリの
スタック完了位置を示すスタックアドレスを更新し、保
持する第1の保持手段と、ソフトウェア・トラップ発生
命令の発生時のみに、呼び出し側のプログラムに復帰さ
せるための戻りアドレスを含むデータが退避されている
前記スタックメモリのスタック完了位置を示すスタック
アドレスを更新し、保持する第2の保持手段と、第1の
ソフトウェア・トラップ発生命令の実行中に第2のソフ
トウェア・トラップ発生命令が発生すると、呼び出し側
のプログラムに復帰させるための戻りアドレスを含むデ
ータと前記第2の保持手段に格納されている第1のスタ
ックアドレスとを前記スタックメモリに退避させ、スタ
ック完了位置を示す第2のスタックアドレスを前記第2
の保持手段に格納させる制御手段とを備えて構成され
る。
A computer according to the present invention is a stack memory of a first-in first-out type that temporarily stores data held in a register when a program call including a software trap generation instruction occurs, and a program call,
First holding means for updating and holding a stack address indicating a stack completion position of the stack memory in which data including a return address for returning to the calling program is saved, and generation of a software trap generation instruction Only when, the second holding means for updating and holding the stack address indicating the stack completion position of the stack memory in which the data including the return address for returning to the calling program is saved is stored; When the second software trap generation instruction is generated during execution of the software trap generation instruction, data including a return address for returning to the calling program and the first storage stored in the second holding means. The stack address and the stack address are saved in the stack memory to indicate the stack completion position. Wherein the second stack address second
And a control means for storing it in the holding means.

〔作用〕[Action]

この発明における第2の保持手段は、ソフトウエア・
トラツプ発生時に主記憶装置に退避された情報の記憶位
置を保持し、ソフトウエア・トラツプ発生命令により直
接的または間接的に呼び出されたプログラムやサブルー
チン実行時にそれらの情報参照を容易にする。
The second holding means in the present invention is software.
The storage location of the information saved in the main memory when a trap occurs is held, and the information is easily referred to when a program or subroutine called directly or indirectly by a software trap generation instruction is executed.

この発明における制御手段は、ソフトウエア・トラツ
プ発生命令を実行する前のプログラムの実行状態やソフ
トウエア・トラツプ処理専用ポインタの内容あるいはこ
れ以外の何等かの情報を、スタツク機構により主記憶装
置に退避し、その記憶位置を前記ソフトウエア・トラツ
プ処理専用ポインタに格納する。
The control means according to the present invention saves the execution state of the program before executing the software trap generation instruction, the contents of the software trap processing dedicated pointer or any other information to the main storage device by the stack mechanism. Then, the storage location is stored in the software trap processing dedicated pointer.

〔実施例〕〔Example〕

以下、この発明の一実施例を図に従つて説明する。第
1図はこの発明の一実施例による計算機のブロツク図で
ある。(1)はソフトウエア・トラツプ処理専用のポイ
ンタ、(7)主記憶装置、(3)は実行する命令が格納
されている主記憶装置内のアドレスを保持するプログラ
ム・カウンタ、(2)は主記憶装置(7)にラストイン
・フアーストアウト形式で蓄積されているデータの最上
位位置を示すスタツク・ポインタ、(4)は少なくとも
1つ以上の汎用または専用のレジスタ、(5)は計算機
の制御フラグや状態フラグを含む制御レジスタ、(6a)
は制御手段である。主記憶装置(7)には、ラストイン
・フアーストアウト形式でデータを蓄積するためのスタ
ツク領域(8)が設けられ、この領域に蓄積されている
データの最上位位置をスタツクポインタ(2)が指して
いる。また、制御手段(6a)は、プログラム・カウンタ
(3)の示す主記憶装置(7)上の位置から取り出した
命令を解釈し命令の実行制御を行うとともに、前記ソフ
トウエア・トラツプ処理専用ポインタ(1)、プログラ
ム・カウンタ(3)、スタツク・ポインタ(2)、レジ
スタ(4)、制御レジスタ(5)、および、主記憶装置
(7)との間のデータ授受制御を行うものである。
An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram of a computer according to an embodiment of the present invention. (1) is a pointer dedicated to software trap processing, (7) is a main memory device, (3) is a program counter that holds an address in the main memory device in which an instruction to be executed is stored, and (2) is a main memory device. A stack pointer indicating the highest position of the data stored in the storage device (7) in the last-in-first-out format, (4) at least one general-purpose or special-purpose register, and (5) of the computer. Control register, including control flags and status flags, (6a)
Is a control means. The main storage device (7) is provided with a stack area (8) for storing data in the last-in / first-out format, and the stack pointer (2) is set to the highest position of the data stored in this area. ) Is pointing. Further, the control means (6a) interprets an instruction fetched from a position on the main storage device (7) indicated by the program counter (3) and controls the execution of the instruction, and at the same time, the software trap processing dedicated pointer ( 1), a program counter (3), a stack pointer (2), a register (4), a control register (5), and a main memory device (7) are used for data transfer control.

この発明の前記実施例の計算機におけるソフトウエア
・トラツプ発生命令実行時の動作について説明する。第
2図は前記計算機のソフトウエア・トラツプ発生命令実
行前後の主記憶装置内のスタツクの状態図である。ソフ
トウエア・トラツプ発生命令実行直前には、スタツク・
ポインタ(2)は、スタツク位置〔S0〕を保持し、矢印
(9)で示されるように、これまでのプログラムの実行
によつてスタツク領域(8)内に蓄積されたデータの最
上位位置を指している。また、ソフトウエア・トラツプ
処理専用ポインタ(1)は、矢印(11)で示されるよう
に、以前のソフトウエア・トラツプ発生命令によつて退
避された情報のスタツク位置を保持している。ソフトウ
エア・トラツプ発生命令が実行されると、ソフトウエア
・トラツプ処理専用ポインタ(1)の内容や戻りアドレ
スを含む情報がスタツク領域のスタツク位置〔S0+1〕
からスタツク位置〔S1a〕の間に保存され、スタツク・
ポインタ(2)とソフトウエア・トラツプ処理専用ポイ
ンタ(1)の内容が、ともに矢印(10a)および、(1
2)で示されるように、スタツク位置〔S1a〕に更新され
る。すなわち、矢印(11)が第1のソフトウェア・トラ
ップ発生命令の発生時にスタック・メモリに退避させた
データとした場合、矢印(12)が第2のソフトウェア・
トラップ発生命令の発生時にスタック・メモリに退避さ
せたデータとなる。次いで、それぞれの計算機あるいは
オペレーテイング・システムにより決められている特定
のプログラムの先頭アドレスがプログラム・カウンタ
(3)に格納される。従つて、次の命令はこのプログラ
ム・カウンタ(3)に格納された主記憶装置のアドレス
から取り出され実行される。以上述べた制御は制御手段
(6a)が行う。
The operation at the time of executing the software trap generation instruction in the computer of the above embodiment of the present invention will be described. FIG. 2 is a state diagram of the stack in the main memory before and after the execution of the software trap generation instruction of the computer. Just before executing the software trap generation instruction, the stack
The pointer (2) holds the stack position [S0] and, as shown by the arrow (9), indicates the highest position of the data accumulated in the stack area (8) by the execution of the program so far. pointing. The software trap processing dedicated pointer (1) holds the stack position of the information saved by the previous software trap generation instruction, as indicated by the arrow (11). When the software trap generation instruction is executed, the information including the contents of the software trap processing dedicated pointer (1) and the return address is transferred to the stack position [S0 + 1] of the stack area.
From the stack position [S1a] to the stack.
The contents of the pointer (2) and the pointer for software trap processing (1) are both indicated by arrows (10a) and (1).
As shown in 2), it is updated to the stack position [S1a]. That is, when the arrow (11) is the data saved in the stack memory when the first software trap generation instruction occurs, the arrow (12) indicates the second software
It is the data saved in the stack memory when the trap generation instruction is generated. Then, the start address of a specific program determined by each computer or operating system is stored in the program counter (3). Therefore, the next instruction is fetched from the main memory address stored in the program counter (3) and executed. The control described above is performed by the control means (6a).

スタツク位置〔S0+1〕からスタツク位置〔S1a〕の
間に保存される情報は、ソフトウエア・トラツプ処理専
用ポインタ(1)の内容やプログラム・カウンタ(3)
の内容(戻りアドレス)の他、制御レジスタ(5)の内
容、汎用または専用レジスタ(4)の内容、主記憶装置
内の特定のデータ等が考えられる。
The information stored between the stack position [S0 + 1] and the stack position [S1a] is the contents of the software trap processing dedicated pointer (1) and the program counter (3).
In addition to the contents (return address) of (1), the contents of the control register (5), the contents of the general-purpose or special-purpose register (4), specific data in the main memory, etc.

この計算機においても、スタツクはプログラムやサブ
ルーチンを呼び出すごとに動的に成長し、それにともな
つて、スタツク・ポインタの内容も動的に変化する。し
かし、ソフトウエア・トラツプ処理専用ポインタ(1)
の内容はソフトウエア・トラツプの処理が終了するか、
あるいは、新たに別のソフトウエア・トラツプ発生命令
が実行されるまで変化しない。例えば、プログラムAが
ソフトウエア・トラツプ発生命令によりシステム・プロ
グラムSを呼び出し、呼び出されたシステム・プログラ
ムSがサブルーチンBを呼び出した場合、スタツクの変
化は第3図のようになる。ソフトウエア・トラツプ発生
命令実行直前には、ソフトウエア・トラツプ処理専用ポ
インタ(1)は、破線の矢印(40)のように以前のソフ
トウエア・トラツプ発生命令によつて主記憶装置によつ
て退避された情報のスタツク位置を指しており、スタツ
ク・ポインタ(2)は、実線の矢印(30)のようにスタ
ツク位置〔SP0〕を指しているが、ソフトウエア・トラ
ツプ発生命令実行によりソフトウエア・トラツプ処理専
用ポインタ(1)の内容および戻りアドレスを含む何等
かの情報がスタツクの一番上である領域(21a)に保存
されると、ソフトウエア・トラツプ処理専用ポインタ
(1)およびスタツク・ポインタ(2)はともに実線の
矢印(41)や破線の矢印(31a)のようにスタツク位置
〔SP1a〕を指すようになる。また、プログラムSの実行
時に何等かの目的のために領域(22)が使用されるとす
ると、システム・プログラムSからサブルーチンBを呼
び出す直前には、スタツクポインタ(2)は破線の矢印
(32)のようになり、スタツク位置〔SP2〕を指す。次
いで、サブルーチンBを呼び出すと戻りアドレスを含む
何等かの情報がスタツクの一番上である領域(23)に保
存され、スタツク・ポインタ(2)は破線の矢印(33)
のようにスタツク位置〔SP3〕を指すようになる。しか
し、ソフトウエア・トラツプ処理専用ポインタの内容は
ソフトウエア・トラツプの処理がすべて終了するか、新
たに別のソフトウエア・トラツプ発生命令が実行される
まで変化しない。例えば、サブルーチンB実行時に新た
にソフトウエア・トラツプ発生命令が実行された場合、
すなわち、矢印(12)が第1のソフトウェア・トラップ
発生命令の発生時にスタック・メモリに退避させたデー
タであり、サブルーチンB実行時に新たに実行されるソ
フトウェア・トラップ発生命令を第2のソフトウェア発
生命令とした場合、上述と同様にソフトウエア・トラツ
プ処理専用ポインタ(1)の内容および戻りアドレスを
含む情報がスタツクに退避され、新たな値がソフトウエ
ア・トラツプ処理専用ポインタ(1)に格納される。し
かし、この新たなソフトウエア・トラツプの処理が終了
すると退避されているソフトウエア・トラツプ処理専用
ポインタ(1)の内容をスタツクから復帰することによ
り前の状態を復元することができる。
Also in this computer, the stack grows dynamically every time a program or a subroutine is called, and the contents of the stack pointer dynamically change accordingly. However, the pointer for software trap processing (1)
The contents of the, when the processing of the software trap is completed,
Alternatively, it does not change until another software trap generation instruction is newly executed. For example, when the program A calls the system program S by the software trap generation instruction and the called system program S calls the subroutine B, the stack changes as shown in FIG. Immediately before the execution of the software trap generation instruction, the software trap processing dedicated pointer (1) is saved in the main memory by the previous software trap generation instruction as indicated by the dashed arrow (40). The stack pointer (2) points to the stack position [SP0] as indicated by the solid arrow (30), but the stack pointer (2) points to the stack position of the stored information. When some information including the contents of the trap processing dedicated pointer (1) and the return address is stored in the area (21a) at the top of the stack, the software trap processing dedicated pointer (1) and the stack pointer Both (2) indicate the stack position [SP1a] as indicated by the solid arrow (41) and the broken arrow (31a). Further, if the area (22) is used for some purpose when the program S is executed, the stack pointer (2) has a broken arrow (32) immediately before the subroutine B is called from the system program S. ), And indicates the stack position [SP2]. Then, when subroutine B is called, some information including the return address is stored in the area (23) at the top of the stack, and the stack pointer (2) is indicated by the broken arrow (33).
The stack position [SP3] is pointed like. However, the contents of the software trap processing-dedicated pointer do not change until the software trap processing is completed or another software trap generation instruction is newly executed. For example, if a new software trap generation instruction is executed when subroutine B is executed,
That is, the arrow (12) is the data saved in the stack memory when the first software trap generation instruction is generated, and the software trap generation instruction newly executed when the subroutine B is executed is changed to the second software generation instruction. In this case, the contents including the contents of the software trap processing dedicated pointer (1) and the return address are saved in the stack as described above, and a new value is stored in the software trap processing dedicated pointer (1). . However, when the processing of this new software trap is completed, the previous state can be restored by restoring the contents of the saved software trap processing dedicated pointer (1) from the stack.

この例において、サブルーチンBの実行が、ソフトウ
エア・トラツプ発生命令によつて(21a)の領域に退避
されているプログラムAの情報によつて制御されるとす
る。例えば、(21a)の領域に割込み許可の識別情報が
含まれており、サブルーチンBの実行中に発生した割込
み要求に対し割込みの許可をこの識別情報によつて決定
するような場合等が考えられる。このような場合には、
ソフトウエア処理専用のポインタ(1)の内容から領域
(21a)に退避された情報内の識別情報の位置を割出せ
ば直ちに識別情報は参照できる。ソフトウエア・トラツ
プ発生命令実行時に退避される情報の形式は、それぞれ
の計算機に固有のものであり、識別情報の位置は常にソ
フトウエア・トラツプ処理専用ポインタ(1)が指すス
タツク位置の内容から一定の値だけ離れた位置にある。
従つて、識別情報をサブルーチンBから参照する場合だ
けでなく、ソフトウエア・トラツプ発生命令によつて直
接的または間接的に呼び出されたどの様なプログラムお
よびサブルーチンからでも、別のソフトウエア・トラツ
プが実行中でない限り同様にして参照できる。
In this example, it is assumed that the execution of the subroutine B is controlled by the information of the program A saved in the area (21a) by the software trap generation instruction. For example, there may be a case where the area (21a) contains interrupt permission identification information and the interrupt permission for the interrupt request generated during the execution of the subroutine B is determined by this identification information. . In such cases,
If the position of the identification information in the information saved in the area (21a) is calculated from the content of the pointer (1) dedicated to software processing, the identification information can be referred to immediately. The format of the information saved when the software trap generation instruction is executed is unique to each computer, and the position of the identification information is always constant from the contents of the stack position pointed to by the software trap processing dedicated pointer (1). They are separated by the value of.
Therefore, not only when the identification information is referred to from the subroutine B, but also from any program or subroutine called directly or indirectly by the software trap generation instruction, another software trap is You can refer to it in the same way as long as it is not running.

なお、上記実施例においては、主記憶装置内のスタツ
ク領域(8)およびスタツク・ポインタ(2)の数はそ
れぞれ1つであつたが、複数のスタツク領域および複数
のスタツク・ポインタが設けられていて、ソフトウエア
・トラツプ処理専用ポインタ(1)とそれ以外の情報が
別々のスタツクに退避されたり、ソフトウエア・トラツ
プ発生命令によつてスタツクが別のスタツクに切り換え
られたり、さらには、ソフトウエア・トラツプ処理専用
ポインタ(1)のための専用のスタツクを新たに別の記
憶装置(例えばレジスタ・スタツクやキヤツシユ・メモ
リ)を設けることにより実現してもよい。何れの場合に
も、上記実施例と同様の効果が得られる。
In the above embodiment, the number of stack areas (8) and the stack pointers (2) in the main memory is one, but a plurality of stack areas and a plurality of stack pointers are provided. The software trap processing pointer (1) and other information are saved in different stacks, the stack is switched to another stack by a software trap generation instruction, and The dedicated stack for the trap processing dedicated pointer (1) may be realized by newly providing another storage device (for example, a register stack or a cache memory). In any case, the same effect as the above embodiment can be obtained.

〔発明の効果〕〔The invention's effect〕

以上のように、この発明によれば、ソフトウェア・ト
ラップ発生命令を含むプログラム呼び出し時にその内容
が更新され常に最新のスタック完了位置を示すスタック
アドレスを保持する第1の保持手段に加え、ソフトウェ
ア・トラップ発生命令処理専用の第2の保持手段と、第
1のソフトウェア・トラップ発生命令の実行中に第2の
ソフトウェア・トラップ発生命令が発生した場合に第2
の保持手段にスタック完了位置を示すアドレスを格納さ
せる制御手段とを設けたことにより、第2の保持手段
は、任意の時点において、その時点から遡って最後に発
生したソフトウェア・トラップ発生命令の発生時のスタ
ック完了位置を示すアドレスを保持することができる。
As described above, according to the present invention, in addition to the first holding means for holding the stack address indicating the latest stack completion position, the contents of which are updated when the program including the software trap generation instruction is called, the software trap is also added. Second holding means dedicated to the processing of the generated instruction and second when the second software trap generating instruction is generated during execution of the first software trap generating instruction.
By providing the control means for storing the address indicating the stack completion position in the second holding means, the second holding means, at an arbitrary time point, generates the last software trap generation instruction that is traced back from that time point. An address indicating the stack completion position at the time can be held.

したがって、ソフトウェア・トラップ発生命令によっ
て呼び出された種々のプログラムから、第2の保持手段
に格納されたスタック完了位置を示すアドレスに基づ
き、当該プログラムを呼び出したソフトウェア・トラッ
プ発生命令の発生時にスタックメモリに退避させたデー
タを容易に参照することができる。
Therefore, from the various programs called by the software trap generation instruction, the stack memory is stored in the stack memory when the software trap generation instruction that calls the program is generated based on the address indicating the stack completion position stored in the second holding unit. The saved data can be easily referenced.

【図面の簡単な説明】[Brief description of drawings]

第1図は、この発明の一実施例による計算機のブロツク
図、第2図は、前記計算機におけるソフトウエア・トラ
ツプ発生命令実行前後の主記憶装置内のスタツクの状態
変化を示す図、第3図は、前記計算機のソフトウエア・
トラツプ処理実行例におけるスタツクの変化を示す図、
第4図は、ソフトウエア・トラツプ発生命令を持つ従来
の計算機の構成図、第5図は、従来の計算機のソフトウ
エア・トラツプ発生命令実行前後の主記憶装置内のスタ
ツクの状態変化を示す図、第6図は、従来の計算機のソ
フトウエア・トラツプ処理実行例におけるスタツクの変
化を示す図である。 (1)はソフトウエア・トラツプ処理専用ポインタ、
(7)は主記憶装置、(3)はプログラム・カウンタ、
(2)はスタツク・ポインタ、(4)は汎用または専用
のレジスタ、(5)は制御レジスタ、(6a)および(6
b)は制御手段である。 なお、各図中同一符号は同一または相当部分を示す。
FIG. 1 is a block diagram of a computer according to an embodiment of the present invention, and FIG. 2 is a diagram showing a state change of a stack in a main memory before and after execution of a software trap generation instruction in the computer. Is the software of the computer
The figure which shows the change of the stack in the trap processing execution example,
FIG. 4 is a block diagram of a conventional computer having a software trap generation instruction, and FIG. 5 is a diagram showing a state change of a stack in a main memory before and after execution of a software trap generation instruction of the conventional computer. FIG. 6 is a diagram showing a stack change in a software trap processing execution example of a conventional computer. (1) is a pointer dedicated to software trap processing,
(7) is the main memory, (3) is the program counter,
(2) is a stack pointer, (4) is a general-purpose or dedicated register, (5) is a control register, and (6a) and (6).
b) is a control means. In the drawings, the same reference numerals indicate the same or corresponding parts.

───────────────────────────────────────────────────── フロントページの続き (56)参考文献 特開 昭59−94147(JP,A) トランジスタ技術、1982年1月号、昭 和57年1月1日、CQ出版株式会社P. 248−251、P.272−277 ─────────────────────────────────────────────────── ─── Continuation of the front page (56) Reference JP-A-59-94147 (JP, A) Transistor Technology, January 1982, January 1, 1982, CQ Publishing Co., Ltd. P. 248-251 , P .; 272-277

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】ソフトウェア・トラップ発生命令を含むプ
ログラム呼び出しが発生した時にレジスタに保持されて
いるデータを一時格納する後入れ先出し方式のスタック
メモリと、 プログラム呼び出し時に、呼び出し側のプログラムに復
帰させるための戻りアドレスを含むデータが退避されて
いる前記スタックメモリのスタック完了位置を示すスタ
ックアドレスを更新し、保持する第1の保持手段と、 ソフトウェア・トラップ発生命令の発生時のみに、呼び
出し側のプログラムに復帰させるための戻りアドレスを
含むデータが退避されている前記スタックメモリのスタ
ック完了位置を示すスタックアドレスを更新し、保持す
る第2の保持手段と、 第1のソフトウェア・トラップ発生命令の実行中に第2
のソフトウェア・トラップ発生命令が発生すると、呼び
出し側のプログラムに復帰させるための戻りアドレスを
含むデータと前記第2の保持手段に格納されている第1
のスタックアドレスとを前記スタックメモリに退避さ
せ、スタック完了位置を示す第2のスタックアドレスを
前記第2の保持手段に格納させる制御手段とを備えたこ
とを特徴とする計算機。
1. A first-in, first-out stack memory for temporarily storing data held in a register when a program call including a software trap generation instruction occurs, and for returning to a calling program at the time of program call. First holding means for updating and holding the stack address indicating the stack completion position of the stack memory in which the data including the return address of the above is saved, and the calling program only when the software trap generation instruction is generated. Second holding means for updating and holding the stack address indicating the stack completion position of the stack memory in which the data including the return address for returning to the above is saved, and during execution of the first software trap generation instruction. To the second
When the software trap generation instruction is generated, data including a return address for returning to the calling program and the first holding means stored in the second holding means.
And a control means for storing the second stack address indicating the stack completion position in the second holding means.
JP61197588A 1986-08-22 1986-08-22 calculator Expired - Lifetime JP2500804B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP61197588A JP2500804B2 (en) 1986-08-22 1986-08-22 calculator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP61197588A JP2500804B2 (en) 1986-08-22 1986-08-22 calculator

Publications (2)

Publication Number Publication Date
JPS6353650A JPS6353650A (en) 1988-03-07
JP2500804B2 true JP2500804B2 (en) 1996-05-29

Family

ID=16376984

Family Applications (1)

Application Number Title Priority Date Filing Date
JP61197588A Expired - Lifetime JP2500804B2 (en) 1986-08-22 1986-08-22 calculator

Country Status (1)

Country Link
JP (1) JP2500804B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6362039A (en) * 1986-09-03 1988-03-18 Mitsubishi Electric Corp Computer
JPH03296144A (en) * 1990-04-13 1991-12-26 Fujitsu Ltd Debug control system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5994147A (en) * 1982-11-19 1984-05-30 Toshiba Corp Stack control system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
トランジスタ技術、1982年1月号、昭和57年1月1日、CQ出版株式会社P.248−251、P.272−277

Also Published As

Publication number Publication date
JPS6353650A (en) 1988-03-07

Similar Documents

Publication Publication Date Title
US6367005B1 (en) System and method for synchronizing a register stack engine (RSE) and backing memory image with a processor's execution of instructions during a state saving context switch
US5369770A (en) Standardized protected-mode interrupt manager
US9104425B2 (en) Apparatus and method for handling exception events
US6601146B2 (en) Technique for efficiently transferring moderate amounts of data across address space boundary
US5812868A (en) Method and apparatus for selecting a register file in a data processing system
EP0487082B1 (en) Nesting management mechanism for use in loop control system
US6553487B1 (en) Device and method for performing high-speed low overhead context switch
US6115777A (en) LOADRS instruction and asynchronous context switch
US4942524A (en) Software trap system which saves previous content of software trap handling pointer in a stack upon execution of a trap
JP2004157636A (en) Data processing apparatus
US6065114A (en) Cover instruction and asynchronous backing store switch
JP2500804B2 (en) calculator
US20050125801A1 (en) Method and apparartus for context switching in computer operating systems
JP2561460B2 (en) Software trap control system
JPS61173358A (en) Register recovery device
US6112292A (en) Code sequence for asynchronous backing store switch utilizing both the cover and LOADRS instructions
US7080205B2 (en) Arrangement and method for reducing the processing time of a data processing device
JP3330767B2 (en) Information processing apparatus and trace acquisition method in information processing apparatus
JPS63118949A (en) Information processor
TW480445B (en) Method for downloading application programs on the compiler system platform of an electronic communication device
JP3264449B2 (en) Storage management device in information processing system
JP2683274B2 (en) Function trace output method
JPS59103146A (en) Operation mode display device
JPS61289432A (en) List control system using descriptor
JPH07141207A (en) Information processing system