JPS63208939A - Decimal arithmetic circuit - Google Patents

Decimal arithmetic circuit

Info

Publication number
JPS63208939A
JPS63208939A JP4130287A JP4130287A JPS63208939A JP S63208939 A JPS63208939 A JP S63208939A JP 4130287 A JP4130287 A JP 4130287A JP 4130287 A JP4130287 A JP 4130287A JP S63208939 A JPS63208939 A JP S63208939A
Authority
JP
Japan
Prior art keywords
operand
decimal
digits
circuit
instruction
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
JP4130287A
Other languages
Japanese (ja)
Inventor
Tei Ishikawa
石川 禎
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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP4130287A priority Critical patent/JPS63208939A/en
Publication of JPS63208939A publication Critical patent/JPS63208939A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To increase processing speed with the adding and subtracting instructions by controlling the overflow detection so that the number of object digits is decreased by one compared with a conventional case when a decimal adding/subtracting instruction of the variable operand length is carried out. CONSTITUTION:An instruction execution control circuit 12 fetches an instruction from a main memory 11 and starts a program executing circuit 13 based on an instruction code. In the case of a decimal adding/subtracting instruction, the circuit 13 sets the parameters L1 and N contained in the instruction at a decimal arithmetic circuit 14 and then reads a 2nd operand out of the memory 11. This reading action is carried out at every byte at and after the most significant rank byte and held by a register 31 at every time. The selection output data on a selector 33 are led to the 0, 1 and 2-9 detecting circuits 34, 35 and 36 respectively. The detecting results for the object digits of the 2nd operand are latched by registers 38 and 39 and then supplied to an overflow detecting circuit 40.

Description

【発明の詳細な説明】 [発明の目的] (産業上の利用分野) この発明は、シフト付き10進加減算を行なう10進演
算回路に関する。
DETAILED DESCRIPTION OF THE INVENTION [Object of the Invention] (Industrial Application Field) The present invention relates to a decimal arithmetic circuit that performs shifted decimal addition and subtraction.

(従来の技術) 一般に可変オペランド長さの10進加減譚命令の実行は
、次のように行なわれる。まず、加減算命令で指定され
る第2オペランドを主記憶から読出して演算回路のレジ
スタに一旦保持した後、これを上記命令で指定されたシ
フト桁数だけシフトする。次に、加減算命令で指定され
た第1オペランドをその下位桁から順に主記憶より取出
し、シフト後の第2オペランドとの間で加減算を行なう
。この加減算は、後述する理由により第1オペランドの
バイト数+1バイト分だけ行なわれる。
(Prior Art) Generally, a decimal addition/subtraction instruction with a variable operand length is executed as follows. First, the second operand specified by the addition/subtraction instruction is read from the main memory and temporarily held in the register of the arithmetic circuit, and then shifted by the number of shift digits specified by the instruction. Next, the first operand specified by the addition/subtraction instruction is fetched from the main memory in order from its lower digits, and addition/subtraction is performed with the shifted second operand. This addition/subtraction is performed for the number of bytes of the first operand + 1 byte for reasons to be described later.

加減篩が終了すると、もし減算で且つ結果が負となった
場合には結果の絶対値化を行ないその絶対値化された結
果、それ以外の場合には加減算結果が、主記憶における
昇1オペランドの格納領域に格納される。
When the addition/subtraction sieve is completed, if it is a subtraction and the result is negative, the result is converted to an absolute value, and in other cases, the addition/subtraction result is stored in the ascending 1 operand in the main memory. is stored in the storage area.

また、上記の演算動作と同時に、演算結果が第1オペラ
ンドの格納領域に格納可能か否か、即ちオーバフローと
なるか否かのチェックが行なわれ、その結果が(該当命
令の実行状態を示す)コンディションコードレジスタに
格納される。このオーバフローチェックでは、まず、シ
フト後の第2オペランドの桁数(実効桁数)が第1オペ
ランドの桁数+1より大きいか否かが調べられ、大きい
場合にはオーバフローと判定される。この判定(チェッ
ク)を、加減算の後のオーバフロー検出と区別するため
、オーバフロープリチェックと呼ぶ。
Also, at the same time as the above operation, a check is made to see whether the operation result can be stored in the storage area of the first operand, that is, whether it will overflow or not, and the result (indicating the execution state of the corresponding instruction) is checked. Stored in the condition code register. In this overflow check, first, it is checked whether the number of digits (effective number of digits) of the second operand after the shift is greater than the number of digits of the first operand + 1, and if so, it is determined that there is an overflow. This determination (check) is called an overflow precheck to distinguish it from overflow detection after addition and subtraction.

ここで、シフト後の第2オペランドの桁数との大小比較
対象を、第1オペランドの桁数でなくて第1オペランド
の桁数+1とするのは、シフト後の第2オペランドの桁
数が第1オペランドの桁数より大きくても、その差が1
であって且つ減算の場合(シフト後の第2オペランドか
ら第1オペランドを引く場合)には、減算の結果、オー
パフ0−とならない可能性があるからである。
Here, the reason why the number of digits of the second operand after the shift is compared with the number of digits of the first operand + 1 instead of the number of digits of the first operand is because the number of digits of the second operand after the shift is Even if the number of digits is greater than the number of digits in the first operand, the difference is 1
This is because, in the case of subtraction (when subtracting the first operand from the second operand after shifting), there is a possibility that the result of the subtraction will not be O-puff 0-.

