JPH05241902A - Software simulator - Google Patents

Software simulator

Info

Publication number
JPH05241902A
JPH05241902A JP4098976A JP9897692A JPH05241902A JP H05241902 A JPH05241902 A JP H05241902A JP 4098976 A JP4098976 A JP 4098976A JP 9897692 A JP9897692 A JP 9897692A JP H05241902 A JPH05241902 A JP H05241902A
Authority
JP
Japan
Prior art keywords
function
stack
processing step
amount
execution
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.)
Granted
Application number
JP4098976A
Other languages
Japanese (ja)
Other versions
JP2747164B2 (en
Inventor
Toshiyuki Noguchi
俊幸 野口
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 IC Microcomputer Systems Co Ltd
Original Assignee
NEC IC Microcomputer Systems 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 NEC IC Microcomputer Systems Co Ltd filed Critical NEC IC Microcomputer Systems Co Ltd
Priority to JP4098976A priority Critical patent/JP2747164B2/en
Publication of JPH05241902A publication Critical patent/JPH05241902A/en
Application granted granted Critical
Publication of JP2747164B2 publication Critical patent/JP2747164B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)
  • Debugging And Monitoring (AREA)

Abstract

PURPOSE:To provide the history of execution to a point, where the amount of used stack exceeds the amount designated by a user, to a program developer in the case of deciding the size of a stack area to be dynamically changed while executing a program. CONSTITUTION:In respect to the conventional software simulator, a stack state display designating amount input processing step 200 is provided just after execution start, and the amount designated by the user is inputted for starting the display of a stack state from an activated line. A stack state display processing step 300 is provided behind a single instruction execution processing step 104 and the point, where the amount of used stacks exceeds the amount designated by the user, is judged. The function names of all the functions executed until the point, where the amount of used stacks exceeds the amount designated by the user, and the amount of used stacks for each function are displayed according to the calling order of functions. Therefore, the size of the stack area can be easily decided.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明はソフトウェア・シミュレ
ータに関し、特にシミュレーションの対象となるマイク
ロプロセサの命令実行時のスタック使用状況の表示に関
する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a software simulator, and more particularly, to displaying a stack usage status during instruction execution of a microprocessor to be simulated.

【0002】[0002]

【従来の技術】従来のマイクロプロセサ用ソフトウェア
・シミュレータにおいて、入力装置からコマンド単位で
動作を指示する処理の全体処理フローを図6に示す。コ
マンド入力処理ステップ100では、入力装置からコマ
ンドを入力し、コマンド解析処理ステップ101ではコ
マンドを解析して、各コマンド処理ステップ102へ分
岐する。コマンド処理ステップ102では、メモリ内容
の表示,レジスタ内容の表示,ステップの実行,あるい
はランの実行等を行なう。
2. Description of the Related Art FIG. 6 shows an overall processing flow of processing for instructing an operation in command units from an input device in a conventional microprocessor software simulator. In the command input processing step 100, a command is input from the input device, and in the command analysis processing step 101, the command is analyzed and branched to each command processing step 102. In the command processing step 102, display of memory contents, display of register contents, execution of steps, execution of runs and the like are performed.

【0003】命令実行系コマンド判定処理ステップ10
3ではステップの実行,ランの実行等の命令実行系のコ
マンドであるか否かを判定する。判定の結果,命令実行
系コマンドの場合には、単一命令実行処理ステップ10
4で命令を実行し、実行後にブレークの条件の成立,命
令実行時の異常,あるいは外部からの強制停止指示等の
発生を命令実行終了判定処理ステップ105で行なう。
その結果に応じて、次の命令を続行するか,あるいはコ
マンド入力処理ステップ100へ分岐し、以降,繰り返
し処理を続行する。
Instruction execution system command determination processing step 10
At 3, it is determined whether the command is an instruction execution type command such as step execution or run execution. If the result of determination is that the command is an instruction execution type command, single instruction execution processing step 10
The instruction is executed in step 4, and after the execution, the break condition is satisfied, the instruction is abnormal at the time of execution, or an external forced stop instruction is generated in the instruction execution end determination processing step 105.
Depending on the result, the next instruction is continued, or the process branches to the command input processing step 100, and the repeating processing is continued thereafter.

【0004】次に、上記説明したソフトウェア・シミュ
レータを使用して、命令実行中のスタック状態を把握
し、適切なスタック領域を決定する方法を説明する。予
め設定したスタック領域が不足している場合、スタック
領域を越えた領域に対してアクセス・ブレーク条件を設
定し、一連の命令を実行させる。ブレーク条件が成立
し、命令実行が停止した地点で、スタックに保存されて
いる状態から、関数の実行経過と各関数でのスタック使
用量とを求め、プログラムのアルゴリズムの変更,ある
いは、関数のパラメータ等の変更によりスタック使用量
を削減する。スタック使用量を削減することができない
場合には、スタック領域を拡張する。ブレーク条件の成
立する箇所が複数ある場合には、上記の作業を複数回行
い、最適なスタック領域を決定する。
Next, a method of grasping the stack state during instruction execution and determining an appropriate stack area using the software simulator described above will be described. If the preset stack area is insufficient, an access break condition is set for the area beyond the stack area and a series of instructions are executed. When the break condition is satisfied and the instruction execution is stopped, the execution history of the function and the stack usage amount of each function are obtained from the state saved in the stack, and the program algorithm is changed or the function parameter is changed. Reduce the stack usage by changing the above. When the stack usage cannot be reduced, the stack area is expanded. When there are a plurality of places where the break condition is satisfied, the above work is performed a plurality of times to determine the optimum stack area.

【0005】[0005]

【発明が解決しようとする課題】解決しようとする問題
は、一連の命令実行中に動的に変化するスタック使用量
に対して、スタック使用量がスタック領域を越えるプロ
グラム箇所を検出していたため、操作が煩雑であるとい
う点である。そのため、スタック使用量がスタック領域
を越えるプログラム箇所を検出するまでの操作が煩雑で
あるという問題があった。
The problem to be solved is to detect a program location where the stack usage exceeds the stack area with respect to the stack usage dynamically changing during execution of a series of instructions. The point is that the operation is complicated. Therefore, there has been a problem that the operation until detecting a program portion whose stack usage amount exceeds the stack area is complicated.

