JPS63223923A - Program counter circuit - Google Patents

Program counter circuit

Info

Publication number
JPS63223923A
JPS63223923A JP5802187A JP5802187A JPS63223923A JP S63223923 A JPS63223923 A JP S63223923A JP 5802187 A JP5802187 A JP 5802187A JP 5802187 A JP5802187 A JP 5802187A JP S63223923 A JPS63223923 A JP S63223923A
Authority
JP
Japan
Prior art keywords
instruction
subroutine
return
program counter
stack
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP5802187A
Other languages
Japanese (ja)
Inventor
Fumiko Obe
大部 文子
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 JP5802187A priority Critical patent/JPS63223923A/en
Publication of JPS63223923A publication Critical patent/JPS63223923A/en
Pending legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)

Abstract

PURPOSE:To decrease the number of dynamic steps of a program containing many repeated processings by providing one more more registers which can prescribe a return address from a subroutine. CONSTITUTION:A stack 102 stores a first return address from a subroutine, and a register 103 stores a second return address from the subroutine. An instruction fetching means 108 fetches an instruction stored in an address designated by a program counter 101. When an instruction decoded by a decoder 9 is a subroutine call instruction, the contents of a counter 101 are pushed to the stack 102, and a call destination address if transferred to the counter 101. Also, when said instruction is a return 1 instruction, the contents of the stack 102 are popped to the counter 101, and when said instruction is a return 2 instruction, the contents of the stack 102 are popped, but the contents of the register 103 are transferred to the counter 101. In such a way, by one instruction, a return and an unconditional jump can be executed.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は、マイクロプロセッサにおけるサブルーチンか
らの戻り番地を決定するプログラムカウンタ回路に関す
る。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a program counter circuit for determining a return address from a subroutine in a microprocessor.

〔従来の技術〕[Conventional technology]

一般に、1つの情報処理プログラム内であるまとまった
処理を行う場合、その部分をサブルーチン化することは
プログラムの設計のしやすさ、わかりやすさなどから広
く行われる。例えば、データがクラスタA、B、その他
に分けられ、第4図のようにクラスタAに属するデータ
にはサブルーチン1の処理を、クラスタBに属するデー
タにはサブルーチン2の処理を行う必要があり、これを
データがクラスタAにもクラスタBにも属さなくなるま
で繰り返す処理を考える。この場合、まとまった処理A
、Bをサブルーチン化すると、設計上やりやすく、また
わかりやすい。従来のプログラムカウンタ回路を持ちマ
イクロプロセッサにおけるこのような処理プログラムを
説明する。第3図は、従来のプログラムカウンタ回路を
示す要部ブロック図である。第3図に示すように、従来
のプログラムカウンタ回路は、次に実行するべき命令の
アドレスを指定するためのプログラムカウンタ301、
サブルーチンからの戻り番地を格納するためのスタック
302、スタックポインタ303により構成される。サ
ブルーチンコール命令を実行した場合には、プログラム
カウンタ301の内容はスタック302にブツシュされ
る。すなわち、スタックポインタ303は+1され、プ
ログラムカウンタ301の内容はスタック302に退避
される。また、リターン命令を実行した場合には、スタ
ック302に退避されている戻り番地がプログラムカウ
ンタ301にポツプされる。すなわち、スタック302
の内容がプログラムカウンタ301に転送され、スタッ
クポインタ303を−1し、スタック302はサブルー
チンコール前の状態に戻される。ここで、従来のプログ
ラムカウンタ回路を持つマイクロプロセッサにより前述
の処理を実行する場合について説明する。この場合のプ
ログラムは、以下のようになる。
Generally, when performing a certain set of processing within one information processing program, it is widely used to make that part a subroutine for ease of program design and understanding. For example, data is divided into clusters A, B, and others, and as shown in FIG. 4, it is necessary to process subroutine 1 for data belonging to cluster A, and process subroutine 2 for data belonging to cluster B. Consider a process in which this process is repeated until the data no longer belongs to cluster A or cluster B. In this case, the collective process A
, B can be made into subroutines, making it easier to design and understand. Such a processing program in a microprocessor having a conventional program counter circuit will be described. FIG. 3 is a block diagram of main parts of a conventional program counter circuit. As shown in FIG. 3, the conventional program counter circuit includes a program counter 301 for specifying the address of the next instruction to be executed;
It is composed of a stack 302 for storing a return address from a subroutine and a stack pointer 303. When a subroutine call instruction is executed, the contents of program counter 301 are pushed onto stack 302. That is, the stack pointer 303 is incremented by 1, and the contents of the program counter 301 are saved to the stack 302. Furthermore, when a return instruction is executed, the return address saved in the stack 302 is popped into the program counter 301. That is, the stack 302
The contents of are transferred to the program counter 301, the stack pointer 303 is decremented by 1, and the stack 302 is returned to the state before the subroutine call. Here, a case where the above-mentioned processing is executed by a microprocessor having a conventional program counter circuit will be described. The program in this case is as follows.