上記したように、従来の10進加′g算処理では、第1
オペランドの桁数より1桁余分に計算を行なわなければ
ならない。加算の場合には、その結果の最上位桁の1バ
イトが0でないか、或は最上位桁計算時にその桁よりキ
ャリー(桁上がり)が出た場合にオーバフローとなり、
減算の場合には、結果が負とならず且つ結果の最旦位バ
イトがOでない場合にオーバフローとなる。
As mentioned above, in the conventional decimal addition 'g calculation process, the first
One more digit than the number of digits in the operand must be calculated. In the case of addition, if one byte of the most significant digit of the result is not 0, or if a carry occurs from that digit when calculating the most significant digit, an overflow occurs.
In the case of subtraction, an overflow occurs if the result is not negative and the most significant byte of the result is not O.

さて、加算の場合には、シフト後の第2オペランドの桁
数が第1オペランドの桁数より大きいならばオーバフロ
ーとなることは明らかであり、第1オペランドの桁数+
1桁の加算を行なうことは無駄である。そこで、実質的
に加算となる場合と、減算となる場合とで処理を分離し
、実質加算の場合には第1オペランドの桁数でオーバフ
ローブリチェックを行ない、第1オペランドの桁数分の
加算演算を行ない、最上位桁計算時にキャリーが出たら
オーバフローとすることも考えられる。しかし、この方
式を適用しても、実質減算時には第1オペランドの桁数
+1桁の計算が必要であることに変わりはなく、10進
加減算命令処理の高速化を図ることができなかった。
Now, in the case of addition, if the number of digits of the second operand after the shift is greater than the number of digits of the first operand, it is clear that an overflow will occur, and the number of digits of the first operand +
Performing single-digit additions is wasteful. Therefore, the processing is separated into cases where it is actually an addition and cases where it is a subtraction, and in the case of an actual addition, an overflow check is performed using the number of digits of the first operand, and an addition corresponding to the number of digits of the first operand is performed. It is also conceivable that an overflow occurs if a carry occurs when calculating the most significant digit. However, even if this method is applied, it is still necessary to calculate the number of digits of the first operand plus one digit during actual subtraction, and it is not possible to speed up the processing of decimal addition/subtraction instructions.

(発明が解決しようとする問題点) 上記したように従来のシフト付き10進演算では、オー
バフローとならない可能性がある場合を考慮して、シフ
ト対象とならない10進数値列の桁数より1桁余分に演
算しなければならず、10進加減算命令処理の高速化が
図れない問題があった。
(Problem to be Solved by the Invention) As mentioned above, in conventional shifted decimal operations, in consideration of the possibility that overflow will not occur, one digit from the number of digits of the decimal value string that is not to be shifted. There is a problem in that the processing speed of decimal addition/subtraction instructions cannot be increased because extra calculations must be performed.

この発明は上記事情に鑑みてなされたものでその目的は
、シフト付き10進加減算の対象桁数を従来に比べて1
桁減少することができ、もって10進加減算命令の処理
速度の向上が図れる10進演算回路を提供することにあ
る。
This invention was made in view of the above circumstances, and its purpose is to increase the number of target digits for shifted decimal addition and subtraction by 1 compared to the conventional method.
It is an object of the present invention to provide a decimal arithmetic circuit that can reduce the number of digits and thereby improve the processing speed of decimal addition/subtraction instructions.

[発明の構成] (問題点を解決するための手段と作用)この発明は、第
1の10進数値列と、第2の10道敗値列を指定桁数だ
けシフトして得られる第3の10進数値列との間の加減
算において、第3の10進数値列の桁数が第1の10進
数値列の桁数より大きい場合でもオーバフローとならな
い可能性があるのは、実質減算の場合で且つ第3の10
進数値列のうち第1の10進数値列の桁数を越える部分
の最下位桁の数値が1である場合のみであることに着目
し、効率的なオーバフロー検出を行なうことにより、従
来のように第1の10進数値列の桁数より1桁余分に加
算或は減算演算を行なわなくても済むようにしたもので
、第3の10進数値列のうち第1の10進数値列の桁数
を越える部分の最下位桁の数値が1であるか或は2以上
であるかを検出する検出手段を設け、この検出手段の検
出結果、第1の10進数値列と第3の10進数値列との
間での第1の10進数値列の桁数分の演算時における最
上位桁からのキャリー出力および演算内容が実質加算で
あるか否かをもとに、演算結果のオーバフロー検出を行
なうようにしたものである。
[Structure of the invention] (Means and effects for solving the problems) This invention provides a third decimal value sequence obtained by shifting a first decimal value string and a second decimal value sequence by a specified number of digits. The reason why there is a possibility that an overflow will not occur even if the number of digits in the third decimal value string is larger than the number of digits in the first decimal value string in addition and subtraction between the decimal value string and the decimal value string is that case and the third 10
By focusing on the fact that the number of digits in the least significant digit of the part of the decimal value string that exceeds the number of digits in the first decimal value string is 1, and by performing efficient overflow detection, This eliminates the need to add or subtract one digit more than the number of digits in the first decimal value string. A detection means is provided for detecting whether the numerical value of the least significant digit of the part exceeding the number of digits is 1 or 2 or more, and the detection result of this detection means is the first decimal value string and the third decimal value string. An overflow of the operation result is determined based on the carry output from the most significant digit when calculating the number of digits of the first decimal value string with the decimal value string and whether or not the operation content is actual addition. It is designed to perform detection.