【0006】[0006]

【課題を解決するための手段】本発明のソフトウェア・
シミュレータは、シミュレーションの対象となるマイク
ロプロセサのプログラム実行時に、スタック使用量がユ
ーザ指定量を越えた地点を判定し、スタック使用量がユ
ーザ指定量を超えた地点までに実行した全ての関数の関
数名と、関数毎のスタック使用量とを、関数の呼び出し
順序に従って表示することを特徴とする。
Means for Solving the Problems The software of the present invention
The simulator determines the points where the stack usage exceeds the user specified quantity during program execution of the microprocessor to be simulated, and the functions of all functions executed up to the point where the stack usage exceeds the user specified quantity. It is characterized in that the name and the stack usage amount for each function are displayed in accordance with the function calling order.

【0007】[0007]

【実施例】次に、本発明について図面を参照して説明す
る。図1は、本発明によるソフトウェア・シミュレータ
の一実施例を示す全体処理フローである。図1におい
て、100はコマンド入力処理ステップ,101はコマ
ンド解析処理ステップ,102はコマンド処理ステッ
プ,103は命令実行系コマンド判定処理ステップ,1
04は単一命令実行処理ステップ,105は命令実行終
了判定処理ステップ,200はスタック状態表示指定量
入力処理ステップ,300はスタック状態表示処理ステ
ップである。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be described with reference to the drawings. FIG. 1 is an overall processing flow showing an embodiment of a software simulator according to the present invention. In FIG. 1, 100 is a command input processing step, 101 is a command analysis processing step, 102 is a command processing step, 103 is an instruction execution type command determination processing step, 1
Reference numeral 04 is a single instruction execution processing step, 105 is an instruction execution end determination processing step, 200 is a stack state display designated amount input processing step, and 300 is a stack state display processing step.

【0008】従来形式の処理フローに加えて、開始直後
に、起動行からスタック状態を表示し始めるため、ユー
ザ指定量を入力するためのスタック状態表示指定量入力
処理ステップ200を配置する。さらに、単一命令実行
処理ステップ104の後に、スタック使用量がユーザ指
定量を越える地点を判定し、スタック使用量がユーザ指
定量を超えた地点までに実行した全ての関数の関数名と
関数毎のスタック使用量とを、関数の呼び出し順序に従
って表示するため、スタック状態表示処理ステップ30
0を追加している。
In addition to the conventional process flow, immediately after the start, the stack state display designated amount input processing step 200 for inputting the user designated amount is arranged in order to start displaying the stack state from the startup line. Further, after the single instruction execution processing step 104, a point where the stack usage exceeds the user specified quantity is determined, and the function names of all the functions executed up to the point where the stack usage exceeds the user specified quantity and each function. Stack display amount is displayed in accordance with the function calling order, the stack state display processing step 30
0 is added.

【0009】また、本発明では、図に示すように命令実
行時の関数毎のスタック使用量格納用データ配列(以
降、関数テーブルと称する。)を追加している。関数テ
ーブルのデータ構造は、命令実行中の関数名,関数実行
開始時のスタック・ポインタ(以降,先頭SPと称す
る。)、および関数実行時の最大スタック・ポインタ
(以降,カレントSPと称する。)を一群としたデータ
の要素の連続と、その一群の先頭を示す指示ポインタ
(以降,関数指示ポインタと称する。)とから構成され
ている。
Further, in the present invention, as shown in the figure, a stack use amount storage data array (hereinafter referred to as a function table) for each function at the time of executing an instruction is added. The data structure of the function table is a function name during instruction execution, a stack pointer at the start of function execution (hereinafter referred to as the top SP), and a maximum stack pointer during function execution (hereinafter referred to as the current SP). Is constituted by a series of data elements and a pointer indicating the head of the group (hereinafter referred to as a function pointer).

【0010】図3は、図1に示すスタック状態表示処理
ステップの処理の詳細を示す処理フローである。次に、
図3に従って、スタック状態表示処理ステップ300で
の処理フローを説明する。なお、本実施例では、スタッ
ク領域はメモリの高アドレスから低アドレスの方向に確
保されるマイクロプロセサを想定している。まず、初期
状態判定処理ステップ301で、ソフトウェア・シミュ
レータで命令のシミュレーションが一度も実行されてい
ない初期状態でこの処理を実行したか否かを判定する。
初期状態で、この処理を実行した場合には、関数テーブ
ル作成処理ステップ302で現時点の関数名,先頭S
P,カレントSP,および関数指示ポインタを関数テー
ブルに設定する。さらに、表示フラグ設定処理ステップ
303で表示フラグをオフに初期化する。
FIG. 3 is a processing flow showing the details of the stack state display processing step shown in FIG. next,
The processing flow in the stack status display processing step 300 will be described with reference to FIG. In this embodiment, it is assumed that the stack area is a microprocessor secured in the direction from the high address to the low address of the memory. First, in the initial state determination processing step 301, it is determined whether or not this processing has been executed in an initial state in which instruction simulation has never been executed by the software simulator.
When this processing is executed in the initial state, the function name at the present time, the start S
Set P, current SP, and function pointer to function table. Further, in the display flag setting processing step 303, the display flag is initialized to off.

