JPH04266126A - Control system for subroutine call - Google Patents

Control system for subroutine call

Info

Publication number
JPH04266126A
JPH04266126A JP2699691A JP2699691A JPH04266126A JP H04266126 A JPH04266126 A JP H04266126A JP 2699691 A JP2699691 A JP 2699691A JP 2699691 A JP2699691 A JP 2699691A JP H04266126 A JPH04266126 A JP H04266126A
Authority
JP
Japan
Prior art keywords
instruction
subroutine
value
address
program counter
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
JP2699691A
Other languages
Japanese (ja)
Inventor
Toshiya Narasaki
奈良崎 俊也
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.)
NEC Solution Innovators Ltd
Original Assignee
NEC Software Kyushu 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 NEC Software Kyushu Ltd filed Critical NEC Software Kyushu Ltd
Priority to JP2699691A priority Critical patent/JPH04266126A/en
Publication of JPH04266126A publication Critical patent/JPH04266126A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To prevent the runaway of a program caused by execution of a transfer control instruction which calls the subroutine included in an unlinked compiling unit. CONSTITUTION:An instruction 4 transfers 'program counter value + byte number of instruction 3 + byte number of instruction 5' to a stack (steps 1 and 5). An instruction 3 shifts the control to a subroutine if a relative address is not identical with O (step 2). An instruction included in the subroutine transfers the value to a program counter from a stack and shifts the control to the instruction (step 4) following an instruction 5 (step 3). The instruction 3 shifts the control to the instruction 5 if the relative address is identical with O (step 6). Then the instruction 5 transfers the value to the program counter from a stack and shifts the control to the next instruction (step 8) in a step 7 respectively.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、制御転送命令において
相対番地が使用される情報処理装置におけるサブルーチ
ンコール制御方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a subroutine call control system in an information processing apparatus in which relative addresses are used in control transfer instructions.

【0002】0002

【従来の技術】従来、汎用的に使用されることを目的と
する複数のコンパイルユニットから構成されるモジュー
ルにおいて、そのモジュールの利用者がそのなかの一部
のコンパイルユニットが持つ機能を実行させたくない場
合、実行させたくないコンパイルユニットを、何も処理
しないような専用のものに作り替えるか、使用する側を
そのコンパイルユニット機能を使用しないように作り替
える必要があった。
[Background Art] Conventionally, in a module composed of multiple compilation units intended for general use, a user of the module wishes to execute the functions of some of the compilation units. If not, it was necessary to either replace the compilation unit that you do not want to run with a dedicated one that does not process anything, or modify the side that uses it so that it does not use the compilation unit function.

【0003】また、必要のないコンパイルユニットをリ
ンクせずにロードモジュールを作成した場合、リンクし
なかったコンパイルユニットにあるサブルーチンをコー
ルする制御転送命令においてコール先の番地が解決され
ないため、相対番地が0となり、すぐ後の命令を実行し
ていた。
[0003] Furthermore, if a load module is created without linking unnecessary compilation units, the address of the call destination is not resolved in a control transfer instruction that calls a subroutine in the compilation unit that was not linked, so the relative address is 0, and the immediately following command was executed.

【0004】即ち通常のコンパイラでは、ソースプログ
ラムでサブルーチンをコールする命令をオブジェクトに
する際、図3に示す命令1のような機能をもつ命令を作
成する。そしてサブルーチンがコンパイルされる場合そ
のオブジェクトの最後に図3の命令2のような機能をも
つ命令がつけられている。そのためリンク時に、命令1
の相対番地が解決されると、命令1に命令でサブルーチ
ン先に制御が移り、命令2の命令で制御が命令1のすぐ
あとに戻るしくみになっている。ところがこの場合、リ
ンク時に命令1の相対番地が解決されず、0のままだと
するとサブルーチン先に制御が移らず、0番地先の命令
、すなわち命令1のすぐあとを実行することになる。
That is, when a normal compiler converts an instruction that calls a subroutine in a source program into an object, it creates an instruction having a function like instruction 1 shown in FIG. 3. When a subroutine is compiled, an instruction having a function such as instruction 2 in FIG. 3 is attached to the end of the object. Therefore, when linking, instruction 1
When the relative address is resolved, control is transferred to the subroutine using instruction 1, and control is returned to immediately after instruction 1 using instruction 2. However, in this case, if the relative address of instruction 1 is not resolved at the time of linking and remains 0, control will not be transferred to the destination of the subroutine, and the instruction at address 0, that is, immediately after instruction 1, will be executed.