(実施例) 第1図はこの発明の一実施例に係る10進演算回路のブ
ロック構成を示し、第2図は第1図の10進演算回路を
備えたデータ処理装置のブロック構成を示す。
(Embodiment) FIG. 1 shows a block configuration of a decimal arithmetic circuit according to an embodiment of the present invention, and FIG. 2 shows a block configuration of a data processing device equipped with the decimal arithmetic circuit of FIG.

第2図において、11は主記憶、12は主記憶11から
10進加減算命令などの各種命令を7エッチし、その命
令の実行制御を行なう命令実行制御回路である。13は
命令実行制御回路12によって起動されてマイクロプロ
グラム制御処理を行なうマイクロプログラム実行回路(
以下、μブOグラム実行回路と称する)、14はμプロ
グラム実行回路13のマイクロプログラム制御処理に従
って10選演算を1行なう10進演算回路である。
In FIG. 2, 11 is a main memory, and 12 is an instruction execution control circuit that etches seven various instructions such as decimal addition/subtraction instructions from the main memory 11 and controls the execution of the instructions. A microprogram execution circuit 13 is activated by the instruction execution control circuit 12 to perform microprogram control processing.
14 is a decimal arithmetic circuit that performs one 10-selection operation in accordance with the microprogram control process of the μ program execution circuit 13.

10進加減算命令は、例えば第3図のフォーマットに示
すように64ビツトで構成され、命令種別を示す命令コ
ードoPと、第1オペランドの主記憶11内格納アドレ
スEA1と、第1オペランドの長さ(バイト数)−1を
示すレングス値L1と、第2オペランドの主記憶11内
格納アドレスEA2と、第2オペランドの長さくバイト
数)−1を示すレングス値L2  (ここでは第2オペ
ランドのバイト数−1)と、第2オペランドに対するシ
フト数N(ビット40〜43)とを有している。Ll。
The decimal addition/subtraction instruction is composed of 64 bits as shown in the format of FIG. 3, for example, and includes an instruction code oP indicating the instruction type, the storage address EA1 in the main memory 11 of the first operand, and the length of the first operand. Length value L1 indicating (number of bytes) -1, storage address EA2 of the second operand in the main memory 11, and length value L2 indicating (number of bytes) -1 of the second operand (here, the byte of the second operand) -1) and the shift number N (bits 40 to 43) for the second operand. Ll.

L2はいずれも4ビツト構成であり、したがって第1お
よび第2オペランドの長さは1〜16バイトである。ま
た、第3因に示す10進加減算命令のビット34は、N
の符号ピッ、トであり、Nが正なら左シフトを、負なら
右シフトを示す。負のときは2の補数表現であるので、
Nの一範囲は一32≦Nく32である。
Both L2s have a 4-bit configuration, so the lengths of the first and second operands are 1 to 16 bytes. Further, bit 34 of the decimal addition/subtraction instruction shown in the third factor is N
If N is positive, it indicates a left shift, and if N is negative, it indicates a right shift. When it is negative, it is expressed in two's complement, so
One range of N is -32≦N×32.

第4図は上記10進加減算命令で扱われる10進数値列
がパック形式10進数の場合のフォーマットを示す。バ
ック形式では、4ビツトで10進数1桁(dO〜dn)
、1バイトで2桁が示され、符号Sは最下位バイトの下
位4ビツトで示される。
FIG. 4 shows the format when the decimal value string handled by the above-mentioned decimal addition/subtraction instruction is a packed decimal number. In back format, 4 bits = 1 decimal digit (dO to dn)
, two digits are shown in one byte, and the code S is shown in the lower four bits of the least significant byte.