【0011】次に、前命令実行時からのスタック・ポイ
ンタの変化を、スタック・ポインタ増減判定処理ステッ
プ304で判定する。増減がなかった場合には、そのま
ま処理を終了する。他の関数の呼び出し時の関数への引
数,戻りアドレス,あるいは関数内での一時変数等をス
タック領域へ待避する等の処理でスタック・ポインタが
増加した場合には、最大スタック・ポインタ判定処理ス
テップ305で現時点のスタック・ポインタと、関数指
示ポインタで示しているデータ構造のカレントSPとを
比較する。スタック・ポインタの方がカレントSPより
大きければ、関数テーブル更新処理ステップ306で、
カレントSP領域にスタック・ポインタを格納する。さ
らに、関数名取得処理ステップ307で、命令実行後の
プログラム・カウンタと、予め言語処理プログラムで生
成している関数用シンボル・テーブルとにより現時点で
実行している関数名を得る。
Next, a change in the stack pointer after the execution of the previous instruction is judged in the stack pointer increase / decrease judgment processing step 304. If there is no increase / decrease, the process ends as it is. If the stack pointer increases due to processing such as saving arguments, return addresses, or temporary variables in a function to the stack area when calling another function, the maximum stack pointer determination processing step At 305, the current stack pointer is compared with the current SP of the data structure indicated by the function instruction pointer. If the stack pointer is larger than the current SP, in the function table update processing step 306,
Store the stack pointer in the current SP area. Further, in the function name acquisition processing step 307, the name of the function currently being executed is obtained from the program counter after executing the instruction and the function symbol table generated in advance by the language processing program.

【0012】次に、実行関数変化判定処理ステップ30
8では、命令実行前の実行関数名と,関数名取得処理ス
テップ307で得られた関数名とが異なるか否かを判定
する。異なる場合には、表示フラグ設定処理ステップ3
09で表示フラグをオフに設定する。さらに、関数テー
ブル追加処理ステップ310で関数テーブルの終端に、
現時点での関数名,先頭SP,およびカレントSPを追
加し、関数指示ポインタを更新する。
Next, execution function change determination processing step 30
In step 8, it is determined whether or not the execution function name before executing the instruction is different from the function name obtained in the function name acquisition processing step 307. If they are different, display flag setting processing step 3
At 09, the display flag is set to off. Furthermore, at the function table addition processing step 310, at the end of the function table,
The function name at the present time, the first SP, and the current SP are added, and the function instruction pointer is updated.

【0013】一方、スタック・ポインタ増減判定処理ス
テップ304で、スタック領域からの回復等によりスタ
ック・ポインタが減少した場合には、関数名の取得処理
ステップ307を実行し、実行関数変化判定処理ステッ
プ308で命令実行前の実行関数名と関数名取得処理ス
テップ307で得られた関数名とが異なるか否かを判定
する。同じである場合には、そのまま処理を終了する。
異なる場合には、最初にスタック使用量算出処理ステッ
プ311により、先頭関数のデータ構造の先頭SPから
関数指示ポインタで示しているデータ構造のカレントS
Pを減算して、現時点でのスタック使用量を算出する。
次に、スタック使用量判定処理ステップ312によりユ
ーザ指定量と、求めたスタック使用量とを比較する。ス
タック使用量がユーザ指定量を越えていれば、表示フラ
グ判定処理ステップ313を実行する。
On the other hand, in the stack pointer increase / decrease determination processing step 304, when the stack pointer decreases due to recovery from the stack area or the like, the function name acquisition processing step 307 is executed, and the execution function change determination processing step 308. Then, it is determined whether or not the execution function name before the instruction is executed and the function name obtained in the function name acquisition processing step 307 are different. If they are the same, the processing is terminated as it is.
If they are different, the stack usage amount calculation processing step 311 is executed first to the current S of the data structure indicated by the function instruction pointer from the first SP of the data structure of the first function.
P is subtracted to calculate the current stack usage.
Next, the stack usage amount determination processing step 312 compares the user-specified amount with the obtained stack usage amount. If the stack usage amount exceeds the user specified amount, display flag determination processing step 313 is executed.

【0014】表示フラグがオフであれば、関数名,およ
びスタック使用量の表示処理ステップ314により、現
時点までの関数名,および関数毎のスタック使用量を,
関数の呼び出し順序に従って表示し、表示フラグ設定処
理ステップ315で表示フラグをオンにする。次に、関
数テーブル削除処理ステップ316では、関数指示ポイ
ンタで示しているデータ構造の関数名格納領域を数値の
0で埋め、関数指示ポインタの指示を1つ戻す。これに
より、関数テーブルから命令実行前の関数名,先頭S
P,およびカレントSPを削除し、処理を終了する。ま
た、スタック使用量判定処理ステップ312では、スタ
ック使用量がユーザ指定量を越えていない場合、または
表示フラグ判定処理ステップ313で、表示フラグがオ
ンの場合には、関数テーブル削除処理ステップ316を
実行し、処理を終了する。
If the display flag is off, the function name and stack usage display step 314 displays the function name up to the present time and the stack usage for each function.
The display is performed according to the function calling order, and the display flag is turned on in the display flag setting processing step 315. Next, in the function table deletion processing step 316, the function name storage area of the data structure indicated by the function instruction pointer is filled with the numerical value 0, and the instruction of the function instruction pointer is returned by one. As a result, the function name before the instruction execution from the function table, the head S
P and the current SP are deleted, and the process ends. If the stack usage amount does not exceed the user-specified amount in the stack usage amount determination processing step 312, or if the display flag is on in the display flag determination processing step 313, the function table deletion processing step 316 is executed. Then, the process ends.

【0015】次に、本実施例におけるスタック使用量
が、ユーザ指定量を越えた場合の表示例を説明する。一
例として、ここでは高級言語の一つであるC言語を用い
て説明する。まず、一般的なC言語でのスタックの使用
方法を図4を参照して説明する。図4において、図4
(a) は第1のソース・プログラムを示し、図4(b) はス
タックの使用状況を示している。
Next, a display example in the case where the stack usage amount exceeds the user designated amount in the present embodiment will be described. As an example, the description will be given using C language, which is one of the high-level languages. First, a method of using a stack in general C language will be described with reference to FIG. In FIG.
(a) shows the first source program, and FIG. 4 (b) shows the use status of the stack.