(1)データを入力する。(1) Enter data.

(2)条件1が偽ならば(5)ヘジャンブする。(2) If condition 1 is false, (5) jump.

(3)サブルーチン1をコールする。(3) Call subroutine 1.

(4) (1)ヘジャンプする。(4) Jump to (1).

(5)条#2が偽ならば、(8)ヘジャンプする。(5) If clause #2 is false, jump to (8).

(6)サブルーチン2をコールする。(6) Call subroutine 2.

(7) (1)ヘジャンプする。(7) Jump to (1).

(8)終了。(8) Finished.

なお、条件lはデータがクラスタAに属する。Note that the condition 1 is that the data belongs to cluster A.

条件2はデータがクラスタBに属するものとする。Condition 2 assumes that the data belongs to cluster B.

このとき、サブルーチン1は、以下のようになる。At this time, subroutine 1 is as follows.

(11)処理Aを実行する。(11) Execute process A.

(12)リターン。(12) Return.

同様に、サブルーチン2は、以下のようになる。Similarly, subroutine 2 is as follows.

(21)処理Bを実行する。(21) Execute process B.

(22)リターン。(22) Return.

上述したように、条件1または条件2が真である場合に
は、必要なサブルーチンがらのリターン後、常に、(1
)へのジャンプ命令を実行することになる。
As mentioned above, if condition 1 or condition 2 is true, then (1
) will be executed.

〔発明が解決しようとする問題点〕[Problem that the invention seeks to solve]

上述した処理を従来のプログラムカウンタ回路を持つマ
イクロプロセッサで実行する場合、サブルーチン中のリ
ターン命令による戻り番地への無条件ジャンプの実行後
、さらに、繰り返し処理のための無条件ジャンプ命令を
実行する必要があり、(+)へのジャンプを2命令で行
なわなければならないという欠点がある。
When the above processing is executed by a microprocessor with a conventional program counter circuit, it is necessary to execute an unconditional jump instruction for repeat processing after executing an unconditional jump to the return address using a return instruction in a subroutine. The disadvantage is that the jump to (+) must be performed in two instructions.

上述した従来のプログラムカウンタ回路は、繰り返し処
理によりサブルーチンコールを実行する場合に、繰り返
しのなめにジャンプを2回行なわなければならないのに
対し、本発明のプログラムカウンタ回路は、プログラム
カウンタへの入力としてサブルーチンから戻り番地を規
定できる1つ以上のレジスタを設けることにより、リタ
ーン命令のみで同様な機能を設ける独創的内容を有する
In the conventional program counter circuit described above, when executing a subroutine call by repeated processing, the jump must be performed twice for each repetition, whereas the program counter circuit of the present invention uses By providing one or more registers that can specify a return address from a subroutine, this method has an original content that provides a similar function with only a return instruction.

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

本発明のプログラムカウンタ回路は、プログラムカウン
タと、前記プログラムカウンタの内容をサブルーチン呼
び出し時に保持するスタック回路と、サブルーチンから
の戻り番地を格納する1つ以上のレジスタと、リターン
命令の種類に従って前記スタック回路の出力または前記
レジスタの出力のいずれかを選択して前記プログラムカ
ウンタに入力する選択制御回路とを有する。
The program counter circuit of the present invention includes a program counter, a stack circuit that holds the contents of the program counter when a subroutine is called, one or more registers that store a return address from the subroutine, and the stack circuit according to the type of return instruction. and a selection control circuit that selects either the output of the register or the output of the register and inputs the selected output to the program counter.

〔実施例1〕 本発明を実施例により説明する。[Example 1] The present invention will be explained by examples.