さて、第2図の10進演算回路14は、第1図に示すよ
うに、第2オペランドを例えば1バイトずつ保持する1
バイト(8ビツト)レジスタ31と、このレジスタ31
に保持されている・バイトデータが符号Sを含む最下位
バイトである場合に、符号の認識と符号の除去を行なう
符号チェック回路32と、この符号チェック回路32の
出力データまたはレジスタ21の保持データのいずれか
一方を選択するセレクタ33とを有している。また10
進演算回路14は、セレクタ33から選択出力されるデ
ータの各桁毎にOであるか否かを検出する0検出回路3
4と、1であるか否かを検出する1検出回路35と、2
〜9のいずれかであるかを検出する2〜9検出回路36
とを有している。更に10進演算回路14は、0検出回
路34のO検出結果をもとに第2オペランドの実効桁数
EDLを算出する実効桁数計算回路37と、1検出回路
35の検出結果をタイミング信号TMに応じてラッチす
る1ビツトレジスタ38と、2〜9@出回路36の検出
結果をタイミング信号TMに応じてラッチする1ビツト
レジスタ39と、オーバフロー検出回路40とを有して
いる。このオーバフロー検出回路40は、第1オペラン
ドのレングス値L1、第2オペランドのシフト数N、計
算回路37の計算結果である実効桁数EDL、第1オペ
ランドと第2オペランドとの間の加減算が実質的加算と
なるか否か(実質的減算となるか)を示す信号ACTA
DD、、上記の加減算を行なう(10進演算回路14内
の)図示せぬ加減算回路のキャリー出力CARRY、レ
ジスタ38の保持データである1検出結果XD1、およ
びレジスタ39の保持データである2〜9検出結果XD
29をもとに、オーバフローの検出を行ないその結果を
示すオーバフロー信@0VFLを出力す−るようになっ
ている。このオーバフロー検出回路49は、例えばゲー
トアレイ−を用いて構成されており、そのオーバフロー
検出論理を、疑似コーディングの形で第5図に示す。
Now, as shown in FIG. 1, the decimal arithmetic circuit 14 in FIG.
Byte (8 bit) register 31 and this register 31
A code check circuit 32 that recognizes the code and removes the code when the byte data held in the byte is the least significant byte containing the code S, and the output data of this code check circuit 32 or the data held in the register 21. and a selector 33 for selecting either one. 10 more
The decimal calculation circuit 14 includes a 0 detection circuit 3 that detects whether each digit of data selectively output from the selector 33 is O or not.
4, a 1 detection circuit 35 that detects whether or not it is 1, and 2
2 to 9 detection circuit 36 that detects whether the
It has Furthermore, the decimal arithmetic circuit 14 includes an effective number of digits calculation circuit 37 that calculates the effective number of digits EDL of the second operand based on the O detection result of the 0 detection circuit 34, and a timing signal TM that uses the detection result of the 1 detection circuit 35. It has a 1-bit register 38 that latches in accordance with the timing signal TM, a 1-bit register 39 that latches the detection result of the output circuit 36 in accordance with the timing signal TM, and an overflow detection circuit 40. This overflow detection circuit 40 detects the length value L1 of the first operand, the shift number N of the second operand, the effective number of digits EDL which is the calculation result of the calculation circuit 37, and the fact that the addition/subtraction between the first operand and the second operand is A signal ACTA indicating whether or not it will be a virtual addition (or a substantial subtraction)
DD, carry output CARRY of the adder/subtracter (not shown) (in the decimal arithmetic circuit 14) that performs the above addition/subtraction, 1 detection result XD1 which is the data held in the register 38, and 2 to 9 which is the data held in the register 39. Detection result XD
29, overflow is detected and an overflow signal @0VFL indicating the result is output. This overflow detection circuit 49 is constructed using, for example, a gate array, and its overflow detection logic is shown in pseudo-coding form in FIG.

次に、この発明の一実施例の動作を第6図のフローチャ
ートを適宜参照して説明する。
Next, the operation of one embodiment of the present invention will be explained with reference to the flowchart of FIG. 6 as appropriate.

今、命令実行制御回路12が主記憶11から命令をフェ
ッチしたものとする。命令実行制御回路12は、命令フ
ェッチを行なうと、その命令コードに従ってμプログラ
ム実行回路13に起動をかける。命令実行制御回路12
によってフェッチされた命令が第3図のフォーマットに
示される10進加減算命令の場合、まずμプログラム実
行回路13は、10進加減算命令中のパラメータ値であ
るLl 、 L2 。
Assume that the instruction execution control circuit 12 has now fetched an instruction from the main memory 11. When the instruction execution control circuit 12 fetches an instruction, it activates the μ program execution circuit 13 according to the instruction code. Instruction execution control circuit 12
If the instruction fetched by is a decimal addition/subtraction instruction shown in the format of FIG. 3, the μ program execution circuit 13 first retrieves the parameter values Ll, L2 in the decimal addition/subtraction instruction.

Nを10進演算回路14の図示せぬワーキングレジスタ
にセットする処理を行なう(ステップ81)。
A process is performed to set N in a working register (not shown) of the decimal arithmetic circuit 14 (step 81).

次にμプログラム実行回路13は、主記憶11からの第
2オペランドの読出しを行なう(ステップS2)、この
第2オペランドの読出しは、その最上位バイトから1バ
イトずつ行なわれ、読出されたバイトデータはその都度
10進演算回路14のレジスタ31に保持される。この
レジスタ31に保持されたバイトデータが、第2オペラ
ンドの最下位バイトの場合、即ち符号Sを含むバイトの
場合には、符号チェック回路32によって符号の認識と
符号の除去が行なわれ、セレクタ33の一方の入力に供
給される。このセレクタ33の他方の入力にはレジスタ
31に保持されているバイトデータが供給される。
Next, the μ program execution circuit 13 reads the second operand from the main memory 11 (step S2).The second operand is read one byte at a time starting from the most significant byte, and the read byte data is held in the register 31 of the decimal arithmetic circuit 14 each time. If the byte data held in this register 31 is the least significant byte of the second operand, that is, if it is a byte containing the code S, the code is recognized and removed by the code check circuit 32, and the selector 33 is fed to one input of The other input of this selector 33 is supplied with the byte data held in the register 31.

セレクタ33は、セレクタ33に保持されているバイト
データが、第2オペランドの最下位バイトでない場合に
はレジスタ31の保持データを選択し、最下位バイトの
場合には符号チェック回路32の出力データを選択する
The selector 33 selects the data held in the register 31 if the byte data held in the selector 33 is not the least significant byte of the second operand, and selects the output data of the sign check circuit 32 if it is the least significant byte. select.

セレクタ33の選択出力データは0検出回路34.1検
出回路35および2〜9検出回路36に導かれて、各桁
毎にその桁の値が0であるか、1であるか。
The selected output data of the selector 33 is guided to a 0 detection circuit 34.1 detection circuit 35 and a 2-9 detection circuit 36, and it is determined whether the value of each digit is 0 or 1.

或は2〜9のいずれかであるかが検出されると共に、図
示せぬワークレジスタに保持されていく。
Or any one of 2 to 9 is detected and held in a work register (not shown).