【0005】[0005]

【発明が解決しようとする課題】従来の場合汎用的に使
用されるモジュールでも、一部の機能を実行させたくな
い場合、上記のように、専用のコンパイルユニットが必
要となり、その作成に工数を取られたり、コンパイルユ
ニットの管理が複雑となる欠点があった。また、必要の
ないコンパイルユニットをリンクせずにロードモジュー
ルを作成した場合、リンクしなかったコンパイルユニッ
トにあるサブルーチンをコールする制御転送命令におい
てコール先の番地が解決されないため、相対番地が0と
なっており、その命令が実行された場合制御が移されず
そのまま次の命令を実行して行くためプログラムが暴走
する危険があった。
[Problem to be solved by the invention] Conventionally, even if a module is used for general purposes, if you do not want to execute some functions, a dedicated compilation unit is required as described above, and creating it requires a lot of man-hours. This has the drawback that the management of compilation units is complicated. Additionally, if a load module is created without linking unnecessary compilation units, the call destination address will not be resolved in a control transfer instruction that calls a subroutine in a compilation unit that was not linked, so the relative address will be 0. Therefore, when that instruction is executed, control is not transferred and the next instruction is executed, which poses a risk of the program running out of control.

【0006】[0006]

【課題を解決するための手段】第1の発明は、ロードモ
ジュール作成時にリンクさせなかったコンパイルユニッ
トにあるサブルーチンをコールする転送制御命令におけ
るコール先の相対番地が0になる情報処理装置でのサブ
ルーチンコール制御方式において、スタックポインタの
値をデクリメントしプログラムカウンタの値に予じめ決
められた値を加算した再開アドレスをスタックポインタ
の示すスタックに保存する第一の手段と、前記第一の手
段によって起動され前記コール先の相対番地が0でなけ
れば前記プログラムカウンタの値に前記相対番地を加算
して前記サブルーチンを起動し前記コール先の相対番地
が0であれば前記プログラムカウンタの値の次の番地を
起動する第二の手段と、前記コール先の相対番地が0の
時に前記第二の手段によって起動され前記スタックポイ
ンタの値をデクリメントし前記再開アドレスを前記プロ
グラムカウンタに設定し前記再開アドレスからプログラ
ムを実行させる第三の手段を備えたことを特徴とする。
[Means for Solving the Problems] A first invention provides a subroutine in an information processing device in which the relative address of a call destination in a transfer control instruction that calls a subroutine in a compilation unit that is not linked when creating a load module is 0. In the call control method, a first means stores a restart address obtained by decrementing a value of a stack pointer and adding a predetermined value to a value of a program counter in a stack indicated by the stack pointer; If the relative address of the called destination is 0, the subroutine is started by adding the relative address to the value of the program counter, and if the relative address of the called destination is 0, the subroutine is executed next to the value of the program counter. a second means for activating an address, and a second means activated by the second means when the relative address of the call destination is 0, decrements the value of the stack pointer, sets the restart address in the program counter, and starts from the restart address. The present invention is characterized by having a third means for executing the program.

【0007】[0007]

【実施例】次に、本発明の実施例について図面を参照し
て説明する。
Embodiments Next, embodiments of the present invention will be described with reference to the drawings.

【0008】図1は本発明の一実施例を示す命令の種類
と構成を示す図である。
FIG. 1 is a diagram showing the types and structure of instructions according to an embodiment of the present invention.

