JPH02230320A - Data processor - Google Patents

Data processor

Info

Publication number
JPH02230320A
JPH02230320A JP4981989A JP4981989A JPH02230320A JP H02230320 A JPH02230320 A JP H02230320A JP 4981989 A JP4981989 A JP 4981989A JP 4981989 A JP4981989 A JP 4981989A JP H02230320 A JPH02230320 A JP H02230320A
Authority
JP
Japan
Prior art keywords
data
size
bit
register
processing device
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
JP4981989A
Other languages
Japanese (ja)
Inventor
Makoto Hanawa
花輪 誠
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.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP4981989A priority Critical patent/JPH02230320A/en
Publication of JPH02230320A publication Critical patent/JPH02230320A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To generate an operation flag which is independent on the size of data by setting the second size of data to be the half or the quarter of a first size having the same data width as that of registers and using the high-order side of the registers when the registers are used as data of the second size. CONSTITUTION:A data processor 700 is constituted of the registers 711-713, a barrel shifter 720, a computing element 730, data length correction mask circuits 731 and 732, a memory data register 740, a memory data aligner 741, a memory bus 742 and data buses 751-753. When data is used as integer type data smaller than register 32 bits, the high-order side among the registers having the width of 32 bits is used. When integer type data smaller than 32 bits are operated, data are drawn to left and '0' is supplemented on a right side to execute an operation. Thus, the size of data can be easily converted by a shift instruction, and the generation circuit of the operation flag is eliminated from giving at every size of data.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は主にマイクロプロセッサ(MPU)の演算フラ
グの生成方式、及び、レジスタ内のビット番号付け規則
に係り、特に,11数型データのサイズが複数種類規定
されているM 1) Uに好適な演算フラグの生成方式
、及び,レジスタ内のビット番号付け規則に関する. 〔従来の技術〕 16ビット以上のワード長を有するマイクロプロセッサ
では.処理するデータのサイズとして、ワードサイズの
他に1バイト(8ビット)のサイズも必要となっている
.そのため、1つの命令でもサイズによって、数種のバ
リエーションがある.例えば、T R O N  Th
e Real−Time Operatingsyst
em Nucleus)仕様に準拠した日立の32ビッ
トマイクロプロセッサGmieroにおいては、整数型
データのデータ長としてワード(32ビット)サイズの
他に、ハーフワード(16ビット),バイト(8ビット
)の3種のデータ長が用意されている.この詳細な仕様
については、日立32ビットマイクロプロセッサH32
/200プログラミングマニュアルに示されている. H32/200においては、メモリ上の32ビット(4
バイト)整数型データを扱う場合、小さいアドレスがデ
ータの上位側に対応し、大きいアドレスがデータの下位
側に対応している.また、データ内のビット番号の付け
方としては、最上位ビットを0として下位側にいくに従
ってビット番号が大きくなるように付けている.一方、
H32/200はレジスタとして32ビット幅のものを
持っている。このレジスタを32ビットより4−さい整
数型データ、例えば、バイト,ハーフワードの整数型デ
ータとして使う場合、32ビットのレジスタのうち下位
側(右側)の部分を使っている. 〔発明が解決しようとするIlllfl)上記の様に従
来の32ビットマイクロプロセッサにおいては、レジス
タのサイズより短い整数型データを扱うとき、レジスタ
の下位側(右側)の部分を使っていたので,演算結果の
フラグ(?フラグ,負フラグ,桁上げフラグ等)を生成
するとき,それぞれのサイズに対応したフラグを全て生
成しておき、その中からサイズに合ったものを選択しな
ければならなかった.そのため、演算回路におけるフラ
グ生成回路が複雑になり、単一サイズの整数型データし
か扱わない場合と比べて回路規模が大きくなっていた. また、H32/200では、データのビット番号の付け
方として、最上位ビットをOとして下位側にいくに従っ
てビット番号が大きくなるように付けているので、レジ
スタのビット番号がサイズによって変ってしまうという
不都合な点があった.つまり,バイトサイズのOビット
目は、ハーフワードのときには8ビット目に対応し、ワ
ードのときには24ビット目に対応している.そのため
、同じ位置を示すのにサイズによって違うビット番号を
指定しなければならず、プログラムから見たとき、特別
の注意が必要になる. そこで,本発明の目的は. (1)データのサイズに依存しない演算フラグの生成方
法、及び、生成回路を提供すること、(2)データのサ
イズに依存しないレジスタのビット番号の指定方法を提
供すること、 である. (課題を解決するための手段〕 上記目的は, (1)レジスタを32ビットより小さい整数型データ.
例えば,バイト,ハーフワードのデータとして使う場合
、32ビット幅のレジスタのうち上位側(左側)の部分
を使うこと、 (2)32ビットより小さい整数型データ、例えば、バ
イト,ハーフワードのデータを演算するとき、データを
左詰にし、右側に0を補って演算すること、 により、達成される. 〔作用〕 レジスタを32ビットより小さいデータ、例えば、バイ
ト,ハーフワードのデータとして使う場合、32ビット
のレジスタのうち上位側(左側)の部分を使うことによ
り、バイトサイズの0ビット目は、ハーフワード,ワー
ドのときにもOビット目に対応する.そのため,サイズ
が違っても同じビット番号なら同じ位置を示すことにな
り、プログラマから見たときの特別な注意は不要になる
.また、32ビットより小さい整数型データ,例えば、
バイト,ハーフワードのデータを演算するとき,データ
を左詰にし、右側にOを補って演算することにより、演
算結果のフラグ(零フラグ,負フラグ,桁上げフラグ等
)を生成するとき、演算フラグはワードサイズのときの
ものを生成すれば、全てのサイズの場合に適用できる。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention mainly relates to a method for generating arithmetic flags in a microprocessor (MPU) and a bit numbering rule in a register. Multiple types of sizes are defined. 1) Concerning the generation method of arithmetic flags suitable for U and the bit numbering rules in registers. [Prior Art] In a microprocessor with a word length of 16 bits or more. In addition to word size, 1 byte (8 bits) is also required as the size of data to be processed. Therefore, even a single instruction has several variations depending on its size. For example, T R O N Th
e Real-Time Operating System
Hitachi's 32-bit microprocessor Gmiero, which complies with the Em Nucleus) specification, has three types of data length for integer data: word (32 bits), halfword (16 bits), and byte (8 bits). Data length is available. For detailed specifications of this Hitachi 32-bit Microprocessor H32
/200 programming manual. In H32/200, 32 bits (4
Byte) When handling integer type data, the smaller address corresponds to the upper part of the data, and the larger address corresponds to the lower part of the data. Furthermore, the bit numbers in the data are assigned such that the most significant bit is 0 and the bit numbers increase as they go to the lower part. on the other hand,
The H32/200 has registers with a width of 32 bits. When this register is used for integer type data 4-bit smaller than 32 bits, for example, byte or halfword integer type data, the lower (right side) part of the 32 bit register is used. [Illllfl to be solved by the invention] As mentioned above, in conventional 32-bit microprocessors, when handling integer type data that is shorter than the register size, the lower side (right side) part of the register is used. When generating flags for the result (? flag, negative flag, carry flag, etc.), it was necessary to generate all flags corresponding to each size and select the one that matched the size from among them. .. As a result, the flag generation circuit in the arithmetic circuit became complicated, and the circuit size became larger than when only handling single-sized integer type data. In addition, in H32/200, the bit numbers of data are assigned such that the most significant bit is O and the bit numbers increase as they go to the lower part, so there is an inconvenience that the bit number of the register changes depending on the size. There was a point. In other words, the Oth bit of the byte size corresponds to the 8th bit when it is a halfword, and corresponds to the 24th bit when it is a word. Therefore, different bit numbers must be specified depending on the size to indicate the same position, which requires special care from the program's perspective. Therefore, the purpose of the present invention is to: (1) To provide a method of generating an operation flag and a generation circuit that does not depend on the size of data. (2) To provide a method of specifying a bit number of a register that does not depend on the size of data. (Means for Solving the Problems) The above objectives are as follows: (1) The registers are integer type data smaller than 32 bits.
For example, when using byte or halfword data, use the upper (left) part of the 32-bit wide register; (2) Integer type data smaller than 32 bits, such as byte or halfword data. This is achieved by aligning the data to the left and padding it with zeros on the right when performing calculations. [Operation] When using a register for data smaller than 32 bits, such as byte or halfword data, by using the upper (left side) part of the 32-bit register, the 0th bit of the byte size can be set as half-word data. It also corresponds to the O-th bit when it is a word. Therefore, even if the sizes are different, the same bit number indicates the same position, and no special precautions are required from the programmer's perspective. In addition, integer type data smaller than 32 bits, for example,
When calculating byte or halfword data, the data is justified to the left and O is added to the right side. If flags are generated for word size, they can be applied to all sizes.