第1図は、本発明の一実施例におけるプログラムカウン
タ回路のブロック図である。第1図において、101は
プログラムカウンタ、102はサブルーチンからの第一
の戻り番地を格納するためのスタック、103はサブル
ーチンからの第二の戻り番地を格納するためのレジスタ
、104はスタック102の出力またはレジスタ103
の出力を選択するマルチプレクサ、105はスタックポ
インタ、106はマルチプレクサ104を制御するため
の制御回路、107はプログラムを格納するためのメモ
リ、108はメモリ107から命令をフェッチするため
の命令フェッチ手段、109は命令フェッチ手段108
から読んだ命令を解読するための命令デコーダである。
FIG. 1 is a block diagram of a program counter circuit in one embodiment of the present invention. In FIG. 1, 101 is a program counter, 102 is a stack for storing the first return address from the subroutine, 103 is a register for storing the second return address from the subroutine, and 104 is the output of the stack 102. or register 103
105 is a stack pointer, 106 is a control circuit for controlling the multiplexer 104, 107 is a memory for storing a program, 108 is an instruction fetch means for fetching instructions from the memory 107, 109 is the instruction fetch means 108
This is an instruction decoder for decoding instructions read from.

本発明のプログラムカウンタ回路を持つマイクロプロセ
ッサのサブルーチン呼出し時における動作について説明
する。本発明のプログラムカウンタ回路を持つマイクロ
プロセッサでは、レジスタ103にサブルーチンからの
任意の戻り番地を予しめセットすることができる。プロ
グラムカウンタ101は、メモリ107に格納されてい
るプログラムにおける次に実行するべき命令の番地を指
定する。命令フェッチ手段108は、プログラムカウン
タ101により指定された番地に格納されている命令の
フェッチを行ない、フェッチされた命令を命令デコーダ
109で解読する。解読された命令がサブルーチンコー
ル命令である場合は、プログラムカウンタ101の内容
をスタック102にブツシュし、コール先番地をプログ
ラムカウンタ101.に転送する。また、解読された命
令がリターン1命令である場合には、スタック102の
内容をプログラムカウンタ101にポツプし、解読され
た命令がリターン2命令である場合には、スタック10
2の内容をポツプするがプログラムカウンタ101には
転送せず、レジスタ103の内容をプログラムカウンタ
101に転送するように、制御回路106により制御す
る。
The operation of a microprocessor having a program counter circuit according to the present invention when calling a subroutine will be described. In the microprocessor having the program counter circuit of the present invention, any return address from a subroutine can be set in register 103 in advance. The program counter 101 specifies the address of the next instruction to be executed in the program stored in the memory 107. The instruction fetch means 108 fetches the instruction stored at the address specified by the program counter 101, and the instruction decoder 109 decodes the fetched instruction. If the decoded instruction is a subroutine call instruction, the contents of the program counter 101 are pushed onto the stack 102, and the call destination address is written to the program counter 101. Transfer to. Furthermore, if the decoded instruction is a return 1 instruction, the contents of the stack 102 are popped into the program counter 101, and if the decoded instruction is a return 2 instruction, the contents of the stack 102 are popped into the program counter 101.
The control circuit 106 pops the contents of register 103 but does not transfer them to program counter 101, but transfers the contents of register 103 to program counter 101.

ここで、本発明のプログラムカウンタ回路を持  。Here, a program counter circuit according to the present invention is included.

つマイクロプロセッサにより第4図に示す処理を実行す
る場合について説明する。この場合のプログラムは、以
下のようになる。
A case will be described in which the processing shown in FIG. 4 is executed by a microprocessor. The program in this case is as follows.

(1)レジスタ103に(2)の番地をセットする。(1) Set the address (2) in the register 103.

(2)データを入力する。(2) Enter data.

(3)条件1が偽ならば(5)ヘジャンプする。(3) If condition 1 is false, jump to (5).

(4)サブルーチン1をコールする。(4) Call subroutine 1.

(5)条件2が偽ならば、(7)ヘジャンプする。(5) If condition 2 is false, jump to (7).

(6)サブルーチン2をコールする。(6) Call subroutine 2.

(7)終了。(7) Finished.

なお、条件1:データがクラスタAに属する。Note that condition 1: data belongs to cluster A.

条件2:データがクラスタBに属するものとする。Condition 2: Data shall belong to cluster B.

このとき、サブルーチン1は、以下のようになる。At this time, subroutine 1 is as follows.

(11)処理Aを実行する。(11) Execute process A.

(12)リターン2゜ 同様に、サブルーチン2は、以下のようになる。(12) Return 2° Similarly, subroutine 2 is as follows.

(21)処理Bを実行する。(21) Execute process B.