【0009】本発明は命令3〜5に示すような機能を持
つ命令を使用する。また、サブルーチンの最後の命令2
の命令は従来通りそのまま使用する。本発明では命令4
を命令3と組み合わせることで従来の命令1と同等の機
能を実現する。ただし、命令4の命令で保存する戻り番
地は「プログラムカウンタの値+命令3のバイト数+命
令5のバイト数」とする。図2(a)はリンク時におい
て命令3の相対番地が解決された場合を示し、命令4(
ステップ1)と命令3(ステップ2)とによって命令1
と同じ条件でサブルーチン先に制御が移り、命令2(ス
テップ3)で命令5の次の命令(ステップ4)に制御が
戻る。図2(b)は命令3の相対番地が解決されず0の
ままの場合を示し、命令4(ステップ5)、命令3(ス
テップ6)の実行後制御はサブルーチンに移らず命令5
(ステップ7)を実行するが、この命令でプログラムカ
ウンタに命令5の次の番地がセットされるため、命令5
の次の命令(ステップ8)を実行することになる。 すなわち命令2に対応する処理が命令5によってとれて
いるため、その後も正常に処理が続く事になる。
The present invention uses instructions having the functions shown in instructions 3 to 5. Also, the last instruction 2 of the subroutine
The command will continue to be used as before. In the present invention, instruction 4
By combining this with instruction 3, the same function as the conventional instruction 1 is realized. However, the return address saved by instruction 4 is "program counter value + number of bytes of instruction 3 + number of bytes of instruction 5." FIG. 2(a) shows a case where the relative address of instruction 3 is resolved at the time of linking, and the relative address of instruction 4 (
instruction 1) by step 1) and instruction 3 (step 2)
Control is transferred to the subroutine under the same conditions as , and control is returned to the instruction following instruction 5 (step 4) at instruction 2 (step 3). FIG. 2(b) shows a case where the relative address of instruction 3 is not resolved and remains 0, and after execution of instruction 4 (step 5) and instruction 3 (step 6), control does not proceed to the subroutine and instruction 5
(Step 7) is executed, but since this instruction sets the address next to instruction 5 in the program counter, instruction 5
The next instruction (step 8) will be executed. In other words, since the processing corresponding to instruction 2 has been taken by instruction 5, the processing continues normally thereafter.

【0010】0010

【発明の効果】本発明により、汎用的に使用されるモジ
ュールにおいて実行させたくない機能を持つコンパイル
ユニットをリンク時に指定しない場合に、リンクしなか
ったコンパイルユニットにあるサブルーチンをコールす
る転送制御命令の実行によるプログラム暴走の危険性を
防ぐ効果がある。
[Effects of the Invention] According to the present invention, when a compilation unit with a function that is not to be executed in a commonly used module is not specified at the time of linking, a transfer control instruction that calls a subroutine in a compilation unit that is not linked. This has the effect of preventing the risk of program runaway due to execution.

【図面の簡単な説明】[Brief explanation of the drawing]

【図1】本発明のサブルーチンコール制御方式の一実施
例を示す命令の種類と構成を示す図である。
FIG. 1 is a diagram showing types and configurations of instructions showing an embodiment of a subroutine call control method of the present invention.

【図2】(a)は本実施例のリンクされたサブルーチン
をコールした場合の動作の一例を示す流れ図であり、(
b)は本実施例のリンクされないサブルーチンをコール
した場合の動作の一例を示す流れ図である。
FIG. 2(a) is a flowchart showing an example of the operation when the linked subroutine of this embodiment is called;
b) is a flowchart showing an example of the operation when an unlinked subroutine of this embodiment is called.

【図3】従来のサブルーチンコールで使用される命令の
種類と構成を示す。
FIG. 3 shows the types and configuration of instructions used in a conventional subroutine call.

【符号の説明】[Explanation of symbols]