つまり、零フラグは32ビット全体の零、負フラグは0
ビット目の値、桁上げフラグは0ビット目からの桁上げ
を検出すれば,全てのサイズの場合に適用できる.その
結果、それぞれのサイズに対応したフラグを全て生成す
る必要が無くなるので,演算回路におけるフラグ生成回
路が簡単になり,回路規模が小さくなる. 〔実施例〕 以下,本発明の一実施例を図を用いて説明する。
In other words, a zero flag is zero for all 32 bits, and a negative flag is zero.
The bit value and carry flag can be applied to all sizes as long as a carry from the 0th bit is detected. As a result, there is no need to generate all flags corresponding to each size, so the flag generation circuit in the arithmetic circuit becomes simpler and the circuit size becomes smaller. [Example] Hereinafter, an example of the present invention will be described with reference to the drawings.

第1図は本発明の一実施例であるデータ処理装置のレジ
スタについて示した図である.レジスタ1・00は32
ビットのデータ幅を持っている.本実施例のデータ処理
装置では、32ビットのデータ幅をワードサイズと呼び
、半分の16ビットのデータ幅をハーフワードサイズ、
8ビットのデータ幅をバイトサイズと呼ぶ.レジスタ1
00は1ワード分のデータ幅を持っている.レジスタ1
00にハーフワードサイズのデータや、バイトサイズの
データを格納するときには,第1図に示したように、レ
ジスタの上位側(左側)に詰めて格納する・. レジスタ内の各ビットは、ビット番号で1ビットずつア
クセスすることができる.ビット番号は、第1図に示し
てあるように、左端の最上位ビット101を0ビット目
とし,右側の下位ビットにいくに従ってビット番号が大
きくなるように付けられている.そのため、ハーフワー
ドサイズや、バイトサイズのデータを上記の様にレジス
タに格納することにより、ワードサイズのOビット目は
ハーフワードやバイトサイズでアクセスしても、常に,
0ビット目となる. 第2図はメモリ上のデータをアクセスする場合の図であ
る.メモリには1バイト単位にアドレスが付けられてい
る.メモリ上のワードサイズやハーフワードサイズのデ
ータを扱う場合、第2図の様になり、小さいアドレスに
対応するバイトがデータの上位側になる.例えば、$2
0008地のハーフワードサイズのデータをアクセスす
ると,$2000番地の内容がデータの上位側になり、
$2001番地の内容がデータの下位側になる.また.
$2000番地のワードサイズのデータをアクセスする
と、$2000番地から$2003番地までの内容が、
第2図に示す様に、データとして扱われる. 本実施例のデータ処理装置ではビットを操作する命令の
1つとして,BTST命令がある。BTST命令は、処
理するビット番号とそのビットが格納されている場所を
オペランドとして指定する.BTST命令は、指定され
たビットの0または1をテストして演算フラグに反映す
る命令である.次の3種の命令 BTST  #O,($2000).wBTST  $
0.($2000).hBTST   SO,  ($
2000).  bは,メモリの$2000番地から始
まる、それぞれワードサイズ,ハーフワードサイズ,バ
イトサイズのデータの0ビット目をテストする命令であ
る。各命令ともビット番号がOであるので、第2図に示
す様に,各命令とも同一のビット(左端のビット)20
1をテストする命令である。
FIG. 1 is a diagram showing a register of a data processing device that is an embodiment of the present invention. Register 1/00 is 32
It has a data width of bits. In the data processing device of this embodiment, the data width of 32 bits is called word size, and the data width of half 16 bits is called halfword size.
The 8-bit data width is called the byte size. register 1
00 has a data width of 1 word. register 1
When storing halfword size data or byte size data in 00, it is stored in the upper part (left side) of the register as shown in Figure 1. Each bit in the register can be accessed one by one using the bit number. As shown in FIG. 1, the bit numbers are assigned such that the most significant bit 101 on the left is the 0th bit, and the bit numbers increase as they go to the lower bits on the right. Therefore, by storing halfword size or byte size data in the register as described above, even if the Oth bit of word size is accessed in halfword or byte size, it will always be
This is the 0th bit. Figure 2 is a diagram when accessing data in memory. Addresses are assigned to each byte of memory. When dealing with word-sized or half-word-sized data in memory, it becomes as shown in Figure 2, and the byte corresponding to the smaller address becomes the upper part of the data. For example, $2
When accessing halfword size data at address 0008, the contents at address $2000 become the upper part of the data,
The contents of address $2001 become the lower part of the data. Also.
When you access the word size data at address $2000, the contents from address $2000 to $2003 will be
As shown in Figure 2, it is treated as data. In the data processing device of this embodiment, there is a BTST instruction as one of the instructions for manipulating bits. The BTST instruction specifies the bit number to be processed and the location where that bit is stored as operands. The BTST instruction is an instruction that tests 0 or 1 of a specified bit and reflects it in the operation flag. The following three types of instructions BTST #O, ($2000). wBTST $
0. ($2000). hBTST SO, ($
2000). b is an instruction to test the 0th bit of data of word size, halfword size, and byte size, respectively, starting from address $2000 in the memory. Since the bit number for each instruction is O, as shown in Figure 2, the same bit (leftmost bit) 20
This is an instruction to test 1.