0検出回路34の0検出結果は実効桁数計算回路37に
導かれ、第2オペランドの最上位桁からの連続する0の
数(リーディング0の桁数)を求めることにより第2オ
ペランドの実効桁数EDLが算出される。この実効桁数
EDLはオーバフロー検出回路40に供給される。一方
、1検出回路35のに1検出結果はレジスタ38に、2
〜9検出回路36の2〜9検出結果はレジスタ39に導
かれ、μプログラム実行回路13の制御により与えられ
るタイミング信号TMにより、上記結果の該5桁が、シ
フト後の第2オペランドのなかで第1オペランドの領域
(長さ)を越える部分の最下位桁(これを1.2〜9の
チェック対象相と呼ぶ)の場合だけラッチされる。
The 0 detection result of the 0 detection circuit 34 is led to the effective digit number calculation circuit 37, which calculates the effective digit number of the second operand by calculating the number of consecutive 0s (the number of leading 0 digits) from the most significant digit of the second operand. The number EDL is calculated. This effective number of digits EDL is supplied to an overflow detection circuit 40. On the other hand, the 1 detection result of the 1 detection circuit 35 is stored in the register 38.
The 2 to 9 detection results of the ~9 detection circuit 36 are led to the register 39, and by the timing signal TM given under the control of the μ program execution circuit 13, the 5 digits of the above result are shifted into the second operand. Only the least significant digit of the portion exceeding the area (length) of the first operand (this is called the phase to be checked from 1.2 to 9) is latched.

ここで、上記のチェック対像桁について、第7図を参照
して説明する。まず、第2オペランドの桁数は第7図(
a)に示すように L2木2+1 であり、第1オペランドの桁数は第7図(b)に示すよ
うに 11木2+1 である。またシフト後の第2オペランドの桁数は第7図
(C)に示すように 12木2+1+N である。この場合、上記チェック対象相は、第7図(d
)から明らかなように、シフト後の第2オペランドの最
上位桁から L2木2−L1木十N 桁目となる。即ち、この実施例では、第2オペランドの
最上位桁からL2木2−L1木+N桁目の(1検出回路
35による)1検出結果がレジスタ38に、(2〜9検
出回路36による)2〜9検出結果がレジスタ39にラ
ッチされる。レジスタ38.39のラッチデータである
第2オペランドのチェック対象相の1検出結果XDI 
、2〜9検出結果XD29はオーパフロー検出回路40
に供給される。なお、チェック対象相が存在しない場合
(即ち、上記の計算でチェック対象相が0以下の値とな
った場合)のレジスタ38.39の値(XDI 、XD
29)は意味を成さない。
Here, the above-mentioned check target digit will be explained with reference to FIG. First, the number of digits of the second operand is shown in Figure 7 (
As shown in FIG. 7(b), the L2 tree is 2+1, and the number of digits of the first operand is 2+1, as shown in FIG. 7(b). The number of digits of the second operand after the shift is 12 trees 2+1+N as shown in FIG. 7(C). In this case, the phase to be checked is shown in Fig. 7 (d
), it is the L2 tree 2-L1 tree 10th Nth digit from the most significant digit of the second operand after the shift. That is, in this embodiment, the 1 detection result (by the 1 detection circuit 35) of the L2 tree 2 - L1 tree + Nth digit from the most significant digit of the second operand is stored in the register 38, and the 2 detection result (by the 2 to 9 detection circuit 36) is stored in the register 38. ~9 detection results are latched into the register 39. 1 detection result XDI of the phase to be checked of the second operand, which is the latch data of registers 38 and 39
, 2 to 9 detection results XD29 are the overflow detection circuit 40
supplied to Note that the values of registers 38 and 39 (XDI, XD
29) makes no sense.

さて、ステップS2において、主記憶11から1バイト
単位で順に読取られた第2オペランドについて、上記し
た符号チェック、実効桁数EDLの算出、およびチェッ
ク対象相の1,2〜9検出が行なわれると(ステップ$
3)、主記憶11からの第1オペランドの読出しがμプ
ログラム実行回路13によってその最下位バイトから順
に行なわれる(ステップ84)。そして、前記した第2
オペランドの場合と同様にして符号チェック回路32に
より符号のチェックと符号の除去が行なわれ、セレクタ
33を介してワークレジスタに保持される(ステップ8
5 )。次に、10進加減算命令の種類(加算/減算)
と、ステップ33 、 S5における第1.2オペラン
ドの符号チェック結果とから、10進演算回路14内の
図示せぬ加減算回路の動作が実質的に加算となるか否か
く減算となるか)を決定し、その旨の(即ち実質的な演
算モードを示す)信号ACTADDを出力する(ステッ
プS6)。この信号ACTADDは、10進演算回路1
4のオーバフロー検出回路40に供給される。
Now, in step S2, the above-mentioned sign check, calculation of the effective number of digits EDL, and detection of phases 1, 2 to 9 to be checked are performed on the second operand that is sequentially read from the main memory 11 in 1-byte units. (Step $
3) The first operand is read from the main memory 11 by the μ program execution circuit 13 in order from the least significant byte (step 84). Then, the second
The code is checked and removed by the code check circuit 32 in the same manner as in the case of the operand, and the result is held in the work register via the selector 33 (step 8).
5). Next, types of decimal addition/subtraction instructions (addition/subtraction)
and the sign check result of the 1.2nd operand in step 33 and S5, it is determined whether the operation of the addition/subtraction circuit (not shown) in the decimal arithmetic circuit 14 is substantially addition or subtraction. Then, it outputs a signal ACTADD to that effect (that is, indicating the actual calculation mode) (step S6). This signal ACTADD is applied to the decimal arithmetic circuit 1.
The signal is supplied to the overflow detection circuit 40 of No. 4.

