JPH0836496A - Microcomputer - Google Patents

Microcomputer

Info

Publication number
JPH0836496A
JPH0836496A JP7055526A JP5552695A JPH0836496A JP H0836496 A JPH0836496 A JP H0836496A JP 7055526 A JP7055526 A JP 7055526A JP 5552695 A JP5552695 A JP 5552695A JP H0836496 A JPH0836496 A JP H0836496A
Authority
JP
Japan
Prior art keywords
instruction
microcomputer
trap
instruction code
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP7055526A
Other languages
Japanese (ja)
Other versions
JP2715967B2 (en
Inventor
Hiromichi Takahashi
浩道 高橋
Katsumi Miura
勝己 三浦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP7055526A priority Critical patent/JP2715967B2/en
Publication of JPH0836496A publication Critical patent/JPH0836496A/en
Application granted granted Critical
Publication of JP2715967B2 publication Critical patent/JP2715967B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Abstract

PURPOSE:To increase processing speed when an instruction which is impossible to be executed in an emulation mode is executed in a native mode. CONSTITUTION:A microcomputer 700 has an emulation mode and a native mode. The microcomputer 700 contains a general purpose register group 111. In the general purpose register group 111, a register XR which is not used in the emultion mode exists. When a prescribed instruction code to be trap factor is supplied to the microcomputer 700 when the microcomputer operates in the emulation mode, the microcomputer stores a value showing the code length from the first byte of a prescribed instruction code to the trap operation instruction and the instruction code which can be recognized in the register XR and shifts the mode to the native mode.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、エミュレーションの実
行中に、所定の命令コードを入力すると割り込みを発生
するマイクロコンピュータに関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a microcomputer which generates an interrupt when a predetermined instruction code is input during emulation.

【0002】[0002]

【従来の技術】マイクロコンピュータ(以下マイコンと
記す)の性能は著しく向上しており、使用されるマイコ
ンも、より上位のマイコンへと移行している。
2. Description of the Related Art The performance of microcomputers (hereinafter referred to as "microcomputers") has been remarkably improved, and the microcomputers used have been upgraded to higher-level microcomputers.

【0003】しかし上位のマイコンを使用する場合、従
来使用してきた下位のマイコン用のソフトウェアがその
まま利用できるかどうかという点が1つの問題点となっ
てくる。一般に上位のマイコンは下位のマイコンとはア
ーキテクチャが異なるため、下位のマイコン用に開発さ
れたソフトウェアをそのまま上位のマイコンで動作させ
ることができない。そのため、上位のマイコンに下位の
マイコンの命令を実行する機能(以下エミュレーション
機能と記す)がない場合は、下位のマイコン用のソフト
ウェアを上位のマイコン用に移植する作業が必要となる
が、費用および工数などの制限により、移植すべきソフ
トウェア量が多いほど作業は困難になる。
However, when a higher-order microcomputer is used, one problem is whether or not the software for the lower-order microcomputer which has been conventionally used can be used as it is. Generally, since the higher-level microcomputer has a different architecture from the lower-level microcomputer, the software developed for the lower-level microcomputer cannot be operated by the higher-level microcomputer as it is. Therefore, if the higher-level microcomputer does not have the function of executing the instructions of the lower-level microcomputer (hereinafter referred to as the emulation function), the work for porting the software for the lower-level microcomputer to the higher-level microcomputer is required. Due to restrictions such as man-hours, work becomes more difficult as the amount of software to be ported increases.

【0004】よって、上位のマイコンにエミュレーショ
ン機能をもたせることは、従来のソフトウェア資産の有
効活用およびソフトウェア移植に要する費用、工数の削
減という点で非常に有効である。
Therefore, it is very effective to provide the host microcomputer with an emulation function in terms of effective use of conventional software resources and cost and man-hours required for software porting.

【0005】ところで、エミュレーション機能をもつマ
イコンの中には、ハードウェアの制限のため、エミュレ
ーションを実施しているモード(以下エミュレーション
モードと記す)で実行不可能な命令ができる場合、この
ような命令を処理するためエミュレーションモードで割
り込み(以下トラップと記す)を起こし、マイコン本来
の命令を実行するモード(以下ネィティブモードと記
す)に制御を移し、ネィティブモードのトラップ処理ル
ーチンにおいて、ユーザが適当な処理を行うマイコンが
ある。
By the way, in a microcomputer having an emulation function, if an instruction that cannot be executed in a mode in which emulation is performed (hereinafter referred to as an emulation mode) is possible due to a hardware limitation, such an instruction In the emulation mode, an interrupt (hereinafter referred to as a trap) is generated in order to process the command, and the control is transferred to a mode for executing the original instruction of the microcomputer (hereinafter referred to as a native mode). There is a microcomputer that does.

【0006】このような従来のマイコンの一例について
以降に説明する。
An example of such a conventional microcomputer will be described below.

【0007】最初に従来のマイコンの構成、マイコンと
外部メモリとの接続および外部メモリ内のプログラム配
置の一例について図11から図13を用いて説明する。
First, an example of the configuration of a conventional microcomputer, the connection between the microcomputer and an external memory, and the arrangement of programs in the external memory will be described with reference to FIGS. 11 to 13.

【0008】図11は従来のマイコンの構成およびマイ
コンと外部メモリとの接続を示したブロック図である。
FIG. 11 is a block diagram showing the structure of a conventional microcomputer and the connection between the microcomputer and an external memory.

【0009】マイコン1100は種々の演算処理を行う
演算処理部1101、命令キュー1103、命令キュー
1103から命令コードが出力されるキューバス110
8、キューバス1108の命令コードを入力解読し種々
の制御信号を演算処理部1101、アドレスバス端子1
104、データバス端子1105および外部メモリ11
17に出力したり、演算処理部1101からの情報を入
力したりする制御部1102、外部アドレスバス111
5と内部アドレスバス1106とを接続するアドレスバ
ス端子1104、外部データバス1116と内部データ
バス1107とを接続するデータバス端子1105から
構成されており、マイコン1100と外部メモリ111
7とは外部アドレスバス1115、外部データバス11
16を介して接続されている。
The microcomputer 1100 has an arithmetic processing unit 1101 for performing various arithmetic processes, an instruction queue 1103, and a queue bus 110 to which instruction codes are output from the instruction queue 1103.
8. Input and decode the instruction code of the queue bus 1108 and send various control signals to the arithmetic processing unit 1101 and the address bus terminal 1.
104, data bus terminal 1105 and external memory 11
17, the control unit 1102 that outputs information to the external processor 17 and inputs information from the arithmetic processing unit 1101, and the external address bus 111.
5 and an internal address bus 1106 are connected to each other, and an external data bus 1116 and an internal data bus 1107 are connected to each other. The microcomputer 1100 and the external memory 111 are connected to each other.
7 is an external address bus 1115 and an external data bus 11
It is connected through 16.

【0010】演算処理部1101は演算部1109、プ
ログラムの実行状況を示す16ビットのレジスタである
プログラムステータスワード(以下PSWと記す)11
10、汎用レジスタ群1111、スタックエリアのポイ
ンタを指す16ビットレジスタであるスタックポインタ
(以下SPと記す)1112、マイコン1100が実行
しようとしているプログラムメモリアドレスのオフセッ
ト情報を保持する16ビットカウンタであるプログラム
カウンタ(以下PCと記す)1113で構成されており
それぞれが内部バス1114を介して接続されている。
An arithmetic processing unit 1101 is an arithmetic unit 1109, a program status word (hereinafter referred to as PSW) 11 which is a 16-bit register indicating the execution status of a program.
10, a general-purpose register group 1111, a stack pointer (hereinafter referred to as SP) 1112 that is a 16-bit register that points to a pointer of a stack area, and a program that is a 16-bit counter that holds offset information of a program memory address that the microcomputer 1100 is about to execute. A counter (hereinafter referred to as a PC) 1113 is connected to each other via an internal bus 1114.

【0011】なおPSW1110の最上位ビットは、マ
イコン1100の動作しているモードを表すステータス
フラグ(以下MDフラグと記す)であり、マイコン11
00はMDフラグが「0」のときエミュレーションモー
ド、「1」のときネィティブモードで動作するものとす
る。(図12参照) ところで、エミュレーション機能を持つマイコンにおい
ては、ハードウェアの増大を防ぐ意味でネィティブモー
ドのレジスタをそのままエミュレーションモードで用い
ることが多い。こうした場合、通常は上位のマイコンの
方が下位のマイコンよりもレジスタ数が多いので、エミ
ュレーションモードにおいては未使用のレジスタができ
る。本マイコンの場合汎用レジスタ群1111中のXR
レジスタが未使用レジスタであるとする。
The most significant bit of the PSW 1110 is a status flag (hereinafter referred to as MD flag) indicating the mode in which the microcomputer 1100 is operating.
00 operates in the emulation mode when the MD flag is "0", and operates in the native mode when the MD flag is "1". (See FIG. 12) By the way, in a microcomputer having an emulation function, a register in a native mode is often used as it is in an emulation mode in order to prevent an increase in hardware. In such a case, since the higher-order microcomputer usually has more registers than the lower-order microcomputer, unused registers can be created in the emulation mode. For this microcomputer XR in general-purpose register group 1111
Assume that the register is an unused register.

【0012】なお、マイコン1100のエミュレーショ
ンモードの命令のうち、1バイト目で動作が決まりかつ
1バイトで構成される命令のうちトラップとなる命令の
コードの1つを「57H」、通常に実行される命令(以
下1バイト定義命令と記す)コードの1つを「20H」
とする。なお「20H」は汎用レンジスタ群1111中
のXレジスタの値をインクリメントする命令のコードと
する。
Of the instructions in the emulation mode of the microcomputer 1100, one of the instruction codes which is trapped among the instructions whose operation is determined by the first byte and which is composed of 1 byte is "57H", which is normally executed. One of the instruction codes (hereinafter referred to as 1-byte definition instruction)
And Note that "20H" is the code of the instruction to increment the value of the X register in the general ranger group 1111.

【0013】次に、外部メモリ1117内のプログラム
配置の一例を示す。
Next, an example of program arrangement in the external memory 1117 will be shown.

【0014】外部メモリ1117のプログラム配置例を
図13に示す。
FIG. 13 shows an example of program arrangement in the external memory 1117.

【0015】外部メモリ117内はベクタ領域 プ
ログラムエリア スタックエリア命令コード解析ル
ーチン 命令別処理ルーチンで構成されている。
The external memory 117 is composed of a vector area program area, a stack area, an instruction code analysis routine, and a processing routine for each instruction.

【0016】以下に各領域について説明する。Each area will be described below.

【0017】 ベクタ領域はエミュレーション中のト
ラップなどによる割り込み処理リーチンの開始アドレス
が格納されているエリアで、1ベクタは2バイト(1ワ
ード)で構成され、エミュレーション中のトラップなど
の割り込みが発生すると、制御部1102の制御によ
り、割り込み要因に対応したベクタの内容がPC111
3にロードされる。エミュレーション中のトラップのベ
クタ番号は16(ベクタアドレスは「0020H」番
地)に設定されているものとする。
The vector area is an area in which the start address of interrupt processing reach due to a trap during emulation is stored, and one vector consists of 2 bytes (1 word). When an interrupt such as a trap during emulation occurs, Under the control of the control unit 1102, the contents of the vector corresponding to the interrupt factor are updated by the PC 111.
Loaded in 3. It is assumed that the vector number of the trap being emulated is set to 16 (vector address is "0020H").

【0018】なおベクタ領域は「0000H」〜「00
FFH」番地に配置してある。
The vector area is "0000H" to "00H".
It is located at address "FFH".

【0019】 プログラムエリアはネィティブモード
のプログラムエリアとエミュレーションモードのプログ
ラムエリアとに分かれている。ネィティブモードのプロ
グラムエリアはエミュレーションモードのプログラムを
実行するために必要な、レジスタ等の初期化を行うため
のプログラムを、エミュレーションモードのプログラム
エリアはマイコン1100がエミュレーションを行う下
位のマイコンのプログラムをそれぞれ格納してある領域
である。なお、プログラムエリアは「0200H」〜
「05FFH」番地に配置してあり、ネィティブモード
のプログラムエリアを「0200H」〜「03FFH」
番地に、エミュレーションモードのプログラムエリアを
「0400H」〜「04FFH」番地にそれぞれ配置し
てある。
The program area is divided into a native mode program area and an emulation mode program area. The program area in the native mode stores a program for initializing the registers and the like necessary for executing the program in the emulation mode, and the program area in the emulation mode stores a program for a lower microcomputer to be emulated by the microcomputer 1100. It is an area that has been. In addition, the program area is from "0200H"
It is located at address "05FFH", and the program area for native mode is "0200H" to "03FFH".
The program areas in the emulation mode are arranged at addresses "0400H" to "04FFH".

【0020】 スタックエリアは、エミュレーション
中にトラップが発生した場合にプログラム実行中のPS
WおよびPCの情報をセーブすることなどに使用され
る。スタックエリアは「2000H」〜「2FFEH」
番地に配置してある。
The stack area is used for PS during program execution when a trap occurs during emulation.
Used for saving W and PC information. Stack area is "2000H" to "2FFEH"
It is located at the address.

【0021】 マイコン1100がトラップを起こし
た後に実行される命令コード解析ルーチンでは、トラッ
プを起こした命令コード部を認識しその命令コード値を
利用して命令別処理ルーチンに分岐する処理が行われ
る。命令コード解析ルーチンは「3200H」〜「32
FFH」番地に配置してある。
In the instruction code analysis routine executed after the microcomputer 1100 causes the trap, the instruction code portion that caused the trap is recognized, and the instruction code value is used to branch to the instruction-specific processing routine. The instruction code analysis routine is "3200H" to "32".
It is located at address "FFH".

【0022】 命令別処理ルーチンでは、トラップを
起こした命令に対してユーザが行う適当なソフトウェア
処理、トラップから復帰するために必要なPC補正およ
びトラップからの復帰命令(以下リターン命令と記す)
による処理が行われる。リターン命令はこのルーチンの
最後の処理になるように配置してある。命令別処理ルー
チンは「5700H」番地〜「57FFH」番地に配置
してある。
In the instruction-by-instruction processing routine, an appropriate software process performed by the user for the instruction causing the trap, a PC correction necessary for returning from the trap, and a return instruction from the trap (hereinafter referred to as a return instruction)
Is performed. The return instruction is arranged so as to be the final processing of this routine. The instruction-specific processing routines are arranged at addresses "5700H" to "57FFH".

【0023】またエミュレーションモードのプログラム
エリア内には1バイト定義命令のコード「20H」が
「0400H」番地に、1バイト目で動作が決まりかつ
1バイトで構成される命令でトラップとなる命令コード
「57H」が「0425H」番地にそれぞれ配置してあ
る。
In the program area of the emulation mode, the code "20H" of the 1-byte definition instruction is located at the address "0400H", and the instruction code "0H" is determined by the first byte and is trapped by the instruction composed of 1 byte. 57H "is arranged at the address" 0425H ".

【0024】以降にマイコン1100の動作について図
14、図15を用いて説明する。
The operation of the microcomputer 1100 will be described below with reference to FIGS. 14 and 15.

【0025】まずリセットにより、マイコン1100の
PC1112は「0200H」に、PSW1110中の
MDフラグは「1」に初期化され、マイコン1100は
「0200H」番地以降のネィティブモードのプログラ
ムを実行していくものとする。
First, by resetting, the PC 1112 of the microcomputer 1100 is initialized to "0200H", the MD flag in the PSW 1110 is initialized to "1", and the microcomputer 1100 executes the program in the native mode after the address "0200H". And

【0026】ネィティブモードのプログラムにおいては
エミュレーションモードのプログラムで使用されるスタ
ックポインタSP1112の値を「2FFEH」に初期
化する処理等が行われた後、MDフラグを「0」にし、
PC1113に「0400H」を格納し、エミュレーシ
ョンモードのプログラムの先頭アドレスの命令コードを
フェッチするための処理が行われる。
In the native mode program, after the process of initializing the value of the stack pointer SP1112 used in the emulation mode program to "2FFEH", etc., the MD flag is set to "0",
"0400H" is stored in the PC 1113, and the process for fetching the instruction code at the start address of the program in emulation mode is performed.

【0027】以降にエミュレーションモードにおける1
バイト定義命令のコード「20H」、1バイト目で命令
の動作が決まりかつ1バイトで構成されトラップとなる
命令のコード「57H」が入力された場合におけるマイ
コン1100の動作についてそれぞれ説明する。
After that, 1 in the emulation mode
The operation of the microcomputer 1100 in the case where the code "20H" of the byte definition instruction and the instruction code "57H" which is determined by the first byte and is composed of 1 byte and becomes a trap are input will be described.

【0028】〔1〕最初に1バイト定義命令コード「2
0H」を処理する場合の本マイコンの動作について説明
する。
[1] First, the 1-byte definition instruction code "2
The operation of the present microcomputer when processing "0H" will be described.

【0029】まず制御部1102は、外部メモリ111
7からPC1113の指すアドレス「0400H」番地
の命令コード「20H」を命令キュー1103に取り込
み、PC1113の値をインクリメントする制御信号を
発生する。
First of all, the control unit 1102 operates the external memory 111.
The instruction code “20H” at the address “0400H” pointed to by the PC 1113 from 7 is fetched into the instruction queue 1103, and a control signal for incrementing the value of the PC 1113 is generated.

【0030】次に命令キュー1103から「20H」が
キューバス1108に出力されて、制御部1102に入
力された場合、制御部1102は演算処理部1101
に、Xレジスタの値を内部バス1114に出力し、演算
処理部1101に入力後、演算部1109において1を
加え、そして演算結果を内部バス1115に出力して再
度Xレジスタに、命令実行状況の情報をPSW1110
にそれぞれ格納するという一連の処理を行う制御信号を
出力する。
Next, when "20H" is output from the instruction queue 1103 to the queue bus 1108 and input to the control unit 1102, the control unit 1102 causes the arithmetic processing unit 1101.
In addition, after the value of the X register is output to the internal bus 1114 and input to the arithmetic processing unit 1101, 1 is added in the arithmetic unit 1109, and the operation result is output to the internal bus 1115, and the instruction execution status of the instruction register is output to the X register again. Information to PSW1110
A control signal for performing a series of processing of storing in each is output.

【0031】〔2〕次に1バイト目でトラップとなる命
令コード「57H」に対する本マイコンの動作について
説明する。
[2] Next, the operation of this microcomputer for the instruction code "57H" which becomes a trap at the first byte will be described.

【0032】まず制御部1102は、外部メモリ111
7からPC1113の指すアドレス「0425H」番地
の命令コード「57H」を命令キュー1103に取り込
み、PC1113の値をインクリメントする制御信号を
発生する。
First, the control unit 1102 determines that the external memory 111
The instruction code "57H" at the address "0425H" pointed to by the PC 1113 from 7 is fetched into the instruction queue 1103, and a control signal for incrementing the value of the PC 1113 is generated.

【0033】次に命令キュー1103から「57H」が
キューバス1108に出力され、制御部1102に入力
された場合、制御部1102は、1バイト目でトラップ
となる命令コードが入力されたときの同制御部1102
の制御フローすなわち図14に示した処理を行う制御信
号を演算処理部1101に対して出力する。
Next, when "57H" is output from the instruction queue 1103 to the queue bus 1108 and is input to the control unit 1102, the control unit 1102 is the same as when the instruction code that becomes a trap at the first byte is input. Control unit 1102
A control signal for performing the processing shown in FIG. 14, that is, a control signal is output to the arithmetic processing unit 1101.

【0034】 すなわち、制御部1102はSP11
12の値「2FFEH」を内部バス1114に出力し
て、演算部1109に入力後、2を減じ、演算結果の
「2FFCH」を内部バス1114に出力し、SP11
12に格納するよう制御する。
That is, the control unit 1102 causes the SP 11
The value “2FFEH” of 12 is output to the internal bus 1114 and input to the arithmetic unit 1109. Then, 2 is subtracted and the arithmetic result “2FFCH” is output to the internal bus 1114.
It controls to store in 12.

【0035】 制御部1102は、SP1112の値
を内部バス1114、内部アドレスバス1106、アド
レス端子1104を通して外部アドレスバス1115
に、またSPW1110の値を内部バス1114、内部
データバス1107、データバス端子1105を通して
外部データバス1116にそれぞれ出力し、外部メモリ
1117のアドレス「2FFCH」にPSW1110の
値を書き込むよう制御する。
The control unit 1102 sends the value of SP 1112 to the external address bus 1115 via the internal bus 1114, the internal address bus 1106, and the address terminal 1104.
Further, the value of the SPW 1110 is output to the external data bus 1116 via the internal bus 1114, the internal data bus 1107, and the data bus terminal 1105, and the value of the PSW 1110 is controlled to be written in the address “2FFCH” of the external memory 1117.

【0036】 の処理で更新されたPS1112の
値「2FFCH」を内部バス1114に出力して、演算
部1109に入力後、2を減じ演算結果の「2FFA
H」を内部バス1114に出力し、SP1112に格納
するよう制御する。
The value “2FFCH” of PS1112 updated by the processing of 1 is output to the internal bus 1114 and input to the arithmetic unit 1109, and then subtracted by 2 to obtain the arithmetic result “2FFA”.
The control unit outputs “H” to the internal bus 1114 and stores it in the SP 1112.

【0037】 SP1112の値を内部バス111
4、内部アドレスバス1106、アドレスバス端子11
04を通して外部アドレスバス1115に出力する。ま
た同時に「0425H」番地の次の番地の命令コードを
フェッチするため「0426H」に更新されていたPC
1113の値をデクリメントして、トラップを起こす命
令の先頭アドレス「0425H」を内部バス1114、
内部データバス1107、データバス端子1105を通
して外部データバス1116に出力し、外部メモリ11
17のアドレス「2FFAH」にPC1113の値を書
き込むよう制御する。
The value of SP1112 is set to the internal bus 111.
4, internal address bus 1106, address bus terminal 11
It outputs to the external address bus 1115 through 04. At the same time, the PC updated to "0426H" in order to fetch the instruction code at the address next to the address "0425H"
The value of 1113 is decremented, and the start address "0425H" of the instruction causing the trap is set to the internal bus 1114,
Output to the external data bus 1116 through the internal data bus 1107 and the data bus terminal 1105, and the external memory 11
The control is performed so that the value of the PC 1113 is written in the address “2FFAH” of 17.

【0038】(〜の処理で外部メモリ1117のス
タックエリアは、図5の状態になる。) PSW1110中のMDフラグを「1」にしてネィ
ティブモードの遷移する。
(By the processing of to, the stack area of the external memory 1117 becomes the state of FIG. 5.) The MD flag in the PSW 1110 is set to "1", and the native mode is changed.

【0039】 ベクタ16(10H)を参照し分岐す
る。すなわち外部メモリ1117のアドレス「0020
H」番地の値「3200H」を外部データバス111
6、データバス端子1105、内部データバス110
7、内部バス1114を通してPC1113に書き込
み、PC1113の指す外部メモリ1117のアドレス
「3200H」番地の命令コードをフェッチするよう制
御する。
The vector 16 (10H) is referenced and branched. That is, the address “0020 of the external memory 1117
The value "3200H" at address "H" is set to the external data bus 111
6, data bus terminal 1105, internal data bus 110
7. Write to the PC 1113 via the internal bus 1114, and control is performed so that the instruction code at the address "3200H" of the external memory 1117 indicated by the PC 1113 is fetched.

【0040】以上に示した処理により命令コード解析ル
ーチンの先頭アドレスに分岐する。
By the processing described above, the operation branches to the start address of the instruction code analysis routine.

【0041】次に、図15に処理フローを示した命令コ
ード解析ルーチンおよび命令別処理ルーチン、すなわち
トラップ動作の次にマイコン1100が実行するプログ
ラム処理について説明する。
The instruction code analysis routine and instruction-specific processing routine whose processing flow is shown in FIG. 15, that is, the program processing executed by the microcomputer 1100 after the trap operation will be described.

【0042】そのうちの(a)〜(d)の命令コード解
析ルーチンにおいては (1)前記の制御によって更新されたSP112が指
す外部メモリ1117のアドレス「2FFAH」の内容
(トラップを起こした命令の先頭アドレス「0425
H」)をXRレジスタに転送する。(メモリリード1回
目) そして、XRレジスタの値が指す外部メモリ1117の
アドレス「0425H」のデータ「57H」をXRレジ
スタに転送する。(メモリリード2回目) (2)XRレジスタの値を8ビット左シフトし、これを
命令別処理ルーチンの先頭アドレスとして分岐する。
In the instruction code analysis routines (a) to (d), (1) the contents of the address "2FFAH" of the external memory 1117 pointed to by the SP 112 and updated by the above control (the start of the instruction that caused the trap) Address "0425
H ") to the XR register. (First memory read) Then, the data "57H" of the address "0425H" of the external memory 1117 indicated by the value of the XR register is transferred to the XR register. (Second memory read) (2) The value of the XR register is left shifted by 8 bits, and this is branched as the start address of the instruction-specific processing routine.

【0043】処理が行われる。続いて図15(e)〜
(g)の命令別処理ルーチンでは、 (3)トラップを起こした命令に対応したユーザによる
適当なソフトウェア処理を行う。
Processing is performed. Then, FIG. 15 (e)-
In the instruction-specific processing routine of (g), (3) appropriate software processing by the user corresponding to the instruction causing the trap is performed.

【0044】(4)命令別処理ルーチンの最後の処理で
あるリターン命令の実行によりトラップを起こした命令
の次のアドレスの命令を実行するために、SP1112
が指す外部メモリ1117のアドレス値「2FFAH」
の内容すなわちトラップを起こした命令の先頭アドレス
値「0425H」をインクリメントする。
(4) To execute the instruction at the address next to the instruction that caused the trap due to the execution of the return instruction, which is the final processing of the instruction-specific processing routine, SP1112
Address value "2FFAH" of external memory 1117 pointed to by
, That is, the start address value “0425H” of the instruction that caused the trap is incremented.

【0045】(5)リターン命令を実行する。(5) The return instruction is executed.

【0046】処理が行われる。Processing is performed.

【0047】[0047]

【発明が解決しようとする課題】前述した従来のマイコ
ンでは、命令別処理ルーチンの中で、トラップを起こす
個々の命令に対してユーザが行う適当なソフトウェア処
理に分岐するために、命令コード解析ルーチンでトラッ
プを起こした命令コード部を認識するソフトウェア処理
には、2回のメモリアクセントが必要であった。また、
従来例に示したようなマイコンでは、トラップを起こす
バイト長の異なる命令が混在していることが多い。よっ
て、トラップとなる命令コード中のトラップを起こした
コード部の認識のためには、図15(a),(b)に示し
た処理の他に、作業用のXRレジスタに格納された命令
コードが、トラップとなる命令コード部と一致するかを
判断するソフトウェア処理が必要となる。このときトラ
ップとなる命令コード群をメモリに配置している場合
は、1バイト目でトラップとなる命令では上記2回のメ
モリアクセスに加えて、XRレジスタに読み込んだ1バ
イト目の命令コードとトラップとなる命令コードとを比
較するために命令コードのテーブル(図13には示して
ない。)を参照する回数と同じ回数(最初の比較で一致
する場合もあるので最低1回)、合計すると最低3回の
メモリアクセスが必要となる。
In the conventional microcomputer described above, in order to branch to an appropriate software process performed by the user for each instruction causing a trap in the instruction-specific processing routine, an instruction code analysis routine is executed. Two memory accents were required for software processing to recognize the instruction code portion that caused the trap. Also,
In the microcomputer as shown in the conventional example, instructions with different byte lengths that cause a trap are often mixed. Therefore, in order to recognize the code portion that causes the trap in the instruction code that becomes the trap, in addition to the processing shown in FIGS. 15A and 15B, the instruction code stored in the working XR register However, software processing is required to determine whether or not it matches the instruction code part that becomes a trap. At this time, when the instruction code group to be trapped is arranged in the memory, the instruction to be trapped at the first byte has the above-mentioned two times of memory access, and the instruction code and trap at the first byte read into the XR register. The same number of times as the number of times the instruction code table (not shown in FIG. 13) is referred to for comparison with the instruction code that becomes Memory access is required three times.

【0048】また1バイト目で一致する命令コードが存
在しなかった場合は2バイト目の命令コードを外部メモ
リから読み込むためにメモリアクセスが1回必要となる
うえ、読み込んだ命令コードが2バイト目でトラップと
なる命令コードかどうか比較するため、トラップを起こ
す命令コードのテーブルを参照するときにメモリアクセ
スが最低1回必要となり、前記の“最低3回”を加える
と、合計して最低5回のメモリアクセスが必要となる。
If there is no matching instruction code in the first byte, memory access is required once to read the second byte instruction code from the external memory, and the read instruction code is the second byte. In order to compare with the instruction code that becomes a trap, the memory access is required at least once when referring to the instruction code table that causes the trap. If the above "at least 3 times" is added, a total of 5 times is required. Memory access is required.

【0049】このようにトラップとなる命令のバイト長
が異なる命令コードが増えるほど、命令コード解析ルー
チンでのメモリアクセスが増加するという問題点を有し
ていた。
As described above, there is a problem that the memory access in the instruction code analysis routine increases as the number of instruction codes having different byte lengths of trap instructions increases.

【0050】[0050]

【課題を解決するための手段】本発明のマイコンは、エ
ミュレーション機能を有し、エミュレーションの実行中
に所定の命令コードを入力すると、所定の命令コードま
たはその一部を所定のレジスタに格納し、割り込みを発
生する制御手段を有している。
A microcomputer of the present invention has an emulation function, and when a predetermined instruction code is input during execution of emulation, the predetermined instruction code or a part thereof is stored in a predetermined register, It has a control means for generating an interrupt.

【0051】さらに、本発明のマイコンは、エミュレー
ション機能を有し、エミュレーションの実行中に所定の
命令コードを入力すると、所定の命令コードの第1バイ
トから割り込み動作命令と認識できる命令コード部まで
のコード長を示す値を所定のレジスタに格納し、割り込
みを発生する制御手段を有している。
Furthermore, the microcomputer of the present invention has an emulation function, and when a predetermined instruction code is input during execution of emulation, the first byte of the predetermined instruction code to the instruction code portion which can be recognized as an interrupt operation instruction. It has a control means for storing a value indicating the code length in a predetermined register and generating an interrupt.

【0052】[0052]

【実施例】従来例の項でも述べたように、エミュレーシ
ョンを行うマイコンにおいては、ハードウェアの増大を
防ぐ意味でネィティブモードのレジスタをそのままエミ
ュレーションモードで用いることが多い。この場合、通
常は上位のマイコンの方が下位のマイコンよりもレジス
タ数が多いので、エミュレーションモードにおいては未
使用のレジスタができることが多い。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS As described in the section of the conventional example, in a microcomputer for emulation, a register in native mode is often used as it is in emulation mode in order to prevent an increase in hardware. In this case, since the higher-order microcomputer usually has more registers than the lower-order microcomputer, unused registers are often created in the emulation mode.

【0053】本実施例では、トラップを起こした命令コ
ードを未使用の汎用レジスタに格納するマイコンについ
て説明する。
In this embodiment, a microcomputer that stores an instruction code that causes a trap in an unused general-purpose register will be described.

【0054】まず本実施例のマイコンの構成、マイコン
とメモリの接続および外部メモリ内のプログラム配置に
ついて図1から図3までを用いて説明する。
First, the structure of the microcomputer of this embodiment, the connection between the microcomputer and the memory, and the program layout in the external memory will be described with reference to FIGS.

【0055】図1は本発明のマイコンの構成およびマイ
コンと外部メモリとの接続を示すブロック図である。
FIG. 1 is a block diagram showing the structure of the microcomputer of the present invention and the connection between the microcomputer and an external memory.

【0056】マイコン100は種々の演算処理を行う演
算処理部101、命令キュー103、命令キュー103
から命令コードが出力されるキューバス108、キュー
バス108上の命令コードを入力解読し種々の制御信号
を演算処理部101、アドレスバス端子104、データ
バス端子105および外部メモリ117に対して出力し
たり演算処理部101からの情報を入力したりする制御
部102、外部アドレスバス116と内部アドレスバス
106とを接続するアドレスバス端子104、外部デー
タバス117と内部データバス107とを接続するデー
タバス端子105から構成されている。
The microcomputer 100 has an arithmetic processing unit 101 for performing various arithmetic processing, an instruction queue 103, and an instruction queue 103.
The instruction code is output from the queue bus 108, the instruction code on the queue bus 108 is input and decoded, and various control signals are output to the arithmetic processing unit 101, the address bus terminal 104, the data bus terminal 105, and the external memory 117. And a control unit 102 for inputting information from the arithmetic processing unit 101, an address bus terminal 104 connecting the external address bus 116 and the internal address bus 106, and a data bus connecting the external data bus 117 and the internal data bus 107. It is composed of the terminal 105.

【0057】演算処理部101は演算部109、PSW
110、汎用レジスタ群111、スタックポインタSP
112、プログラムカウンタPC113がそれぞれ内部
バス114を介して接続されている。またマイコン10
0と外部メモリ117とは外部アドレスバス115、外
部データバス116を介して接続されている。
The arithmetic processing unit 101 includes an arithmetic unit 109 and a PSW.
110, general-purpose register group 111, stack pointer SP
112 and a program counter PC 113 are connected to each other via an internal bus 114. In addition, the microcomputer 10
0 and the external memory 117 are connected via an external address bus 115 and an external data bus 116.

【0058】なおPSW110の最上位ビットは、マイ
コン100の動作しているモードを表すステータスフラ
グ(以下MDフラグと記す)であり、マイコン100は
MDフラグが「0」のときエミュレーションモード、
「1」のときネィティブモードで動作するものとする。
(図2参照) また本マイコンの場合汎用レジスタ111中のXRレジ
スタが未使用レジスタであるとする。
The most significant bit of the PSW 110 is a status flag (hereinafter referred to as MD flag) indicating the mode in which the microcomputer 100 is operating, and the microcomputer 100 emulates the mode when the MD flag is "0".
When it is "1", it shall operate in the native mode.
(See FIG. 2) Further, in the case of this microcomputer, it is assumed that the XR register in the general-purpose register 111 is an unused register.

【0059】なお、マイコン100のエミュレーション
モードの命令のうち、1バイト目で動作が決まりかつ1
バイトで構成される命令のうちトラップとなる命令のコ
ードの1つを「57H」、1バイト定義命令のコードの
1つを「20H」とする。なお「20H」は汎用レジス
タ群111中のXレジスタの値をインクリメントする命
令のコードとする。
In the emulation mode instruction of the microcomputer 100, the operation is determined by the first byte and
Among the instructions composed of bytes, one of the trapping instruction codes is "57H" and one of the byte defining instruction codes is "20H". Note that "20H" is a code of an instruction to increment the value of the X register in the general register group 111.

【0060】次に、外部メモリ117内のプログラム配
置の一例を示す。
Next, an example of program arrangement in the external memory 117 is shown.

【0061】外部メモリ117のプログラム配置例を図
3に示す。
FIG. 3 shows an example of program arrangement in the external memory 117.

【0062】外部メモリ117内は ベクタ領域
プログラムエリア スタックエリア 命令コード解
析ルーチン 命令別処理ルーチンで構成されている。
The external memory 117 has a vector area.
Program area Stack area This consists of instruction code analysis routines and instruction-specific processing routines.

【0063】以下に各領域について説明する。Each area will be described below.

【0064】 ベクタ領域はエミュレーション中のト
ラップなどによる割り込み処理ルーチン開始アドレスが
格納されているエリアで、1ベクタは2バイト(1ワー
ド)で構成され、エミュレーション中のトラップなどの
割り込みが発生すると、制御部1202の制御により、
割り込み要因に対応したベクタの内容がPC113にロ
ードされる。エミュレーション中のトラップのベクタ番
号は16(ベクタアドレスは「0020H」番地)に設
定されているものとする。
The vector area is an area in which an interrupt processing routine start address due to a trap during emulation is stored, and one vector is composed of 2 bytes (1 word). When an interrupt such as a trap during emulation occurs, control is performed. By the control of the part 1202,
The contents of the vector corresponding to the interrupt factor are loaded into the PC 113. It is assumed that the vector number of the trap being emulated is set to 16 (vector address is "0020H").

【0065】なお、ベクタ領域は「0000H」〜「0
0FFH」番地に配置してある。
The vector area is "0000H"-"0H".
It is located at address "0FFH".

【0066】 プログラムエリアはネィティブモード
のプログラムエリアとエミュレーションモードのプログ
ラムエリアとに分かれている。ネィティブモードのプロ
グラムエリアはエミュレーションモードのプログラムを
実行するために必要な、レジスタ等の初期化を行うため
のプログラムを、エミュレーションモードのプログラム
エリアはマイコン100がエミュレーションを行う下位
のマイコンのプログラムをそれぞれ格納してある領域で
ある。なお、プログラムエリアは「0200H」〜「0
3FFH」番地に、エミュレーションモードのプログラ
ムエリアを「0400H」〜「05FFH」番地にそれ
ぞれ配置してある。
The program area is divided into a native mode program area and an emulation mode program area. The program area in the native mode stores a program for initializing the registers and the like necessary to execute the program in the emulation mode, and the program area in the emulation mode stores a program for a lower microcomputer to be emulated by the microcomputer 100. It is an area that has been. The program area is from "0200H" to "0
The program area of the emulation mode is arranged at the address "3FFH" to the addresses "0400H" to "05FFH".

【0067】 スタックエリアは、エミュレーション
中にトラップが発生した場合にプログラム実行中のPC
WおよびPCの情報をセーブすることなどに使用され
る。スタックエリアは「2000H」〜「2FFEH」
番地に配置してある。
The stack area is a PC that is executing a program when a trap occurs during emulation.
Used for saving W and PC information. Stack area is "2000H" to "2FFEH"
It is located at the address.

【0068】 マイコン100がトラップを起こした
後に実行される命令コード解析ルーチンでは、トラップ
を起こした命令コード部を認識しその命令コード値を利
用して命令別処理ルーチンに分岐する処理が行われる。
命令コード解析ルーチンは「3200H」〜「32FF
H」番地に配置してある。
In the instruction code analysis routine that is executed after the microcomputer 100 causes the trap, the instruction code portion that caused the trap is recognized, and the instruction code value is used to branch to the instruction-specific processing routine.
The instruction code analysis routine is "3200H" to "32FF
It is located at address "H".

【0069】 命令別処理ルーチンでは、トラップを
起こした命令に対してユーザが行う適当なソフトウェア
処理、トラップから復帰するために必要なPC補正およ
びトラップからの復帰命令(以下リターン命令と記す)
による処理が行われる。リターン命令はこのルーチンの
最後の処理になるように配置してある。命令別処理ルー
チンは「5700H」番地〜「57FFH」番地に配置
してある。
In the instruction-specific processing routine, appropriate software processing performed by the user for the instruction that caused the trap, PC correction necessary for returning from the trap, and a return instruction from the trap (hereinafter referred to as a return instruction)
Is performed. The return instruction is arranged so as to be the final processing of this routine. The instruction-specific processing routines are arranged at addresses "5700H" to "57FFH".

【0070】またエミュレーションモードのプログラム
エリア内には1バイト定義命令のコード「20H」が
「0400H」番地に、1バイト目で動作が決まりかつ
1バイトで構成される命令でトラップとなる命令のコー
ド「57H」が「0425H」番地にそれぞれ配置して
ある。
In the program area of the emulation mode, the code "20H" of the 1-byte definition instruction is located at the address "0400H", and the code of the instruction which becomes a trap when the operation is determined by the first byte and is composed of 1 byte. "57H" is arranged at the address "0425H".

【0071】次にマイコン100の動作について図4か
ら図7を用いて説明する。
Next, the operation of the microcomputer 100 will be described with reference to FIGS. 4 to 7.

【0072】まずリセットにより、マイコン100のP
C113は「0200H」に、PSW110中のMDフ
ラグは「1」に初期化され、マイコン100は「020
0H」番地以降のネィティブモードのプログラムを実行
していくものとする。
First, by resetting, the P of the microcomputer 100 is
The C113 is initialized to "0200H", the MD flag in the PSW 110 is initialized to "1", and the microcomputer 100 is initialized to "020H".
It is assumed that the native mode program after the address "0H" is executed.

【0073】ネィティブモードのプログラムにおいては
エミュレーションモードのプログラムで使用されるスタ
ックポインタSP112の値を「2FFEH」に初期化
する処理等が行われた後、MDフラグを「0」にし、P
C113に「0400H」を格納し、エミュレーション
モードのプログラムの先頭アドレスの命令コードをフェ
ッチするための処理が行われる。
In the native mode program, after the process of initializing the value of the stack pointer SP112 used in the emulation mode program to "2FFEH", etc., the MD flag is set to "0" and P
"0400H" is stored in C113, and the processing for fetching the instruction code at the start address of the program in the emulation mode is performed.

【0074】1バイト目で命令の動作が決まりかつ1バ
イトで構成される命令のうちトラップとなる命令のコー
ドが入力された場合におけるマイコン100の動作につ
いてそれぞれ説明する。
The operation of the microcomputer 100 when the instruction operation is determined by the first byte and the instruction code that becomes the trap among the instructions formed by the first byte is input will be described.

【0075】〔1〕最初に1バイト定義命令コード「2
0H」を処理する場合の本マイコンの動作について説明
する。
[1] First, the 1-byte definition instruction code "2
The operation of the present microcomputer when processing "0H" will be described.

【0076】まず制御部102は、外部メモリ117か
らPC113の指すアドレス「0400H」番地の命令
コード「20H」を命令キュー103に取り込み、PC
113の値をインクリメントする制御信号を発生する。
First, the control unit 102 fetches the instruction code "20H" at the address "0400H" pointed to by the PC 113 from the external memory 117 into the instruction queue 103, and the PC
A control signal for incrementing the value of 113 is generated.

【0077】次に命令キュー103から「20H」がキ
ューバス108に出力されて、制御部102に入力され
た場合、制御部102は演算処理部101に対して、X
レジスタを選択してその値を内部バス114に出力し演
算処理部101に入力後、演算部109において1加え
る。そして演算結果を内部バス114に出力して再度X
レジスタに、命令実行状況の情報をPSW110にそれ
ぞれ格納する。
Next, when “20H” is output from the instruction queue 103 to the queue bus 108 and input to the control unit 102, the control unit 102 sends X to the arithmetic processing unit 101.
After selecting a register and outputting the value to the internal bus 114 and inputting it to the arithmetic processing unit 101, 1 is added in the arithmetic unit 109. Then, the calculation result is output to the internal bus 114 and X is again output.
Information on the instruction execution status is stored in the registers in the PSW 110.

【0078】〔2〕次に1バイト目でトラップとなる命
令のコード「57H」に対する本マイコンの動作につい
て説明する。
[2] Next, the operation of the microcomputer for the instruction code "57H" which becomes a trap at the first byte will be described.

【0079】まず制御部102は、外部メモリ117か
らPC113の指すアドレス「0425H」番地の命令
コード「57H」を命令キュー103に取り込み、PC
113の値をインクリメントする制御信号を発生する。
First, the control unit 102 fetches the instruction code “57H” at the address “0425H” pointed to by the PC 113 from the external memory 117 into the instruction queue 103, and
A control signal for incrementing the value of 113 is generated.

【0080】次に命令キュー103から「57H」がキ
ューバス108に出力され、制御部102に入力される
と、制御部102はまず図4に示した処理を行う制御信
号を演算処理部101に対して出力する。
Next, when "57H" is output from the instruction queue 103 to the queue bus 108 and input to the control unit 102, the control unit 102 first sends to the arithmetic processing unit 101 a control signal for performing the processing shown in FIG. Output to.

【0081】 制御部102はSP112の値「2F
FEH」を内部バス114に出力して、演算部109に
入力後、2を減じ演算結果の「2FFCH」を内部バス
114に出力し、SP112に格納するよう制御する。
The control unit 102 controls the SP 112 value “2F
It outputs "FEH" to the internal bus 114, inputs it to the arithmetic unit 109, subtracts 2 and outputs "2FFCH" of the arithmetic result to the internal bus 114, and stores it in the SP 112.

【0082】 制御部102は、SP112の値を内
部バス114、内部アドレスバス106、アドレスバス
端子104を通して外部アドレスバス115に、またP
SW110の値を内部バス114、内部データバス10
7、データバス端子105を通して外部データバス11
6にそれぞれ出力し、内部データバス107、データバ
ス端子105を通して外部データバス116にそれぞれ
出力し、外部メモリ117のアドレス「2FFCH」に
PSW110の値を書き込むよう制御する。
The control unit 102 transfers the value of SP 112 to the external address bus 115 through the internal bus 114, the internal address bus 106, and the address bus terminal 104, and P
The value of SW110 is set to the internal bus 114 and the internal data bus 10.
7. External data bus 11 through data bus terminal 105
6, and outputs to the external data bus 116 through the internal data bus 107 and the data bus terminal 105, respectively, and controls to write the value of the PSW 110 to the address “2FFCH” of the external memory 117.

【0083】 の処理で更新されたSP112の値
「2FFCH」を内部バス114に出力して、演算部1
09に入力後、2を減じ演算結果の「2FFAH」を内
部バス114に出力し、SP112に格納するよう制御
する。
The value “2FFCH” of the SP 112 updated in the processing of 1 is output to the internal bus 114, and the arithmetic unit 1
After being input to 09, it subtracts 2 and outputs "2FFAH" of the calculation result to the internal bus 114 and controls it to be stored in SP112.

【0084】 SP112の値を内部バス114、内
部アドレスバス106、アドレスバス端子104を通し
て外部アドレスバス115に出力する。次に、「042
5H」番地の次の番地の命令コードをフェッチするため
「0426H」に更新されていたPC113の値をデク
リメントし、トラップ命令の先頭アドレス「0425
H」を内部バス115、内部データバス107、データ
バス端子105を通して外部データバス116にそれぞ
れ出力し、外部メモリ118のアドレス「2FFAH」
にPC113の値を書き込むよう制御する。
The value of SP 112 is output to the external address bus 115 through the internal bus 114, the internal address bus 106, and the address bus terminal 104. Next, "042
The value of the PC 113 updated to "0426H" for fetching the instruction code at the address next to the address "5H" is decremented, and the start address "0425" of the trap instruction is decremented.
"H" is output to the external data bus 116 through the internal bus 115, the internal data bus 107, and the data bus terminal 105, respectively, and the address "2FFAH" of the external memory 118 is output.
The value of the PC 113 is controlled to be written in.

【0085】 キューバス108上のコード「57
H」を内部バス114に出力してXRレジスタの下位側
に書き込む。
The code “57” on the cue bus 108
"H" is output to the internal bus 114 and written to the lower side of the XR register.

【0086】(〜までの処理で外部メモリ117の
スタックエリアは図5に示した状態になる。) MDフラグを「1」にしてネィティブモードに遷移
する。
(By the processes up to, the stack area of the external memory 117 becomes the state shown in FIG. 5.) The MD flag is set to "1" and the mode is changed to the native mode.

【0087】 ベクタ16(10H)を参照し分岐す
る。すなわち外部メモリ117のアドレス「0020
H」番地の値「3200H」を外部データバス116、
データバス端子105、内部データバス107、内部バ
ス114を通してPC113に格納し、PC113の指
す外部メモリ117のアドレス「3200H」番地の命
令コードをフェッチするよう制御する。
The process branches with reference to the vector 16 (10H). That is, the address “0020 of the external memory 117
The value “3200H” at the address “H” is set to the external data bus 116,
The instruction is stored in the PC 113 through the data bus terminal 105, the internal data bus 107, and the internal bus 114, and the instruction code at the address “3200H” of the external memory 117 designated by the PC 113 is fetched.

【0088】以上に示した処理により命令コード解析ル
ーチンの先頭アドレスに分岐する。
By the processing described above, the operation branches to the start address of the instruction code analysis routine.

【0089】次に、図6(a)〜(e)に示した命令コ
ード解析ルーチンおよび命令別処理ルーチン、すなわち
トラップ動作の次にマイコン100が実行するプログラ
ム処理について説明する。
Next, the instruction code analysis routine and the instruction-specific processing routine shown in FIGS. 6A to 6E, that is, the program processing executed by the microcomputer 100 after the trap operation will be described.

【0090】まず、命令コード解析ルーチンにおいては
図6(a),(b)のソフトウェア処理すなわち (1)XRレジスタの値を8ビット左シフトし、これを
命令別処理ルーチンの先頭アドレスとして分離する処理
を行う。
First, in the instruction code analysis routine, the software processing of FIGS. 6A and 6B, that is, (1) the value of the XR register is left-shifted by 8 bits, and this is separated as the start address of the instruction-specific processing routine. Perform processing.

【0091】次に図6(c)〜(e)に示した命令別処
理ルーチンの処理すなわち、 (2)トラップを起こした命令に対応したユーザによる
適当なソフトウェア処理を行う。
Next, the processing of the instruction-specific processing routine shown in FIGS. 6C to 6E, that is, (2) appropriate software processing by the user corresponding to the instruction causing the trap is performed.

【0092】(3)命令別処理ルーチンの最後の処理で
あるリターン命令の実行によりトラップを起こした命令
の次のアドレスの命令を実行するために、SP112が
指す外部メモリ117のアドレス値「2FFAH」の内
容すなわちトラップを起こした命令の先頭アドレス値
「0425H」をインクリメントする。
(3) The address value "2FFAH" of the external memory 117 pointed to by the SP 112 in order to execute the instruction at the address next to the instruction that caused the trap due to the execution of the return instruction, which is the final processing of the instruction-specific processing routine. , That is, the start address value “0425H” of the instruction that caused the trap is incremented.

【0093】(4)リターン命令を実行する。(4) Execute a return instruction.

【0094】2バイト目で命令の動作が決まりかつ2バ
イトで構成される命令において2バイト目でトラップと
なる命令については、1バイト目では命令の動作は決ま
らないので、マイコン100は2バイト目を読み込み、
2バイト目の命令コードが制御部102に入力されると
トラップとなり、以降は1バイト目でトラップとなる命
令と同様の処理が行われる。
Regarding the instruction which is determined by the second byte and which is trapped at the second byte in the instruction composed of two bytes, the operation of the instruction is not decided by the first byte. Read
When the instruction code of the second byte is input to the control unit 102, it becomes a trap, and thereafter, the same processing as that of the instruction which becomes the trap at the first byte is performed.

【0095】つまりXRレジスタには、命令コードの2
バイト目が格納される。
That is, the XR register contains the instruction code 2
The byte is stored.

【0096】本実施例では未使用の汎用レジスタに命令
コードを格納したが、エミュレーションの時に未使用レ
ジスタができない場合は専用のレジスタを増設する手段
も考えられる。
In this embodiment, the instruction code is stored in the unused general-purpose register. However, if an unused register cannot be created during emulation, a means for adding a dedicated register can be considered.

【0097】なお、本実施例のマイコンはトラップを起
こすと判別できる命令コード部がすべて異なる値の場合
に有効であるが、これが一致した場合においても、トラ
ップを起こすバイト位置の種類により割り込みベクタを
別に設定して、異なる命令コード解析ルーチンを設定す
ることなどにより容易に実施できる。
The microcomputer of this embodiment is effective when all instruction code parts that can be determined to cause a trap have different values, but even if they match, an interrupt vector is generated depending on the type of byte position causing a trap. This can be easily implemented by separately setting and setting a different instruction code analysis routine.

【0098】第二の実施例として、トラップを起こした
命令の第1バイトからトラップを起こすと認識できる命
令コード部までのコード長を表す値を未使用の汎用レジ
スタに格納するマイコンについて説明する。
As a second embodiment, a microcomputer for storing a value representing the code length from the first byte of the instruction that caused the trap to the instruction code portion that can be recognized as causing the trap in an unused general-purpose register will be described.

【0099】図7は本発明の第二の実施例のマイコンの
ブロック図およびマイコンと外部メモリとの接続図であ
る。マイコン700が実施例1のマイコンと異なる点
は、制御部701が定数発生回路702(実施例1のマ
イコンでは明示していない)にトラップを起こした命令
の第1バイトからトラップを起こすと認識できる命令コ
ード部までのコード長を表す値を発生させ、その値を内
部バス114に出力する制御を行うことである。
FIG. 7 is a block diagram of a microcomputer according to the second embodiment of the present invention and a connection diagram between the microcomputer and an external memory. The microcomputer 700 is different from the microcomputer of the first embodiment in that it can be recognized that the control unit 701 causes the constant generation circuit 702 (not explicitly shown in the microcomputer of the first embodiment) to generate a trap from the first byte of the instruction. The control is to generate a value representing the code length up to the instruction code part and output the value to the internal bus 114.

【0100】マイコン700において、1バイト定義命
令のコードの1つが「20H」、1バイト目でトラップ
となる命令コードの1つが「57H」であることは実施
例1と同じであるが、それ以外にnバイト目(nは2以
上の整数)で命令の動作が決まりかつnバイトで構成さ
れる命令でトラップとなる命令の1つとして3バイトで
構成されている命令のコード「9FH」「40H」「7
5H」があるものとする。
In the microcomputer 700, one of the codes of the 1-byte definition instruction is "20H" and one of the instruction codes trapped at the first byte is "57H", which is the same as the first embodiment, but other than that. The instruction code is determined by the nth byte (n is an integer of 2 or more), and the instruction code "9FH""40H" configured by 3 bytes is one of the instructions that are trapped in the instruction configured by n bytes. "7
5H ”.

【0101】図8は本実施例における外部メモリ117
内のプログラム配置図であり、「7500H」番地〜
「75FFH」番地の命令別処理ルーチン2を命令コー
ド「9FH」「40H」「75H」の命令別処理ルーチ
ンに設定していることと、命令のコード「9FH」「4
0H」「75H」を「0580H」番地〜「0582
H」番地に配置していること以外は実施例1における外
部メモリ117のプログラム配置図と同じである。
FIG. 8 shows the external memory 117 in this embodiment.
It is a program layout diagram in the inside, and is from "7500H"
The instruction-specific processing routine 2 at the address "75FFH" is set to the instruction-specific processing routine with the instruction codes "9FH", "40H", and "75H", and the instruction codes "9FH" and "4".
0H "and" 75H "from" 0580H "to" 0582 "
The program layout is the same as that of the external memory 117 in the first embodiment except that it is located at the address "H".

【0102】以降に本実施例のマイコンの動作について
説明する。
The operation of the microcomputer of this embodiment will be described below.

【0103】ネィティブモードのプログラムおよび1バ
イト定義命令のコード「20H」をマイコン700が処
理する場合の制御部701の制御は実施例1と同じであ
る。
The control of the control unit 701 when the microcomputer 700 processes the native mode program and the code "20H" of the 1-byte definition instruction is the same as that of the first embodiment.

【0104】次に、1バイト目でトラップとなる命令コ
ード「57H」をマイコン700が外部メモリ117か
ら命令キュー103に取り込み、命令コード「57H」
が命令キュー103からキューバス108に出力されて
制御部701に入力されると、まず図9(a)の処理す
なわち図4(a),(b)と同様の処理を行う制御信号を
演算処理部101に対して出力する。
Next, the microcomputer 700 fetches the instruction code "57H" which becomes a trap at the first byte from the external memory 117 into the instruction queue 103, and the instruction code "57H".
Is output from the instruction queue 103 to the queue bus 108 and input to the control unit 701, first, a control signal for performing the processing of FIG. 9A, that is, the processing similar to FIG. 4A and FIG. It is output to the unit 101.

【0105】次に、制御部701は図9(b)に示す処
理を行う制御信号を出力する。すなわち、 定数発生回路702にトラップを起こす命令の第1
バイトからトラップを起こすと認識できる命令コード部
までのコード長を表す値「0000H」を内部バス11
4に出力するよう制御する。
Next, the control section 701 outputs a control signal for performing the processing shown in FIG. 9 (b). That is, the first instruction that causes a trap in the constant generation circuit 702.
The value "0000H" representing the code length from the byte to the instruction code part that can be recognized as causing a trap is set to the internal bus 11
The output is controlled to 4.

【0106】 汎用レジスタ群111中のXRレジス
タに、内部バス114上の値「0000H」を格納する
よう制御する。
The XR register in the general-purpose register group 111 is controlled to store the value “0000H” on the internal bus 114.

【0107】次に図9(c)に示した処理すなわち図4
(d),(c)と同様の処理を実施して、命令コード解析
ルーチンの先頭アドレスに分岐する。
Next, the processing shown in FIG. 9C, that is, FIG.
The same processing as in (d) and (c) is executed to branch to the start address of the instruction code analysis routine.

【0108】続いて、図10に示した命令コード解析ル
ーチンおよび命令別処理ルーチン、すなわちトラップ動
作の次にマイコン700が実行するプログラム処理につ
いて説明する。
The instruction code analysis routine and instruction-specific processing routine shown in FIG. 10, that is, the program processing executed by the microcomputer 700 after the trap operation will be described.

【0109】命令コード解析ルーチンにおいては (1)図4(b)に示した処理によって更新されたSP
112の値「2FFAH」で示される外部メモリ117
のアドレスの内容「0425H」とXRレジスタの値
「0000H」を加算して結果をXRレジスタに格納す
る。(メモリリード1回目) (2)XRレジスタの値「0425H」で指し示される
外部メモリ117のアドレスの内容「57H」をXRレ
ジスタに格納する。(メモリリード2回目) (3)XRの値を8ビット左シフトして、これを命令別
処理ルーチン1の先頭アドレスとして分岐する。
In the instruction code analysis routine (1) SP updated by the processing shown in FIG.
External memory 117 indicated by the value “2FFAH” of 112
The address content "0425H" and the value "0000H" in the XR register are added and the result is stored in the XR register. (First memory read) (2) The content "57H" of the address of the external memory 117 indicated by the value "0425H" of the XR register is stored in the XR register. (Second memory read) (3) The value of XR is left-shifted by 8 bits, and this is branched as the start address of the instruction-specific processing routine 1.

【0110】図9(c)は命令別処理ルーチン1での処
理であり、実施例1のマイコンにおける命令別処理ルー
チンと同じソフトウェア処理を行う。
FIG. 9C shows the processing in the instruction-specific processing routine 1, which performs the same software processing as the instruction-specific processing routine in the microcomputer of the first embodiment.

【0111】3バイト目でトラップとなる命令コード
「9FH」「40H」「75H」をマイコン800が処
理する場合、以下に示す点が異なるだけであとは命令コ
ード「57H」の場合と同様な処理を行う。
When the microcomputer 800 processes the instruction code "9FH""40H""75H" which becomes a trap at the third byte, the same processing as that of the instruction code "57H" is performed except that the following points are different. I do.

【0112】 XRレジスタには「0002H」が格
納される。
“0002H” is stored in the XR register.

【0113】 命令別処理ルーチン2において、「0
002H」をSPの指すメモリの内容に加算する。
In the instruction-specific processing routine 2, “0
"002H" is added to the contents of the memory pointed to by SP.

【0114】なお、本実施例のマイコンもトラップを起
こすと認識できる命令コード部の値が一致しないマイコ
ンの場合に有効であるが、これが一致する場合において
も、トラップを起こす命令コードの第1バイトからトラ
ップを起こすと認識できる命令コード部までのバイト長
の種類によって割り込みベクタを別に設定して、異なる
命令コード解析ルーチンを設定することなどにより容易
に実施できる。
The microcomputer of this embodiment is also effective in the case where the values of the instruction code portion that can be recognized as causing a trap do not match, but even if these values match, the first byte of the instruction code causing a trap Can be easily implemented by separately setting an interrupt vector according to the type of byte length from the to the instruction code part that can be recognized when a trap is generated and setting a different instruction code analysis routine.

【0115】[0115]

【発明の効果】以上の説明のようにトラップを起こした
命令コードを格納するマイクロコンピュータの場合、従
来のマイクロコンピュータのように、トラップを起こし
た命令コード部を認識するために1バイト目でトラップ
となる命令の場合は最低3回、2バイト目でトラップと
なる命令の場合は最低5回のメモリアクセスを必要とし
ていた場合と比較すると、所定のレジスタに命令コード
を格納するため、命令コード部を認識するためのメモリ
アクセスを全く必要としない。またトラップを起こした
命令の先頭からトラップとなった命令コード部までのコ
ード長の値を格納するマイクロコンピュータの場合、ト
ラップを起こす命令コードのバイト位置に関係なく命令
コード部を認識するためのメモリアクセスは2回のみで
ある。そのため命令コード解析ルーチンでの処理を高速
にできるという効果を有する。
As described above, in the case of the microcomputer that stores the instruction code that caused the trap, the first byte is used to recognize the instruction code portion that caused the trap, as in the conventional microcomputer. The instruction code part stores the instruction code in a predetermined register as compared with the case where the memory access is required at least 3 times in the case of the instruction which becomes the second instruction and at least 5 times in the case of the instruction which becomes the trap in the second byte. Does not require any memory access to recognize. In the case of a microcomputer that stores the code length value from the beginning of the instruction that caused the trap to the instruction code portion that caused the trap, a memory for recognizing the instruction code portion regardless of the byte position of the instruction code that causes the trap. Access is only twice. Therefore, there is an effect that the processing in the instruction code analysis routine can be speeded up.

【0116】なお、トラップを起こす命令コード部の値
を所定のレジスタに格納する方法とトラップを起こす命
令の第1バイトからトラップを起こすと認識できる命令
コード部までのコード長を表す値を所定のレジスタに格
納する方法を混在させることも可能である。例えば1バ
イト目でトラップとなる命令、2バイト目でトラップと
なる命令の場合はトラップを起こす命令コード部の値
を、未定義命令の場合はトラップを起こす命令の第1バ
イトからトラップを起こすと認識できる命令コード部ま
でのコード長を表す値を所定のレジスタに格納するとい
う制御を行う。この場合、トラップを起こす命令の第1
バイトからトラップを起こすと認識できる命令コード部
までのコード長を表す値が1バイト目および2バイト目
でトラップとなる命令コードと一致してしまって、命令
コード解析ルーチンで両者のどちらであるかが認識不可
となるときは、トラップのベクタを、1バイト目でトラ
ップとなる命令および2バイト目でトラップとなる命令
の場合と未定義命令の場合で別に設定すること等の簡単
な対応を施せばよい。このように本発明による応用効果
も大きい。
A method of storing the value of the instruction code portion that causes a trap in a predetermined register and a value representing the code length from the first byte of the instruction that causes a trap to the instruction code portion that can be recognized as causing a trap are predetermined. It is also possible to mix the method of storing in the register. For example, in the case of an instruction that becomes a trap at the 1st byte and an instruction that becomes a trap at the 2nd byte, if the value of the instruction code part that causes the trap is generated, and if it is an undefined instruction, the trap is generated from the first byte of the instruction that causes the trap. Control is performed to store a value representing a code length up to a recognizable instruction code part in a predetermined register. In this case, the first instruction that causes a trap
Which of the two is the value in the instruction code analysis routine when the value indicating the code length from the byte to the instruction code part that can be recognized as causing a trap matches the instruction code that becomes the trap at the first and second bytes. If is not recognized, take a simple action such as setting the trap vector separately for the instruction that becomes a trap at the 1st byte and the instruction that becomes a trap at the 2nd byte, and for the undefined instruction. Good. Thus, the application effect of the present invention is great.

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

【図1】本発明の第一の実施例におけるマイコンの構成
およびマイコンと外部メモリとの接続を示すブロック図
である。
FIG. 1 is a block diagram showing a configuration of a microcomputer and a connection between a microcomputer and an external memory in a first embodiment of the present invention.

【図2】同実施例におけるPSWのビット構成図であ
る。
FIG. 2 is a bit configuration diagram of a PSW in the embodiment.

【図3】同実施例における外部メモリのプログラム配置
図である。
FIG. 3 is a program layout diagram of an external memory in the embodiment.

【図4】同実施例のマイコンにおいて命令コード「57
H」が入力された場合の制御部の制御フローである。
FIG. 4 shows an instruction code “57” in the microcomputer of the embodiment.
It is a control flow of a control part when "H" is input.

【図5】図4に示した処理によるスタックエリアの状態
図である。
FIG. 5 is a state diagram of a stack area by the processing shown in FIG.

【図6】同実施例のマイコンの命令コード解析ルーチン
と命令別処理ルーチンの処理フローである。
FIG. 6 is a processing flow of an instruction code analysis routine and an instruction-specific processing routine of the microcomputer of the embodiment.

【図7】本発明の第二の実施例のマイコンの構成および
マイコンと外部メモリとの接続を示したブロック図であ
る。
FIG. 7 is a block diagram showing a configuration of a microcomputer according to a second embodiment of the present invention and a connection between the microcomputer and an external memory.

【図8】同実施例における外部メモリのプログラム配置
図である。
FIG. 8 is a program layout diagram of an external memory in the embodiment.

【図9】同実施例のマイコンが命令コード「57H」を
処理する場合の制御部の制御フローである。
FIG. 9 is a control flow of the control unit when the microcomputer of the embodiment processes the instruction code “57H”.

【図10】同実施例のマイコンの命令コード解析ルーチ
ンと命令別処理ルーチン1の処理フローである。
FIG. 10 is a processing flow of an instruction code analysis routine and an instruction-specific processing routine 1 of the microcomputer of the embodiment.

【図11】従来のマイコンの構成およびマイコンと外部
メモリの接続を示したブロック図である。
FIG. 11 is a block diagram showing a configuration of a conventional microcomputer and a connection between the microcomputer and an external memory.

【図12】PSWのビット構成図である。FIG. 12 is a bit configuration diagram of PSW.

【図13】外部メモリのプログラム配置図である。FIG. 13 is a program layout diagram of an external memory.

【図14】従来のマイコンが命令コード「57H」を処
理する場合の制御部の制御フローである。
FIG. 14 is a control flow of a control unit when a conventional microcomputer processes an instruction code “57H”.

【図15】従来のマイコンの命令コード解析ルーチンと
命令別処理ルーチンの処理フローである。
FIG. 15 is a processing flow of a conventional microcomputer instruction code analysis routine and instruction-specific processing routine.

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

100 マイコン 101 演算処理部 102 制御部 103 命令キュー 104 アドレスバス端子 105 データバス端子 106 内部アドレスバス 107 内部データバス 108 キューバス 109 演算部 110 PSW 111 汎用レジスタ群 112 SP 113 PC 114 内部バス 115 外部アドレスバス 116 外部データバス 117 外部メモリ 700 マイコン 701 制御部 702 定数発生回路 1100 マイコン 1101 演算処理部 1102 制御部 1103 命令キュー 1104 アドレスバス端子 1105 データバス端子 1106 内部アドレスバス 1107 内部データバス 1108 キューバス 1109 演算部 1110 PSW 1111 汎用レジスタ群 1112 SP 1113 PC 1114 内部バス 1115 外部アドレスバス 1116 外部データバス 1117 外部メモリ 100 microcomputer 101 arithmetic processing unit 102 control unit 103 instruction queue 104 address bus terminal 105 data bus terminal 106 internal address bus 107 internal data bus 108 queue bus 109 arithmetic unit 110 PSW 111 general-purpose register group 112 SP 113 PC 114 internal bus 115 external address Bus 116 External data bus 117 External memory 700 Microcomputer 701 Control unit 702 Constant generation circuit 1100 Microcomputer 1101 Arithmetic processing unit 1102 Control unit 1103 Instruction queue 1104 Address bus terminal 1105 Data bus terminal 1106 Internal address bus 1107 Internal data bus 1108 Queue bus 1109 Operation Part 1110 PSW 1111 General-purpose register group 1112 SP 1113 PC 1114 Internal bus 1115 External adapter Dress bus 1116 External data bus 1117 External memory

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 エミュレーション機能を有するマイクロ
コンピュータにおいて、前記エミュレーションの実行中
に所定の命令コードを入力すると、前記所定の命令コー
ドの第1バイトから割り込み動作命令と認識できる命令
コードまでのコード長を示す値を所定のレジスタに格納
し、割り込みを発生する制御手段を含むことを特徴とす
るマイクロコンピュータ。
1. In a microcomputer having an emulation function, when a predetermined instruction code is input during execution of the emulation, a code length from a first byte of the predetermined instruction code to an instruction code which can be recognized as an interrupt operation instruction. A microcomputer characterized by including control means for storing an indicated value in a predetermined register and generating an interrupt.
JP7055526A 1995-03-15 1995-03-15 Microcomputer Expired - Lifetime JP2715967B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7055526A JP2715967B2 (en) 1995-03-15 1995-03-15 Microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7055526A JP2715967B2 (en) 1995-03-15 1995-03-15 Microcomputer

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP63128841A Division JP2637770B2 (en) 1988-05-25 1988-05-25 Microcomputer

Publications (2)

Publication Number Publication Date
JPH0836496A true JPH0836496A (en) 1996-02-06
JP2715967B2 JP2715967B2 (en) 1998-02-18

Family

ID=13001176

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7055526A Expired - Lifetime JP2715967B2 (en) 1995-03-15 1995-03-15 Microcomputer

Country Status (1)

Country Link
JP (1) JP2715967B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6785886B1 (en) 1998-05-15 2004-08-31 Vmware, Inc. Deferred shadowing of segment descriptors in a virtual machine monitor for a segmented computer architecture
US7516453B1 (en) 1998-10-26 2009-04-07 Vmware, Inc. Binary translator with precise exception synchronization mechanism
US8631066B2 (en) 1998-09-10 2014-01-14 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users
CN107346401A (en) * 2016-05-06 2017-11-14 波音公司 Information Guarantee System for safely configuration processor

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5971550A (en) * 1982-09-30 1984-04-23 Fujitsu Ltd Instruction processing system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5971550A (en) * 1982-09-30 1984-04-23 Fujitsu Ltd Instruction processing system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6785886B1 (en) 1998-05-15 2004-08-31 Vmware, Inc. Deferred shadowing of segment descriptors in a virtual machine monitor for a segmented computer architecture
US8631066B2 (en) 1998-09-10 2014-01-14 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users
US9323550B2 (en) 1998-09-10 2016-04-26 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users
US7516453B1 (en) 1998-10-26 2009-04-07 Vmware, Inc. Binary translator with precise exception synchronization mechanism
CN107346401A (en) * 2016-05-06 2017-11-14 波音公司 Information Guarantee System for safely configuration processor

Also Published As

Publication number Publication date
JP2715967B2 (en) 1998-02-18

Similar Documents

Publication Publication Date Title
US5077657A (en) Emulator Assist unit which forms addresses of user instruction operands in response to emulator assist unit commands from host processor
US6564179B1 (en) DSP emulating a microcontroller
US4084235A (en) Emulation apparatus
JP2965884B2 (en) Method and apparatus for detecting and performing cross-domain calls in a computer system
US5430862A (en) Emulation of CISC instructions by RISC instructions using two pipelined stages for overlapped CISC decoding and RISC execution
US6009261A (en) Preprocessing of stored target routines for emulating incompatible instructions on a target processor
US5896522A (en) Selective emulation interpretation using transformed instructions
US20050160415A1 (en) Method and system for improving performance of Java virtual machine
US5034880A (en) Apparatus and method for executing a conditional branch instruction
JP2715967B2 (en) Microcomputer
EP0969357A2 (en) Utilizing a program counter with one or more data counters for executing instructions
JPH0683615A (en) Computer for executing instruction set emulation
JP2637770B2 (en) Microcomputer
US6233675B1 (en) Facility to allow fast execution of and, or, and test instructions
JPH0667896A (en) Single chip microcomputer
JPH10124312A (en) Central processor
JP2002157115A (en) Data processor
US6029003A (en) Method of assigning external variables to memories when compiling source program
US6934728B2 (en) Euclidean distance instructions
JP4545777B2 (en) Data processing device
US6289439B1 (en) Method, device and microprocessor for performing an XOR clear without executing an XOR instruction
JPH1115660A (en) Micro processor
JPH03216734A (en) Data processing method and central processing unit
US20060165094A1 (en) Encapsulation of large native operating system functions as enhancements of the instruction set in an emulated central processor system
JP2001222447A (en) Debug method and device to be debugged under operating environment

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19971007