一方,次の3種の命令 B ’rS ’rn O , R 1 . wBTST
  $0,R1.h BTST  #0.Rl.b は、1番目のレジスタを,それぞれワードサイズ,ハー
フワードサイズ,バイトサイズのデータとして、0ビッ
ト目をテストする命令である。各命令ともビット番号が
Oであるので、第1図に示す様に、各命令とも同一のビ
ット(左端のビット)101をテストする命令である. 第3図は従来のデータ処理装置のレジスタについて示し
た図である,従来は、レジスタのサイズより短いデータ
をレジスタに格納するとき、レジスタの下位側(右側)
に詰めて格納していた.そのため、上記の様なビット操
作命令を実行すると、データのサイズにより、同じビッ
ト番号が指すビット位置が変ってしまう。例えば、上記
のBTST命令を実行した場合を考えてみると、 BTST  110,Rl.w は、レジスタの最上位ビットであるOビット目301を
対象にしているが、 BTST  #O,Rl.h は,レジスタの16ビット目302を対象にしており、
また、 BTST  #O,Rl.b は,レジスタの24ビット目303を対象にしている. 以上の様に、従来のデータ格納方式によると、レジスタ
に格納されたデータのビット番号がデータのサイズによ
り変化してしまうという問題点があった. 本実施例のデータ格納方式によれば、サイズの短いデー
タをレジスタの左側に詰めているので、ビットテスト命
令の様にビット番号でデータをアクセスする場合、同じ
ビット番号のビット位置がサイズによって変ることがな
い.したがって、プログラムを作成するときに、サイズ
によるビット番号のずれを意識しなくても良いので、プ
ログラムの作成が容易になり、また、エラーの発生を未
然に防止することができる。
On the other hand, the following three types of instructions B 'rS 'rn O, R 1 . wBTST
$0, R1. h BTST #0. Rl. b is an instruction to test the 0th bit of the first register as data of word size, halfword size, and byte size, respectively. Since the bit number of each instruction is O, as shown in FIG. 1, each instruction tests the same bit (leftmost bit) 101. Figure 3 is a diagram showing the registers of a conventional data processing device. Conventionally, when storing data shorter than the register size in a register, the lower side (right side) of the register
It was packed and stored. Therefore, when a bit manipulation instruction like the one described above is executed, the bit position pointed to by the same bit number changes depending on the data size. For example, if we consider the case where the above BTST instruction is executed, BTST 110, Rl. w targets the Oth bit 301, which is the most significant bit of the register, but BTST #O, Rl. h targets the 16th bit 302 of the register,
Also, BTST #O, Rl. b targets the 24th bit 303 of the register. As described above, the conventional data storage method has the problem that the bit number of the data stored in the register changes depending on the size of the data. According to the data storage method of this embodiment, short data is packed on the left side of the register, so when accessing data by bit number like a bit test instruction, the bit position of the same bit number changes depending on the size. Never. Therefore, when creating a program, there is no need to be aware of the bit number deviation due to size, making it easier to create a program and preventing errors from occurring.