(22)リターン2゜ 上述のように、(1)でレジスタ103には(2)の番
地がセットされているので、サブルーチン1およびサブ
ルーチン2のリターン2命令を実行すると(2)ヘジャ
ンプすることになる。これにより、リターン2が、サブ
ルーチンからのリターン命令および繰り返し処理のため
の無条件ジャンプ命令の機能を同時に果たし、第4図の
処理を実現する。
(22) Return 2゜As mentioned above, the address (2) is set in register 103 in (1), so when the return 2 instruction of subroutine 1 and subroutine 2 is executed, it will jump to (2). Become. As a result, return 2 simultaneously functions as a return command from a subroutine and an unconditional jump command for repeated processing, thereby realizing the processing shown in FIG. 4.

また、リターン2を実行する場合にも、スタックポイン
タ105はリターン1を実行する場合と同様な動作をす
るため、スタックはサブルーチンコール前の状態に戻さ
れる。以上のように、本実施例はリターン命令と無条件
ジャンプ命令を1命令で行なうことができる。
Also, when executing return 2, the stack pointer 105 operates in the same way as when executing return 1, so the stack is returned to the state before the subroutine call. As described above, in this embodiment, a return instruction and an unconditional jump instruction can be executed in one instruction.

〔実施例2〕 第2図は、本発明の第二の実施例のブロック図である。[Example 2] FIG. 2 is a block diagram of a second embodiment of the invention.

図において、201はプログラムカウンタ、202はサ
ブルーチンからの第一の戻り番地を格納するためのスタ
ック、203−1はサブルーチンからの第二の戻り番地
を格納するためのレジスタ、203−2はサブルーチン
からの第三の戻り番地を格納するたむのレジスタ、20
4はスタック202またはレジスタ203−1またはレ
ジスタ203−2の出力を選択するマルチプレクサ、2
05はスタックポインタ、206はマルチプレクサ20
4を制御するための制御回路、207はプログラムを格
納するためのメモリ、208はメモリ207から命令を
フェッチするための命令フェッチ手段、209は命令フ
ェッチ手段208から読んだ命令を解読するための命令
デコーダである。
In the figure, 201 is a program counter, 202 is a stack for storing the first return address from the subroutine, 203-1 is a register for storing the second return address from the subroutine, and 203-2 is a register for storing the second return address from the subroutine. Tamu's register, 20, which stores the third return address of
4 is a multiplexer that selects the output of the stack 202 or the register 203-1 or the register 203-2;
05 is the stack pointer, 206 is the multiplexer 20
207 is a memory for storing a program, 208 is an instruction fetch means for fetching instructions from the memory 207, and 209 is an instruction for decoding the instruction read from the instruction fetch means 208. It is a decoder.

本実施例における制御回路206は、リターン−1命令
のときはスタック202をポツプしてプログラムカウン
タ201に戻し、リターン2命令では同様にスタック2
02をポツプするが、プログラムカウンタへの転送は行
なわずにレジスタ203−1の内容をプログラムカウン
タ201に転送し、リターン3命令では同じくスタック
202をポツプするが、レジスタ203−2の内容をブ
ロダラムカウンタ201に転送するように制御する。
The control circuit 206 in this embodiment pops the stack 202 and returns it to the program counter 201 for the return-1 instruction, and similarly pops the stack 202 for the return-2 instruction.
02, but the contents of register 203-1 are transferred to the program counter 201 without being transferred to the program counter, and the return 3 instruction also pops the stack 202, but the contents of register 203-2 are transferred to the program counter 201. The data is controlled to be transferred to the counter 201.

この実施例では、サブルーチンからの第二、第三の戻り
番地を規定することが可能なレジスタを用いることによ
り、複数の戻り番地を設けることを可能とし、リターン
命令を無条件ジャンプ命令を1命令で実現できる。
In this embodiment, by using registers that can specify the second and third return addresses from a subroutine, it is possible to provide multiple return addresses, and a return instruction and an unconditional jump instruction are used as one instruction. This can be achieved with

〔発明の効果〕〔Effect of the invention〕

以上説明したように、本発明はサブルーチンからの戻り
番地を規定できる1つ以上のレジスタを設けることによ
り、1命令でリターンと無条件ジャンプを実行できるた
め、繰り返し処理を多く含むようなプログラムの動的ス
テップ数を大きく減少させることが可能となり、プログ
ラムの実行時間を大きく減少させるという効果がある。
As explained above, by providing one or more registers that can specify the return address from a subroutine, the present invention makes it possible to execute a return and an unconditional jump with a single instruction. This has the effect of greatly reducing the number of target steps and the program execution time.

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