μプログラム実行回路13により実質的な演算モードが
決定されると、10進演算回路14では、ワーキングレ
ジスタに保持されていた第2オペランドが、第1オペラ
ンドに位取りが合うようにシフト数Nを考慮して取出さ
れ、第1オペランドの桁数だけの加減算が図示せぬ加減
算回路において行なわれる(ステップS7)。この加減
算回路での最上位桁(実際の演算対象桁の最上位桁)の
計算時のキャリ出力CARRYは、オーバフロー検出回
路40に供給される。
When the actual operation mode is determined by the μ program execution circuit 13, the decimal operation circuit 14 takes into account the shift number N so that the second operand held in the working register matches the scale of the first operand. Then, addition and subtraction by the number of digits of the first operand are performed in an addition/subtraction circuit (not shown) (step S7). A carry output CARRY during calculation of the most significant digit (the most significant digit of the actual operation target digit) in this addition/subtraction circuit is supplied to the overflow detection circuit 40.

ステップS7が終了すると、ステップS7の演算が実質
的減算で且つその結果が負であるか否かの判定が行なわ
れる(ステップ88)。ステップ$8の判定がYESの
場合には、結果の絶対値化が行なわれ(ステップS9ン
、オーバフロー検出回路40を用いたオーバフローチェ
ックが行なわれる(ステップ510)。これに対して、
ステップS8の判定がNoの場合には、ステップS9を
スキップしてステップ810のオーバフローチェックが
行なわれる。
When step S7 is completed, it is determined whether the operation in step S7 is actually a subtraction and the result is negative (step 88). If the determination in step $8 is YES, the result is converted into an absolute value (step S9), and an overflow check using the overflow detection circuit 40 is performed (step 510).On the other hand,
If the determination in step S8 is No, step S9 is skipped and an overflow check is performed in step 810.

オーバフロー検出回路40は、第5図に示すオーバフロ
ー検出論理から明らかなよ−うに、第1オペランドの桁
数+1(L1木x2+2)がシフト後の第2オペランド
(実効部のみ)の桁数(EDL+N)より小さい場合に
は、従来と同様にオーバフロー有りを示すを論理“1″
のオーバフロー信号0VFLを出力する。
As is clear from the overflow detection logic shown in FIG. ), the logic “1” indicates that there is an overflow, as in the past.
outputs an overflow signal 0VFL.

これに対して、第1オペランドの桁数+1がシフト後の
第2オペランド(実効部のみ)の桁数より小さくない場
合には、信号ACTADDが論理“1″であり(即ち実
質的に加算であり)、且つキャリー出力CARRY、1
検出結果XD1および2〜9検出結果×D29の少なく
とも1つが論理111 IIであれば(即ち、加減算回
路において実際に演算対象となった桁の最上位桁の計算
時にキャリー(桁上がり)が発生したか、チェック対傘
桁がOでなければ)、論理“1″のオーバフロー信号0
VFLが出力され、それ以外であれば(即ち、最上位桁
の計算時にキャリーが発生せず且つチェック対象桁がO
であれば)オーバフロー信号0VFLは論理“ONとな
る。
On the other hand, if the number of digits of the first operand +1 is not smaller than the number of digits of the second operand (effective part only) after shifting, the signal ACTADD is logic "1" (i.e., addition is not actually possible). Yes), and carry output CARRY, 1
If at least one of the detection result XD1 and 2 to 9 detection results or if the check umbrella digit is not O), the overflow signal of logic "1" is 0
VFL is output, and if it is not otherwise (i.e., no carry occurs when calculating the most significant digit and the digit to be checked is O)
If so), the overflow signal 0VFL becomes logic "ON".

また、第1オペランドの桁数+1がシフト後の第2オペ
ランド(実効部のみ)の桁数より小さくなく、且つ信号
ACTADDが論理“011である場合(即ち実質的に
減算である場合)には、キャリー出力CARRYが論理
“1″であって(正しく引けて)、且つ1検出結果XD
1および2〜9検出結果×D29の少なくとも1つが論
理“1”であれば(即ちチェック対象桁が0でなければ
)、或はキャリー出力CARRYが論理“OIIであっ
て(即ちボローが出て)、且つ2〜9検出結果XD29
が論理“1”であれば(即ちチェック対象桁がOまたは
1でなければ)、いずれも論理“1”のオーバフロー信
号0VFLが出力され、それ以外であればオーバフロー
信号0VFLは論理゛0″となる。
Further, if the number of digits of the first operand + 1 is not smaller than the number of digits of the second operand (effective part only) after shifting, and the signal ACTADD is logic "011" (that is, if it is substantially a subtraction), , the carry output CARRY is logic “1” (correctly drawn), and the 1 detection result XD
If at least one of 1 and 2 to 9 detection results x D29 is logic "1" (that is, the digit to be checked is not 0), or the carry output CARRY is logic "OII" (that is, a borrow has occurred). ), and 2 to 9 detection results XD29
If is logic "1" (that is, the digit to be checked is not O or 1), overflow signal 0VFL of logic "1" is output, and otherwise, overflow signal 0VFL is logic "0". Become.

