第 3 章 ソフトウェア環境
3.1 レジスタ
AMD-K6
プロセッサは、汎用、セグメント、浮動小数点、MMX
、EFLAGS
、制御、タ スク、デバッグ、テスト、およびディスクリプタ/メモリ管理レジスタなど、x86
アーキテクチャで定義されているレジスタをすべて実装している。本章ではさ らに、AMD-K6
のモデル固有レジスタ(MSR
)についても記述する。注:予約の指定があるレジスタ領域は、ソフトウェアで変更してはならない。
汎用レジスタ
x86
に対応する8
個の32
ビット汎用レジスタを使って、命令で使用する整数デー タまたはメモリ・ポインタを保管する。表2
に、それらの汎用レジスタ名とその機 能を示す。表
2.
汎用レジスタFunction EAX Commonly used as an accumulator EBX Commonly used as a pointer
ECX Commonly used for counting in loop operations
EDX Commonly used to hold I/O information and to pass parameters Register
ECX
およびEDX
にも適用される。EDI
、ESI
、ESP
およびEBP
はそれぞれ、DI
、SI
、SP
およびBP
と呼ばれる小容量の16
ビット・レジスタとしても使用できるが、これらのレジスタには
8
ビット対応はない。図6
に、EAX
レジスタにおけるネーム 構成を、また表3
に、ダブルワード(32
ビット)の汎用レジスタ名と、それぞれに該 当するワード(16
ビット)・ネームおよびバイト(8
ビット)・ネームを示す。8 7 0
15 16 31
EAX
AX
AH AL
図
6.
EAX
レジスタにおける16
ビットおよび8
ビット・ネームの構成表
3.
ダブルワードの汎用レジスタ名と、該当するワードおよびバイトの ネーミング32-Bit Name (Dword)
16-Bit Name (Word)
8-Bit Name (High-order Bits)
8-Bit Name (Low-order Bits)
EAX AX AH AL
EBX BX BH BL
ECX CX CH CL
EDX DX DH DL
EDI DI – –
ESI SI – –
ESP SP – –
EBP BP – –
整数データのタイプ
汎用レジスタでは、バイト、ワード、ダブルワードおよびクワッドワードという
4
種 類の整数データを使用する。図7
に、整数データ・レジスタの形式を示す。15 0
31 0
Precision — 32 Bits
Precision — 16 Bits Word Integer
Doubleword Integer
7 0
Precision — 8 Bits Byte Integer
63 0
Precision — 64 Bits Quadword Integer
図
7.
整数データ・タイプセグメント・レジスタ
6
個の16
ビット・セグメント・レジスタを、メモリ領域(セグメント)のポインタとし て使用する。表4
に、それらのセグメント・レジスタ名とそれぞれの機能を示す。図
8
に、セグメント・レジスタ全6
個の形式を示す。表
4.
セグメント・レジスタCS Code segment, where instructions are located DS Data segment, where data is located ES Data segment, where data is located FS Data segment, where data is located GS Data segment, where data is located SS Stack segment
Segment
Register Segment Register Function
0 15
図
8.
セグメント・レジスタ セグメントの使用法OS
によって、実装されているメモリ・モデルのタイプを識別する。セグメント・レ ジスタの使用法はOS
のメモリ・モデルにより決定される。リアル・モードのメモ リ・モデルでは、セグメント・レジスタはメモリ内のベース・アドレスをポイントす る。プロテクト・モードのメモリ・モデルでは、セグメント・レジスタはセレクタと 呼ばれ、ディスクリプタ・テーブル内のセグメント・ディスクリプタを選定する。こ のディスクリプタにはセグメント・ベース、セグメント限界および各種保護属性を 指し示すポインタが含まれている。なお、ディスクリプタ形式の詳細についてはSegment Register
Real Mode Memory Model
Segment Selector
Physical Memory
Protected Mode Memory Model Base
Descriptor Table
Physical Memory
Segment Base
Base
Limit Base Limit
Segment Base
図
9.
セグメントの使用法 命令ポインタ命令ポインタ(
EIP
またはIP
)は、コード・セグメント・レジスタ(CS
)と併用され る。命令ポインタは32
ビット・レジスタ(EIP
)か、または16
ビット・レジスタ(IP
) のいずれかであり、双方とも、次の命令が常駐しているメモリ内の場所を保持 している。このレジスタは直接操作することはできないが、JMP
命令または8
個の浮動小数点レジスタは、80
ビット幅で、FPR0
からFPR7
のラベルが付けら れている。図10
に、これら浮動小数点レジスタの形式を示す。使用可能な浮動 小数点のデータ・タイプについては、「浮動小数点のデータ・タイプ」の項を参 照。64 63 0
78 79
Sign Exponent Significand
図
10.
浮動小数点レジスタ16
ビットのFPU
ステータス・ワード・レジスタは、浮動小数点実行ユニットのス テータス情報を保管している。図11
に、このレジスタの形式を示す。15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 P E
O E E
S C 0 C 1
I E Z E U E S TOSP F
C 3
B C
2
D E
Symbol Description Bits
B FPU Busy 15
C3 Condition Code 14
TOSP Top of Stack Pointer 13–11
C2 Condition Code 10
C1 Condition Code 9
C0 Condition Code 8
ES Error Summary Status 7
SF Stack Fault 6
Exception Flags
PE Precision Error 5
UE Underflow Error 4
OE Overflow Error 3
ZE Zero Divide Error 2
DE Denormalized Operation Error 1 IE Invalid Operation Error 0
TOSP Information 000 = FPR0 111 = FPR7
FPU
コントロール・ワード・レジスタを使用すれば、設計者はFPU
処理オプション の管理が可能になる。図12
に、このレジスタの形式を示す。P M
O M P
C R C
I M Z M U
M D
M
Rounding Control Information 00b = Round to the nearest or even number 01b = Round down toward negative infinity 10b = Round up toward positive infinity 11b = Truncate toward zero
Reserved
Y
Precision Control Information 00b = 24 bits Single Precision Real 01b = Reserved
10b = 53 bits Double Precision Real 11b = 64 bits Extended Precision Real 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Symbol Description Bits
Y Infinity Bit (80287 compatibility) 12
RC Rounding Control 11–10
PC Precision Control 9–8
Exception Masks
PM Precision 5
UM Underflow 4
OM Overflow 3
ZM Zero Divide 2
DM Denormalized Operation 1
IM Invalid Operation 0
図
12.
FPU
コントロール・ワード・レジスタFPU
タグ・ワード・レジスタは、レジスタ・スタック内のレジスタに関する情報を 保管している。図13
に、このレジスタの形式を示す。9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15
TAG (FPR7)
TAG (FPR6)
TAG (FPR5)
TAG (FPR4)
TAG (FPR3)
TAG (FPR2)
TAG (FPR1)
TAG (FPR0)
浮動小数点レジスタのデータ・タイプ
浮動小数点レジスタは、パック
10
進数、単精度実数、倍精度実数、および拡張精 度実数の4
通りのデータ・タイプを使用する。図14
および図15
に、これらのレジ スタの形式を示す。0 79
Precision — 18 Digits, 72 Bits Used, 4-Bits/Digit 71
SIgnore or Zero
Description Bits
Ignored on Load, Zeros on Store 78-72 Sign Bit 79 78 72
図
14.
パック10
進数データ・レジスタ0 63
31 0
0 79
22
S Biased
Exponent 78
23
S Biased Exponent
63 64
51 52 Biased Exponent S
Significand
Significand
Significand 30
62
S = Sign Bit
S = Sign Bit
S = Sign Bit
I 62
I = Integer Bit 単精度実数
拡張精度実数 倍精度実数
図
15.
精度実数データ・レジスタMMX
®レジスタAMD-K6
プロセッサは、マルチメディア・ソフトウェア用として、8
個の64
ビットMMX
レジスタと3
つのデータ・タイプを搭載している。レジスタは浮動小数点レ ジスタにマッピングされる。MMX
命令ではmmreg 0
からmmreg 7
までがMMX
レジスタとなっている。図16
、図17
に、MMX
レジスタの形式とデータ・タイプを 示す。詳細についてはA M D - K 6 P r o c e s s o r R e f e r e n c e M a n u a l
(
Order#20726
)を参照。63 0
mmreg0
mmreg7 mmreg1
mmreg6 mmreg5 mmreg2 mmreg3 mmreg4
図
16.
MMX
®レジスタ63 0 Packed Bytes
63 0
Packed Words
63 0
Packed Doublewords
32 31
48 47 32 31 16 15
56 55 48 47 40 39 32 31 24 23 16 15 8 7
図
17.
MMX
®データ・タイプEFLAGS
レジスタEFLAGS
レジスタは、システム、制御、およびステータスの3
種類のフラグ・タイ プを備えている。システム・フラグはOS
制御を、制御フラグはストリング演算の 方向情報を、またステータス・フラグは論理・算術演算の結果情報をそれぞれ提 供する。図18
に、このレジスタの形式を示す。9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21
I O P L 31 30 29 28 27 26 25 24 23 22
A F
P F Z
F S F I F D F
T F O F N T R F V M A C V I F V I P I D
C F
Reserved
Symbol Description Bits
ID ID Flag 21
VIP Virtual Interrupt Pending 20 VIF Virtual Interrupt Flag 19 AC Alignment Check 18 VM Virtual-8086 Mode 17
RF Resume Flag 16
NT Nested Task 14
IOPL I/O Privilege Level 13–12
OF Overflow Flag 11
DF Direction Flag 10
IF Interrupt Flag 9
TF Trap Flag 8
SF Sign Flag 7
ZF Zero Flag 6
AF Auxiliary Flag 4
PF Parity Flag 2
CF Carry Flag 0
図
18.
EFLAGS
レジスタ制御レジスタ
5
個の制御レジスタは、システム制御ビットおよびポインタを保管している。図19
から図23
に、これらのレジスタの形式を示す。7 6 5 4 3 2 1 0 31
P S E
T S D M
C E
V M E D E
P V I
Reserved
Symbol Description Bit
MCE Machine Check Enable 6 PSE Page Size Extensions 4 DE Debugging Extensions 3 TSD Time Stamp Disable 2 PVI Protected Virtual Interrup 1 VME Virtual-8086 Mode Extension 0
図
19.
制御レジスタ4
(CR4
)P C D
Reserved
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Page Directory Base
Symbol Description Bit
PCD Page Cache Disable 4 PWT Page Write Through 3
P W T
図
20.
制御レジスタ3
(CR3
)0 31
Page Fault Linear Address
図
21.
制御レジスタ2
(CR2
)0 31
Reserved
図
22.
制御レジスタ1
(CR1
)E T
T S
Reserved
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
A M
E M W
P
M P
P E N
E P
G C D
N W
Symbol Description Bit
PG Paging 31
CD Cache Disable 30 NW Not Writethrough 29
Symbol Description Bit AM Alignment Mask 18 WP Write Protect 16 NE Numeric Error 5 ET Extension Typ 4 TS Task Switched 3
EM Emulation 2
MP Monitor Co-processor 1 PE Protection Enable 0
図
23.
制御レジスタ0
(CR0
)デバッグ・レジスタ
図
24
から図27
に、K6
プロセッサがサポートしている32
ビットのデバッグ・レジス タを示す。Symbol Description Bit
GD General Detect Enable 13
GE Global Exact Breakpoint Enabled 9 LE Local Exact Breakpoint Enabled 8 G3 Global Exact Breakpoint # 3 Enabled 7 L3 Local Exact Breakpoint # 3 Enabled 6 G2 Global Exact Breakpoint # 2 Enabled 5 L2 Local Exact Breakpoint # 2 Enabled 4 G1 Global Exact Breakpoint # 1 Enabled 3 L1 Local Exact Breakpoint # 1 Enabled 2 G0 Global Exact Breakpoint # 0 Enabled 1 L0 Local Exact Breakpoint # 0 Enabled 0
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15
L 2
L 1 L
3 G 3 G E
L E
L 0
Reserved
G 0 G 1 L 2 G
D 25 24 23 22 21 20 19 18 17 16 26
27 28 29 30 31
R/W 3 LEN
3 R/W
2 LEN
2 R/W
1 LEN
1 R/W
0 LEN
0
Symbol Description Bits
LEN 3 Length of Breakpoint #3 31–30 R/W 3 Type of Transaction(s) to Trap 29–28 LEN 2 Length of Breakpoint #2 27–26 R/W 2 Type of Transaction(s) to Trap 25–24 LEN 1 Length of Breakpoint #1 23–22 R/W 1 Type of Transaction(s) to Trap 21–20 LEN 0 Length of Breakpoint #0 19–18 R/W 0 Type of Transaction(s) to Trap 17–16
図
24.
デバッグ・レジスタDR7
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
B 1 B 2 B
S B
0
Reserved
B T
B D
Symbol Description Bit
BT Breakpoint Task Switch 15 BS Breakpoint Single Step 14 BD Breakpoint Debug Access Detected 13 B3 Breakpoint #3 Condition Detected 3 B2 Breakpoint #2 Condition Detected 2 B1 Breakpoint #1 Condition Detected 1 B0 Breakpoint #0 Condition Detected 0
B 3
図
25.
デバッグ・レジスタDR6
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Reserved
DR5
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Reserved
DR4
図
26.
デバッグ・レジスタDR5
およびDR4
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Breakpoint 3 32-bit Linear Address
DR3
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Breakpoint 0 32-bit Linear Address
DR0
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Breakpoint 2 32-bit Linear Address
DR2
9 8 7 6 5 4 3 2 1 0 10
11 12 13 14 15 16 17 18 19 20 21 31 30 29 28 27 26 25 24 23 22
Breakpoint 1 32-bit Linear Address
DR1
図
27.
デバッグ・レジスタDR3
、DR2
、DR1
およびDR0
モデル固有レジスタ(
MSR
)AMD-K6
プロセッサは7
個のMSR
を装備している。ECX
レジスタの値により、RDMSR
およびWRMSR
命令でアドレスするMSR
を指定する。EAX
およびEDX
の値は、RDMSR
およびWRMSE
命令により、入出力用として使用される。表5
に、MSR
および対応するECX
レジスタの値を示す。また図28
から図32
に、MSR
の形式を示す。表
5.
モデル固有レジスタ(MSR
)Model-Specific Register Value of ECX Machine Check Address Register (MCAR) 00h Machine Check Type Register (MCTR) 01h
Test Register 12 (TR12) 0Eh
Time Stamp Counter (TSC) 10h
Write Handling Control Register (WHCR) C000_0082h
RDMSR
およびWRMSR
命令の詳細については、AMD-K86
®Family BIOS and Software Tools Development Guide
(Order#21062
)を参照。MCAR
およびMCTR
AMD-K6
プロセッサはマシンチェック例外生成をサポートしていないものの、64
ビットのマシンチェック・アドレス・レジスタ(MCAR
)と、64
ビットのマシン チェック・タイプ・レジスタ(MCTR
)、およびCR4
内マシンチェック・イネーブル(
MCE
)ビットをサポートしている。プロセッサがマシンチェック例外生成をサ ポートしていないため、M C A R
およびM C T R
の内容で影響を受けるのは、WRMSR
命令およびアサートされた状態でサンプリングされる(各レジスタの 全ビットが0
にリセットされる)RESET
命令の場合に限られる。5 4 0 63
Reserved
MCTR
図
29.
マシンチェック・タイプ・レジスタ(MCTR
) テスト・レジスタ12
(TR12
)テスト・レジスタ
12
は、L1
キャッシュをディセーブルする方法を提供する。図30
にTR12
の形式を示す。Reserved
4 3 2 1 0 63
C I
Symbol Description Bit CI Cache Inhibit Bit 3
図
30.
テスト・レジスタ12
(TR12
) タイムスタンプ・カウンタ各プロセッサのクロック・サイクル毎に、プロセッサは
64
ビットのタイム・スタン プ・カウンタ(TSC
)MSR
を+1
する。図31
にTSC
の形式を示す。0 63
TSC
図
31.
タイムスタンプ・カウンタ(TSC
)ライト・ハンドリング制御レジスタ(
WHCR
)ライト・ハンドリング制御レジスタ(
WHCR
)は、WCDE
ビット、ライト・アロケー ト・イネーブル・リミット(WAELIM
)フィールドと、ライト・アロケート・イネーブル15-to-16M
バイト(WAE15M
)ビットの、3
つのフィールドを格納するMSR
であ る。図32
にWHCR
の形式を示す。詳細は「ライト・アロケート」の項を参照。7 1 0 63
Reserved
WAELIM 8
0
Note: Hardware RESET initializes this MSR to all zeros.
W A E 1 5 M
Symbol Description Bits
WCDE Always program to 0 8
WAELIM Write Allocate Enable Limit 7–1 WAE15M Write Allocate Enable 15-to-16-Mbyte 0
9
図
32.
ライト・ハンドリング制御レジスタ(WHCR
) メモリ管理レジスタAMD-K6
プロセッサは、表6
に示すレジスタを使用して、セグメント化されたメモ リ管理レジスタを制御する。図33
に、これらのレジスタの形式を示す。表
6.
メモリ管理レジスタRegister Name Function
Global Descriptor Table Register Contains a pointer to the base of the Global Descriptor Table Interrupt Descriptor Table Register Contains a pointer to the base of the Interrupt Descriptor Table