ステップ1    命令4 ステップ2    命令3 ステップ3    命令2 ステップ4    次の命令 ステップ5    命令4 ステップ6    命令3 ステップ7    命令5 ステップ8    次の命令 Step 1 Instruction 4 Step 2 Instruction 3 Step 3 Instruction 2 Step 4 Next command Step 5 Instruction 4 Step 6 Instruction 3 Step 7 Instruction 5 Step 8 Next command

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  ロードモジュール作成時にリンクさせ
なかったコンパイルユニットにあるサブルーチンをコー
ルする転送制御命令におけるコール先の相対番地が0に
なる情報処理装置でのサブルーチンコール制御方式にお
いて、スタックポインタの値をデクリメントしプログラ
ムカウンタの値に予じめ決められた値を加算した再開ア
ドレスをスタックポインタの示すスタックに保存する第
一の手段と、前記第一の手段によって起動され前記コー
ル先の相対番地が0でなければ前記プログラムカウンタ
の値に前記相対番地を加算して前記サブルーチンを起動
し前記コール先の相対番地が0であれば前記プログラム
カウンタの値の次の番地を起動する第二の手段と、前記
コール先の相対番地が0の時に前記第二の手段によって
起動され前記スタックポインタの値をデクリメントし前
記再開アドレスを前記プログラムカウンタに設定し前記
再開アドレスからプログラムを実行させる第三の手段を
備えたことを特徴とするサブルーチンコール制御方式。
Claim 1: In a subroutine call control method in an information processing device in which the relative address of the call destination in a transfer control instruction that calls a subroutine in a compilation unit that was not linked when creating a load module is 0, the value of the stack pointer is a first means for saving a restart address obtained by decrementing the value of the program counter and adding a predetermined value to the stack indicated by the stack pointer; If not, a second means for activating the subroutine by adding the relative address to the value of the program counter, and activating an address next to the value of the program counter if the relative address of the called destination is 0; Third means is activated by the second means when the relative address of the call destination is 0, decrements the value of the stack pointer, sets the restart address in the program counter, and causes the program to be executed from the restart address. A subroutine call control method characterized by:
JP2699691A 1991-02-21 1991-02-21 Control system for subroutine call Pending JPH04266126A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2699691A JPH04266126A (en) 1991-02-21 1991-02-21 Control system for subroutine call

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2699691A JPH04266126A (en) 1991-02-21 1991-02-21 Control system for subroutine call

Publications (1)

Publication Number Publication Date
JPH04266126A true JPH04266126A (en) 1992-09-22

Family

ID=12208770

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2699691A Pending JPH04266126A (en) 1991-02-21 1991-02-21 Control system for subroutine call

Country Status (1)

Country Link
JP (1) JPH04266126A (en)

Similar Documents

Publication Publication Date Title
JP2666847B2 (en) Heterogeneous language communication method
JPH01154267A (en) Incorporating system for input/output device control program of operating system
JPH04245543A (en) Method and device for executing subprogram calling and compiler device
US5388263A (en) Procedure state descriptor system for digital data processors
JPH04266126A (en) Control system for subroutine call
JPH05297911A (en) Sequence control circuit for sequence controller
JP2002182931A (en) Common os system call method
JPH02118727A (en) System for calling system sub-routine
JPH03182945A (en) Transfer system for data in main storage
JPS62166444A (en) Program debugging device
JPH0675757A (en) Link system for virtual space resident program
JPH0296244A (en) Program execution system
JPH02231639A (en) Calling system for service program
JPS62212734A (en) Executing system for intermediate code program
JPH02137054A (en) Information processor
JPH064319A (en) Shared routine control system in operating system
JPS62121549A (en) High speed system for os simulator
JPS62216041A (en) Compiler start processing system by command
JPS63158632A (en) System program execution system in interpreter system
JPS62137641A (en) High-grade language compiler
JPS58137069A (en) Multi-processor control system
JPH03218532A (en) Control system for arbitrary starting program
JPH03266023A (en) Dynamic coupling system for variable
JPH05241805A (en) Portable flectronic equipment equipment with c-language library
JPS6365978B2 (en)