さて、例えば第8図に示すように、第1オペランドが 0000001 (Ll −3) 第2オペランドが 000000001  (、L2 −4)で、N−7の
場合には、シフト後の第2オペランドの実効部桁数は、
第1オペラン下の桁数より1桁だけ越える。しかし、上
記の場合の減算結果(シフト後の第2オペランドから第
1オペランドを引いた値)は、 となり、オーパフ〇−とならない。従来は、このような
可能性があることを考慮し、正しいオーバフロー検出の
ために第1オペランドより1桁多い桁数の演算(減算)
を行なっていた。これに対して本実施例では、例えば上
記した第8図の減算であれば、CARRY−0であるこ
と以外に、シフト後の第2オペランドにおいて第1オペ
ランドを越えた部分の最下位桁であるチェック対象桁の
数値が1であること(1検出結果XD1 )がオーバフ
ロー検出回2840におけるオーバフロー検出で考慮さ
れるので、第1オペランドの桁数だけの減算を行なって
も、誤ってオーバフローと判断される恐れはない。
For example, as shown in Figure 8, if the first operand is 0000001 (Ll -3) and the second operand is 000000001 (, L2 -4), and N-7, the effective value of the second operand after the shift is The number of digits is
Exceed by one digit than the number of digits below the first operan. However, the result of subtraction in the above case (the value obtained by subtracting the first operand from the second operand after the shift) is as follows, which does not result in O-puff 0-. Conventionally, in consideration of this possibility, an operation (subtraction) with one digit more than the first operand was performed in order to correctly detect overflow.
was being carried out. On the other hand, in this embodiment, for example, in the case of the subtraction shown in FIG. Since the fact that the value of the digit to be checked is 1 (1 detection result There is no fear that

ステップ310のオーバフローチェックが終了すると、
加減算結果の符号が決定され(ステップ511)、この
決定に基づく結果への符号付加、この符号付加された結
果の主記憶11内第1オペランド領域への格納およびオ
ーバフローチェック結果のコンディションコードレジス
タへの格納が行なわれ(ステップ512)、1つの10
進加減算命令処理が終了する。
When the overflow check in step 310 is completed,
The sign of the addition/subtraction result is determined (step 511), a sign is added to the result based on this determination, the result with the sign added is stored in the first operand area in the main memory 11, and the overflow check result is stored in the condition code register. A store is performed (step 512) and one 10
The base addition/subtraction instruction processing ends.

なお、前記実施例では、10進加減算命令で扱われる1
0進数値列(演算対象オペ、ランド)がバック形式10
進数である場合について説明したが、この発明は、1バ
イトで10進数1桁を表わすゾーン形式10進数の場合
にも応用できる。ゾーン形式では、第9図のフォーマッ
トに示すように、(最下位バイトを除く)各バイトの下
位4ビツトで10進数値1桁が表、わされ、上位4ビツ
ト(ゾーンフィールド)2は成る一定の値にセットされ
る。この2は、10進数値列の表わす数値に対しては意
味を持たない。また最下位バイトは、数値と符号とを表
わす。したがって、ゾーン形式の場合には、第1.第2
オペランドの桁数は、Ll +1.Ll +2となる。
In addition, in the above embodiment, 1, which is handled by the decimal addition/subtraction instruction,
The decimal value string (operation target, land) is in back format 10
Although the case of a base number has been described, the present invention can also be applied to the case of a zoned decimal number in which one byte represents one digit of the decimal number. In the zone format, as shown in the format of Figure 9, the lower 4 bits of each byte (excluding the least significant byte) represent a single decimal value, and the upper 4 bits (zone field) 2 represent a constant value. is set to the value of This 2 has no meaning for the numerical value represented by the decimal value string. Furthermore, the least significant byte represents a numerical value and a sign. Therefore, in the case of the zone format, the first . Second
The number of digits of the operand is Ll +1. It becomes Ll +2.

[発明の効果] 以上詳述したようにこの発明によれば、第1の10進数
値列と、第2の10進数値列を指定桁数だけシフトして
得られる第3の10進数値列と□の間の加減算において
、第3の10進数値列のうち第1の10進数値列の桁数
を越える部分の最下位桁の数値が1であるか否かを予め
検出しておき、この検出結果を上記の加減算結果のオー
バフローチェックに加えることにより、従来より1桁少
ない加減II(即ち第1の10進数値列の桁数分だけの
加減算)を行なっても、オーバフロー検出を正しく行な
うことができる。
[Effects of the Invention] As detailed above, according to the present invention, the third decimal value string is obtained by shifting the first decimal value string and the second decimal value string by a specified number of digits. In addition and subtraction between and □, detect in advance whether or not the lowest digit of the part of the third decimal value string that exceeds the number of digits of the first decimal value string is 1. By adding this detection result to the overflow check of the addition/subtraction results described above, overflow detection can be performed correctly even if addition/subtraction II is performed one digit less than before (i.e., addition/subtraction for the number of digits in the first decimal value string). be able to.

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

第1図はこの発明の一実施例に係る10進′e4算回路
のブロック構成図、第2図は第1図の10進演算回路を
備えたデータ処理装置の概略ブロック図、第3図は10
進加減算命令のフォーマットを示す図、第4図は上記1
0進加減算命令で扱われるバック形式10進数のフォー
マットを示す図、第5図は第1図に示すオーバフロー検
出回路40のオーバフロー検出論理を疑似コーディング
の形で示す図、第6図は10進加減算命令処理手順を示
すフローチャート、第7図はチェック対象相を説明する
図、第8図はシフト後の第2オペランドの桁数が第1オ
ペランドの桁数より大きい場合でもオーバフローとなら
ない減算例を示す図、第9図はゾーン形式10進数のフ
ォーマットを示す図である。 11・・・主記憶、12・・・命令実行制御回路、13
・・・μプログラム実行回路、14・・・10進演算回
路、34・・・0検出回路、35・・・1検出回路、3
6・・・2〜9検出回路、31・・・実効桁数計算回路
、40・・・オーパフロー検出回路。 出願人代理人 弁理士 鈴 江 武 彦第1図 第2図 第3図 1パイト ド・論理和 &・・論理積 第6図 N桁 第7図
FIG. 1 is a block diagram of a decimal 'e4 arithmetic circuit according to an embodiment of the present invention, FIG. 2 is a schematic block diagram of a data processing device equipped with the decimal arithmetic circuit of FIG. 1, and FIG. 10
A diagram showing the format of the base addition/subtraction instruction, Figure 4 is the same as 1 above.
A diagram showing the format of a back-format decimal number handled by the 0-base addition/subtraction instruction. FIG. 5 is a diagram showing the overflow detection logic of the overflow detection circuit 40 shown in FIG. 1 in the form of pseudo coding. FIG. 6 is a diagram showing the decimal addition/subtraction A flowchart showing the instruction processing procedure, FIG. 7 is a diagram explaining the phases to be checked, and FIG. 8 shows an example of subtraction that does not cause an overflow even when the number of digits of the second operand after shifting is greater than the number of digits of the first operand. 9 are diagrams showing the format of zoned decimal numbers. 11... Main memory, 12... Instruction execution control circuit, 13
... μ program execution circuit, 14 ... Decimal calculation circuit, 34 ... 0 detection circuit, 35 ... 1 detection circuit, 3
6... 2 to 9 detection circuit, 31... Effective digit number calculation circuit, 40... Overflow detection circuit. Applicant's representative Patent attorney Takehiko Suzue Figure 1 Figure 2 Figure 3 Figure 1 Pieced, logical sum &... logical product Figure 6 N digit Figure 7

Claims (1)

【特許請求の範囲】[Claims] 第1の10進数値列と、第2の10進数値列を指定桁だ
けシフトして得られる第3の10進数値列との間で、上
記第1の10進数値列の桁数分の加算或は減算演算を行
なう加減算手段と、上記第3の10進数値列のうち上記
第1の10進数値列の桁数を越える部分の最下位桁の数
値が1であるか或は2以上であるかを検出する第1検出
手段と、この第1検出手段の検出結果、上記演算手段か
らの最後のキャリー出力および上記演算手段の演算内容
が実質加算であるか否かをもとに、演算結果のオーバフ
ロー検出を行なう第2検出手段とを具備することを特徴
とする10進演算回路。
Between the first decimal value string and the third decimal value string obtained by shifting the second decimal value string by a specified number of digits, the number of digits in the first decimal value string is Addition and subtraction means for performing addition or subtraction operations, and a number of least significant digits of the portion of the third decimal value string that exceeds the number of digits of the first decimal value string is 1 or 2 or more; Based on the detection result of the first detection means, the last carry output from the arithmetic means, and whether the content of the arithmetic operation of the arithmetic means is substantially addition, A decimal arithmetic circuit comprising: second detection means for detecting overflow of arithmetic results.
JP4130287A 1987-02-26 1987-02-26 Decimal arithmetic circuit Pending JPS63208939A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4130287A JPS63208939A (en) 1987-02-26 1987-02-26 Decimal arithmetic circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4130287A JPS63208939A (en) 1987-02-26 1987-02-26 Decimal arithmetic circuit

Publications (1)

Publication Number Publication Date
JPS63208939A true JPS63208939A (en) 1988-08-30

Family

ID=12604679

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4130287A Pending JPS63208939A (en) 1987-02-26 1987-02-26 Decimal arithmetic circuit

Country Status (1)

Country Link
JP (1) JPS63208939A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011248890A (en) * 2010-05-28 2011-12-08 International Business Maschines Corporation Detection of decimal floating point quantum exception

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011248890A (en) * 2010-05-28 2011-12-08 International Business Maschines Corporation Detection of decimal floating point quantum exception
US8219605B2 (en) 2010-05-28 2012-07-10 International Business Machines Corporation Decimal floating-pointing quantum exception detection

Similar Documents

Publication Publication Date Title
EP0221577B1 (en) Microprogram control unit
EP0755015B1 (en) Combining data values
JPS6351287B2 (en)
US4317170A (en) Microinstruction controlled data processing system including micro-instructions with data align control feature
US4413326A (en) Floating point division control
JPH06202850A (en) Data processor
JPH0477338B2 (en)
US4799181A (en) BCD arithmetic using binary arithmetic and logical operations
JPH0228830A (en) Integer number dividing circuit
JPS6027030A (en) Microprocessor
US3001708A (en) Central control circuit for computers
JPH0479015B2 (en)
JPS6227412B2 (en)
JPH034936B2 (en)
JPS608933A (en) Arithmetic processing unit
JPS63208939A (en) Decimal arithmetic circuit
JP3735438B2 (en) RISC calculator
JPS59184944A (en) Rounding arithmetic system
JPH0435777B2 (en)
JPS61224036A (en) Arithmetic unit
JP2624738B2 (en) Rounding method
JPS61285539A (en) Information processor
JP2985093B2 (en) Arithmetic control unit
JP2587407B2 (en) Micro program controller
JPH02148140A (en) Conditional branch control system for information processor