【0016】図4(a) に示す第1のソース・プログラム
400は、関数FUNC2が外部関数であることを宣言
する外部関数宣言部401と、関数func1の始まり
を示す関数宣言部402と、関数func1内で一時変
数i,j,lを宣言している変数宣言部403と、一時
変数i,lに数値を代入する変数代入部404と、i,
lを引数として関数FUNC2を呼び出し、関数FUN
C2の返り値を一時変数jに代入している関数呼び出し
部405とから構成する。この時のスタックの使用状況
を図4(b) に示す。
The first source program 400 shown in FIG. 4 (a) has an external function declaration section 401 that declares that the function FUNC2 is an external function, a function declaration section 402 that indicates the beginning of the function func1, and a function. A variable declaration unit 403 that declares temporary variables i, j, l in func1, a variable assignment unit 404 that assigns a numerical value to the temporary variables i, l, i,
Call the function FUNC2 with l as an argument, and
It is composed of a function calling unit 405 which substitutes the return value of C2 into the temporary variable j. The stack usage status at this time is shown in Fig. 4 (b).

【0017】スタック領域はメモリの高アドレスから低
アドレスの方向に確保されるマイクロプロセッサを想定
しているため図4(a) の変数宣言部403において、一
時変数i,j,lが一時変数格納領域406に積まれ
る。この時点で、スタック・ポインタ409である。次
に、図4(a) の関数呼び出し部405では、引数1と引
数iとが引数格納領域407に積まれ、更に、関数fu
nc1への返り番地が関数への返り番地格納領域408
へ積まれる。この時点で、スタック・ポインタは第2の
スタック・ポインタ410となる。外部関数FUNC2
の実行後、関数funcl内で不用となった関数への返
り番地格納領域408と、引数格納領域407とを開放
するため、スタック・ポインタは第1のスタック・ポイ
ンタ409まで戻される。
Since the stack area is assumed to be a microprocessor secured in the direction from the high address to the low address of the memory, temporary variables i, j and l are stored in the variable declaration section 403 of FIG. 4 (a). Stacked in area 406. At this point, it is the stack pointer 409. Next, in the function calling unit 405 of FIG. 4A, the argument 1 and the argument i are stacked in the argument storage area 407, and further, the function fu
The return address to nc1 is the return address storage area 408 to the function.
Piled up. At this point, the stack pointer becomes the second stack pointer 410. External function FUNC2
After executing, the stack pointer is returned to the first stack pointer 409 in order to release the return address storage area 408 and the argument storage area 407 for the function which is no longer needed in the function funcl.

【0018】図5は、第2のソース・プログラムの構
成,スタック領域の状態,および関数テーブルの状態を
示す説明図である。以上、説明したC言語で一般的なス
タック使用方法にもとづいて、第2のソース・プログラ
ムの実行開始から、スタック使用量がユーザ指定量を越
えた場合の表示例を出力するステップまでを図1〜図3
を参照して説明する。ここで、図5は第2のソースプロ
グラム500を示す説明図である。また、図13はスタ
ック使用量がユーザ指定量を越えた場合の表示例であ
る。
FIG. 5 is an explanatory diagram showing the structure of the second source program, the state of the stack area, and the state of the function table. The process from the start of execution of the second source program to the step of outputting a display example when the amount of stack usage exceeds the amount specified by the user, based on the general method of using the stack in C described above, is shown in FIG. ~ Figure 3
Will be described. Here, FIG. 5 is an explanatory diagram showing the second source program 500. Further, FIG. 13 is a display example when the stack usage amount exceeds the user-specified amount.

【0019】図5に示す第2のソースプログラム500
において、main関数はmain関数宣言部501か
らmain関数の終端部505までによって定義されて
いる。main関数は、一時変数i,jの変数宣言部5
02と,func1関数呼び出し部503と,func
2関数呼び出し部504とから成る。
The second source program 500 shown in FIG.
In, the main function is defined by the main function declaration unit 501 to the main function termination unit 505. The main function is the variable declaration part 5 of the temporary variables i and j.
02, the func1 function calling unit 503, and func
2 function call unit 504.

【0020】func1関数は、func1関数宣言部
506からfunc1関数の終端部508までによって
定義されていて、一時変数xの変数宣言部507から成
る。func2関数は、func2関数宣言部509か
らfunc2関数の終端部512までによって定義され
ていて、一時変数i,jの変数宣言部510と、fun
c3関数呼び出し部511とから成る。func3関数
は、func3関数宣言部513からfunc3関数の
終端部516までによって定義されていて、一時変数x
の変数宣言部514と、func4関数呼び出し部51
5とから成る。func4関数は、func4関数宣言
部517からfunc4関数の終端部519までによっ
て定義されていて、一時変数xの変数宣言部518から
成る。
The func1 function is defined by the func1 function declaring unit 506 to the func1 function terminating unit 508, and includes a variable declaring unit 507 of the temporary variable x. The func2 function is defined by the func2 function declaration unit 509 to the end unit 512 of the func2 function, and the variable declaration unit 510 of the temporary variables i and j and the fun
and a c3 function calling unit 511. The func3 function is defined by the func3 function declaration unit 513 to the end unit 516 of the func3 function, and the temporary variable x
Variable declaration part 514 and func4 function calling part 51
It consists of 5 and. The func4 function is defined by the func4 function declaration unit 517 to the func4 function termination unit 519, and includes the variable declaration unit 518 of the temporary variable x.

【0021】図1のスタック状態表示指定量入力処理ス
テップ200で得られるユーザ指定量を15バイトと
し、main関数が実行されたときのスタック・ポイン
タが7ffeH番地、スタック領域の7ffeH番地と
7fffH番地とには、それぞれmain関数の戻り番
地が格納されているものとする。ここで、C言語のin
t型のサイズは2バイト、記述できる関数名の長さは最
大8文字とする。従って、関数テーブルの関数名格納領
域は固定して8バイトを確保し、8文字未満の関数名の
場合には、残りの領域は数値の0を埋めることにする。
The user designated amount obtained in the stack state display designated amount input processing step 200 of FIG. 1 is set to 15 bytes, and the stack pointer when the main function is executed is 7ffeH, 7ffeH and 7fffH of the stack area. It is assumed that each stores the return address of the main function. Where C language in
The size of the t type is 2 bytes, and the maximum length of the function name that can be described is 8 characters. Therefore, the function name storage area of the function table is fixed to secure 8 bytes, and in the case of a function name of less than 8 characters, the remaining area is filled with the numerical value 0.