第4図は本発明の一実施例であるデータ処理装置の演算
フラグの生成方式について示した図である。本データ処
理装置の演算フラグには、演算時の最上位ビットからの
桁上がりを示す桁上げ(キャリー.C)フラグ,及び、
演算結果の正または負を示す負(ネガティブ、N)フラ
グ、演算結果の零または非零を示す零(ゼロ、Z)フラ
グがある. 第4図(a)はワードサイズの整数型データの加算にお
ける演算フラグの生成方式を示している.Cフラグは0
ビット目からの桁上げ401、Nフラグはビット0の値
402、Zフラグは32ビット全部のオールOを検出(
403)L,て反映する.第4図(b)はハーフワード
サイズの整数型データの加算における演算フラグの生成
方式を示している.演算に先立ち入力データは、図に示
す様に、左詰めにされ、左側の残りの部分には0が補充
されている。この場合、左側のOは演算に関与しないの
で,Cフラグは0ビット目からの桁上げ401.Nフラ
グはビット0の値402、また、2フラグは32ビット
全部のオールOを検出(403)して反映すれば良い. 第4図(c)はバイトサイズの整数型データの加算にお
ける演算フラグの生成方式を示している.第4図(b)
と同様に、演算に先立ち人力データは、図に示す様に、
左詰めにされ、左側の残りの部分にはOが補充されてい
る.この場合も同様に、右側のOは演算に関与しないの
で,CフラグはOビット目からの桁上げ401、Nフラ
グはビットOの値402、また,Zフラグは32ビット
全部のオールOを検出(403)L,て反映すれば良い
.第5図は、データを右詰めにして演算する、従来のデ
ータ処理装置における、演算フラグの生成方式を示した
ものである. 第5図(a)はワードサイズの整数型データの加算にお
ける演算フラグの生成方式を示している.CフラグはO
ビット目からの桁上げ501.NフラグはビットOの値
502.Zフラグは32ビット全部のオールOを検出(
503)L/て反映する.この場合は本発明の実施例と
同じになる.第5図(b)はハーフワードサイズの整数
型データの加算における演算フラグの生成方式を示して
いる.Cフラグはレジスタの16ビット目からの桁上げ
511、Nフラグは16ビット目の値512,また、2
フラグは下位16ビットのオールOを検出(513)L
て反映する必要がある.第5図(a)はバイトサイズの
整数型データの加算における演算フラグの生成方式を示
している.Cフラグは24ビット目からの桁上げ521
、Nフラグは16ビット目の値522、また、2フラグ
は下位8ビットのオール0を検出(523)Lて反映す
る必要がある. 以上の様に、本発明の実施例によれば,演算フラグの生
成回路をデータのサイズ毎に持つ必要が無くなるので,
演算フラグの生成回路を簡略化できる. なお,上記の説明では、演算として加算の場合について
説明したが,減算、或いは、AND/ORの様な論理演
算の場合でも、右側にOを補って演算しても問題無いこ
とは明らかである。
FIG. 4 is a diagram showing a calculation flag generation method of a data processing device according to an embodiment of the present invention. The calculation flags of this data processing device include a carry (carry.C) flag indicating a carry from the most significant bit during calculation, and
There is a negative (N) flag indicating whether the operation result is positive or negative, and a zero (Z) flag indicating the operation result is zero or non-zero. Figure 4(a) shows a method for generating operation flags in addition of word-sized integer type data. C flag is 0
Carry from bit 401, N flag detects bit 0 value 402, Z flag detects all O's in all 32 bits (
403) L, reflect. FIG. 4(b) shows a method for generating calculation flags in addition of halfword-sized integer type data. Prior to the calculation, the input data is left-justified as shown in the figure, and the remaining portion on the left side is filled with 0's. In this case, since O on the left side is not involved in the calculation, the C flag is a carry from the 0th bit, 401. The N flag should be reflected in the value 402 of bit 0, and the 2 flag should be reflected by detecting all O's in all 32 bits (403). Figure 4(c) shows the method for generating calculation flags in addition of byte-sized integer type data. Figure 4(b)
Similarly, prior to calculation, the human data is calculated as shown in the figure.
It is left-justified, and the remaining part on the left side is filled with O's. In this case as well, since the O on the right side is not involved in the calculation, the C flag detects the carry from the O-th bit, 401, the N flag detects the value of bit O, 402, and the Z flag detects all O's in all 32 bits. (403) L, just reflect it. FIG. 5 shows a method for generating calculation flags in a conventional data processing device that performs calculations by right-aligning data. FIG. 5(a) shows a method for generating operation flags in addition of word-sized integer type data. C flag is O
Carry from bit 501. The N flag is the value of bit O, 502. The Z flag detects all O's in all 32 bits (
503) Reflect L/te. This case is the same as the embodiment of the present invention. FIG. 5(b) shows a method for generating operation flags in addition of halfword-sized integer type data. The C flag is the carry value 511 from the 16th bit of the register, and the N flag is the value 512 from the 16th bit, and 2
The flag detects all O's in the lower 16 bits (513) L
It is necessary to reflect this. Figure 5(a) shows a method for generating calculation flags in addition of byte-sized integer type data. The C flag is a carry from the 24th bit, 521.
, the N flag needs to have the 16th bit value 522, and the 2nd flag needs to detect all 0s in the lower 8 bits (523) and reflect it. As described above, according to the embodiment of the present invention, there is no need to have a calculation flag generation circuit for each data size.
The calculation flag generation circuit can be simplified. In addition, in the above explanation, we have explained the case of addition as the operation, but it is clear that there is no problem even in the case of subtraction or logical operations such as AND/OR, by adding O to the right side. .

