source: Daodan/src/beaengine/Includes/instr_set/opcodes_prefixes.c@ 1192

Last change on this file since 1192 was 984, checked in by alloc, 11 years ago

Daodan: TV code

File size: 8.8 KB
RevLine 
[984]1/* Copyright 2006-2009, BeatriX
2 * File coded by BeatriX
3 *
4 * This file is part of BeaEngine.
5 *
6 * BeaEngine is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * BeaEngine is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with BeaEngine. If not, see <http://www.gnu.org/licenses/>. */
18
19/* ====================================================================
20 * Legacy Prefix F0h-Group 1
21 * ==================================================================== */
22void __bea_callspec__ PrefLock(PDISASM pMyDisasm)
23{
24 if (!Security(0, pMyDisasm)) return;
25 (*pMyDisasm).Prefix.LockPrefix = InvalidPrefix;
26 GV.EIP_++;
27 (*pMyDisasm).Prefix.Number++;
28 GV.NB_PREFIX++;
29 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
30 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
31 GV.OperandSize = 32;
32}
33
34/* ====================================================================
35 * Legacy Prefix F2h-Group 1
36 * ==================================================================== */
37void __bea_callspec__ PrefREPNE(PDISASM pMyDisasm)
38{
39 if (!Security(0, pMyDisasm)) return;
40 (*pMyDisasm).Prefix.RepnePrefix = SuperfluousPrefix;
41 GV.EIP_++;
42 (*pMyDisasm).Prefix.Number++;
43 GV.NB_PREFIX++;
44 GV.PrefRepne = 1;
45 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
46 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
47 GV.PrefRepne = 0;
48}
49
50/* ====================================================================
51 * Legacy Prefix F3h-Group 1
52 * ==================================================================== */
53void __bea_callspec__ PrefREPE(PDISASM pMyDisasm)
54{
55 if (!Security(0, pMyDisasm)) return;
56 (*pMyDisasm).Prefix.RepPrefix = SuperfluousPrefix;
57 GV.EIP_++;
58 (*pMyDisasm).Prefix.Number++;
59 GV.NB_PREFIX++;
60 GV.PrefRepe = 1;
61 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
62 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
63 GV.PrefRepe = 0;
64}
65
66/* ====================================================================
67 * Legacy Prefix 2Eh-Group 2
68 * ==================================================================== */
69void __bea_callspec__ PrefSEGCS(PDISASM pMyDisasm)
70{
71 if (!Security(0, pMyDisasm)) return;
72 (*pMyDisasm).Prefix.CSPrefix = InUsePrefix;
73 GV.EIP_++;
74 (*pMyDisasm).Prefix.Number++;
75 GV.NB_PREFIX++;
76 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
77 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
78}
79
80/* ====================================================================
81 * Legacy Prefix 3Eh-Group 2
82 * ==================================================================== */
83void __bea_callspec__ PrefSEGDS(PDISASM pMyDisasm)
84{
85 if (!Security(0, pMyDisasm)) return;
86 (*pMyDisasm).Prefix.DSPrefix = InUsePrefix;
87 GV.EIP_++;
88 (*pMyDisasm).Prefix.Number++;
89 GV.NB_PREFIX++;
90 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
91 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
92}
93
94/* ====================================================================
95 * Legacy Prefix 26h-Group 2
96 * ==================================================================== */
97void __bea_callspec__ PrefSEGES(PDISASM pMyDisasm)
98{
99 if (!Security(0, pMyDisasm)) return;
100 (*pMyDisasm).Prefix.ESPrefix = InUsePrefix;
101 GV.EIP_++;
102 (*pMyDisasm).Prefix.Number++;
103 GV.NB_PREFIX++;
104 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
105 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
106}
107
108/* ====================================================================
109 * Legacy Prefix 64h-Group 2
110 * ==================================================================== */
111void __bea_callspec__ PrefSEGFS(PDISASM pMyDisasm)
112{
113 if (!Security(0, pMyDisasm)) return;
114 (*pMyDisasm).Prefix.FSPrefix = InUsePrefix;
115 GV.EIP_++;
116 (*pMyDisasm).Prefix.Number++;
117 GV.NB_PREFIX++;
118 GV.SEGMENTFS = 1;
119 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
120 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
121}
122
123/* ====================================================================
124 * Legacy Prefix 65h-Group 2
125 * ==================================================================== */
126void __bea_callspec__ PrefSEGGS(PDISASM pMyDisasm)
127{
128 if (!Security(0, pMyDisasm)) return;
129 (*pMyDisasm).Prefix.GSPrefix = InUsePrefix;
130 GV.EIP_++;
131 (*pMyDisasm).Prefix.Number++;
132 GV.NB_PREFIX++;
133 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
134 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
135}
136
137
138/* ====================================================================
139 * Legacy Prefix 36h-Group 2
140 * ==================================================================== */
141void __bea_callspec__ PrefSEGSS(PDISASM pMyDisasm)
142{
143 if (!Security(0, pMyDisasm)) return;
144 (*pMyDisasm).Prefix.SSPrefix = InUsePrefix;
145 GV.EIP_++;
146 (*pMyDisasm).Prefix.Number++;
147 GV.NB_PREFIX++;
148 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
149 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
150}
151
152/* ====================================================================
153 * Legacy Prefix 66h-Group 3
154 * ==================================================================== */
155void __bea_callspec__ PrefOpSize(PDISASM pMyDisasm)
156{
157 if (!Security(0, pMyDisasm)) return;
158 (*pMyDisasm).Prefix.OperandSize = InUsePrefix;
159 GV.EIP_++;
160 (*pMyDisasm).Prefix.Number++;
161 GV.NB_PREFIX++;
162 GV.OriginalOperandSize = GV.OperandSize; /* if GV.OperandSize is used as a mandatory prefix, keep the real operandsize value */
163 if (GV.Architecture == 16) {
164 GV.OperandSize = 32;
165 }
166 else {
167 if (GV.OperandSize != 64) {
168 GV.OperandSize = 16;
169 }
170 }
171 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
172 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
173 if (GV.Architecture == 16) {
174 GV.OperandSize = 16;
175 }
176 else {
177 GV.OperandSize = 32;
178 }
179}
180
181/* ====================================================================
182 * Legacy Prefix 67h-Group 4
183 * ==================================================================== */
184void __bea_callspec__ PrefAdSize(PDISASM pMyDisasm)
185{
186 if (!Security(0, pMyDisasm)) return;
187 (*pMyDisasm).Prefix.AddressSize = InUsePrefix;
188 GV.EIP_++;
189 (*pMyDisasm).Prefix.Number++;
190 GV.NB_PREFIX++;
191 if (GV.Architecture == 16) {
192 GV.AddressSize = GV.AddressSize << 1;
193 }
194 else {
195 GV.AddressSize = GV.AddressSize >> 1;
196 }
197
198 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_);
199 (void) opcode_map1[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
200 if (GV.Architecture == 16) {
201 GV.AddressSize = GV.AddressSize >> 1;
202 }
203 else {
204 GV.AddressSize = GV.AddressSize << 1;
205 }
206
207}
208
209/* ====================================================================
210 * Escape Prefix 0Fh-two bytes opcodes
211 * ==================================================================== */
212void __bea_callspec__ Esc_2byte(PDISASM pMyDisasm)
213{
214 if (!Security(0, pMyDisasm)) return;
215 GV.EIP_++;
216 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_)+0x0F00;
217 (void) opcode_map2[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
218}
219
220/* ====================================================================
221 * Escape Prefix 0F38h-three bytes opcodes
222 * ==================================================================== */
223void __bea_callspec__ Esc_tableA4(PDISASM pMyDisasm)
224{
225 if (!Security(0, pMyDisasm)) return;
226 GV.EIP_++;
227 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_)+0x0F3800;
228 (void) opcode_map3[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
229}
230/* ====================================================================
231 * Escape Prefix 0F3Ah-three bytes opcodes
232 * ==================================================================== */
233void __bea_callspec__ Esc_tableA5(PDISASM pMyDisasm)
234{
235 if (!Security(0, pMyDisasm)) return;
236 GV.EIP_++;
237 (*pMyDisasm).Instruction.Opcode = *((UInt8*) (UIntPtr)GV.EIP_)+0x0F3A00;
238 (void) opcode_map4[*((UInt8*) (UIntPtr)GV.EIP_)](pMyDisasm);
239}
Note: See TracBrowser for help on using the repository browser.