【0022】まず、図5のmain関数宣言部501で
は、通常、main関数の関数名のみが存在し、本ソフ
トウェア・シミュレータでシミュレーションを実行すべ
き実行命令は存在しない。変数宣言部502によって一
時変数i,jを宣言した時点では、図2の初期状態判定
処理ステップ301において、命令のシミュレーション
が一度も実行されていない初期状態である。従って、関
数テーブル作成処理ステップ302で図6(b) に示す現
時点の関数テーブルを作成する。更に、表示フラグ設定
処理ステップ303で表示フラグをオフに初期化する。
First, in the main function declaring section 501 of FIG. 5, normally, only the function name of the main function exists, and there is no execution instruction for executing the simulation by the software simulator. At the time when the variable declaration unit 502 declares the temporary variables i and j, in the initial state determination processing step 301 of FIG. 2, the simulation of the instruction has not been executed even once. Therefore, in the function table creation processing step 302, the current function table shown in FIG. 6B is created. Further, in the display flag setting processing step 303, the display flag is initialized to off.

【0023】スタック・ポインタ増減判定処理ステップ
304では、実行前のスタック・ポインタと実行後のス
タック・ポインタとを比較する。ここでは、一時変数
i,jがスタックに積まれ、スタック・ポインタが増加
している。このため、最大スタック・ポインタ判定処理
ステップ305でも、関数指示ポインタで示しているデ
ータ構造のカレントSPの方が現時点のスタック・ポイ
ンタよりも大きくなる。よって、関数テーブル更新処理
ステップ306によって、カレントSP領域にスタック
・ポインタを格納する。更に、関数名取得処理ステップ
307では、関数名としてmainが得られる。次に、
実行関数変化判定処理ステップ308を実行するが、命
令実行前の実行関数名と関数名取得処理ステップ307
で得られた関数名とがともにmainであるため、その
まま処理を終了する。図5の変数宣言部502におい
て、スタックの状態は図6(a) に示すとおりであり、関
数テーブルは図6(b) に示すとおりである。
In the stack pointer increase / decrease determination processing step 304, the stack pointer before execution and the stack pointer after execution are compared. Here, the temporary variables i and j are stacked on the stack and the stack pointer is increased. Therefore, even in the maximum stack pointer determination processing step 305, the current SP of the data structure indicated by the function instruction pointer becomes larger than the current stack pointer. Therefore, the function table update processing step 306 stores the stack pointer in the current SP area. Further, in the function name acquisition processing step 307, main is obtained as the function name. next,
The execution function change determination processing step 308 is executed, but the execution function name before the instruction execution and the function name acquisition processing step 307
Since both the function name obtained in step 1 and main are main, the process is terminated. In the variable declaration unit 502 of FIG. 5, the state of the stack is as shown in FIG. 6 (a), and the function table is as shown in FIG. 6 (b).

【0024】func1関数呼び出し部503では、関
数func1への引数i,jおよび関数func1の戻
り番地がスタックに積まれる。スタックが増加している
ため、最大スタック・ポインタ判定処理ステップ305
でも、関数指示ポインタで示しているデータ構造のカレ
ントSPの方が現時点のスタック・ポインタよりも大き
くなる。よって、関数テーブル更新処理ステップ306
で、スタック・ポインタをカレントSPに格納する。更
に、関数名取得処理ステップ307では、関数名として
func1が得られる。
In the func1 function calling unit 503, the arguments i and j to the function func1 and the return address of the function func1 are stacked on the stack. Since the stack has increased, the maximum stack pointer determination processing step 305
However, the current SP of the data structure indicated by the function instruction pointer becomes larger than the current stack pointer. Therefore, the function table update processing step 306
Then, the stack pointer is stored in the current SP. Further, in the function name acquisition processing step 307, func1 is obtained as the function name.

【0025】次に、実行関数変化判定処理ステップ30
8では、命令実行前の実行関数名mainと関数名取得
処理ステップ307で得られた現時点での関数名とが異
なる。従って、表示フラグ設定処理ステップ309で、
表示フラグをオフに設定する。更に、関数テーブル追加
処理ステップ310によって、関数テーブルの終端に現
時点での関数テーブルの追加処理を行い、処理を終了す
る。図5のfunc1関数呼び出し部503において、
スタックの状態は図7(a) に示すとおりであり、関数テ
ーブルは図7(b) に示すとおりである。
Next, the execution function change judgment processing step 30
8, the execution function name main before executing the instruction is different from the current function name obtained in the function name acquisition processing step 307. Therefore, in the display flag setting processing step 309,
Set the display flag to off. Further, in the function table addition processing step 310, the function table addition processing at the present time is performed at the end of the function table, and the processing ends. In the func1 function calling unit 503 of FIG.
The state of the stack is as shown in FIG. 7 (a), and the function table is as shown in FIG. 7 (b).

【0026】func1関数宣言部506および変数宣
言部507の処理は、以上説明した処理と同様である。
図5の関数func1内の変数宣言部507において、
スタックの状態は図8(a) に示すとおりであり、関数テ
ーブルは図8(b) に示すとおりである。func1関数
の終端部508では、一時変数xがスタック領域から削
除され、main関数に実行が戻り、更に、func1
関数の戻り番地と引数i,jとがスタックから削除され
る。スタック・ポインタが減少しているため、関数名取
得処理ステップ307を実行し、関数名としてmain
を取得する。
The processes of the func1 function declaration unit 506 and the variable declaration unit 507 are the same as the processes described above.
In the variable declaration unit 507 in the function func1 of FIG.
The state of the stack is as shown in FIG. 8 (a), and the function table is as shown in FIG. 8 (b). At the end portion 508 of the func1 function, the temporary variable x is deleted from the stack area, execution returns to the main function, and further, func1
The return address of the function and the arguments i and j are deleted from the stack. Since the stack pointer has decreased, the function name acquisition processing step 307 is executed, and the function name main
To get.