第6図はレジスタ内の整数型データのサイズ変換につい
て示したものである. 第6図(a)はバイトサイズのデータをワードサイズに
変換する様子を示している.バイトサイズのデータはレ
ジスタに左詰めで格納されているので,ワードサイズに
拡張する場合は、24ビット右にシフトすれば良い.こ
こで、データを符号無しの2進数とみなす場合は左側か
ら0をシフトインすれば良い.また,データを符号付き
の2進数とみなす場合は最上位のビットと同じ値を左側
からシフトインすれば良い. 第6図(b)はハーフワードサイズのデータをワードサ
イズに変換する様子を示している.バイトサイズからワ
ードサイズへの場合と同様に,ハーフワードサイズのデ
ータもレジスタに左詰めで格納されているので、ワード
サイズに拡張する場合は、16ビット右にシフトすれば
良い.第6図(c)はバイトサイズのデータをハーフワ
ードサイズに変換する様子を示している.この場合も同
様に、バイトサイズのデータがレジスタに左詰めで格納
されているので,ハーフワードサイズに拡張する場合は
、8ビット右にシフトすれば良い. 以上述べた様に、データを符号無しの2進数として扱う
場合はOをシフトインし、データを符号付きの2進数と
して扱う場合は符号をシフトインすれば良い.これらの
処理は,マイクロプロセッサの基本的な命令である、論
理右シフト命令と算術右シフトによって容易に実現でき
る.また逆に、長いサイズのデータを短いサイズに変換
する場合は、左にシフトすれば良い.つまり、ワードサ
イズからハーフワードサイズに変換するときは,右側か
ら0をシフトインしながら,16ビット左にシフトすれ
ば良い.同様に、ワードサイズからバイトサイズに変換
するときは、24ビット左にシフトし、ハーフワードサ
イズからバイトサイズに変換するときは、8ビット左に
シフトすれば良い. なお、上記のようにデータのサイズを大きくする場合は
、データの符号付き/符号無に関係なく、左からシフト
インする値は常にOで良い。したがって,この処理も,
マイクロプロセッサの基本的な命令である左シフト命令
によって容易に実現できる. 以上の様に、本発明のデータ処理装置では、データのサ
イズの変換をシフト命令で容易に実現できる.従来のデ
ータ処理装置では、サイズ変換のための専用命令を特別
に設けておく必要があったが,本発明によれば、基本的
なシフト命令を使って容易に実現できるので、特別な命
令を設ける必要がなくなり、命令体系をシンプルにする
ことができる. 第7図は以上に述べてきた本発明の一実施例であるデー
タ処理装置のブロック図である.データ処理装置700
はレジスタRl(711)、R2 (712),R3 
(713).バレルシフタ720、演算器730、デー
タ長補正用マスク回路731,732、メモリデータレ
ジスタ740、メモリデータアライナ741,メモリバ
ス742,及び、データバス751,752,753か
ら成る。
Figure 6 shows the size conversion of integer type data in registers. Figure 6(a) shows how byte-sized data is converted to word-sized data. Byte-sized data is stored left-justified in the register, so if you want to expand it to word-sized data, just shift it 24 bits to the right. Here, if you want to consider the data as an unsigned binary number, just shift in 0 from the left side. Also, if you consider the data to be a signed binary number, just shift in the same value as the most significant bit from the left. Figure 6(b) shows how halfword size data is converted to word size. As with the case from byte size to word size, halfword size data is stored left-justified in the register, so if you want to expand it to word size, just shift it 16 bits to the right. Figure 6(c) shows how byte size data is converted to halfword size. In this case as well, byte-sized data is stored left-justified in the register, so if you want to expand it to half-word size, just shift it 8 bits to the right. As mentioned above, if you want to treat the data as an unsigned binary number, you can shift in O, and if you want to treat the data as a signed binary number, you can shift in the sign. These processes can be easily realized using the basic microprocessor instructions, the logical right shift instruction and the arithmetic right shift instruction. Conversely, if you want to convert long size data to short size data, just shift it to the left. In other words, when converting from word size to halfword size, all you have to do is shift in 0 from the right side and shift 16 bits to the left. Similarly, when converting from word size to byte size, shift to the left by 24 bits, and when converting from halfword size to byte size, shift to the left by 8 bits. Note that when increasing the data size as described above, the value shifted in from the left may always be O, regardless of whether the data is signed or unsigned. Therefore, this process also
This can be easily achieved using the left shift instruction, which is a basic microprocessor instruction. As described above, in the data processing device of the present invention, data size conversion can be easily realized using a shift command. In conventional data processing devices, it was necessary to specially provide a dedicated instruction for size conversion, but according to the present invention, it can be easily realized using basic shift instructions, so it is not necessary to provide a special instruction. There is no need to provide one, and the command system can be simplified. FIG. 7 is a block diagram of a data processing device which is an embodiment of the present invention described above. Data processing device 700
are registers Rl (711), R2 (712), R3
(713). It consists of a barrel shifter 720, an arithmetic unit 730, data length correction mask circuits 731, 732, a memory data register 740, a memory data aligner 741, a memory bus 742, and data buses 751, 752, 753.

