JPH0775003B2 - Program content analyzer - Google Patents
Program content analyzerInfo
- Publication number
- JPH0775003B2 JPH0775003B2 JP1319451A JP31945189A JPH0775003B2 JP H0775003 B2 JPH0775003 B2 JP H0775003B2 JP 1319451 A JP1319451 A JP 1319451A JP 31945189 A JP31945189 A JP 31945189A JP H0775003 B2 JPH0775003 B2 JP H0775003B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- branch
- program
- line number
- data
- 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 - Fee Related
Links
Landscapes
- Debugging And Monitoring (AREA)
Description
【発明の詳細な説明】 概 要 アセンブラ言語で記述されたプログラムをその仕様と対
比して基本的構造や動作を解析するのは、従来では人手
により膨大な労力を用いて行つており、また過誤を避け
ることが困難であつた。本発明では、このような被解析
プログラムの基本的動作と構造とはロード命令やストア
命令による入力/出力状態と、実行順序を配列順序と異
ならせる分岐命令による分岐状態とによつて決定される
ことに着目した。したがつて、分岐命令に規定される実
行経路を識別する経路データと、分岐命令に関連して分
岐先命令や分岐元命令の位置データなどを命令毎に設定
するようにしている。[Detailed Description of the Invention] In general, comparing a program written in an assembler language with its specifications and analyzing the basic structure and operation thereof has conventionally been performed with a great deal of manual labor, and is also erroneous. Was difficult to avoid. In the present invention, the basic operation and structure of such a program to be analyzed is determined by the input / output state by the load instruction or the store instruction and the branch state by the branch instruction that makes the execution order different from the array order. I focused on that. Therefore, the path data for identifying the execution path defined by the branch instruction and the position data of the branch destination instruction and the branch source instruction in relation to the branch instruction are set for each instruction.
プログラムはストア命令や分岐命令から逆上られて読取
られ、その実行内容や分岐条件などが命令毎の実行内容
を表す論理式の結合された論理式として、たとえばフロ
ーチヤートやPAD図などの出力を得る。このとき、プロ
グラムが長いほど前記出力量は膨大となるので、前記論
理式の結合された論理式に論理演算を施し、簡約化して
出力する。これにより、前記出力がプログラムの仕様と
対比が容易な簡約化された形式にて得られることにな
り、解析処理の効率化と過誤の発生とを防止することが
できる。A program is read upside down from a store instruction or a branch instruction, and the output contents such as flow charts and PAD diagrams are output as a combined logical expression whose execution contents and branch conditions represent the execution contents of each instruction. obtain. At this time, the longer the program is, the larger the output amount becomes. Therefore, a logical operation is performed on the combined logical expression of the logical expressions, and the output is simplified. As a result, the output can be obtained in a simplified format that can be easily compared with the program specifications, and the efficiency of analysis processing and the occurrence of errors can be prevented.
産業上の利用分野 本発明は、マイクロプロセツサなどを動作させるために
用いられるプログラムの内容を解析する装置に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a device for analyzing the contents of a program used to operate a microprocessor or the like.
従来の技術 マイクロプロセツサが動作するにあたつて実際に読取る
機械語に最も近い言語としてアセンブラ言語がプログラ
ムを記述するために用いられている。このアセンブラ言
語は高級言語と異なり、機械語の各命令と1対1対応を
なす言語であるため、このプログラムに基づく各種入出
力装置の動作内容やプログラムの実行内容の概略など
が、アセンブラ言語にては把握しにくく、仕様上の記載
内容と照合するにあたり、人手によつて命令毎に行う必
要がある。またシユミレーシヨンやエミユレーシヨンな
どを行つてプログラムの動作状態を確認する技術が採用
されているが、これらはプログラムの中で要求される各
種入力命令に対応して数値やデータを設定しなければな
らない。2. Description of the Related Art The assembler language is used to describe a program as a language that is the closest to the machine language that is actually read when the microprocessor operates. Unlike a high-level language, this assembler language has a one-to-one correspondence with each machine language instruction, so the operation contents of various input / output devices based on this program and the outline of the program execution contents are It is difficult to understand, and it is necessary to manually perform each command in order to check the contents described in the specifications. Moreover, the technique of checking the operating state of the program by performing simulation or emulation, etc. is adopted, but these must set numerical values and data corresponding to various input commands required in the program.
したがつてプログラムの各命令を読取つてプログラム全
体の処理や流れの構造を認識し、プログラムの実行内容
を概略的に記述したり、また入出力装置の動作として記
述するなど、プログラムの実行内容の把握が容易な形式
の出力を得ようとする技術が想定される。この場合、プ
ログラムに基づく入出力装置への最終的な出力は、マイ
クロプロセツサが或データをメモリの所定のアドレスに
書込むストア命令である。したがつてストア命令に表れ
るオペランドの変数の内容が最終的に確定されるたとえ
ばロード命令まで、プログラムを逆上つて命令を読取れ
ば、当該ロード命令でデータが入力されるものとして前
記変数の内容が確定することになる。このようにして前
記ロード命令に用いられたオペランドの変数でプログラ
ムの実行内容を概略的に記述できることなる。Therefore, by reading each instruction of the program and recognizing the process and flow structure of the entire program, the execution contents of the program can be roughly described, or described as the operation of the input / output device. It is envisioned that the technology will try to obtain an output in a format that is easy to understand. In this case, the final output to the I / O device based on the program is a store instruction in which the microprocessor writes some data to a predetermined address of the memory. Therefore, if the contents of the variable of the operand appearing in the store instruction are finally determined, for example, the load instruction, if the instruction is read upside down and the instruction is read, the content of the variable is assumed to be data input by the load instruction. Will be confirmed. In this way, the execution contents of the program can be roughly described by the variables of the operands used in the load instruction.
発明が解決しようとする課題 このような従来例において、解析する対象のプログラム
がたとえば第19図示の構造である場合について説明す
る。このプログラムは、ステツプa1〜a10の命令から成
り、ステツプa2,a4にサブルーチンプログラムを呼出す
コール命令「CALL A」および「CALL B」が配置され
ている。ここでステツプa5からプログラムを逆上る場
合、逆上り経路としては、 a5→a8→a7→a6→… および a5→a8→a7→a10→a9→… の2種類想定されるが、実際のプログラムの実行順を考
慮すると後者は実際には実行され得ない経路である。Problems to be Solved by the Invention In such a conventional example, a case where a program to be analyzed has a structure shown in FIG. 19 will be described. This program is composed of the instructions of steps a1 to a10, and call instructions "CALL A" and "CALL B" for calling a subroutine program are arranged in steps a2 and a4. Here, when going up the program from step a5, there are two types of reverse going paths: a5 → a8 → a7 → a6 → ... and a5 → a8 → a7 → a10 → a9 → ... Considering the order of execution, the latter is a path that cannot actually be executed.
すなわちプログラムの内容を解析するにあたつて、プロ
グラムを命令の実行内容に基づいて逆上つて順次的に読
取る技術のみでは、実際のプログラムの実行経路からは
あり得ない経路も解析な対象としてしまい、解析時間が
長くなつてしまうとともに、実際のプログラム実行内容
と異なる解析結果を導出することになり極めて不具合で
ある。In other words, when analyzing the contents of a program, only the technique of reading the program in reverse order and sequentially based on the execution contents of the instruction makes the path that is impossible from the actual execution path of the program subject to analysis. However, the analysis time becomes long, and an analysis result different from the actual program execution content is derived, which is a serious problem.
本発明の目的は、プログラムの所定の実行内容が実行さ
れるための条件を表示するにあたり、複雑な表現を判り
やすく変形して表示することができるようにしたプログ
ラム内容解析装置を提供することである。An object of the present invention is to provide a program content analysis device capable of displaying a complicated expression in an easily understandable manner in displaying a condition for executing a predetermined execution content of a program. is there.
課題を解決するための手段 本発明は、複数の命令からなるプログラムの各命令を配
列順序とは逆に逆上つて読取り、その内容を解析し、各
実行内容と該実行内容が行われる条件を出力する装置に
おいて、 プログラムを逆上つて各命令の実行内容を読取る読取手
段と、 読取られた各命令のうち実行内容に関連する命令に至る
経路を通過するための条件に対応する第1論理式情報を
求め、前記実行内容に関連する全ての経路毎の第1論理
式情報を論理和形式の総合論理式情報として合成し、該
総合論理式情報を前記実行内容に関連して記憶する実行
内容記憶手段と、 与えられた論理式情報を論理積の論理和の形式に変形し
て出力する分解手段と、 前記分解手段から与えられた論理式情報に対して、同一
項に関連する項を括弧でくくつた形式に変形して出力す
る第1同一項整理手段と、 与えられた論理式情報に対して、同一項に関連する項を
括弧でくくつた形式に変形して出力する第2同一項整理
手段と、 第1同一項整理手段から与えられた論理式情報のうち、
所定の変形パターンに該当する項を、該所定の変形パタ
ーンに従つて変形して出力するパターン変形手段と、 パターン変形手段から与えられる論理式情報とその実行
内容とを関連して表示する実行内容出力手段と、 前記第1同一項整理手段とパターン変形手段との間に設
けられ、第1同一項整理手段から与えられた論理式情報
に前記所定パターンが含まれているか否かを検出し、前
記所定パターンが含まれていれば前記パターン合成手段
に論理式情報を出力し、含まれていなければ前記分解手
段に論理式情報を出力する第1選択手段と、 前記パターン変形手段と実行内容出力手段との間に設け
られ、前記パターン変形手段から与えられた論理式情報
に同一項が含まれているか否かを判断し、同一項が含ま
れていれば前記第2同一項整理手段を介して前記第1選
択手段に論理式情報を与え、同一項が含まれていなけれ
ば前記実行内容出力手段に論理式情報を与える第2選択
手段とを具備するすることを特徴とするプログラム内容
解析装置である。Means for Solving the Problems The present invention reads each instruction of a program consisting of a plurality of instructions in reverse order of the arrangement order, analyzes the content, and analyzes each execution content and a condition under which the execution content is performed. In a device for outputting, a reading means for reading the execution contents of each instruction by reversing a program, and a first logical expression corresponding to a condition for passing a path leading to an instruction related to the execution contents among the read instructions. Execution content for obtaining information, synthesizing first logical expression information for all paths related to the execution content as total logical expression information in a logical sum form, and storing the total logical expression information in association with the execution content Storage means, decomposing means for transforming and outputting the given logical expression information into a logical sum form of logical products, and for the logical expression information given from the decomposing means, parenthesized terms related to the same term In a tough form A first identical term organizing means for outputting in a form, and a second identical term organizing means for transforming the given logical expression information into terms related to the same term in parenthesized form, and outputting 1 Of the formula information given from the same term arrangement means,
Pattern transformation means for transforming and outputting a term corresponding to a predetermined transformation pattern according to the predetermined transformation pattern, and execution contents for displaying logical expression information given by the pattern transformation means and its execution contents in association with each other. It is provided between the output means and the first identical term organizing means and the pattern transforming means, and detects whether or not the predetermined pattern is included in the logical expression information given from the first identical term organizing means, If the predetermined pattern is included, logical formula information is output to the pattern synthesizing unit; if not, the first selecting unit that outputs logical formula information to the decomposing unit; the pattern transforming unit and execution content output. Means for determining whether or not the same term is included in the logical expression information provided from the pattern transforming means, and if the same term is included, the second same term organizing means. Program content analysis, characterized by further comprising: second selection means for giving logical expression information to the first selecting means via the above, and for giving logical expression information to the execution content output means if the same term is not included. It is a device.
作 用 本発明に従えば、プログラムを逆上つて読取り、これに
よつて第1論理式情報を求め、分解手段は、論理積の論
理和の形式に変形して出力する機能を有し、この分解手
段からの論理式情報に対して同一項に関連する項を括弧
でくくつた形式、すなわち同一項を含む項を識別するこ
とを可能とし、このようにして変形して第1同一項を整
理手段から出力し、また第2同一項整理手段もまた設け
られ、さらにパターン変形手段と実行内容出力手段と第
1選択手段と第2選択手段とを備えることによつて、所
定の実行内容が実行されるための条件を表示するにあた
り、複雑な表示を判りやすく変形して表示することが可
能になる。Operation According to the present invention, the program is read upside down, the first logical expression information is obtained by this, and the decomposing means has a function of transforming into a form of the logical sum of logical products and outputting it. It is possible to identify terms related to the same term in parentheses with respect to the logical expression information from the disassembling means, that is, to identify terms including the same term. Output from the means, a second same term arrangement means is also provided, and the predetermined execution content is executed by including the pattern transformation means, the execution content output means, the first selection means, and the second selection means. In displaying the conditions for performing, it is possible to easily display the complicated display by transforming it.
実施例 第1図は本発明の一実施例のプログラム内容解析装置
(以下、解析装置と略す)1の構成例を示すブロツク図
である。解析装置1には外部記憶装置2が接続され、解
析対象となる高級言語やアセンブラ言語で記述されたプ
ログラムが保存される。解析装置1は外部記憶装置2か
らのプログラムを機械語に変化するアセンブラ3を備
え、アセンブラ3からのアセンブルリストがアセンブル
リストフアイル記憶部4に記憶される。以下「記憶部」
の名称は解析装置1に備えられるたとえばRAM(ランダ
ムアクセスメモリ)や固定デイスク装置などの内部記憶
装置の所定の領域を示す。First Embodiment FIG. 1 is a block diagram showing a configuration example of a program content analysis device (hereinafter abbreviated as an analysis device) 1 according to an embodiment of the present invention. An external storage device 2 is connected to the analysis device 1 and stores a program written in a high-level language or an assembler language to be analyzed. The analysis apparatus 1 includes an assembler 3 that changes the program from the external storage device 2 into a machine language, and the assemble list from the assembler 3 is stored in the assemble list file storage unit 4. Below "memory section"
Indicates a predetermined area of an internal storage device such as a RAM (random access memory) or a fixed disk device provided in the analysis device 1.
アセンブルリストフアイル記憶手段4からの解析対象と
なるアセンブルプログラムは、解析準備処理手段5に与
えられ、後述するプログラム解析に先立ち解析対象とな
るプログラムのデータが内容別に分類される。解析準備
処理手段5には複数の記憶部が接続される。リストフア
イル記憶部6には被解析プログラムの機械語とアセンブ
ラ言語のニーモニツクから成る命令列が記憶される。RA
Mフアイル記憶部7には被解析プログラムで用いられる
各種変数が記憶される。マツプデータ記憶部8には被解
析プログラムで用いられるマツプ形式などでの固定デー
タが記憶される。またその他に記憶部9が接続され、被
解析プログラムで用いられるたとえば割込みベクトルの
ベクトルアドレスや、前記リストフアイル記憶部6に記
憶されているニーモニツクのプログラムに関するラベル
などが記憶される。また解析装置1には命令データフア
イル記憶部10が設けられ、被解析プログラムで用いられ
る命令が予め記憶される。The assemble program to be analyzed from the assemble list file storage means 4 is given to the analysis preparation processing means 5, and the data of the program to be analyzed is classified according to the contents prior to the program analysis described later. A plurality of storage units are connected to the analysis preparation processing means 5. The list file storage unit 6 stores an instruction sequence including a machine language of a program to be analyzed and a mnemonic of an assembler language. RA
Various variables used in the analyzed program are stored in the M file storage unit 7. The map data storage unit 8 stores fixed data in a map format or the like used in the analyzed program. In addition, the storage unit 9 is connected to store the vector address of the interrupt vector used in the analyzed program, the label related to the mnemonic program stored in the list file storage unit 6, and the like. The analysis device 1 is also provided with an instruction data file storage unit 10 in which instructions used in the analyzed program are stored in advance.
前記リストフアイル記憶部6らのニーモニツク形式での
プログラムは分岐データ作成手段としての流れ構造解析
手段11に与えられ、被解析プログラムにおける処理の流
れの構造、すなわち分岐の有無、分岐命令が想定される
場合の分岐先命令の位置の変動およびスタツクのネステ
イングの程度などを解析するようにしている。ここでは
これ以降のすべての解析処理の基礎データとなる流れ制
御フアイルを作成し、流れ制御フアイル記憶部12に記憶
する。前記リストフアイル記憶部6、命令フアイル記憶
部20および流れ制御フアイル記憶部12からの各データに
基づいて分岐条件解析部13、ストア内容解析部14、完全
分岐条件解析部15は後述するそれぞれの解析処理を行
い、得られた各データを経路データ記憶手段および位置
データ記憶手段を含む分岐条件フアイル記憶部16、実行
内容フアイル記憶部17、および完全分岐条件フアイル記
憶部18に記憶する。The program in the mnemonic format from the list file storage unit 6 is given to the flow structure analysis unit 11 as a branch data creation unit, and the structure of the processing flow in the analyzed program, that is, the presence or absence of a branch and the branch instruction are assumed. In this case, the position variation of the branch destination instruction and the stack nesting degree are analyzed. Here, a flow control file, which is the basic data for all subsequent analysis processes, is created and stored in the flow control file storage unit 12. Based on the respective data from the list file storage unit 6, the instruction file storage unit 20 and the flow control file storage unit 12, the branch condition analysis unit 13, the store content analysis unit 14, and the complete branch condition analysis unit 15 perform respective analyzes described later. The processing is performed, and each obtained data is stored in the branch condition file storage unit 16 including the route data storage unit and the position data storage unit, the execution content file storage unit 17, and the complete branch condition file storage unit 18.
流れ制御フアイル、分岐条件フアイルおよび実行内容フ
アイルからフローチヤート作成部19は、被解析プログラ
ムのフローチヤートを作成して出力する。また実行内容
フアイルおよび完全分岐条件フアイルから実行内容解析
結果出力部20は被解析プログラムの実行内容をたとえば
印字出力する。The flow chart creating unit 19 creates and outputs a flow chart of the analyzed program from the flow control file, the branch condition file, and the execution content file. Further, the execution content analysis result output unit 20 prints out the execution content of the analyzed program from the execution content file and the complete branch condition file, for example.
第2図は解析準備処理手段5の動作を説明するフローチ
ヤートである。ステツプa1において解析装置1は外部記
憶装置2からソースプログラムを読込み、アセンブラ3
にてアセンブル処理を行う。アセンブルリストフアイル
4に記憶されたアセンブルプログラムに対して、解析準
備処理手段5はステツプa2にて各命令毎に一連の番号
(以下、行番号と称する)を付与する。このとき各命令
は後述するようにたとえばストア命令、入出力命令、分
岐命令あるいは演算命令などのようにその種類によつて
分類される。これは前記命令データフアイル記憶部10に
記憶されている命令を参照して行われる。ステツプa3で
はこのような命令の分類に基づいて、前述した各種デー
タフアイルの作成が行われる。FIG. 2 is a flow chart for explaining the operation of the analysis preparation processing means 5. In step a1, the analysis device 1 reads the source program from the external storage device 2, and the assembler 3
Assemble at. To the assemble program stored in the assemble list file 4, the analysis preparation processing means 5 gives a series of numbers (hereinafter referred to as line numbers) to each instruction in step a2. At this time, each instruction is classified according to its type, such as a store instruction, an input / output instruction, a branch instruction, or an arithmetic instruction, as will be described later. This is performed by referring to the instructions stored in the instruction data file storage unit 10. At step a3, the above-mentioned various data files are created based on the classification of such instructions.
次に解析装置1は、流れ構造解析手段11によりリストフ
アイル記憶部6に記憶されている機械語とニーモニツク
から成るプログラムフアイルに関して流れ構造解析処理
を行う。この解析処理は被解析プログラムの流れ構造
(分岐の有無、分岐先の特定、スタツクのネステイング
の程度など)を解析する処理であり、以後のすべての解
析プログラムの基礎データとなる前述した各種フアイル
を作成する。とりわけ分岐命令の存在に基づく分岐先命
令の行番号などの抽出の他、「逆上り(さかのぼり)」
概念と「属性」概念とを表すデータを作成する。Next, the analysis apparatus 1 performs the flow structure analysis processing on the program file composed of the machine language and the mnemonic stored in the list file storage unit 6 by the flow structure analysis means 11. This analysis process is the process of analyzing the flow structure of the analyzed program (whether there is a branch, specification of branch destination, stack nesting degree, etc.), and the various files described above that are the basic data of all subsequent analysis programs are analyzed. create. In particular, in addition to extracting the line number of the branch destination instruction based on the existence of a branch instruction, "backward going"
Create data representing concepts and "attribute" concepts.
(1)逆上り概念 プログラムの実行内容を解析するためにプログラムをそ
の実行順に従つて命令を読取つて解析しようとする場
合、各種フラグなどのコンデイシヨンコードの変化、複
数の命令の間の相関関係など、当該命令に関連して想定
されるすべてのデータを蓄積しておく必要がある。この
ようなデータの中には命令の種類によつては不必要なデ
ータがある場合であつても、以後の解析処理で、どのデ
ータが必要になるか判断できず、このためすべてのデー
タを収集する必要がある。(1) Reverse going up concept When analyzing the execution contents of a program in order to read and analyze the instructions according to the execution order, the change of the condition code such as various flags and the correlation between a plurality of instructions It is necessary to store all the data expected to be associated with the command, such as relationships. Even if such data contains unnecessary data depending on the type of instruction, it is not possible to determine which data will be needed in the subsequent analysis processing, so all data will be deleted. Need to collect.
本発明に従う「逆上り」概念はこのような課題を解消す
るための方策である。The "reverse uphill" concept according to the present invention is a measure for solving such a problem.
本発明は機械語やアツセンブラプログラムで記述された
プログラムを、分岐命令およびストア命令の分岐条件や
ストア内容を合成することにより、把握容易な形式に論
理式により記述しようとするものである。このため前記
分岐命令またはストア命令を始点とし、当該分岐条件ま
たはストア命令の内容が確定する個所までプログラムを
逆上りつつ、必要な情報のみを収集するものである。The present invention is intended to describe a program written in a machine language or an assembler program by a logical expression in a format that is easy to understand by synthesizing branch conditions and store contents of a branch instruction and a store instruction. Therefore, starting from the branch instruction or the store instruction, the program goes back up to a point where the content of the branch condition or the store instruction is determined, and only necessary information is collected.
ここでプログラム例として下記第1表のプログラムに則
して説明する。Here, a program example will be described according to the program shown in Table 1 below.
上記プログラム例で、実行順序は行番号1→2→3→4
→5→6または行番号1→2→3→4→5→7である。
分岐命令は「BCC」であり、その条件は行番号4の(A
−#8)が0以上か負であるかで決定される。そのため
にはアキユムレータAの値が確定する必要がある。その
ためには行番号3にてアキユムレータA,Bの双方の値が
確定する必要があり、行番号2,1を読取つて初めてその
値が確定する。 In the above program example, the execution order is line number 1 → 2 → 3 → 4
→ 5 → 6 or line numbers 1 → 2 → 3 → 4 → 5 → 7.
The branch instruction is "BCC", and the condition is line number 4 (A
-# 8) is determined to be 0 or more or negative. For that purpose, the value of the accumulator A must be determined. For that purpose, it is necessary to determine the values of both accumulators A and B at line number 3, and the values are determined only after reading line numbers 2 and 1.
流れ構造解析手段11では上記逆上り処理に必要な情報、
すなわち或命令とその前行とはプログラムの実行順に従
つた連続した命令あるか否かの判断のためのデータや、
これらの命令が不連続の場合、どの行番号の命令へ連続
しているかに関するデータなどの後述する属性データを
作成している。In the flow structure analysis means 11, the information required for the reverse processing,
That is, a certain instruction and its preceding line are data for judging whether or not there is a continuous instruction according to the execution order of the program,
When these commands are discontinuous, attribute data, which will be described later, such as data regarding to which line number the command is continuous, is created.
(2)属性概念 プログラムにはメンインルーチンと、メインルーチンの
所定の個所から処理が分岐されるサブルーチンとを含ん
で構成される。同一のサブルーチンでも複数箇所から呼
出される場合があり、メインルーチンに処理を戻すリタ
ーン命令RETによる分岐先の位置は、メインルーチンの
呼出し命令に対応して変化する。したがつて1つのサブ
ルーチンによつても複数の実行経路が設定されていると
考えられ、処理経路を区分する情報として属性概念を設
定する。以下、第2表で示されるプログラム例に沿つて
説明する。(2) Attribute concept The program is composed of a main routine and a subroutine whose processing branches from a predetermined part of the main routine. Even the same subroutine may be called from a plurality of locations, and the position of the branch destination by the return instruction RET that returns processing to the main routine changes corresponding to the calling instruction of the main routine. Therefore, it is considered that a plurality of execution paths are set even by one subroutine, and the attribute concept is set as information for dividing the processing paths. Hereinafter, description will be given along the program example shown in Table 2.
上記プログラム例のフローチヤートは第3図に示され
る。 The flow chart of the above program example is shown in FIG.
このプログラム例の実行順序は行番号1→2→3→9→
10→11→4→5→6→8→9→10→11→7→…である。
一方、行番号7からプログラムを逆上る場合、第1の経
路として行番号7→11→10→9→8→6→5→4→11→
10→9→3→2→1→…があるが、その他に行番号7→
11→10→9→3→2→…などの逆上り経路が存在してい
ることになる。このような後者の逆上り経路は実行順序
からはあり得ない経路であり、前記属性概念を用いてこ
のような不所望な経路の選択が防止される。The execution order of this program example is line number 1 → 2 → 3 → 9 →
10 → 11 → 4 → 5 → 6 → 8 → 9 → 10 → 11 → 7 → ....
On the other hand, when going up the program from line number 7, the first route is line numbers 7 → 11 → 10 → 9 → 8 → 6 → 5 → 4 → 11 →
There are 10 → 9 → 3 → 2 → 1 →…, but in addition, line number 7 →
It means that there are reverse going routes such as 11 → 10 → 9 → 3 → 2 →. Such a latter reverse uplink route is a route that is impossible in the order of execution, and the attribute concept is used to prevent the selection of such an undesired route.
第2表のプログラム例において、分岐先欄、分岐元欄、
流れフラグ欄および属性欄の内容が以下のようにして決
定される。In the program example of Table 2, the branch destination column, the branch source column,
The contents of the flow flag column and the attribute column are determined as follows.
(a)属 性 行番号1〜7は行番号3,6のCALL命令によつて処理が分
岐し、かつサブルーチンプログラムを含んでいないの
で、すべて同一の属性記号Mが与えられる。行番号9〜
11は行番号3のCALL命令により処理が移されるサブルー
チンプログラムであり、属性記号Aが与えられる。また
行番号8〜11は行番号6のCALL命令により処理が移され
るサブルーチンプログラムであり、前記属性記号Aと異
なる属性記号Bがそれぞれ与えられる。(A) Attributes Line numbers 1 to 7 are all given the same attribute symbol M because their processing branches by the CALL instruction of line numbers 3 and 6 and does not include a subroutine program. Line number 9-
Reference numeral 11 is a subroutine program whose processing is moved by the CALL instruction at line number 3 and is given the attribute symbol A. Line numbers 8 to 11 are subroutine programs whose processing is transferred by the CALL instruction of line number 6, and attribute symbols B different from the attribute symbol A are given respectively.
(b)分岐先欄 上記プログラムの分岐命令は行番号3,6,7,11に配置され
ており、これらの処理が移る先は各命令の内容に対応し
てそれぞれ行番号9,8,1であり、分岐命令RETでは対応す
るCALL命令の直後の行番号4または行番号7である。分
岐先欄にはこのような分岐先の行番号と当該行番号の命
令が有する属性とが組になつたデータが設定される。(B) Branch destination column The branch instructions of the above program are arranged in line numbers 3, 6, 7, and 11, and the destinations to which these processes move correspond to the line numbers 9, 8, 1 respectively. In the branch instruction RET, the line number 4 or line number 7 immediately after the corresponding CALL instruction is used. In the branch destination column, data in which the line number of the branch destination and the attribute of the instruction of the line number are paired is set.
(c)分岐元欄 前記各分岐命令により処理を移される分岐先の命令から
見て、処理が当該分岐先命令へ移る元となる分岐元命令
が対応付けられる。したがつて分岐元欄には、各命令毎
に前記分岐元命令が対応付けられる場合にはその分岐元
命令の行番号と当該分岐命令の所属する属性記号とが組
となつたデータが設定される。(C) Branch source column From the branch destination instruction to which the processing is shifted by each of the branch instructions, the branch source instruction from which the processing shifts to the branch destination instruction is associated. Therefore, in the branch source column, when the branch source instruction is associated with each instruction, data in which the line number of the branch source instruction and the attribute symbol to which the branch instruction belongs are paired is set. It
(d)流れフラグ欄 流れフラグ「1」は当該命令が前行の命令から連続した
命令であることを示す。流れフラグ「0」は当該命令が
前行の命令以外の他の命令から処理が分岐してくる分岐
先命令であることを示す。すなわち行番号1〜3は一連
の命令であり、行番号4の命令は行番号3のCALL命令に
よりサブルーチンプログラムAが実行されて行番号11の
RET命令により処理が分岐してきた命令である。このた
め流れフラグ「0」が付される。同様にして行番号5,6
には流れフラグ「1」が付され、行番号7には流れフラ
グ「0」が付される。(D) Flow flag column The flow flag "1" indicates that the instruction is an instruction continuous from the instruction in the preceding line. The flow flag “0” indicates that the instruction is a branch destination instruction from which the process branches from an instruction other than the instruction in the preceding line. That is, the line numbers 1 to 3 are a series of commands, and the command of line number 4 is executed by the subroutine program A by the CALL command of line number 3 and the command of line number 11 is executed.
This is an instruction whose processing has branched by the RET instruction. Therefore, the flow flag “0” is attached. Similarly, line numbers 5,6
Is assigned a flow flag “1”, and row number 7 is assigned a flow flag “0”.
行番号8が行番号6のCALL命令により処理が分岐してく
る命令であり、流れフラグ「0」が付される。行番号9
は行番号3のCALL命令により処理が分岐してくる命令で
あり、流れフラグ「0」が付される命令であるが、前記
行番号3りCLLの後に行番号6のCALL命令が行われるの
で、行番号9は行番号8に連続する命令となり、第2表
のように流れフラグ「1」が与えられる。行番号10,11
については流れフラグ「1」が与えられる。Line number 8 is an instruction whose processing is branched by the CALL instruction of line number 6, and a flow flag "0" is added. Line number 9
Is an instruction whose processing is branched by the CALL instruction of line number 3 and is an instruction to which a flow flag "0" is added. However, since the CALL instruction of line number 6 is performed after the CLL for the line number 3 , Line number 9 is an instruction continuous to line number 8, and the flow flag "1" is given as shown in Table 2. Line number 10,11
Is given the flow flag "1".
上記第2表のプログラム例では、CALL命令などその命令
から処理が分岐し、またその命令へ処理が分岐してくる
命令に関して説明したが、一般にマイクロコンピユータ
のプログラムの実行は、プログラムカウンタ(PC)の出
力するアドレスの命令を読取つて実行し、その命令の実
行により次に実行すべき命令のアドレスがプログラムカ
ウンタに格納される。In the program examples in Table 2 above, the instructions such as the CALL instruction in which the processing branches from the instruction and the processing branches to the instruction are explained. Generally, the execution of the program of the microcomputer is performed by the program counter (PC). The instruction of the address output by is read and executed, and the address of the instruction to be executed next by the execution of the instruction is stored in the program counter.
一方、プログラム中にサブルーチンプログラムが含まれ
ている場合、処理が分岐するが、このときスタツクが用
いられる。スタツクは周知のように、先入れ後出し(フ
アーストインラストアウト,FILO方式)のメモリであ
り、サブルーチンを呼出すときサブルーチンから処理が
戻るべきメインルーチンの次のアドレスが格納される。
サブルーチンの処理が終了後、リターン命令RETにより
スタツクに格納されているデータがプログラムカウンタ
に転送され、当該アドレスからプログラムが実行され
る。したがつてスタツクの記憶内容を変更する命令が含
まれていれば、サブルーチンプログラムからの復帰先を
変更することができる。このようなプログラム例を下記
第3表に示す。On the other hand, if the program includes a subroutine program, the process branches, but at this time, the stack is used. As is well known, the stack is a first-in / first-out (first-in-last-out, FILO method) memory and stores the next address of the main routine to which the process returns when the subroutine is called.
After the processing of the subroutine is completed, the data stored in the stack is transferred to the program counter by the return instruction RET, and the program is executed from that address. Therefore, if the instruction to change the stored contents of the stack is included, the return destination from the subroutine program can be changed. An example of such a program is shown in Table 3 below.
第3表のプログラム例は第2表のプログラム例の行番号
4〜8が変更されている。第3表のプログラム例で分岐
先欄、分岐元欄および流れフラグ欄のデータの決定方法
は第2表のプログラム例の場合と同様である。以下、属
性の決定方法について説明する。 In the program example of Table 3, line numbers 4 to 8 of the program example of Table 2 are changed. The method of determining the data in the branch destination column, the branch source column and the flow flag column in the program example of Table 3 is the same as in the program example of Table 2. Hereinafter, a method of determining attributes will be described.
行番号1〜3は一連の命令であり、属性データMを与え
る。行番号3のCALL命令により処理は行番号9に分岐す
るので、行番号9〜11には他の属性記号Aを与える。行
番号11のRET命令により処理は行番号4に復帰する。こ
の命令には属性記号Mを与える。Line numbers 1 to 3 are a series of instructions and give attribute data M. Since the process branches to the line number 9 by the CALL instruction of the line number 3, another attribute symbol A is given to the line numbers 9 to 11. The RET instruction at line number 11 returns the process to line number 4. The attribute symbol M is given to this command.
行番号5のPSH命令により、前述したスタツクの最新の
アドレスデータがXレジスタの内容に書換えられる。こ
の時点で属性データをBに変更し、以下行番号11まで同
一の属性データBを与える。このようにして、前述した
スタツクに格納されているデータを変更する命令を含む
プログラムに関する属性が決定される。The latest address data of the stack described above is rewritten to the contents of the X register by the PSH instruction in line number 5. At this time, the attribute data is changed to B, and the same attribute data B is given up to line number 11 below. In this way, the attributes relating to the program including the instruction to change the data stored in the stack are determined.
上記第2表および第3表のプログラム例に関する流れ制
御データの属性データは、スタツクの内容を変更する命
令を含む分岐命令に関してプログラムの実行経路毎に、
前述したように異なる記号を与えるようにしている。こ
のような方法の場合、被解析プログラムにおける属性の
数が増大すると、後述するようにプログラムを逆上つて
解析を行う場合、命令毎にすべての属性欄の属性データ
を検索して同一の属性に沿つて逆上るような処理を行う
ので、前記属性データの数を減少できればより高速な処
理が実現できる。The attribute data of the flow control data relating to the program examples in Tables 2 and 3 above are, for each execution path of the program, for a branch instruction including an instruction for changing the contents of the stack,
Different symbols are given as described above. In the case of such a method, when the number of attributes in the analyzed program increases, when analyzing the program in the reverse way as described later, the attribute data in all the attribute columns are searched for each instruction and the same attributes are obtained. Since a process that goes up along with it is performed, a faster process can be realized if the number of the attribute data can be reduced.
下記第4表はプログラム内容は第3表のプログラム内容
と同一であるが、前記第2表および第3表とは異なる流
れ制御データを、分岐欄1,2,…および属性欄1,2,…とし
て設定している。以下、これらの決定方法について説明
する。The following Table 4 has the same program content as the program content of Table 3, but the flow control data different from those in Tables 2 and 3 are stored in the branch columns 1, 2, ... And the attribute columns 1, 2 ,. It is set as ... Hereinafter, these determination methods will be described.
(e)属性欄i(i=1,2)… 属性欄の行番号データNOは分岐命令毎に設定され、分岐
先命令の行番号が記述される。属性データtoは当該分岐
命令により、どの属性欄に処理が分岐したかを表す。ま
た行上りフラグ欄においてフラグ=「0」は対応する命
令が分岐先命令であり、直前の行の命令とは処理が連続
しない命令であることを示し、フラグ=「j」(j=1,
2,…)は属性欄の番号を示す。行番号1は行番号11を分
岐命令とする分岐先命令の場合があり、したがつてフラ
グ=「0」が設定される。また順下りフラグ欄において
フラグ=「0」は、対応する命令が直後の命令と処理が
連続しない命令であり、分岐命令であることを示す。 (E) Attribute column i (i = 1, 2) ... The line number data NO in the attribute column is set for each branch instruction, and the line number of the branch destination instruction is described. The attribute data to indicates to which attribute column the process has branched by the branch instruction. In the ascending flag column, flag = “0” indicates that the corresponding instruction is a branch target instruction, and the instruction on the immediately preceding line is an instruction whose processing is not continuous, and flag = “j” (j = 1, j = 1,
2, ...) indicates the number in the attribute column. Line number 1 may be a branch target instruction having line number 11 as the branch instruction, and accordingly, the flag = "0" is set. Further, in the forward flag column, a flag = “0” indicates that the corresponding instruction is an instruction whose processing is not continuous with the instruction immediately after it and is a branch instruction.
行番号2ではまず設定された属性欄1の番号がフラグ=
「1」として設定される。行番号3は分岐命令であり、
分岐先の行番号データNO=「9」が設定される。属性デ
ータtoについてto=「1」が設定される。この後、処理
は行番号9へ分岐し、したがつて逆上りフラグ=「0」
が設定される。行番号10には逆上りフラグ=「1」が設
定される。行番号「11」は分岐元命令であり、行番号デ
ータNO=「4」が設定される。この行番号4の命令は現
時点では属性欄1の範囲にあり、したがつて属性データ
to=「1」が設定される。In line number 2, the number in the attribute column 1 that was set first is flag =
It is set as "1". Line number 3 is a branch instruction,
The branch destination line number data NO = “9” is set. To = “1” is set for the attribute data to. After this, the process branches to the line number 9, and accordingly, the reverse flag = “0”.
Is set. The reverse flag = “1” is set in the line number 10. Line number "11" is the branch source instruction, and line number data NO = "4" is set. The instruction of line number 4 is currently in the range of attribute column 1, and therefore the attribute data
to = “1” is set.
この後、処理は行番号4へ移る。このため逆上りフラグ
および順下りフラグは「0」、「1」となる。これ以
降、行番号5〜10には逆上りフラグ=「0」または
「1」のいずれかが設定される。この後、処理は行番号
11に到達する。分岐先は行番号5のRSH命令により行番
号1に変更されており、したがつて属性欄2が増設さ
れ、逆上りフラグ=「2」が設定される。また行番号デ
ータNO=「1」と属性データto=「1」が設定される。After this, the process moves to line number 4. Therefore, the reverse ascending flag and the forward descending flag are "0" and "1". After this, the reverse flag = “0” or “1” is set in the row numbers 5 to 10. After this, the process is line number
To reach 11. The branch destination is changed to the line number 1 by the RSH instruction of the line number 5, and accordingly, the attribute column 2 is added and the reverse ascending flag = “2” is set. Line number data NO = "1" and attribute data to = "1" are set.
(f)分岐元欄i(i=1,2,…) この分岐元欄のデータは分岐先命令とについて設定さ
れ、分岐先の行番号データNOと、当該分岐命令の直前の
命令が属する属性欄番号frと、分岐先命令の属する属性
欄番号toとがそれぞれ設定される。(F) Branch source column i (i = 1, 2, ...) The data of this branch source column is set for the branch destination instruction, and the line number data NO of the branch destination and the instruction immediately preceding the branch instruction belong. The column number fr and the attribute column number to to which the branch destination instruction belongs are set.
以下、分岐元欄のデータと属性欄のデータとを用いて第
4表のプログラム例で逆上り解析可能であることを説明
する。逆上りフラグ=「1」について逆上ると、行番号
9で逆上りフラグ=「0」となるので分岐元欄を参照
し、行番号3の属性欄1から分岐していることが理解さ
れる。さらに逆上り、行番号1ですべての情報が確定す
る。したがつて逆上りフラグ=「1」に関する経路は行
番号10→9→3→2→1となる。Hereinafter, it will be explained that reverse program analysis is possible with the program example of Table 4 using the data in the branch source column and the data in the attribute column. If the user reverses the reverse flag = “1”, the reverse flag = “0” at line number 9, so the branch source column is referred to, and it is understood that the branch is made from the attribute column 1 at line number 3. . Further, in the reverse direction, line number 1 fixes all the information. Therefore, the route relating to the reverse ascending flag = "1" is the line number 10 → 9 → 3 → 2 → 1.
それぞれの実行内容は 10行目 A→[X+0] …未定義変数A,X 09行目 A←A+1 …未定義変数A,X 03行目 未定義A,Xに関する変化なし 02行目 A←[X+0] …未定義変数X 01行目 X←PORT1 …未定義変数無し であるから、10行目で得られた A→[X+0] の‘A'の代りに09行目で得られた‘A+1'を置き換えて A+1→[X+0] その‘A'の代りに02行目で得て‘X+0'を置き換えて [X+0]+1→[X+0] その‘X'の代りに01行目で得られた‘PORT1'を置き換え
ると [PORT1+0]+1→[PORT1+0] が得られる。The contents of each execution are 10th line A → [X + 0]… Undefined variable A, X 09th line A ← A + 1… Undefined variable A, X 03th line Undefined A, X No change 02 line A ← [ X + 0]… Undefined variable X 01th line X ← PORT1… Since there are no undefined variables, A → [X + 1] obtained on the 10th line instead of A → [X + 0] 'A' obtained on the 10th line. Replace'A + 1 → [X + 0] Instead of'A ', get at line 02 and replace'X + 0' [X + 0] + 1 → [X + 0] Get at line 01 instead of'X 'Replacing'PORT1'yields [PORT1 + 0] + 1 → [PORT1 + 0].
その処理内容は、 [PORT1+0]+1→[PORT1+0] …(1) となることが理解される。It is understood that the processing content is [PORT1 + 0] + 1 → [PORT1 + 0] (1).
逆に逆上りフラグ=「2」について逆上ると、まず属性
欄2が参照されるが、行番号9にて逆上りフラグ=
「1」に変更されるので、行番号8については属性欄1
が参照される。これ以降、前述と同様に逆上つて読取
り、行番号6にてすべての情報が確定する。これによれ
ば処理内容は、先ほどと同様に行番号10→9→8→7→
6とたどることで、 [PORT2+0]+1+1→[PORT2+0] …(2) となることが理解される。On the contrary, if the user goes up for the reverse flag = “2”, the attribute column 2 is first referenced, but the reverse flag =
Since it is changed to "1", the attribute column 1 for the line number 8
Is referred to. From this point onward, as in the case described above, reading is performed in reverse, and all the information is determined at line number 6. According to this, the processing contents are line numbers 10 → 9 → 8 → 7 →
It can be understood that by following 6 it becomes [PORT2 + 0] + 1 + 1 → [PORT2 + 0] (2).
第4図は流れ構造解析手段11の動作を説明するフローチ
ヤートである。流れ構造解析手段11の動作の概略は上記
第2表〜第4表を参照して説明したが、以下にその動作
を詳述する。第4図ステツプc1では解析を開始する行番
号lnを所定の値に設定し、また各種データを所定の値に
初期化する。ステツプc2では処理が最終行まで到達した
か否かを判断する。到達していなければ処理はステツプ
c3に移り、現在解析の対象となつている命令の行番号ln
に関して設定される属性欄の個数を表す配列CZ[ln]が
0であるか否かを判断する。個数配列CZが0であれば、
初めて解析する命令であることを意味する。FIG. 4 is a flow chart for explaining the operation of the flow structure analysis means 11. The outline of the operation of the flow structure analyzing means 11 has been described with reference to Tables 2 to 4 above, and the operation will be described in detail below. In step c1 in FIG. 4, the line number ln for starting the analysis is set to a predetermined value, and various data are initialized to predetermined values. At step c2, it is determined whether the processing has reached the last line. If not, processing is step
Move to c3, the line number ln of the instruction currently being analyzed
It is determined whether or not the array CZ [ln] representing the number of attribute fields set for is 0. If the number array CZ is 0,
This means that this is the first instruction to be analyzed.
ステツプc3の判断が否定であれば処理はステツプc4に移
り、属性欄の個数を1つ増加する。ステップc5では第4
表を参照して説明した属性データを設定する。ステツプ
c6では行番号lnの命令が分岐先行であるか否かを判断す
る。分岐先行であればステツプc7で第4表行番号4の命
令における分岐元欄1などの分岐元欄を設定し、ステツ
プc8に移る。ステツプc6の判断が否定であればステツプ
c9に移り、前記逆上りフラグや順下りフラグを設定す
る。If the determination in step c3 is negative, the process proceeds to step c4 and the number of attribute fields is increased by one. Fourth in step c5
Set the attribute data described with reference to the table. Step
At c6, it is determined whether the instruction at line number ln is a branch preceding. If it is a branch preceding, the branch source column such as the branch source column 1 in the instruction of the fourth table row number 4 is set at step c7, and the process proceeds to step c8. If the judgment at step c6 is negative, step c6
Moving to c9, the reverse uplink flag and the forward downlink flag are set.
以下、上記逆上りフラグと順下りフラグとについて説明
する。第5図は流れ制御フアイル記憶部12の構造を説明
する図である。流れ制御フアイル記憶部12は、分岐元フ
アイル部21と属性フアイル部22とから構成される。第6
図は分岐元フアイル部21の構造を説明する図である。分
岐元フアイル部21は行番号毎に設けられ、当該行番号を
分岐先とする分岐元命令の個数を記憶する分岐元個数記
憶部23と、第4表を参照して説明した分岐元欄に相当す
る分岐元欄記憶部24がたとえば80領域設定される。分岐
元欄記憶部24は行番号記憶部25、分岐元属性記憶部26、
分岐先属性記憶部27を含んで構成される。Hereinafter, the reverse uplink flag and the forward downlink flag will be described. FIG. 5 is a diagram for explaining the structure of the flow control file storage unit 12. The flow control file storage unit 12 includes a branch source file unit 21 and an attribute file unit 22. Sixth
The figure illustrates the structure of the branch source file portion 21. The branch source file unit 21 is provided for each line number, and the branch source number storage unit 23 that stores the number of branch source instructions whose branch destination is the line number and the branch source column described with reference to Table 4 are provided. For example, 80 areas are set in the corresponding branch source column storage unit 24. The branch source column storage unit 24 includes a line number storage unit 25, a branch source attribute storage unit 26,
It is configured to include a branch destination attribute storage unit 27.
第7図は属性フアイル部22の構造を説明する図である。
属性フアイル部22は各行番号毎に設けられ、当該行番号
に設定された属性欄の個数を記憶する属性個数記憶部2
8、当該命令行の属性データが確定すれば「1」、不定
の場合は「0」で表される不定フラグを記憶する不定フ
ラグ記憶部29、第4表の属性欄の属性データtoに相当す
る属性値を記憶する属性値記憶部30、第1図示の分岐条
件フアイル記憶部16において当該行番号の命令の分岐条
件を記憶しているアドレスを記憶する分岐条件記憶部3
1、第4表の属性欄における行番号データNOと属性デー
タtoとをそれぞれ記憶する分岐先行番号記憶部32、分岐
先属性欄番号33、第4表の属性欄のフラグに相当する逆
上りフラグを記憶する逆上りフラグ記憶部34、順下りフ
ラグを記憶する順下りフラグ憶部35を含んで構成され
る。FIG. 7 is a diagram for explaining the structure of the attribute file unit 22.
The attribute file unit 22 is provided for each line number, and the attribute number storage unit 2 stores the number of attribute columns set for the line number.
8, "1" if the attribute data of the command line is confirmed, "0" if indefinite, an indefinite flag storage unit 29 for storing an indefinite flag, corresponding to the attribute data to in the attribute column of Table 4 The attribute value storage unit 30 for storing the attribute value, and the branch condition storage unit 3 for storing the address storing the branch condition of the instruction of the line number in the branch condition file storage unit 16 shown in FIG.
1, a branch leading number storage unit 32 that stores the line number data NO and the attribute data to in the attribute column of Table 4, a branch destination attribute column number 33, and a reverse up flag corresponding to the flag of the attribute column of Table 4 And a forward-downward flag storage unit 35 for storing a forward-downward flag.
前記順下りフラグは第4表のたとえば属性欄1の順下り
フラグ欄に示すように設定される。すなわち、或行番号
の命令が直後の行番号の命令と連続した命令であれば
「1」、不連続な命令であれば「0」を与える。第4表
の行番号2は行番号3と連続する命令であり、前記デー
タ「1」が与えられる。ところが行番号3は行番号4の
命令とは連続せず、したがつてデータ「0」が与えられ
る。The forward flag is set as shown in the forward flag column of the attribute column 1 of Table 4, for example. That is, "1" is given if the instruction of a certain line number is an instruction continuous with the instruction of the immediately following line number, and "0" is given if it is a discontinuous instruction. Line number 2 in Table 4 is an instruction that is continuous with line number 3 and is given the data "1". However, the line number 3 is not continuous with the command of the line number 4, and therefore data "0" is given.
第4図示ステツプc7,c9では、上述したような内容を有
する逆上り属性、順下り属性および分岐元欄が設定され
る。In the fourth illustrated steps c7 and c9, the reverse ascending attribute, the forward descending attribute, and the branch source column having the above-described contents are set.
まずステツプc8で当該命令が分岐命令であるか否かが判
断される。分岐命令であればステツプc10に移り、当該
分岐命令が第4表行番号11RET命令のような割込み処理
を終了させる命令であるか否かを判断する。この判断が
否定であればステツプc11に移り、分岐先行番号を求め
る。これは第1図のリストフアイル記憶部6を参照して
求められる。ステツプc12では、分岐の数を表す分岐数
データbiを+1インクリメントし、ステツプc13では当
該分岐数データbiと当該行番号を配列m、 m(bi)=ln …(3) で対応付ける。First, in step c8, it is judged whether or not the instruction is a branch instruction. If it is a branch instruction, the process proceeds to step c10, and it is determined whether or not the branch instruction is an instruction such as the fourth table line number 11RET instruction which terminates the interrupt processing. If this judgment is negative, the process proceeds to step c11 to obtain the branch leading number. This is obtained by referring to the list file storage unit 6 in FIG. In step c12, the branch number data bi representing the number of branches is incremented by +1. In step c13, the branch number data bi and the row number are associated with the array m, m (bi) = ln ... (3).
ステツプc14では、後述するようにスタツクの変化がチ
エツクされる。ステツプc15では属性データが計算され
ステツプc16では次の行番号を変数lnに設定し、処理を
ステツプc2に戻す。前記ステツプc8の判断が否定であれ
ば処理はステツプc14に移る。At step c14, the stack changes are checked as described later. At step c15, the attribute data is calculated, and at step c16, the next line number is set in the variable ln, and the process is returned to step c2. If the determination in step c8 is negative, the process proceeds to step c14.
前記ステツプc3の判断が肯定であれば当該命令は初めて
解析する命令行ではないことになり、ステツプc17で同
一属性を有する属性欄が存在するか否かが判断される。
この判断が否定であればステツプc4に移り、属性欄が増
加される。ステツプc17の判断が肯定であればステツプc
18に移り、当該分岐命令が分岐先行であるか否かが判断
される。分岐先行であればステツプc19で、第4表の分
岐元欄が設定され、ステツプc20に移る。ステツプc18の
判断が否定であればステツプc21において前記ステツプc
9で説明した逆上りフラグおよび順下りフラグが設定さ
れる。ここでステツプc19,c21の後、ステツプc17の判断
が肯定となつているので同一属性欄がすでに存在してい
ることになり、この属性に関しては解析は終了してお
り、再び解析を行うことなく解析処理が終了され、ステ
ツプc20に処理を移している。If the determination in step c3 is affirmative, the instruction is not the instruction line to be analyzed for the first time, and it is determined in step c17 whether or not there is an attribute column having the same attribute.
If this judgment is negative, the process moves to step c4 and the attribute column is increased. If the determination in step c17 is affirmative, step c
Moving to 18, it is determined whether or not the branch instruction is a branch preceding. If it is a branch preceding, the branch source column of Table 4 is set in step c19, and the process proceeds to step c20. If the determination at step c18 is negative, at step c21 the above step c
The reverse uplink flag and forward downlink flag described in 9 are set. Here, after steps c19 and c21, since the determination in step c17 is affirmative, it means that the same attribute column already exists, and the analysis has been completed for this attribute, and the analysis is not performed again. The analysis process is completed, and the process is moved to step c20.
ステツプc20では前記分岐数データbiが0であるか否か
が判断される。肯定であれば処理は終了する。否定であ
れば解析処理が終了していないことになり、ステツプc2
0に前記ステツプc13で記憶した分岐命令の行番号lnを前
記配列m(bi)にて読出し、またステツプc23にて分岐
数データbiを−1デクリメントし、処理はステツプc2に
戻る。すなわちステツプc22で読出された行番号lnから
再び解析処理を行う。At step c20, it is judged whether or not the branch number data bi is zero. If so, the process ends. If the answer is negative, it means that the analysis process has not been completed, and step c2
At 0, the line number ln of the branch instruction stored in step c13 is read in the array m (bi), the branch number data bi is decremented by 1 in step c23, and the process returns to step c2. That is, the analysis process is performed again from the line number ln read in step c22.
第8図は、分岐条件解析手段13の動作を説明するフロー
チヤートである。上記第4表に示したプログラム内容に
即して分岐条件解析処理について説明する。第8図ステ
ツプd1では行番号slnを0に設定し、ステツプd2では行
番号slnを+1インクリメントする。ステツプd3では当
該行番号lnがプログラムの最終行番号、すなわち第4表
のプログラム例では行番号11を超えたか否かを判断す
る。超えていれば処理は終了し、超えていなければステ
ツプd4に移る。ステツプd4では行番号lnの命令が分岐命
令であるか否かを判断する。上記プログラム例では、行
番号1は分岐命令ではなく処理はステツプb2へ戻り、次
の行番号の命令へ進む。行番号3で分岐命令であること
が判断され、ステツプd5へ進む。FIG. 8 is a flow chart for explaining the operation of the branch condition analyzing means 13. The branch condition analysis processing will be described according to the program contents shown in Table 4 above. In step d1, the line number sln is set to 0, and in step d2 the line number sln is incremented by +1. At step d3, it is determined whether the line number ln exceeds the last line number of the program, that is, the line number 11 in the program example of Table 4. If so, the process ends, and if not, the process moves to step d4. At step d4, it is determined whether the instruction at line number ln is a branch instruction. In the above program example, line number 1 is not a branch instruction, and the process returns to step b2 to proceed to the instruction of the next line number. It is determined that the instruction is a branch instruction at line number 3, and the process proceeds to step d5.
ステツプd5では、属性欄番号を表す変数kを0に設定
し、ステツプd6では変数kを+1インクリメントする。
ステツプd7では、当該行番号lnの命令に関する属性欄の
個数を表す配列CZ(ln)に関して、 k≦CZ(ln) …(4) の判断を行う。この判断が否定であれば、第4図に示し
た流れ構造解析処理の際の命令毎の属性欄の個数を超過
したことになり、すなわち当該分岐命令におけるすべて
の属性について分岐条件解析が終了したことになり、処
理はステツプd2へ移り、次の行番号の命令へ進む。At step d5, the variable k representing the attribute column number is set to 0, and at step d6 the variable k is incremented by +1.
At step d7, k≤CZ (ln) (4) is judged with respect to the array CZ (ln) representing the number of attribute fields related to the instruction of the line number ln. If this judgment is negative, it means that the number of attribute columns for each instruction in the flow structure analysis processing shown in FIG. 4 has been exceeded, that is, branch condition analysis has been completed for all attributes in the branch instruction. Then, the processing shifts to step d2 to proceed to the instruction of the next line number.
ステツプd7の判断が肯定であればステツプd8へ移り、当
該行番号lnの前記命令における属性欄番号kに沿って後
述する逆上り処理を開始して逆上り経路を求める。前述
したように分岐命令の分岐条件を確定するに必要な命令
には、後述する関与フラグを設定する。ステツプd9で
は、後述するように逆上つて読取つた命令毎の実行内容
を分岐条件として構成する。ステツプd10では、このよ
うにして得られた分岐条件を第1図示の分岐条件フアイ
ル記憶部16に記憶する。If the determination in step d7 is affirmative, the process proceeds to step d8, and the reverse ascending process described later is started along the attribute column number k in the instruction of the line number ln to obtain the reverse ascending route. As described above, a participation flag, which will be described later, is set to the instruction necessary to determine the branch condition of the branch instruction. At step d9, the execution content of each instruction read backward is constructed as a branch condition as described later. At step d10, the branch condition thus obtained is stored in the branch condition file storage unit 16 shown in FIG.
第9図は、第8図のステツプd8の逆上り処理の詳細を説
明するフローチヤートである。第9図ステツプe1では、
後述する制御変数SWが0に初期化される。ステツプe2で
は、上記制御変数SWが0であるか否かを判断し、肯定で
あればステツプe3に移り、第4表の属性欄に示される逆
上りフラグをチエツクして、逆上りフラグが0のとき制
御変数SW=2とし、逆上りフラグが0以内のときSW=1
と設定する。この後、処理はステツプe2に戻る。FIG. 9 is a flow chart for explaining the details of the reverse ascending process of step d8 of FIG. Fig. 9 At step e1,
A control variable SW described later is initialized to 0. At step e2, it is judged whether or not the control variable SW is 0, and if affirmative, the process goes to step e3 to check the reverse ascending flag shown in the attribute column of Table 4 so that the reverse ascending flag becomes 0. Control variable SW = 2 when, and SW = 1 when reverse going flag is within 0
And set. After this, the processing returns to step e2.
第10図は、前記ステツプe3の逆上り判断処理の詳細を説
明するフローチヤートである。第10図ステツプf1では、
第4表行番号3の属性欄1の属性データtoで示される属
性欄番号を読出す。上記例ではto=「1」であり、属性
欄1が読出される。ステツプf2では、属性欄1の逆上り
フラグの値を前記属性データtoの値に設定する。ステツ
プf3では、属性データtoが0であるか否かを判断する。
0であれば前行の命令とは実行順に関する持続性が失わ
れていることになり、ステツプf4で前記制御変数SW=2
に設定して処理は終了する。FIG. 10 is a flow chart for explaining the details of the reverse ascending determination processing of the step e3. Figure 10 At step f1,
The attribute column number indicated by the attribute data to in the attribute column 1 of the fourth table row number 3 is read. In the above example, to = “1”, and the attribute column 1 is read. At step f2, the value of the reverse ascending flag in the attribute column 1 is set to the value of the attribute data to. At step f3, it is determined whether or not the attribute data to is 0.
If it is 0, it means that the instruction in the preceding line has lost the continuity in the execution order, and the control variable SW = 2 in step f4
And the process ends.
前記ステツプf3で判断が否定であれば、前行の命令とは
処理が連続していることになり、ステツプf5にて制御変
数SW=1に設定する。ステツプf6では、行番号を表す変
数lnを−1デクリメントして処理を終了する。第4表の
プログラムと例の行番号3では属性データto=「1」で
あり、この場合、制御変数SW=1となる。If the determination in step f3 is negative, the processing is continuous with the instruction in the preceding line, and the control variable SW = 1 is set in step f5. At step f6, the variable ln representing the line number is decremented by -1, and the processing is terminated. In the program of Table 4 and the line number 3 in the example, the attribute data to = “1”, and in this case, the control variable SW = 1.
再び第9図を参照して、前記ステツプe2の判断が否定で
あればステツプe4へ移り、制御変数SW=1であるか否か
を判断する。肯定であればステツプe5へ移り、上記分岐
命令の分岐条件を確定するに必要な情報が全て得られて
いるとき、対応する逆上りフラグをクリアし、新たに必
要な情報を対応するフラグをセツトする。全てのフラグ
がクリアされたとき、制御変数SW=4と設定され、これ
以外のときには制御変数SW=0に設定される。この後、
処理はステツプe2に戻る。Referring again to FIG. 9, if the determination at step e2 is negative, the process proceeds to step e4 to determine whether the control variable SW = 1. If affirmative, the process moves to step e5, and when all the information necessary to determine the branch condition of the above branch instruction is obtained, the corresponding reverse uplink flag is cleared and the newly necessary information is set to the corresponding flag. To do. When all the flags are cleared, the control variable SW = 4 is set, and otherwise, the control variable SW = 0 is set. After this,
The process returns to step e2.
第11図は、前記ステツプe5の逆上り情報設定処理の詳細
を説明するフローチヤートである。第11図ステツプg1で
は、被解析プログラムを1行ずつ逆上る毎に+1インク
リメントされる逆上り行カウンタrcを+1インクリメン
トする。ステツプg2では、逆上り用カウンタcnを変数と
し、行番号ln、属性データto、分岐欄番号ndおよび分岐
命令またはストア命令の分岐条件、またはストア条件を
確定するに必要な命令の行番号rn0を一時的に記憶する
ワークメモリmに、先ず逆上つた行番号lnを記憶する。FIG. 11 is a flow chart for explaining the details of the reverse uplink information setting process of the step e5. In step g1 in FIG. 11, the reverse ascending row counter rc is incremented by +1 every time the program to be analyzed is moved up one line at a time. In step g2, the counter cn for reverse going is used as a variable, and the line number ln, the attribute data to, the branch column number nd, the branch condition of the branch instruction or the store instruction, or the line number rn0 of the instruction necessary to determine the store condition is set. In the work memory m which is temporarily stored, the row number ln which is inverted is stored first.
ステツプg3では同じくワークメモリmに逆上つた命令の
属性データtoを記憶する。ステツプg4では、逆上つた行
番号に対応する第6図示の分岐元フアイル部21の分岐元
欄21において、当該命令の属性データtoと同一属性へ分
岐している分岐元命令の個数を計数し、記憶する。ま
た、前記ワークメモリmに記憶された分岐元命令毎に分
岐元欄番号ntをワークメモリmに記憶する。At step g3, similarly, the attribute data to of the inverted command is stored in the work memory m. In step g4, the number of branch source instructions branching to the same attribute as the attribute data to of the instruction is counted in the branch source column 21 of the branch source file unit 21 shown in FIG. 6 corresponding to the inverted line number. ,Remember. Further, the branch source column number nt is stored in the work memory m for each branch source instruction stored in the work memory m.
ステツプg5では、前記ステツプg2〜g4で得られた各種デ
ータが必要であるか否かを判断する。第4表の行番号3
のCALL命令は、無条件分岐命令であり、したがつて行番
号2の上記各種データは不必要であり、判断は否定とな
る。一方、第4表行番号3が前記第1表行番号5のBBC
命令のように条件付き分岐命令であつて、行番号2がそ
の分岐条件に関与するならばステツプg7へ移り、そのよ
うな命令毎に与えられる番号を前記ワークメモリに記憶
する。ステツプg8では、前記ワークメモリ以外の情報フ
ラグをクリアし、ステツプg9に移る。At step g5, it is judged whether or not the various data obtained at steps g2 to g4 are necessary. Line number 3 in Table 4
CALL instruction is an unconditional branch instruction. Therefore, the above-mentioned various data of line number 2 are unnecessary, and the determination is negative. On the other hand, the fourth table row number 3 is the BBC of the first table row number 5
If the instruction is a conditional branch instruction and the line number 2 is involved in the branch condition, the process moves to step g7, and the number given to each such instruction is stored in the work memory. In step g8, the information flags other than the work memory are cleared, and the process proceeds to step g9.
ステツプg9では、新たな必要情報があるか否かが判断さ
れ、あればステツプg10で新たな情報フラグを設定し、
ステツプg11に移る。前記ステツプg5の判断が否定の場
合、前記ワークメモリm(rcrn0)にはデータ「0」が
設定され、ステツプg11に移る。ステツプg9の判断が否
定の場合も同様である。In step g9, it is judged whether or not there is new necessary information, and if there is new information, a new information flag is set in step g10,
Move to step g11. If the determination in step g5 is negative, data "0" is set in the work memory m (rcrn0), and the process proceeds to step g11. The same applies when the judgment in step g9 is negative.
ステツプg11では、分岐条件やストア命令の内容を確定
するためにさらに新たな情報が必要か否かを表す必要情
報フラグが「0」であるか否かを判断する。すなわち、
必要情報フラグが「1」のとき、逆上り解析処理が出発
した前記分岐命令やストア命令の実行内容が確定したこ
とになり、処理はステツプg12へ移り、前記制御変数SW
=「4」とする。これは後述するように、前記ワークメ
モリmに記憶されたデータを第1図の分岐条件フアイル
記憶部16に書込む処理を行うためである。また、前記ス
テツプg11の判断が否定であれば、処理はステツプg13に
移り、制御変数SW=「0」に設定される。これは後述す
るように、処理が第9図ステツプe2へ戻つたとき、ステ
ツプe3へ移つて逆上り処理を続行するためである。At step g11, it is judged whether or not a necessary information flag indicating whether or not new information is necessary to determine the branch condition or the contents of the store instruction is "0". That is,
When the necessary information flag is "1", it means that the execution contents of the branch instruction or the store instruction from which the reverse ascending analysis processing has started are fixed, and the processing moves to step g12, and the control variable SW
= "4". This is because, as will be described later, a process of writing the data stored in the work memory m into the branch condition file storage unit 16 of FIG. 1 is performed. If the determination in step g11 is negative, the process proceeds to step g13 and the control variable SW = "0" is set. This is because, as will be described later, when the process returns to step e2 in FIG. 9, the process moves to step e3 to continue the reverse ascending process.
このようにして第9図ステツプe5が実行され、処理はス
テツプe2に戻る。前記ステツプe4の判断が否定であれば
ステツプe6へ移り、制御変数SW=「2」であるか否かが
判断される。この場合は、ステツプe3で説明したよう
に、逆上りフラグ=「0」であつて、行番号が直前の命
令とは処理の順序が連続していない命令である場合を示
している。このような場合には、逆上り解析処理を分岐
させる必要があるため、ステツプe7に移る。ステツプe7
では、後述するように逆上り解析処理の分岐先の行番号
を求め、制御変数SW=「1」として処理をステツプe2に
戻す。In this way, step e5 in FIG. 9 is executed, and the process returns to step e2. If the determination in step e4 is negative, the process proceeds to step e6, and it is determined whether the control variable SW = “2”. In this case, as described in step e3, the case where the backward flag is "0" and the processing order is not continuous with the instruction immediately before the line number is shown. In such a case, since it is necessary to branch the reverse uplink analysis process, the process moves to step e7. Step e7
Then, as will be described later, the line number of the branch destination of the reverse ascending analysis processing is obtained, the control variable SW is set to "1", and the processing is returned to step e2.
第12図は、第9図ステツプe7の逆上り分岐処理の詳細を
示すフローチヤートである。第12図ステツプh1では、第
11図ステツプg4で分岐元欄番号が記憶されたワークメモ
リm[rc,nd(cn)]から分岐元欄番号を読出し、第4
表に示されるような分岐元欄1などにおいて、対応する
分岐元行番号データNOや、分岐元の属性データすなわち
分岐元属性欄番号frを求め、行番号lnに前記分岐元行番
号データNOを設定し、ステツプh2では属性データtoに分
岐元属性データを設定する。FIG. 12 is a flow chart showing the details of the reverse ascending branch process of step e7 in FIG. Fig. 12 In step h1,
In step g4 of FIG. 11, the branch source column number is read from the work memory m [rc, nd (cn)] in which the branch source column number is stored, and the fourth
In the branch source column 1 or the like as shown in the table, the corresponding branch source line number data NO or the branch source attribute data, that is, the branch source attribute column number fr is obtained, and the branch source line number data NO is assigned to the line number ln. The branch source attribute data is set in the attribute data to in step h2.
ステツプh3では、第11図ステツプg4で設定された分岐個
数データm[rc],cnを−1デクリメントする。この
後、ステツプh4で前記制御変数SW=「1」とし、処理は
終了する。At step h3, the branch number data m [rc], cn set at step g4 in FIG. 11 is decremented by -1. After that, in step h4, the control variable SW is set to "1", and the process is terminated.
このように第9図ステツプe7の処理が終了してステツプ
e2に戻る。ステツプe6の判断が否定であればステツプe8
に移り、制御変数SW=「3」であるか否かを判断する。
この判断が肯定であればステツプe9に移り、逆上り解析
を保留している解析経路の開始行番号を求め、制御変数
SW=「2」として処理をステツプe2へ戻す。Thus, the processing of step e7 in FIG.
Return to e2. If the judgment in step e6 is negative, step e8
Then, it is determined whether or not the control variable SW = “3”.
If this judgment is affirmative, the process moves to step e9 to find the start line number of the analysis route that holds the reverse ascending analysis, and
Set SW = "2" and return the process to step e2.
第13図は第9図ステツプe9の未解析データ処理の詳細を
示すフローチヤートである。第13図ステツプp1では、逆
上り経路カウンタrcが「0」であるか否かを判断する。
すなわち、未解析の逆上り解析経路が残つているかどう
かを判断する。このような未解析逆上りルートが存在し
なければステツプp2に移り、制御変数SW=「5」として
処理を終了する。ステツプp1の判断が否定であればステ
ツプp3に移り、逆上り経路カウンタrcを−1デクリメン
トし、ステツプp4にて第11図ステツプg4で説明した分岐
個数ワークデータm(rc),cnが0であるか否かを判断
する。0であれば処理はステツプp1に戻り、他の未解析
経路に関して同様な処理を行う。FIG. 13 is a flow chart showing the details of the unanalyzed data processing of FIG. 9 step e9. In step p1 of FIG. 13, it is judged whether or not the reverse path counter rc is "0".
That is, it is determined whether or not there are unanalyzed reverse uplink analysis routes. If such an unanalyzed reverse ascending route does not exist, the process proceeds to step p2, the control variable SW is set to "5", and the process ends. If the determination in step p1 is negative, the process moves to step p3, the reverse route counter rc is decremented by -1, and the branch number work data m (rc), cn explained in step g4 in FIG. 11 is 0 in step p4. Determine if there is. If it is 0, the process returns to step p1 and the same process is performed for other unanalyzed routes.
ステツプp4の判断が否定であればステツプp5に移り、制
御変数SW=「2」に設定して処理を終了する。If the determination in step p4 is negative, the process proceeds to step p5, the control variable SW is set to "2", and the process is terminated.
再び第9図を参照して、このようにしてステツプe9の未
解析ルート解析処理が終了して処理はステツプe2に戻
る。ステツプe8の判断が否定であればステツプe10に移
り、制御変数SW=「4」であるか否かを判断する。肯定
であれば、逆上り解析処理は想定される全ての逆上り解
析経路に関して終了していることになり、ステツプe11
にて得られた解析経路、すなわち逆上り解析経路を構成
する各命令の行番号データを第1図の分岐条件フアイル
16に書込む。未解析経路が残つている場合には、制御変
数SW=「3」と設定される。Referring again to FIG. 9, the unanalyzed route analysis processing of step e9 is completed in this way, and the processing returns to step e2. If the determination in step e8 is negative, the process proceeds to step e10 to determine whether the control variable SW = "4". If the result is affirmative, it means that the reverse-link analysis processing has been completed for all the possible reverse-link analysis paths, and step e11
The branch condition file of FIG. 1 is used as the analysis path obtained in step 1, that is, the line number data of each instruction forming the reverse analysis path.
Write to 16. When the unanalyzed route remains, the control variable SW is set to "3".
第14図は、第9図ステツプe11の処理を詳述するフロー
チヤートである。第14図ステツプq1で前記逆上り経路カ
ウンタrcが0であるか否かが判断される。0であれば、
前逆上り経路に亘つて解析が終了したことになり、前述
した経路データの記憶処理を行い、処理は終了する、ス
テツプq1の判断が否定であれば、ステツプq3に移り、制
御変数SW=「3」に設定して処理を終了する。FIG. 14 is a flow chart detailing the processing of step e11 in FIG. In step q1 in FIG. 14, it is judged whether or not the reverse uplink route counter rc is zero. If 0,
Since the analysis has been completed over the previous reverse uphill route, the above-mentioned route data storage processing is performed, and the processing is terminated. If the determination at step q1 is negative, the process proceeds to step q3 and the control variable SW = “ "3" is set and the processing ends.
再び第9図を参照して、このようにしてステツプe11で
データの書込み処理が終了して処理はステツプe2に戻
る。ステツプe10の判断が否定の場合、第13図ステツプp
2で説明したように、全解析経路に亘つて解析が終了し
ていることになり、第8図ステツプd8で説明したプログ
ラムを逆上る経路を求める処理が終了する。Referring to FIG. 9 again, the data writing process is thus completed at step e11, and the process returns to step e2. If the judgment in step e10 is negative, step p in FIG.
As described in 2, the analysis has been completed over the entire analysis path, and the processing for obtaining the path going up the program described in step d8 in FIG. 8 ends.
第8図ステツプd9では、ステツプd8で得られた逆上り解
析経路毎に分岐条件を合成する処理を行う。上記第2表
〜第3表における分岐命令は、無条件分岐命令であり、
第1表のプログラム例に関して説明する。このプログラ
ム例の分岐命令は、行番号5のBCC命令であり、前述し
た逆上る経路を求める処理に従えば行番号5から出発す
る逆上り解析経路として行番号5→4→3→2→1が得
られる。In step d9 of FIG. 8, processing for synthesizing branch conditions is performed for each reverse ascending analysis path obtained in step d8. The branch instructions in Tables 2 to 3 above are unconditional branch instructions,
The program example in Table 1 will be described. The branch instruction of this program example is the BCC instruction of line number 5, and according to the above-described process for obtaining the reverse route, line number 5 → 4 → 3 → 2 → 1 is set as the reverse ascending analysis route starting from line number 5. Is obtained.
すなわち、行番号5の分岐命令の分岐条件は行番号4で
得られる、 A−#8≧0 …(5) であり、変数Aが未確定である。行番号3で変数Aにつ
いて、 A←(A−B) …(6) の演算が行われ、未確定変数はA,Bとなる。行番号2〜
1の命令にて A=#3 …(7) B=#5 …(8) が得られ、変数A,Bは確定する。したがつて、これらを
合成すると、分岐条件として 3*5−8≧8 …(9) が得られる。That is, the branch condition of the branch instruction at line number 5 is A- # 8 ≧ 0 (5) obtained at line number 4, and the variable A is undetermined. The calculation of A ← (A−B) (6) is performed on the variable A in the line number 3, and the undetermined variables are A and B. Line numbers 2 to
With the instruction of 1, A = # 3 (7) B = # 5 (8) is obtained, and the variables A and B are determined. Therefore, when these are combined, 3 * 5-8 ≧ 8 (9) is obtained as the branching condition.
第8図のステツプd10では、このようにしてステツプd9
で得られた分岐条件を第1図分岐条件フアイル記憶部16
に記憶する。このようにして、被解析プログラムを分岐
命令から逆上り、分岐条件を求める処理は終了する。In step d10 in FIG. 8, in this way, step d9
The branch condition obtained in step 1 is shown in FIG.
Remember. In this way, the program to be analyzed is moved backward from the branch instruction, and the processing for obtaining the branch condition is completed.
また、第4表のプログラム例において、実行内容を求め
る処理は、第8図ステツプd8で得られた逆上り解析経路
を、たとえば行番号10のST命令から開始することによつ
て得られる。得られた第1の解析経路は、前述したよう
に 行番号 10→9→3→2→1 である。この経路に沿つて前記分岐条件を合成した手法
と同様な技術により、実行内容を合成すると、 [PORT1+0]+1→[PORT1+0] …(10) [PORT1]は、アドレスPORT1に格納されたデータを示
す。Further, in the program example of Table 4, the process for obtaining the execution content is obtained by starting the reverse ascending analysis path obtained at step d8 in FIG. 8 from the ST instruction at line number 10, for example. The first analysis path obtained is the line number 10 → 9 → 3 → 2 → 1 as described above. When the execution contents are combined by a technique similar to the method of combining the branch conditions along this path, [PORT1 + 0] + 1 → [PORT1 + 0] (10) [PORT1] indicates the data stored in the address PORT1. .
が得られる。たとえば、[PORT1+0]+1→[PORT1+
0]が実行される条件(このような実行内容が合成され
るような順序でプログラムが実行される条件、すなわち
このような実行内容が合成されるような順番でプログラ
ムを辿ったときに現れる条件分岐命令の分岐条件の合成
条件)が 分岐Aで分岐し、分岐Bで分岐し、分岐Cで分岐しなか
つたとき、 もしくは 分岐Aで分岐し、分岐Bで分岐せず、分岐Cで分岐しな
かつたとき、 であるなら、分岐Xで分岐することをX、分岐Xで分岐
しないことをで表すと、上記条件は AかつBかつもしくはAかつかつ となり、これを式で表すことにより A・B・+A・・=A・ と簡略化でき、最終的に 「分岐Aで分岐し、分岐Cで分岐しなかつたとき」に [PORT1+0]+1→[PORT1+0]が実行されるという
簡略化された命題を得ることができる。Is obtained. For example, [PORT1 + 0] +1 → [PORT1 +
0] is executed (a condition in which the programs are executed in such an order that such execution contents are combined, that is, a condition that appears when the program is traced in such an order that such execution contents are combined). When the composition condition of the branch condition of the branch instruction is branched at branch A, branched at branch B, and not branched at branch C, or if branched at branch A and not at branch B, then at branch C. If it is, then if branching with branch X is represented by X and branching with branch X is not represented, then the above condition becomes A and B and / or A and and.・ Simplified proposition that [PORT1 + 0] + 1 → [PORT1 + 0] is executed when "branch A and not branch C" can be simplified as + A ... = A. Can be obtained.
すなわちアドレスPORT1にプリセツトデータ0を加えた
アドレスの内容にデータ1を加えたものを同一アドレス
に再び格納する処理、すなわちアドレスPORT1のデータ
を+1インクリメントする処理を示している。That is, a process of storing again the contents of the address obtained by adding the preset data 0 to the address PORT1 and the data 1 at the same address, that is, a process of incrementing the data of the address PORT1 by +1.
他の解析経路は 行番号10→9→8→7→6 となる。この経路に沿つて実行内容を合成すると、先程
と同様に [PORT2+0]+1+1→[PORT2+0] …(11) となり、アドレスPORT2のデータを2ずつインクリメン
トする処理であることが判る。このような実行内容のデ
ータは、第1図の実行内容フアイル記憶部17に記憶され
る。The other analysis routes are line numbers 10 → 9 → 8 → 7 → 6. When the execution contents are combined along this path, [PORT2 + 0] + 1 + 1 → [PORT2 + 0] (11) as in the previous case, and it is understood that this is a process of incrementing the data of the address PORT2 by two. Such execution content data is stored in the execution content file storage unit 17 shown in FIG.
以上のようにして本実施例に従えば、上記第2表〜第4
表や第5図〜第7図に示した分岐元欄の各データや属性
欄を構成する各データを、逆上り解析処理に先立つて設
定するようにしたので、逆上り解析時においてプログラ
ムの実行順序に矛盾する不所望な逆上り解析経路が選択
されて、無駄な処理が行われる事態を防ぐことができ
る。According to the present embodiment as described above, Tables 2 to 4 above
Since each data in the branch source column and each data constituting the attribute column shown in FIG. 5 to FIG. 7 is set prior to the reverse uplink analysis processing, the program is executed during the reverse uplink analysis. It is possible to prevent a situation in which useless processing is performed by selecting an undesired reverse uplink analysis path inconsistent with the order.
また本実施例では、前記第2表に示したプログラム例の
行番号9〜11のサブルーチンプログラムAのように、行
番号3のCALL命令で呼出されるとともに、行番号6のCA
LL命令で呼出されたサブルーチンプログラムBが呼出さ
れることにより再び実行されるような命令列において、
複数の分岐命令毎に解析経路を識別する属性データを設
定するようにしている。Further, in this embodiment, like the subroutine program A of the line numbers 9 to 11 in the program example shown in Table 2, the CALL instruction of the line number 3 is called and the CA of the line number 6 is called.
In the instruction sequence that is executed again by calling the subroutine program B called by the LL instruction,
Attribute data for identifying an analysis path is set for each of a plurality of branch instructions.
したがつて、このようなサブルーチンプログラムの中か
ら逆上り解析処理を行うに際して、CALL命令などの呼出
し箇所に応じた解析経路を設定することができ、誤つた
解析経路が設定される事態を防ぐことができる。Therefore, when performing reverse ascending analysis processing from such a subroutine program, it is possible to set the analysis path according to the call location of the CALL instruction, etc., and prevent the situation where an incorrect analysis path is set. You can
以下、第4表の属性欄における順下がりフラグについて
説明する。The forward drop flag in the attribute column of Table 4 will be described below.
第15図はこの順下がりフラグを用いる理由を説明するプ
ログラム例を示すフローチヤートであり、第16図は第15
図示のプログラム実行時に用いられるスタツク36の記憶
内容を説明する図である。メインルーチンプログラムの
実行時にサブルーチンプログラムが呼出されると、第16
図(1)に示すようにスタツク36には戻りアドレスが格
納されてスタツクポインタは+1インクリメントされ、
処理はたとえば第15図示のサブルーチンプログラムに移
る。FIG. 15 is a flow chart showing a program example for explaining the reason why the forward-downward flag is used, and FIG.
It is a figure explaining the memory content of the stack 36 used at the time of execution of the illustrated program. If the subroutine program is called during execution of the main routine program, the 16th
As shown in FIG. 1A, the stack 36 stores the return address and the stack pointer is incremented by +1.
The processing shifts to, for example, the subroutine program shown in FIG.
第15図のサブルーチンプログラムにおいて、ステツプr1
でスタツク36に新たなアドレスデータを書込むプツシユ
命令PSHが実行されると、スタツク36には第16図(2)
図示のようにアドレスデータが書込まれ、スタツクポイ
ンタは+1インクリメントされる。これ以降、処理がス
テツプr2,r3,r4,r5と進行した場合、スタツク36から最
新に書込まれたアドレスデータを読出してスタツクポイ
ンタを−1デクリメントするプル命令PULLによりスタツ
ク36では、第16図(3)に示すように前記アドレスデー
タが消去され、戻りアドレスのみが残る状態となる。In the subroutine program of FIG. 15, step r1
When the push instruction PSH for writing new address data to the stack 36 is executed, the stack 36 is loaded into the stack 36 as shown in FIG. 16 (2).
As shown, address data is written and the stack pointer is incremented by +1. After that, when the processing proceeds to steps r2, r3, r4, r5, the stack 36 is read by the pull instruction PULL that reads out the latest written address data from the stack 36 and decrements the stack pointer by -1. As shown in FIG. 3C, the address data is erased and only the return address remains.
第15図示のようなサブルーチンプログラムにおいて、前
記スタツク操作命令PSHとスタツク操作命令PULLとが単
一のサブルーチンプログラム内で1個ずつ組となつてい
るか否かを検査しようとする場合を想定する。このとき
逆上り処理では、下記の3種類の経路が存在する。It is assumed that the subroutine program as shown in the fifteenth example is intended to check whether or not the stack operation instruction PSH and the stack operation instruction PULL are paired one by one in a single subroutine program. At this time, in the reverse uplink processing, there are the following three types of routes.
行番号R7,R6 …(12) 行番号R7,R6,R2,R1 …(13) 行番号R7,R5,R4,R3,R2,R1 …(14) である。したがつて、前記検査を行う場合、第12式の経
路についても検査することになり、スタツク操作命令に
全く関係を有さない無駄な検査を行つてしまうことにな
る。したがつて、前記のような検査を行う場合、プログ
ラムの実行順に命令を読取つて検査を行う手法が無駄な
処理を省く点で有利である。Line numbers R7, R6 (12) Line numbers R7, R6, R2, R1 (13) Line numbers R7, R5, R4, R3, R2, R1 (14) Therefore, when the inspection is performed, the route of the twelfth formula is also inspected, and a useless inspection having no relation to the stack operation command is performed. Therefore, in the case of performing the inspection as described above, the method of reading the instruction in the order of execution of the program and performing the inspection is advantageous in that unnecessary processing is omitted.
このため本実施例では、第4表の属性欄における順下が
りフラグを設定するようにした。この順下がりフラグ
は、前述したように、ある命令が次の行番号の命令と実
行順序に関して連続した命令であるか否かを識別するフ
ラグである。この順下がりフラグを前述の実施例におい
て説明した逆上りフラグと同様な手法にて用いることに
より、被解析プログラムを順下がりの経路にて読取つて
解析を行うことができる。これにより無駄な処理は省か
れ、処理の高速化と高効率化とを図ることができる。Therefore, in this embodiment, the forward-downward flag is set in the attribute column of Table 4. As described above, the forward drop flag is a flag for identifying whether or not a certain instruction is a sequential instruction in the execution order with the instruction of the next line number. By using this forward-downward flag in the same manner as the reverse-upward flag described in the above embodiment, it is possible to read and analyze the program to be analyzed along the forward-downward path. As a result, wasteful processing is omitted, and the processing speed and efficiency can be increased.
前述の第4表のプログラム例において、サブルーチンプ
ログラムAに対し、複数のCALL命令が配置される場合、
同表の分岐元欄および属性欄は、CALL命令の数だけ設定
されることになる。このようなサブルーチンプログラム
がその中でスタツクの内容を変化させないならば、異な
るCALL命令によって呼出された場合でも実行内容は同一
であり、このような場合には後述するように分岐元欄お
よび属性欄に割りあてられるメモリの容量を削減するこ
とができる。In the program example of Table 4 above, when a plurality of CALL instructions are arranged for the subroutine program A,
The branch source column and the attribute column in the table are set as many as the number of CALL instructions. If such a subroutine program does not change the contents of the stack in it, the execution contents are the same even if called by different CALL instructions. In such a case, the branch source column and attribute column It is possible to reduce the amount of memory allocated to.
このような本実施例の動作例を、下記第5表のプログラ
ム例に沿つて説明する。An operation example of this embodiment will be described along with a program example shown in Table 5 below.
上記の第5表の分岐元欄および属性欄のデータは、上記
第4表を参照して説明したデータの設定方法に基づいて
設定されている。ここで前述したように、分岐元欄およ
び属性欄に割りあてられるメモリの容量を削減するため
に、第5表のプログラム例に基づいて下記第6表のよう
な分岐元欄および属性欄を作成する。 The data in the branch source column and the attribute column in Table 5 above are set based on the data setting method described with reference to Table 4 above. As described above, in order to reduce the memory capacity allocated to the branch source column and the attribute column, the branch source column and the attribute column as shown in Table 6 below are created based on the program example of Table 5. To do.
上記第5表と第6表とでは、下線を付したデータが変更
されている。すなわち、行番号3のCALL命令とこれより
分岐した行番号8〜10の命令列、およびリターン命令RE
Tによりさらに分岐した行番号4に関する分岐元欄や属
性欄の決定に関しては、上記第5表と同様に設定され
る。引続き行番号6を読取つたとき、行番号8に分岐す
る。 In Tables 5 and 6 above, the underlined data has been changed. That is, the CALL instruction at line number 3, the instruction sequence at line numbers 8 to 10 branched from this, and the return instruction RE
The determination of the branch source column and the attribute column for the line number 4 further branched by T is set in the same manner as in Table 5 above. When the line number 6 is continuously read, the process branches to the line number 8.
第4表の例では新たな分岐元欄2および属性欄2が設定
されるが、本実施例は同一のサブルーチンプログラムを
解析するため、このような分岐元欄および属性欄の増加
を行わず、分岐元欄1の行番号8において、行番号デー
タNO=「0」と設定し、また行番号4の属性データfr=
「0」と設定する。さらに、行番号8の属性欄to=
「0」と設定する。このようなデータ「0」を用いて、
行番号6のCALL命令に基づく行番号8〜10のサブルーチ
ンプログラムの解析を終了したことを表示する。In the example of Table 4, new branch source column 2 and attribute column 2 are set, but since this embodiment analyzes the same subroutine program, such branch source column and attribute column are not increased, In line number 8 of branch source column 1, line number data NO = “0” is set, and line number 4 attribute data fr =
Set it to "0". Furthermore, the attribute column of line number to =
Set it to "0". By using such data “0”,
It indicates that the analysis of the subroutine program of line numbers 8 to 10 based on the CALL instruction of line number 6 has been completed.
このとき、属性欄も同様に、行番号1→2→3→8→9
→10→4→5までの解析が終了した段階では、第5表の
属性欄1のようなデータが設定されるが、行番号6以降
の前述のような処理によつて属性欄2を増設せず、第6
表の属性欄1のようなデータが設定される。At this time, similarly in the attribute column, the line numbers 1 → 2 → 3 → 8 → 9
At the stage when the analysis of → 10 → 4 → 5 is completed, the data like the attribute column 1 in Table 5 is set, but the attribute column 2 is expanded by the processing as described above after the line number 6. No, No. 6
Data such as the attribute column 1 in the table is set.
逆上り処理にあたつて、行番号8の分岐元欄1の行番号
データNOが参照されるとこれは「0」てあるため、分岐
元行番号が不明となる。したがつて、前述した分岐元欄
および属性欄を作成する処理において、行番号8に分岐
する分岐元命令の行番号の逆上り時における次の行番
号、すなわち第5表の例では行番号5,2をフアーストイ
ンラストアウト(FILO)形のメモリに記憶する。したが
つて、逆上り解析時において、分岐元欄で行番号データ
「0」のデータが参照された場合には、前記行番号を記
憶したFILO形メモリからデータを読出して逆上り処理に
おける分岐先行番号とする。When the line number data NO in the branch source column 1 of the line number 8 is referred to during the reverse processing, since this is "0", the branch source line number becomes unknown. Therefore, in the process of creating the branch source column and the attribute column described above, the next line number when the line number of the branch source instruction branching to the line number 8 is reversed, that is, the line number 5 in the example of Table 5 is used. , 2 are stored in the memory of the first in last out (FILO) type. Therefore, when the data of the line number data “0” is referred to in the branch source column during the reverse ascending analysis, the data is read from the FILO type memory storing the line number and the branch preceding in the reverse ascending process is performed. Number.
このようにすることによつて、流れ制御フアイル記憶部
12において、分岐元欄および属性欄に割当てられるメモ
リの容量を削減することができる。By doing so, the flow control file storage
In 12, the capacity of the memory allocated to the branch source column and the attribute column can be reduced.
前記第4表のプログラム例における実行内容は、行番号
3,5,11などの分岐命令やスタツクの内容を操作する命令
などによつて変化するスタツクの記憶内容に大きく作用
されることが知られている。このようなスタツクの内容
を予め属性欄のデータとしてまとめておくと、プログラ
ムの解析上便利である。とりわけ前記第4表の行番号5
のPSH命令や、これと対を成すPULL命令などのようにス
タツクの内容を変化させる命令が含まれる場合には、プ
ログラムの実行状態の変化が明瞭になり、プログラム解
析経路の特定が容易になる。The execution contents in the program example of Table 4 above are line numbers.
It is known that the memory contents of the stack, which are changed by a branch instruction such as 3, 5, 11 or an instruction for manipulating the contents of the stack, are greatly affected. It is convenient to analyze the program if the contents of such a stack are collected in advance as data in the attribute column. In particular, row number 5 in table 4 above
If an instruction that changes the contents of the stack is included, such as the PSH instruction and the PULL instruction that forms a pair with it, the change in the execution state of the program becomes clear and the program analysis path can be easily specified. .
上記第4表と同一のプログラム例において、当該プログ
ラムの各命令毎に下記第7表のようなアドレスが設定さ
れる場合を想定して説明する。In the same program example as in Table 4 above, description will be given assuming that an address as shown in Table 7 below is set for each instruction of the program.
本実施例では、分岐元欄および属性欄のデータは第4表
のデータを用いるが、これに加えスタツクの内容が変化
する命令がある場合には、その命令により変化したスタ
ツクの内容をデータとするスタツクデータVALの欄を設
ける。これによれば、行番号3で行番号9へ分岐する
が、このときスタツクにはデータ#F007が格納される。
したがつて、行番号9〜11のVAL欄には、当該アドレス
#F007の上位バイトおよび下位バイトを転換したデータ
VAL=「07F0」がそれぞれ設定される。 In the present embodiment, the data in the branch source column and the attribute column use the data in Table 4, but in addition to this, when there is an instruction that changes the contents of the stack, the contents of the stack changed by the instruction are treated as data. A column for stack data VAL is provided. According to this, the line is branched to the line number 9 at the line number 3, but at this time, the data # F007 is stored in the stack.
Therefore, in the VAL column of line numbers 9 to 11, data obtained by converting the upper byte and the lower byte of the address # F007 is converted.
VAL = "07F0" is set respectively.
行番号11から行番号4へ処理が戻り、次に行番号5にお
いてスタツクの記憶内容が行番号1のアドレス#F000に
変更される。したがつて、これ以降の行番号4〜8の属
性欄1においては、スタツクデータVAL=「00F0」が設
定される。行番号8にて、新たな属性欄2が設定され、
引続きスタツクデータVAL=「00F0」が設定される。The process returns from the line number 11 to the line number 4, and then at line number 5, the contents of the stack are changed to the address # F000 of the line number 1. Therefore, stack data VAL = "00F0" is set in the attribute column 1 of the line numbers 4 to 8 thereafter. At line number 8, a new attribute column 2 is set,
Subsequently, stack data VAL = "00F0" is set.
以上のようにして本実施例によれば、属性欄にスタツク
のデータを設定するようにしたので、たとえばサブルー
チン命令のメインルーチンへの復帰命令RETから逆上り
処理を行う場合、前記メインルーチンへの復帰先は、ス
タツクデータVALを参照すれば判明し、各命令を逆上つ
て順次的に解析して検知する必要が解消される。これに
より処理の高速化が図られる。また、前記スタツクデー
タVALを用いれば、各命令毎に設定される属性の種類お
よび処理経路等の属性の識別が格段に容易となる。As described above, according to the present embodiment, since the stack data is set in the attribute column, for example, when performing the reverse processing from the return instruction RET of the subroutine instruction to the main routine, The return destination is known by referring to the stack data VAL, and it is possible to eliminate the need to sequentially analyze and detect each instruction in reverse order. This speeds up the processing. Further, the use of the stack data VAL makes it much easier to identify the attributes such as the type of attribute and the processing route set for each instruction.
第8図ステツプd9において、分岐条件を合成して第1図
に示すフローチヤート作成手段19や実行内容解析結果出
力手段20などから、当該得られた結果を論理式の結合し
た形式としてフローチヤートやPAD図の形式で出力した
り、または実行内容を印字出力したりする場合、被解析
プログラムが長くなるほどその出力量が膨大となる。し
たがつて、これらの論理式で記述される出力をブール代
数を用いて簡易な形に整理する技術が必要となる。In step d9 in FIG. 8, the branch condition is synthesized and the obtained result is converted from the flow chart creating means 19 and the execution content analysis result output means 20 shown in FIG. When outputting in the form of PAD diagram or printing out the execution contents, the longer the analyzed program becomes, the larger the output amount becomes. Therefore, it is necessary to have a technique for organizing the outputs described by these logical expressions into a simple form using Boolean algebra.
第17図は、このような実施例を説明するフローチヤート
である。フローチヤート作成手段19や実行内容解析結果
出力手段20からの出力がたとえば下式、 F=C・(+(A・B))+(・(+AB)+A・
) のような論理記号の結合した論理式として与えられてい
る場合、これを簡約化するには以下の処理を行う。この
簡約化処理の基本方針は下記の第16式と第17式とであ
る。FIG. 17 is a flow chart for explaining such an embodiment. The output from the flow chart creating means 19 and the execution content analysis result output means 20 is, for example, the following formula: F = C · (+ (A · B)) + (· (+ AB) + A ·
) Is given as a logical expression in which logical symbols are combined, the following processing is performed to reduce it. The basic policy of this reduction processing is the following 16th and 17th equations.
A+=U …(16) A+・g=A+g …(17) U;全体集合 A;Uの部分集合 ;Aの補集合 g;単項 ・;論理積演算 +;論理和演算 第18図は、上記第16式と第17式の内容を説明するベン図
である。上記第16式は、全体集合Uにおいて、部分集合
Aとその補集合との和集合が常に全体集合となる意味
である。また、上記第17式は部分集合Aと単項gとが互
いに素であるならば、補集合と単項gとの積集合と集
合Aとは集合Aと単項gとの和集合になる意味である。A + = U (16) A + · g = A + g (17) U; Overall set A; Subset of U; Complement of A g; Unary ・; Logical AND operation +; Logical OR operation Fig. 18 above FIG. 16 is a Venn diagram for explaining the contents of Expression 16 and Expression 17. The above 16th expression means that in the universal set U, the union of the subset A and its complement is always the universal set. Further, the above 17th expression means that if the subset A and the unary g are disjoint, the intersection of the complement and the unary g and the set A are the union of the set A and the unary g. .
このような上記第16式および第17式の基本方式に基づい
て、上記第15式を簡約化する手順について第17図のフロ
ーチヤートを参照して説明する。第17図ステツプs1にお
いて、各項を分解する。これにより上記第15式は下記第
18式に変化される。Based on the basic schemes of the 16th and 17th equations, the procedure for simplifying the 15th equation will be described with reference to the flow chart of FIG. In FIG. 17, step s1, each term is decomposed. As a result, Equation 15 above becomes
It is changed to 18 formulas.
F=C・+C・A・B+・+・A・B+A・
…(18) 次にステツプs2にて共通項があるか否かが判断される。
先ず第18式の第1項および第2項について、共通項Cが
あることが判断され、ステツプs3で()でくくられ、下
記第19式が得られる。F = C ・ + C ・ A ・ B + ・ + ・ A ・ B + A ・
(18) Next, it is determined in step s2 whether there is a common term.
First, it is judged that there is a common term C for the first term and the second term of the 18th equation, and the equation (19) below is obtained by being bracketed by () in step s3.
C・(+A・B) …(19) 次にステツプs4では、前記第16式および第17式に基づく
合成パターンがあるか否かが判断される。第19式の()
内では、第17式に基づく合成が可能であり、判断が肯定
となり、ステツプs5に移り、下記第20式のように合成さ
れる。前記ステツプs4で合成パターンがないことが判断
されると、ステツプs6に移り、他に()でくくれる同一
項があるか否かが判断され、なければステツプs3に移
る。下記第20式の例では、()内でこれ以上の合成パタ
ーンがなく、処理はステツプs1に戻され、()が分解さ
れ、下記第21式が得られる。C · (+ A · B) (19) Next, in step s4, it is judged whether or not there is a combined pattern based on the 16th and 17th equations. Formula 19 ()
In the above, the composition based on the expression (17) is possible, the judgment is affirmative, the process proceeds to step s5, and the composition is made as the following expression (20). If it is determined in step s4 that there is no composite pattern, the process proceeds to step s6, and it is determined whether there is another identical term that is enclosed in (). If not, the process proceeds to step s3. In the example of the following expression 20, there is no more combined pattern in (), the process is returned to step s1, and () is decomposed to obtain the following expression 21.
C・(+B) …(20) C・+CB …(21) 次に第21式第1項と第18式第3項とに関して、前記ステ
ツプs2,ステツプs3の処理が適用され、下記第22式が得
られる。C · (+ B) (20) C · + CB (21) Next, regarding the first term of the 21st equation and the third term of the 18th equation, the processing of the steps s2 and s3 is applied, and the following equation 22 is applied. Is obtained.
C・+・=・(C+) …(22) 次のステツプs4,s5にて上記第16式の基本方針が適用さ
れ、下記第23式が得られる。C • + • = • (C +) (22) In the next steps s4 and s5, the basic policy of the above-mentioned expression 16 is applied, and the following expression 23 is obtained.
・(C+)= …(23) 次に第21式第2項と第18式第4項とに関して、同様な処
理が行われ、下記第24式の結果が得られる。(C +) = ... (23) Next, similar processing is performed on the second term of the 21st equation and the fourth term of the 18th equation, and the result of the following 24th equation is obtained.
C・B+・A・B=B・(+C・A)=BC+BA …
(24) 次に第24式最右辺の第2項と、第18式第5項との間で同
様な処理が行われ、下記第25式が得られる。C ・ B + ・ A ・ B = B ・ (+ C ・ A) = BC + BA ...
(24) Next, similar processing is performed between the second term on the rightmost side of the 24th equation and the 5th term of the 18th equation, and the following 25th equation is obtained.
B・A+A・=A・(B+)=A …(25) したがつて第23式、第24式最右辺第1項および第25式よ
り下記第26式が得られる。B · A + A · = A · (B +) = A (25) Accordingly, the following formula 26 is obtained from formula 23, formula 24, the first term on the rightmost side, and formula 25.
+B・C+A=B・C+U=U …(26) このようにして上記第16式および第17式に示す基本方式
の元で、第17図に示す処理手順に基づいて上記第15式に
示す論理式が全体集合Uに簡約化されることが確認され
た。このようにして第8図ステツプd9で分岐条件を合成
する処理を行うにあたつて、前述したようにブール代数
を用いて論理式を論理演算にて簡略化して表現する。こ
れによりフローチヤート作成手段19でフローチヤートを
作成して出力したり、または実行内容解析結果出力手段
20にて実行内容を論理式にて印字出力する場合にあたつ
て、実行内容をより内容の把握が容易な形式にて表現す
ることができ、本件プログラム内容解析装置をプログラ
ムのデバツグなどに用いる場合にきわめて効率的であ
る。+ B · C + A = B · C + U = U (26) In this way, based on the basic method shown in the 16th and 17th equations, the logic shown in the 15th equation based on the processing procedure shown in FIG. It was confirmed that the formula was reduced to the universal set U. In this way, in performing the processing of synthesizing the branch condition in step d9 in FIG. 8, the logical expression is simplified by the logical operation using the Boolean algebra as described above. Thereby, the flow chart creating means 19 creates and outputs the flow chart, or the execution content analysis result outputting means.
When the execution contents are printed out as a logical expression in 20, the execution contents can be expressed in a format that makes it easier to grasp the contents, and the program content analysis device of this case is used for debugging the program. Very efficient in case.
発明の効果 以上のように本発明によれば、所定の実行内容が実行さ
れるための条件を表示するにあたり、複雑な表示を判り
やすく変形して表示することが可能になる。EFFECTS OF THE INVENTION As described above, according to the present invention, in displaying the condition for executing the predetermined execution content, a complicated display can be easily transformed and displayed.
第1図は解析装置1の構成を示すブロツク図、第2図は
解析準備処理手段5の動作を説明するフローチヤート、
第3図は被解析プログラム例の動作の流れを示すフロー
チヤート、第4図は流れ構造解析手段11の動作を説明す
るフローチヤート、第5図は流れ制御フアイル記憶部12
の構成を示す図、第6図は分岐元フアイル記憶部21の構
成を示す図、第7図は属性フアイル記憶部22の構成を示
す図、第8図は分岐条件解析手段13の動作を説明するフ
ローチヤート、第9図は本実施例の逆上りフラグを説明
するフローチヤート、第10図逆上り処理における逆上り
判断を説明するフローチヤート、第11図は逆上り処理に
おけるデータ設定処理を説明するフローチヤート、第12
図は逆上り処理の逆上り分岐処理を説明するフローチヤ
ート、第13図は逆上り処理の未解析ルート処理の動作を
説明するフローチヤート、第14図はデータ書込み処理を
説明するフローチヤート、第15図は被解析プログラム例
の動作の流れを説明するフローチヤート、第16図はスタ
ツクの状態を説明する図、第17図は論理式のブール代数
を用いる簡約化処理を説明するフローチヤート、第18図
は本実施例を説明するベン図、第19図はプログラム例の
流れを示すフローチヤートである。 1……解析装置、3……アセンブラ、4……アセンブル
リストフアイル記憶部、5……解析準備処理手段、6…
…リストフアイル記憶部、10……命令データフアイル記
憶部、11……流れ構造解析手段、12……流れ制御フアイ
ル記憶部、13……分岐条件解析手段、16……分岐条件フ
アイル記憶部、21……分岐元フアイル部、22……属性フ
アイル部、23……属性元個数記憶部、24……分岐元欄記
憶部、25……行番号記憶部、26……分岐元属性記憶部、
27……分岐先属性記憶部、28……属性個数記憶部、29…
…不定フラグ記憶部、30……属性値記憶部FIG. 1 is a block diagram showing the configuration of the analysis apparatus 1, and FIG. 2 is a flow chart for explaining the operation of the analysis preparation processing means 5.
3 is a flow chart showing the flow of the operation of the analyzed program example, FIG. 4 is a flow chart explaining the operation of the flow structure analysis means 11, and FIG. 5 is a flow control file storage unit 12.
6 shows the structure of the branch source file storage unit 21, FIG. 7 shows the structure of the attribute file storage unit 22, and FIG. 8 shows the operation of the branch condition analysis means 13. FIG. 9 is a flow chart for explaining the reverse flow flag of this embodiment, FIG. 10 is a flow chart for explaining the reverse flow determination in the reverse flow processing, and FIG. 11 is a data setting process for the reverse flow processing. Float Chart, No. 12
FIG. 13 is a flow chart for explaining the reverse uplink branch processing of the reverse uplink processing, FIG. 13 is a flow chart for explaining the operation of the unanalyzed route processing of the reverse uplink processing, and FIG. 14 is a flow chart for explaining the data write processing. FIG. 15 is a flow chart for explaining the operation flow of the analyzed program example, FIG. 16 is a diagram for explaining the state of the stack, FIG. 17 is a flow chart for explaining the simplification process using the Boolean algebra of the logical expression, and FIG. FIG. 18 is a Venn diagram for explaining the present embodiment, and FIG. 19 is a flow chart showing the flow of a program example. 1 ... Analysis device, 3 ... Assembler, 4 ... Assemble list file storage unit, 5 ... Analysis preparation processing means, 6 ...
… List file storage unit, 10 …… Instruction data file storage unit, 11 …… Flow structure analysis means, 12 …… Flow control file storage unit, 13 …… Branch condition analysis unit, 16 …… Branch condition file storage unit, 21 ...... Branch source file part, 22 ...... Attribute file part, 23 ...... Attribute source number storage part, 24 ...... Branch source column storage part, 25 ...... Line number storage part, 26 ...... Branch source attribute storage part,
27 ... Branch destination attribute storage unit, 28 ... Attribute number storage unit, 29 ...
… Indeterminate flag memory, 30 …… Attribute value memory
Claims (1)
配列順序とは逆に逆上つて読取り、その内容を解析し、
各実行内容と該実行内容が行われる条件を出力する装置
において、 プログラムを逆上つて各命令の実行内容を読取る読取手
段と、 読取られた各命令のうち実行内容に関連する命令に至る
経路を通過するための条件に対応する第1論理式情報を
求め、前記実行内容に関連する全ての経路毎の第1論理
式情報を論理和形式の総合論理式情報として合成し、該
総合論理式情報を前記実行内容に関連して記憶する実行
内容記憶手段と、 与えられた論理式情報を論理積の論理和の形式に変形し
て出力する分解手段と、 前記分解手段から与えられた論理式情報に対して、同一
項に関連する項を括弧でくくつた形式に変形して出力す
る第1同一項整理手段と、 与えられた論理式情報に対して、同一項に関連する項を
括弧でくくつた形式に変形して出力する第2同一項整理
手段と、 第1同一項整理手段から与えられた論理式情報のうち、
所定の変形パターンに該当する項を、該所定の変形パタ
ーンに従つて変形して出力するパターン変形手段と、 パターン変形手段から与えられる論理式情報とその実行
内容とを関連して表示する実行内容出力手段と、 前記第1同一項整理手段とパターン変形手段との間に設
けられ、第1同一項整理手段から与えられた論理式情報
に前記所定パターンが含まれているか否かを検出し、前
記所定パターンが含まれていれば前記パターン合成手段
に論理式情報を出力し、含まれていなければ前記分解手
段に論理式情報を出力する第1選択手段と、 前記パターン変形手段と実行内容出力手段との間に設け
られ、前記パターン変形手段から与えられた論理式情報
に同一項が含まれているか否かを判断し、同一項が含ま
れていれば前記第2同一項整理手段を介して前記第1選
択手段に論理式情報を与え、同一項が含まれていなけれ
ば前記実行内容出力手段に論理式情報を与える第2選択
手段とを具備するすることを特徴とするプログラム内容
解析装置。1. An instruction of a program consisting of a plurality of instructions is read in the reverse order of the arrangement order, and the contents are analyzed,
In an apparatus that outputs each execution content and a condition under which the execution content is performed, a reading unit that reverses a program to read the execution content of each instruction, and a path to an instruction related to the execution content among the read instructions. The first logical expression information corresponding to the condition for passing is obtained, and the first logical expression information for all the paths related to the execution content is combined as comprehensive logical expression information in a logical sum form, and the comprehensive logical expression information is obtained. Execution content storage means for storing in relation to the execution content, decomposing means for transforming given logical expression information into a form of logical sum of logical products and outputting, logical expression information given by the decomposing means , The first same-arrangement means for transforming and outputting the terms related to the same term in parentheses, and for the given logical expression information, the terms related to the same term are parenthesized. It is transformed into an output format and output. A second same term organizing means, among the logical expression information given from the first same paragraph arranging unit,
Pattern transformation means for transforming and outputting a term corresponding to a predetermined transformation pattern according to the predetermined transformation pattern, and execution contents for displaying logical expression information given by the pattern transformation means and its execution contents in association with each other. It is provided between the output means and the first identical term organizing means and the pattern transforming means, and detects whether or not the predetermined pattern is included in the logical expression information given from the first identical term organizing means, If the predetermined pattern is included, logical formula information is output to the pattern synthesizing unit; if not, the first selecting unit that outputs logical formula information to the decomposing unit; the pattern transforming unit and execution content output. Means for determining whether or not the same term is included in the logical expression information provided from the pattern transforming means, and if the same term is included, the second same term organizing means. Program content analysis, characterized by further comprising: second selection means for giving logical expression information to the first selecting means via the above, and for giving logical expression information to the execution content output means if the same term is not included. apparatus.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1319451A JPH0775003B2 (en) | 1989-12-07 | 1989-12-07 | Program content analyzer |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1319451A JPH0775003B2 (en) | 1989-12-07 | 1989-12-07 | Program content analyzer |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH03179537A JPH03179537A (en) | 1991-08-05 |
| JPH0775003B2 true JPH0775003B2 (en) | 1995-08-09 |
Family
ID=18110349
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP1319451A Expired - Fee Related JPH0775003B2 (en) | 1989-12-07 | 1989-12-07 | Program content analyzer |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH0775003B2 (en) |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS62166445A (en) * | 1986-01-20 | 1987-07-22 | Nec Corp | Debug supporting device |
| JPS63244239A (en) * | 1987-03-31 | 1988-10-11 | Hitachi Ltd | Program execution path verification method |
| JPS63317848A (en) * | 1987-06-20 | 1988-12-26 | Fujitsu Ten Ltd | Analyzing device for program contents |
| JPH0820969B2 (en) * | 1987-06-20 | 1996-03-04 | 富士通テン株式会社 | Program content analyzer |
| JPH0820973B2 (en) * | 1987-06-20 | 1996-03-04 | 富士通テン株式会社 | Program content analyzer |
-
1989
- 1989-12-07 JP JP1319451A patent/JPH0775003B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JPH03179537A (en) | 1991-08-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5210859A (en) | Program debugging support method and apparatus | |
| US5557774A (en) | Method for making test environmental programs | |
| JPH1063550A (en) | Execution performance analysis display method and medium recording program for executing the method | |
| US6968544B1 (en) | Method for transformation of interface definitions and intermediate format tables thereof | |
| JPH06149589A (en) | Reference target variable determination processing method and translation processing system | |
| US5907851A (en) | Editing nested documents by appointing a portion for insertion with an alternative substitute | |
| JPH0775003B2 (en) | Program content analyzer | |
| JPH0769856B2 (en) | Program content analyzer | |
| JPH0769855B2 (en) | Program content analyzer | |
| US5761508A (en) | Information processing system and method applied to the development of computer programs | |
| JPH0772873B2 (en) | Program content analyzer | |
| JPH07219810A (en) | Module test method and device | |
| JPS6136868A (en) | Information retriever | |
| JPH0887417A (en) | Compiler device | |
| JPH09292985A (en) | Program reuse parts generation method | |
| JPH08202741A (en) | Functional design support device and functional design support method | |
| JPH03177940A (en) | Analyzing device for program contents | |
| EP0578830A1 (en) | Information processing apparatus and method therefor | |
| JPH0721765B2 (en) | Flow chart display | |
| JPH04278633A (en) | How to edit and execute a graphical representation functional program | |
| JP2765911B2 (en) | Data driven control method and compiling device | |
| JP2719277B2 (en) | Automatic program analyzer | |
| JPH0695914A (en) | Program monitoring device | |
| JP2555011B2 (en) | Vector data processing method | |
| JPH09147132A (en) | CAD system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| LAPS | Cancellation because of no payment of annual fees |