【0027】次に、実行関数変化判定処理ステップ30
8では、命令実行前の実行関数名func1と、関数名
取得処理ステップ307で得られた現時点での関数名と
が異なる。また、先頭関数のデータ構造の先頭SPが7
ffeH、関数指示ポインタで示しているデータ構造の
カレントSPが7ffe4Hである。従って、スタック
使用量算出処理ステップ311を実行し、スタック使用
量が10バイトであることを求める。更に、スタック使
用量判定処理ステップ312では、求められたスタック
使用量10バイトと、ユーザ指定量の15バイトとを比
較し、スタック使用量がユーザ指定量を越えないことを
確認する。そこで、関数削除処理ステップ316で関数
テーブルから関数func1の情報を削除し、処理を終
了する。図5のfunc1関数の終端部508におい
て、スタックの状態は図6(a) に示すとおりであり、関
数テーブル図6(b) に示すとおりである。
Next, execution function change determination processing step 30
8, the execution function name func1 before the instruction execution is different from the current function name obtained in the function name acquisition processing step 307. Further, the first SP of the data structure of the first function is 7
ffeH, the current SP of the data structure indicated by the function instruction pointer is 7ffe4H. Therefore, the stack usage amount calculation processing step 311 is executed to determine that the stack usage amount is 10 bytes. Further, in the stack usage amount determination processing step 312, the obtained stack usage amount of 10 bytes is compared with the user specified amount of 15 bytes, and it is confirmed that the stack usage amount does not exceed the user specified amount. Therefore, in the function deletion processing step 316, the information of the function func1 is deleted from the function table, and the processing ends. In the terminal part 508 of the func1 function in FIG. 5, the state of the stack is as shown in FIG. 6 (a) and the function table in FIG. 6 (b).

【0028】func2関数呼び出し部504,fun
c2関数宣言部509,変数宣言部510,func3
関数呼び出し部511,func3関数宣言部513,
変数宣言部514,func4関数呼び出し部515,
func4関数宣言部517および変数宣言部518の
処理は、以上説明した処理と同様である。図5の変数宣
言部518において、スタックの状態は図9(a) に示す
とおりであり、関数テーブルは図9(b) に示すとおりで
ある。
Func2 function calling unit 504, fun
c2 function declaration part 509, variable declaration part 510, func3
Function calling unit 511, func3 function declaration unit 513,
Variable declaration unit 514, func4 function calling unit 515,
The processes of the func4 function declaration unit 517 and the variable declaration unit 518 are the same as the processes described above. In the variable declaration unit 518 of FIG. 5, the state of the stack is as shown in FIG. 9 (a), and the function table is as shown in FIG. 9 (b).

【0029】func4関数の終端部519では一時変
数xがスタック領域から削除され、func3関数に実
行が戻り、更にfunc4関数の戻り番地と引数iとが
スタックから削除される。スタック・ポインタが減少し
ているため、関数名取得処理ステップ307を実行し、
関数名としてfunc3を取得する。次に、実行関数変
化判定処理ステップ308では、命令実行前の実行関数
名func4と関数名取得処理ステップ307で得られ
た現時点での関数名とが異なる。また、先頭関数のデー
タ構造の先頭SPが7ffeH、関数指示ポインタで示
しているデータ構造のカレントSPが7ffe6Hであ
る。従って、スタック使用量算出処理ステップ311を
実行し、スタック使用量が24バイトであることを求め
る。更に、スタック使用量判定処理ステップ312で
は、求められたスタック使用量24バイトと、ユーザ指
定量の15バイトとを比較し、スタック使用量がユーザ
指定量を越えることを確認する。そこで、表示フラグ判
定処理ステップ313を実行する。
At the end portion 519 of the func4 function, the temporary variable x is deleted from the stack area, execution is returned to the func3 function, and the return address of the func4 function and the argument i are deleted from the stack. Since the stack pointer has decreased, the function name acquisition processing step 307 is executed,
Func3 is acquired as the function name. Next, in the execution function change determination processing step 308, the execution function name func4 before the instruction execution is different from the current function name obtained in the function name acquisition processing step 307. Further, the head SP of the data structure of the head function is 7ffeH, and the current SP of the data structure indicated by the function instruction pointer is 7ffe6H. Therefore, the stack usage calculation step 311 is executed to determine that the stack usage is 24 bytes. Further, in the stack usage amount determination processing step 312, the obtained stack usage amount of 24 bytes is compared with the user specified amount of 15 bytes, and it is confirmed that the stack usage amount exceeds the user specified amount. Therefore, the display flag determination processing step 313 is executed.

【0030】ここで、表示フラグはオフであるため、関
数名およびスタック使用量の表示処理ステップ314で
現時点までの関数名および関数毎のスタック使用量を関
数の呼び出し順序に従って表示し、表示フラグ設定処理
ステップ315で表示フラグをオンにする。更に、関数
削除処理ステップ316で関数テーブルから関数fun
c4の情報を削除し、処理を終了する。図5のfunc
4関数の終端部519において、スタックの状態は図1
0(a)に示すとおりであり、関数テーブルは図10(b)
に示すとおりである。また、関数名およびスタック使用
量表示例は、図13に示すとおりである。
Here, since the display flag is off, in step 314 of displaying the function name and stack usage amount, the function name up to the present time and the stack usage amount for each function are displayed according to the function calling order and the display flag is set. In process step 315, the display flag is turned on. Furthermore, in the function deletion processing step 316, the function fun is deleted from the function table.
The information of c4 is deleted, and the process ends. 5 func
In the terminal portion 519 of the 4-function, the stack state is shown in FIG.
0 (a), and the function table is shown in Fig. 10 (b).
As shown in. The display example of the function name and the stack usage amount is as shown in FIG.