レジスタ711,712,713,740、データバス
751,752,753,742,及び、演算器類(7
20,730)のデータ輸は32ビット(4バイト)あ
り、これをワードサイズとよぶ. メモリデータレジスタ740は、メモリとのデータ転送
時にバッファとして使用される.メモリデータアライナ
741は,4バイトの境界にないメモリデータを扱うと
きに、データの位置を調整するために使用される. 演算器730は左詰めにされたデータの加減算,及び、
論理演算を行い、演算結果と演算フラグ760を出力す
る.データ長補正用マスク回路731,732は、ワー
ドサイズより小さいサイズのデータを演算するとき、左
詰めにされたデータ以外の部分に0を挿入するための回
路である.なお、本実施例では上記の様に,データ長補
正用マスク回路731,732を用いてOを挿入してい
るが、(1)演算結果をレジスタに格納するとき,右側
のOも一緒に書き込むこと、(2)短いデータをメモリ
から読み出すとき、アライナ741によって右側に0を
補う様にすることにより、データ長補正用マスク回路7
31,732を省略することもできる. バレルシフタ720はシフト命令に対応する処理を1サ
イクルで実行する回路である。
Registers 711, 712, 713, 740, data buses 751, 752, 753, 742, and arithmetic units (7
20,730) has 32 bits (4 bytes), which is called the word size. Memory data register 740 is used as a buffer during data transfer to and from memory. The memory data aligner 741 is used to adjust the position of data when handling memory data that is not on 4-byte boundaries. The arithmetic unit 730 adds and subtracts left-justified data, and
Performs a logical operation and outputs the operation result and operation flag 760. The data length correction mask circuits 731 and 732 are circuits for inserting 0 into parts other than the left-justified data when calculating data of a size smaller than the word size. Note that in this embodiment, as described above, O is inserted using the data length correction mask circuits 731 and 732, but (1) when storing the calculation result in the register, the O on the right side is also written. (2) When reading short data from the memory, the data length correction mask circuit 7 can be
31,732 can also be omitted. Barrel shifter 720 is a circuit that executes processing corresponding to a shift command in one cycle.

次に本実施例の動作について、例をあげて説明する. レジスタ711に格納されているハーフワードサイズの
符号付き整数データと、レジスタ712に格納されてい
るバイトサイズの符号付き整数データとを加算して、ハ
ーフワードサイズの符号付き整数データとして、レジス
タ713に格納する場合を考える. (1)レジスタ712のバイトサイズの符号付き整数デ
ータをバレルシフタ720を用いて、8ビット分、右に
算術シフトし、その結果を、レジスタ712.に格納す
る. (2)レジスタ711、及び、712の内容をそれぞれ
バス751,752を介して、演算器に730に入力し
て加算する.なおこのとき、入力データは、それぞれデ
ータ長補正用マスク回路731,732によって、32
ビットデータ幅のうち右側16ビットは0にマスクされ
て、演算される. (3)演算器730の演算結果をレジスタ713に格納
する.また同時に、演算結果のOビット目からの桁上が
りを桁上げフラグ、0ビット目の値を負フラグ、32ビ
ット全体のオールOを検出してそれを零フラグとする. 以上の様に本発明の実施例によれば,演算器やレジスタ
のデータ幅より小さいデータを容易に処理することがで
きる. 〔発明の効果〕 以上述べてきたように本発明によれば、レジスタのビッ
ト番号がデータのサイズによって変らないので,メモリ
のビット番号と同様に扱うことができ、プログラム作成
時にビット番号に対する特別な注意が不要になり、プロ
グラムの作成不良が混入する確率を少なくできる効果が
ある.また、演算フラグの生成回路がデータのサイズに
よる影響を受けないので、生成回路の簡略化ができ、回
路規模削減、並びに、動作速度向上の効果がある. また、本発明によれば、データのサイズを更に拡張する
ときにも、ビット番号の付け方が容易に拡張でき、並び
に、演算フラグの生成回路は変更が不要であることから
、データサイズを拡張したデータ.処理装置の移行が容
易に行なえるという効果がある.
Next, the operation of this embodiment will be explained using an example. Halfword size signed integer data stored in register 711 and byte size signed integer data stored in register 712 are added and stored in register 713 as halfword size signed integer data. Consider the case of storing. (1) The byte-sized signed integer data in register 712 is arithmetic shifted to the right by 8 bits using barrel shifter 720, and the result is transferred to register 712. Store it in . (2) The contents of registers 711 and 712 are input to an arithmetic unit 730 via buses 751 and 752, respectively, and added. At this time, the input data is processed by data length correction mask circuits 731 and 732 to 32
The right 16 bits of the bit data width are masked to 0 before calculation is performed. (3) Store the calculation result of the calculation unit 730 in the register 713. At the same time, the carry from the 0th bit of the operation result is set as a carry flag, the value of the 0th bit is set as a negative flag, and all O's of the entire 32 bits are detected and set as a zero flag. As described above, according to the embodiments of the present invention, data smaller than the data width of the arithmetic unit or register can be easily processed. [Effects of the Invention] As described above, according to the present invention, the register bit number does not change depending on the data size, so it can be treated in the same way as a memory bit number, and when creating a program, special This eliminates the need for caution and has the effect of reducing the probability that programming errors will occur. Furthermore, since the calculation flag generation circuit is not affected by the data size, the generation circuit can be simplified, reducing the circuit size and improving operating speed. Further, according to the present invention, even when the data size is further expanded, the bit numbering method can be easily expanded, and the calculation flag generation circuit does not need to be changed, so that the data size can be expanded. data. This has the effect of making it easier to migrate processing equipment.

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

