OSDN Git Service

6939e91bd030a200121e6fff16273ae5f6454ef1
[csp-qt/common_source_project-fm7.git] / source / src / vm / mame / emu / cpu / i86 / modrm286.h
1 static struct
2 {
3         struct
4         {
5                 WREGS w[256];
6                 BREGS b[256];
7         } reg;
8         struct
9         {
10                 WREGS w[256];
11                 BREGS b[256];
12         } RM;
13 } Mod_RM;
14
15 #define RegWord(ModRM) cpustate->regs.w[Mod_RM.reg.w[ModRM]]
16 #define RegByte(ModRM) cpustate->regs.b[Mod_RM.reg.b[ModRM]]
17
18 #define GetRMWord(ModRM) \
19         ((ModRM) >= 0xc0 ? cpustate->regs.w[Mod_RM.RM.w[ModRM]] : ( (*GetEA[ModRM])(cpustate), i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_WORD, I80286_READ), ReadWord( cpustate->ea ) ))
20
21 #define PutbackRMWord(ModRM,val)                                                                        \
22 {                                                                                                       \
23         if (ModRM >= 0xc0) cpustate->regs.w[Mod_RM.RM.w[ModRM]]=val;                                        \
24         else                                                                                                \
25         {                                                                                                   \
26                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_WORD, I80286_WRITE);   \
27                 WriteWord(cpustate->ea,val);                                                                    \
28         }                                                                                                   \
29 }
30
31 #define GetnextRMWord                                                                                                                   \
32         (                                                                                                                                   \
33         i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->ea + 2 - cpustate->base[cpustate->ea_seg], I80286_WORD, I80286_READ), \
34         ReadWord(cpustate->ea+2)                                                                                                            \
35         )
36
37 #define GetRMWordOffset(offs)                                                                                       \
38                 (                                                                                                           \
39                 i80286_check_permission(cpustate, cpustate->ea_seg, (UINT16)(cpustate->eo+offs), I80286_WORD, I80286_READ), \
40                 ReadWord(cpustate->ea-cpustate->eo+(UINT16)(cpustate->eo+offs))                                             \
41                 )
42
43 #define GetRMByteOffset(offs)                                                                                       \
44                 (                                                                                                           \
45                 i80286_check_permission(cpustate, cpustate->ea_seg, (UINT16)(cpustate->eo+offs), I80286_BYTE, I80286_READ), \
46                 ReadByte(cpustate->ea-cpustate->eo+(UINT16)(cpustate->eo+offs))                                             \
47                 )
48
49 #define PutRMWord(ModRM,val)                                                                            \
50 {                                                                                                       \
51         if (ModRM >= 0xc0)                                                                                  \
52                 cpustate->regs.w[Mod_RM.RM.w[ModRM]]=val;                                                       \
53         else {                                                                                              \
54                 (*GetEA[ModRM])(cpustate);                                                                      \
55                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_WORD, I80286_WRITE);   \
56                 WriteWord( cpustate->ea ,val);                                                                  \
57         }                                                                                                   \
58 }
59
60 #define PutRMWordOffset(offs, val)                                                                                      \
61                 i80286_check_permission(cpustate, cpustate->ea_seg, (UINT16)(cpustate->eo+offs), I80286_WORD, I80286_WRITE);    \
62                 WriteWord( cpustate->ea-cpustate->eo+(UINT16)(cpustate->eo+offs), val)
63
64 #define PutRMByteOffset(offs, val)                                                                                      \
65                 i80286_check_permission(cpustate, cpustate->ea_seg, (UINT16)(cpustate->eo+offs), I80286_BYTE, I80286_WRITE);    \
66                 WriteByte( cpustate->ea-cpustate->eo+(UINT16)(cpustate->eo+offs), val)
67
68 #define PutImmRMWord(ModRM)                                                                             \
69 {                                                                                                       \
70         WORD val;                                                                                           \
71         if (ModRM >= 0xc0)                                                                                  \
72                 FETCHWORD(cpustate->regs.w[Mod_RM.RM.w[ModRM]])                                                 \
73         else {                                                                                              \
74                 (*GetEA[ModRM])(cpustate);                                                                      \
75                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_WORD, I80286_WRITE);   \
76                 FETCHWORD(val)                                                                                  \
77                 WriteWord( cpustate->ea , val);                                                                 \
78         }                                                                                                   \
79 }
80
81 #define GetRMByte(ModRM) \
82         ((ModRM) >= 0xc0 ? cpustate->regs.b[Mod_RM.RM.b[ModRM]] : ( (*GetEA[ModRM])(cpustate), i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_BYTE, I80286_READ), ReadByte( cpustate->ea )) )
83
84 #define PutRMByte(ModRM,val)                                                                            \
85 {                                                                                                       \
86         if (ModRM >= 0xc0)                                                                                  \
87                 cpustate->regs.b[Mod_RM.RM.b[ModRM]]=val;                                                       \
88         else                                                                                                \
89         {                                                                                                   \
90                 (*GetEA[ModRM])(cpustate);                                                                      \
91                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_BYTE, I80286_WRITE);   \
92                 WriteByte( cpustate->ea,val);                                                                   \
93         }                                                                                                   \
94 }
95
96 #define PutImmRMByte(ModRM)                                                                             \
97 {                                                                                                       \
98         if (ModRM >= 0xc0)                                                                                  \
99                 cpustate->regs.b[Mod_RM.RM.b[ModRM]]=FETCH;                                                     \
100         else {                                                                                              \
101                 (*GetEA[ModRM])(cpustate);                                                                      \
102                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_BYTE, I80286_WRITE);   \
103                 WriteByte( cpustate->ea , FETCH );                                                              \
104         }                                                                                                   \
105 }
106
107 #define PutbackRMByte(ModRM,val)                                                                        \
108 {                                                                                                       \
109         if (ModRM >= 0xc0)                                                                                  \
110                 cpustate->regs.b[Mod_RM.RM.b[ModRM]]=val;                                                       \
111         else                                                                                                \
112         {                                                                                                   \
113                 i80286_check_permission(cpustate, cpustate->ea_seg, cpustate->eo, I80286_BYTE, I80286_WRITE);   \
114                 WriteByte(cpustate->ea,val);                                                                    \
115         }                                                                                                   \
116 }
117
118 #define DEF_br8(dst,src)                    \
119         unsigned ModRM = FETCHOP;               \
120         unsigned src = RegByte(ModRM);          \
121         unsigned dst = GetRMByte(ModRM)
122
123 #define DEF_wr16(dst,src)                   \
124         unsigned ModRM = FETCHOP;               \
125         unsigned src = RegWord(ModRM);          \
126         unsigned dst = GetRMWord(ModRM)
127
128 #define DEF_r8b(dst,src)                    \
129         unsigned ModRM = FETCHOP;               \
130         unsigned dst = RegByte(ModRM);          \
131         unsigned src = GetRMByte(ModRM)
132
133 #define DEF_r16w(dst,src)                   \
134         unsigned ModRM = FETCHOP;               \
135         unsigned dst = RegWord(ModRM);          \
136         unsigned src = GetRMWord(ModRM)
137
138 #define DEF_ald8(dst,src)                   \
139         unsigned src = FETCHOP;                 \
140         unsigned dst = cpustate->regs.b[AL]
141
142 #define DEF_axd16(dst,src)                  \
143         unsigned src = FETCHOP;                 \
144         unsigned dst = cpustate->regs.w[AX];    \
145         src += (FETCH << 8)