【0031】func3関数の終端部515では、fu
nc4関数の終端部519と同様の処理を実行するが、
表示フラグ判定処理ステップ313以降の処理が異なっ
ている。表示フラグ判定処理ステップ313では、表示
フラグがオンであるため、関数削除処理ステップ316
で関数テーブルから関数func3の情報を削除し、処
理を終了する。図5のfunc3関数の終端部515に
おいて、スタックの状態は図11(a)に示すとおりであ
り、関数テーブルは図11(b) に示すとおりである。図
5のfunc2関数の終端部512において、スタック
の状態は図6(a) に示すとおりであり、関数テーブルは
図6(b) に示すとおりである。図5のmain関数の終
端部505において、スタックの状態は図12(a) に示
すとおりであり、関数テーブルは図12(b) に示すとお
りである。
In the end part 515 of the func3 function, fu
The same processing as the termination unit 519 of the nc4 function is executed,
The processing after the display flag determination processing step 313 is different. In the display flag determination processing step 313, since the display flag is on, the function deletion processing step 316
Then, the information of the function func3 is deleted from the function table, and the process ends. In the terminal part 515 of the func3 function of FIG. 5, the state of the stack is as shown in FIG. 11 (a), and the function table is as shown in FIG. 11 (b). In the terminal part 512 of the func2 function of FIG. 5, the stack state is as shown in FIG. 6 (a), and the function table is as shown in FIG. 6 (b). In the main function termination unit 505 of FIG. 5, the stack state is as shown in FIG. 12 (a), and the function table is as shown in FIG. 12 (b).

【0032】[0032]

【発明の効果】以上説明したように本発明は、プログラ
ム開発者がスタック領域を決定する際、プログラム実行
時に関数名およびスタック使用量を関数の呼び出し順序
に従って表示することにより、最適なスタック・サイズ
を求めるための検出工数およびスタック使用方法の変更
工数を短縮できる効果がある。
As described above, according to the present invention, when the program developer decides the stack area, the function name and the stack usage amount are displayed according to the calling order of the function when the program is executed, so that the optimum stack size can be obtained. This has the effect of reducing the detection man-hours and the man-hours for changing the stack usage method for obtaining

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

【図1】本発明によるソフトウェア・シミュレータの一
実施例を示す全体処理のフローである。
FIG. 1 is a flow of overall processing showing an embodiment of a software simulator according to the present invention.

【図2】スタック状態表示処理のフローである。FIG. 2 is a flow chart of a stack status display process.

【図3】関数テーブルの構成図である。FIG. 3 is a configuration diagram of a function table.

【図4】第1のソース・プログラムの構成、および第1
のソース・プログラムのスタック領域の使用状況を示す
説明図である。
FIG. 4 is a first source program structure and a first
FIG. 6 is an explanatory diagram showing the usage status of the stack area of the source program of FIG.

【図5】第2のソース・プログラムの構成、スタック領
域の状態、および関数テーブルの状態を示す説明図であ
る。
FIG. 5 is an explanatory diagram showing a configuration of a second source program, a state of a stack area, and a state of a function table.

【図6】従来技術によるソフトウェア・シミュレータを
示す全体処理のフローである。
FIG. 6 is an overall processing flow showing a software simulator according to a conventional technique.

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

100〜105,200,300,301〜316 処
理ステップ 400,500 ソース・プログラム 401〜405,501〜519 ソース・プログラム
の構成要素 406〜410 スタック領域の構成要素
100 to 105, 200, 300, 301 to 316 Processing step 400, 500 Source program 401 to 405, 501 to 519 Source program component 406 to 410 Stack area component

─────────────────────────────────────────────────────
─────────────────────────────────────────────────── ───

【手続補正書】[Procedure amendment]

【提出日】平成4年12月22日[Submission date] December 22, 1992

【手続補正1】[Procedure Amendment 1]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】図面の簡単な説明[Name of item to be corrected] Brief description of the drawing

【補正方法】追加[Correction method] Added

【補正内容】[Correction content]

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

【図1】本発明によるソフトウェア・シミュレータの一
実施例を示す全体処理のフローである。
FIG. 1 is a flow of overall processing showing an embodiment of a software simulator according to the present invention.

【図2】スタック状態表示処理のフローである。FIG. 2 is a flow chart of a stack status display process.

【図3】関数テーブルの構成図である。FIG. 3 is a configuration diagram of a function table.

【図4】第1のソース・プログラムの構成、および第1
のソース・プログラムのスタック領域の使用状況を示す
説明図である。
FIG. 4 is a first source program structure and a first
FIG. 6 is an explanatory diagram showing the usage status of the stack area of the source program of FIG.

【図5】第2のソース・プログラムの構成、スタック領
域の状態、および関数テーブルの状態を示す説明図であ
る。
FIG. 5 is an explanatory diagram showing a configuration of a second source program, a state of a stack area, and a state of a function table.

【図6】従来技術によるソフトウェア・シミュレータを
示す全体処理のフローである。
FIG. 6 is an overall processing flow showing a software simulator according to a conventional technique.

【図7】func1関数の呼び出し部のスタック状態を
示す図である。
FIG. 7 is a diagram showing a stack state of a calling unit of a func1 function.

【図8】func1内の変数宣言部のスタック状態,お
よび関数テーブルを示す図である。
FIG. 8 is a diagram showing a stack state of a variable declaration unit in func1 and a function table.

【図9】変数宣言部のスタック状態,および関数テーブ
ルを示す図である。
FIG. 9 is a diagram showing a stack state of a variable declaration part and a function table.

【図10】func4関数の終端部のスタックの状態,
および関数テーブルを示す図である。
FIG. 10 shows the state of the stack at the end of the func4 function,
It is a figure which shows and a function table.

【図11】func3関数の終端部のスタックの状態,
および関数テーブルを示す図である。
FIG. 11 shows the state of the stack at the end of the func3 function,
It is a figure which shows and a function table.