第1図は本発明の一実施例であるデータ処理装置のレジ
スタの図、第2図は同じくメモリの図、第3図は従来の
データ処理装置のレジスタの図,第4図は本発明の一実
施例であるデータ処理装置における演算フラグの生成方
式を示す図、第5図は従来のデータ処理装置における演
算フラグの生成方式を示す図、第6図は本発明の一実施
例であるデータ処理装置におけるデータサイズの変換方
式を示す図,第7図は本発明の一実施例であるデータ処
理装置のブロック図である. 100・・・レジスタ、700・・・データ処理装置、
711,712,713・・・レジスタ、720・・・
バレルシフタ、730・・・演算器.731,732・
・・データ長補正用マスク回路、740・・・メモリデ
ータレジスタ、741・・・メモリデータアライナ,7
42・・・メモリデータバス、751,752,753
・・・データバス. 第 ■ (αつ 第 口 (b) 4o3 32ビ,トう辷イイ(シ11=4今jl二,←一−一一
一一一 ノVイト 第 ハーフワード 口 箒 凹 /DO   レシ゛スタ /o+   ftrイ立ビノト 201   最t仕ビ・7ト 奉 目 (α) 第 占 図 ( しり 第 S 口(C) 第 6 口(α) パイトーワード 第  6  図 (ト〕 ハーフ7−ドー ワード 第 6 口(C) ノVイト ーハーフヮード
FIG. 1 is a diagram of a register of a data processing device which is an embodiment of the present invention, FIG. 2 is a diagram of a memory as well, FIG. 3 is a diagram of a register of a conventional data processing device, and FIG. 4 is a diagram of a register of a data processing device of the present invention. FIG. 5 is a diagram showing a calculation flag generation method in a data processing device that is an embodiment of the present invention. FIG. 6 is a diagram showing a calculation flag generation method in a conventional data processing device. FIG. 7, which is a diagram showing a data size conversion method in a processing device, is a block diagram of a data processing device that is an embodiment of the present invention. 100...Register, 700...Data processing device,
711, 712, 713... register, 720...
Barrel shifter, 730...Arithmetic unit. 731,732・
・・Mask circuit for data length correction, 740 ・・Memory data register, 741 ・・Memory data aligner, 7
42...Memory data bus, 751, 752, 753
...Data bus. No. ■ (α th mouth (b) 4 o 3 32 bis, toyotai ii (shi 11 = 4 now jl 2, ← 1 - 11 11 no V itto 1st half word mouth broom concave / DO register / o + ftr Itachibinoto 201 Saitabi 7th Homoku (α) 1st Horoscope (Siri No. S mouth (C) 6th mouth (α) Paito Ward 6th diagram (G) Half 7-Dou Ward 6th mouth (C ) No Vite - Half-Ward

Claims (1)

【特許請求の範囲】 1、整数型データとして、複数種類のサイズのデータを
処理することができるデータ処理装置において、 該データの第1のサイズは、プロセッサ内のレジスタの
データ幅と同じであり、 該データの第2のサイズは、該第1のサイズの2分の1
、または、4分の1のサイズであり、該レジスタを該第
2のサイズのデータとして使用するときには、該レジス
タの上位側(左側)を使う ことを特徴とするデータ処理装置。 2、請求項1記載のデータ処理装置において、該データ
のビット番号は、最上位ビットを0ビット目とし、以下
、下位側(右側)のビットにいくにしたがつて、順次大
きくなるように、ビット番号を対応付ける ことを特徴とするデータ処理装置。 3、整数型データとして、複数種類のサイズのデータを
処理することができるデータ処理装置において、 該データの第1のサイズは、プロセッサ内の演算器のデ
ータ幅と同じであり、 該データの第2のサイズは、該第1のサイズの2分の1
、または、4分の1のサイズであり、該第2のサイズの
データを演算するとき、該データを左詰めにして、該演
算器の上位側を使つて演算する ことを特徴とするデータ処理装置。 4、請求項3記載のデータ処理装置において、該第2の
サイズのデータを左詰めにして演算するとき、右側の残
りの部分に0を挿入して演算する ことを特徴とするデータ処理装置。 5、請求項3記載のデータ処理装置において、該第2の
サイズのデータを演算するとき、 該演算器の演算結果のうち左端の最上位ビットを、該第
2のサイズのデータ演算の負フラグとする ことを特徴とするデータ処理装置。 6、請求項3記載のデータ処理装置において、該第2の
サイズのデータを演算するとき、 該演算器の演算結果のうち左端の最上位ビットからの桁
上がりを、該第2のサイズのデータ演算の桁上げフラグ
とする ことを特徴とするデータ処理装置。 7、請求項4記載のデータ処理装置において、該第2の
サイズのデータを演算するとき、 該演算器の演算結果の全てのビットの零を検出して、該
第2のサイズのデータ演算の零フラグとする ことを特徴とするデータ処理装置。
[Claims] 1. In a data processing device capable of processing data of multiple types of sizes as integer type data, the first size of the data is the same as the data width of a register in the processor. , the second size of the data is half the first size
, or one-fourth the size, and when the register is used as data of the second size, the upper side (left side) of the register is used. 2. In the data processing device according to claim 1, the bit numbers of the data are set such that the most significant bit is the 0th bit, and the bit numbers increase sequentially as the bits go to the lower (right side) side. A data processing device characterized by associating bit numbers. 3. In a data processing device capable of processing data of multiple sizes as integer type data, the first size of the data is the same as the data width of the arithmetic unit in the processor; The second size is half of the first size.
, or 1/4 the size, and when calculating data of the second size, data processing is characterized in that the data is left-justified and the calculation is performed using the upper side of the calculating unit. Device. 4. The data processing apparatus according to claim 3, wherein when the data of the second size is left-aligned and arithmetic is performed, 0 is inserted into the remaining part on the right side. 5. In the data processing device according to claim 3, when calculating data of the second size, the leftmost most significant bit of the calculation result of the calculation unit is set as a negative flag of the data calculation of the second size. A data processing device characterized by: 6. In the data processing device according to claim 3, when calculating the data of the second size, a carry from the leftmost most significant bit of the calculation result of the calculation unit is used as the data of the second size. A data processing device characterized by using a carry flag for calculation. 7. In the data processing device according to claim 4, when calculating the data of the second size, detecting zeros in all bits of the calculation result of the calculation unit, and calculating the data of the second size. A data processing device characterized in that a zero flag is set.
JP4981989A 1989-03-03 1989-03-03 Data processor Pending JPH02230320A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4981989A JPH02230320A (en) 1989-03-03 1989-03-03 Data processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4981989A JPH02230320A (en) 1989-03-03 1989-03-03 Data processor

Publications (1)

Publication Number Publication Date
JPH02230320A true JPH02230320A (en) 1990-09-12

Family

ID=12841719

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4981989A Pending JPH02230320A (en) 1989-03-03 1989-03-03 Data processor

Country Status (1)

Country Link
JP (1) JPH02230320A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03119420A (en) * 1989-10-03 1991-05-21 Nec Corp Information processor
JP2020526825A (en) * 2017-07-10 2020-08-31 エイアールエム リミテッド Testing bit values in vector elements

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03119420A (en) * 1989-10-03 1991-05-21 Nec Corp Information processor
JP2020526825A (en) * 2017-07-10 2020-08-31 エイアールエム リミテッド Testing bit values in vector elements
US11422807B2 (en) 2017-07-10 2022-08-23 Arm Limited Testing bit values inside vector elements

Similar Documents

Publication Publication Date Title
US4021655A (en) Oversized data detection hardware for data processors which store data at variable length destinations
US5666510A (en) Data processing device having an expandable address space
JPS5862746A (en) Divider
JPH0414385B2 (en)
JPH0546383A (en) Data processor
JP4002151B2 (en) Information processing device
JPH034936B2 (en)
JPH02230320A (en) Data processor
JPS5826584B2 (en) data processing equipment
JP2703884B2 (en) Data write control method
JPH0831033B2 (en) Data processing device
JPH02127726A (en) Information processor
JP3613466B2 (en) Data arithmetic processing apparatus and data arithmetic processing program
US6128636A (en) Method for interfacing floating point and integer processes in a computer system
JP2752220B2 (en) String processing unit
JP3055558B2 (en) n-bit arithmetic unit
KR930003410B1 (en) Data processing apparatus having high-sped reference of stack data
JPH0588887A (en) Data processor
JPS59188900A (en) Data processor
JP3541776B2 (en) Microcomputer
JP2707256B2 (en) Micro computer
JPH04195629A (en) Arithmetic flag generation device
JPH0553759A (en) Fixed decimal point arithmetic unit
JPH03149656A (en) Arithmetic circuit
JP2002522822A (en) Circuit device and method for performing data conversion by processor