第・1図は、本発明の実施例1におけるプログラム・カ
ウンタ回路の構成を示すブロック図、第2図は、本発明
の実施例2におけるプログラム・カウンタ回路の構成を
示すブロック図、第3図は、従来例におけるプログラム
・カウンタ回路の構成を示すブロック図、第4図は、繰
り返し処理の一例を示すフローチャートである。 101.201,301・・・プログラムカウンタ、1
02.202,302・・・スタック、103,203
−1,203−2・・・レジスタ、104,204・・
・マルチプレクサ、105,205,303・・・スタ
ックポインタ、106.206・・・制御回路、107
.207・・・メモリ、108,208・・・命令フェ
ッチ手段、109,209・・・命令デコーダ。 代理人 弁理士 内 原  晋・パ′ ・−、++。 /θ7 第 1 面 2θ7 $ 2 M 茅 4WJ
1 is a block diagram showing the configuration of the program counter circuit in Embodiment 1 of the present invention, FIG. 2 is a block diagram showing the configuration of the program counter circuit in Embodiment 2 of the present invention, and FIG. 4 is a block diagram showing the configuration of a conventional program counter circuit, and FIG. 4 is a flow chart showing an example of repetitive processing. 101.201,301...Program counter, 1
02.202,302...Stack, 103,203
-1,203-2...Register, 104,204...
・Multiplexer, 105, 205, 303... Stack pointer, 106.206... Control circuit, 107
.. 207...Memory, 108,208...Instruction fetch means, 109,209...Instruction decoder. Agent Patent Attorney Susumu Uchihara Pa' ・-, ++. /θ7 1st surface 2θ7 $ 2 M Kaya 4WJ

Claims (1)

【特許請求の範囲】[Claims] マイクロプロセッサのプログラムカウンタ回路において
、プログラムカウンタと、前記プログラムカウンタの内
容をサブルーチン呼び出し時に保持するスタック回路と
、サブルーチンからの戻り番地を格納する1つ以上のレ
ジスタと、リターン命令の種類に従って前記スタック回
路の出力または前記レジスタの出力のいずれかを選択し
て前記プログラムカウンタに入力する選択制御回路とを
有することを特徴とするプログラムカウンタ回路。
A program counter circuit of a microprocessor includes a program counter, a stack circuit that holds the contents of the program counter when a subroutine is called, one or more registers that store a return address from the subroutine, and the stack circuit according to the type of return instruction. and a selection control circuit that selects either the output of the register or the output of the register and inputs the selected output to the program counter.
JP5802187A 1987-03-13 1987-03-13 Program counter circuit Pending JPS63223923A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5802187A JPS63223923A (en) 1987-03-13 1987-03-13 Program counter circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5802187A JPS63223923A (en) 1987-03-13 1987-03-13 Program counter circuit

Publications (1)

Publication Number Publication Date
JPS63223923A true JPS63223923A (en) 1988-09-19

Family

ID=13072303

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5802187A Pending JPS63223923A (en) 1987-03-13 1987-03-13 Program counter circuit

Country Status (1)

Country Link
JP (1) JPS63223923A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS58168152A (en) * 1982-03-30 1983-10-04 Fujitsu Ltd Program restoration system of information processor
JPS6224328A (en) * 1985-07-23 1987-02-02 Nec Corp Program counter circuit

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS58168152A (en) * 1982-03-30 1983-10-04 Fujitsu Ltd Program restoration system of information processor
JPS6224328A (en) * 1985-07-23 1987-02-02 Nec Corp Program counter circuit

Similar Documents

Publication Publication Date Title
EP1104559A1 (en) Data processor with an arithmetic logic unit and a stack
JP3452989B2 (en) Central processing unit
JPS63223923A (en) Program counter circuit
JPH0520010A (en) Register file
JP2731740B2 (en) Parallel computer with communication register
JPS61194566A (en) Vector data reference control system
JPS60250438A (en) Information processor
JP2883489B2 (en) Instruction processing unit
JPS59173876A (en) Vector data processor
JP2743947B2 (en) Micro program control method
JPS6375833A (en) Information processor
JPH036735A (en) Data processor
JPS6398035A (en) Microprogram controller
JPH06161778A (en) Multi-flow instruction control method and instruction processor
JPS6024642A (en) Microprogram controlling system
JPH0353322A (en) Information processor
JPS61216032A (en) Instruction buffer circuit
JPH0683614A (en) Microcomputer
JPH04373044A (en) Information processor
JPH11249907A (en) Microcomputer
JPH0644066A (en) Information processor
JPH02103635A (en) Digital system
JPH03204029A (en) Information processor
JPS63298634A (en) Information processor
JPS6136657B2 (en)