【図12】main関数の終端部のスタックの状態,お
よび関数テーブルを示す図である。
FIG. 12 is a diagram showing a stack state at the end of the main function and a function table.

【図13】関数名およびスタック使用量表示例を示す図
である。
FIG. 13 is a diagram showing a display example of a function name and a stack usage amount.

【図14】マイクロプロセサ用ソフトウェア・シミュレ
ータの入力装置からコマンド単位で動作を指示する処理
の全体処理フローを示す図である。
FIG. 14 is a diagram showing an overall processing flow of processing for instructing an operation in command units from an input device of a software simulator for a microprocessor.

【符号の説明】 100〜105,200,300,301〜316 処
理ステップ 400,500 ソース・プログラム 401〜405,501〜519 ソース・プログラム
の構成要素 406〜410 スタック領域の構成要素
[Description of Reference Signs] 100 to 105, 200, 300, 301 to 316 Processing Steps 400 and 500 Source Program 401 to 405, 501 to 519 Source Program Components 406 to 410 Stack Area Components

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 処理データの保存,回復を目的にしたス
タック機構を有するマイクロプロセサのシミュレーショ
ンにおいて、シミュレーションの対象となるマイクロプ
ロセサのプログラム実行時に、スタック使用量がユーザ
指定量を超えた地点を判定するための判定手段と、 前記スタック使用量がユーザ指定量を超えた地点まで実
行したすべての関数の関数名と前記関数毎のスタック使
用量とを、関数の呼び出し順序に従って表示するための
表示手段とを備えたソフトウェア・シミュレータ。
1. In a simulation of a microprocessor having a stack mechanism for the purpose of saving and recovering processing data, a point where the stack usage exceeds a user specified quantity is determined when a program of the microprocessor to be simulated is executed. Display means for displaying the function names of all the functions executed up to the point where the stack usage exceeds the user specified quantity and the stack usage for each function in accordance with the function calling order. A software simulator with and.
【請求項2】 前記表示手段は関数テーブルの生成を判
定し、生成されていなければ関数テーブルを生成した
後、スタック・ポインタの増減を判定するステップと、 前記スタック・ポインタの増加時にはスタック・ポイン
タがカレントSPよりも大きいか否かを判定して、前者
が後者より大きいときには前記関数テーブルを更新し、
関数名を取得することにより実行関数変化を判定して、
変化時には表示フラグをオフにし、関数テーブルを追加
しするステップと、 前記スタック・ポインタの減少時には前記関数名を取得
して実行関数変化を判定し、変化時にはスタック使用量
を算出した後、ユーザ指定量がスタック使用量より大き
いか否かを判定して、前者が後者より大きいときには関
数名およびスタック使用量を表示し、表示フラグをオン
にして関数テーブルを削除するステップとから成る請求
項1記載のソフトウェア・シミュレータ。
2. The display means determines generation of a function table, and if not generated, generates a function table, and then determines increase / decrease of stack pointer; and when the stack pointer increases, stack pointer Is larger than the current SP, and when the former is larger than the latter, the function table is updated,
By determining the execution function change by acquiring the function name,
When changing, the display flag is turned off and a function table is added, and when the stack pointer decreases, the function name is acquired to determine the execution function change, and when changing, the stack usage amount is calculated, and then the user specifies 2. The step of determining whether the amount is larger than the stack usage amount, displaying the function name and the stack usage amount when the former is larger than the latter, and turning on the display flag to delete the function table. Software simulator.
【請求項3】 前記関数テーブルは関数名,先頭SP,
およびカレントSPを含むように構成した請求項1記載
のソフトウェア・シミュレータ。
3. The function table includes a function name, a head SP,
The software simulator according to claim 1, wherein the software simulator is configured to include a current SP and a current SP.
JP4098976A 1992-02-28 1992-02-28 Software simulator Expired - Lifetime JP2747164B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4098976A JP2747164B2 (en) 1992-02-28 1992-02-28 Software simulator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4098976A JP2747164B2 (en) 1992-02-28 1992-02-28 Software simulator

Publications (2)

Publication Number Publication Date
JPH05241902A true JPH05241902A (en) 1993-09-21
JP2747164B2 JP2747164B2 (en) 1998-05-06

Family

ID=14234061

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4098976A Expired - Lifetime JP2747164B2 (en) 1992-02-28 1992-02-28 Software simulator

Country Status (1)

Country Link
JP (1) JP2747164B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07129429A (en) * 1993-10-28 1995-05-19 Toppan Printing Co Ltd Output error predicting device and code optimizing device for printer page describing language

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07129429A (en) * 1993-10-28 1995-05-19 Toppan Printing Co Ltd Output error predicting device and code optimizing device for printer page describing language

Also Published As

Publication number Publication date
JP2747164B2 (en) 1998-05-06

Similar Documents

Publication Publication Date Title
EP0120135A2 (en) Screen management system
JP2883784B2 (en) Microcomputer
US5539432A (en) Method of and apparatus of converting a set of attributes of display data into code
JPH05241902A (en) Software simulator
JP3538292B2 (en) Runtime program translation method
JP3463331B2 (en) Menu selection method
JPH0410081B2 (en)
JP3752698B2 (en) Document processing device
JP3341064B2 (en) Control program creation device
JPS61210415A (en) Crt key input operating device
JPS63205731A (en) Program start processing system
JPH06202841A (en) Display method for icon
JPH0581075A (en) Software development device
JP2845519B2 (en) Data path simulation device
CN112657188A (en) Method and system for skipping keywords in game event text
JPH07168743A (en) Information display system in abnormal completion of user program
JPH0916381A (en) Program preparation and execution system
JPH08314672A (en) Display comand executing method and update command executing method, and device for same
JPH077346B2 (en) Data flow computer debugging method
JPH0212332A (en) System for processing program including plural same instructions
JPH07114463A (en) Object-oriented analysis design aid device
JPH0877007A (en) Real-time system exceptional process determining device
JPH08194462A (en) Display method of external character pattern
JPH07152794A (en) Logic simulator
JP2001067245A (en) Simulation method and simulation device