PCem
view src/x86_ops_string.h @ 142:bd46c39a78e8
Implemented selector limits on some instructions - fixes LBA2.
GPFs in real mode now work.
Selectors correctly zeroed on far return to lower privilege.
| author | TomW |
|---|---|
| date | Wed Aug 13 20:33:56 2014 +0100 |
| parents | 9c201151bb4b |
| children |
line source
1 static int opMOVSB_a16(uint32_t fetchdat)
2 {
3 uint8_t temp = readmemb(ea_seg->base, SI); if (abrt) return 0;
4 writememb(es, DI, temp); if (abrt) return 0;
5 if (flags & D_FLAG) { DI--; SI--; }
6 else { DI++; SI++; }
7 cycles -= 7;
8 return 0;
9 }
10 static int opMOVSB_a32(uint32_t fetchdat)
11 {
12 uint8_t temp = readmemb(ea_seg->base, ESI); if (abrt) return 0;
13 writememb(es, EDI, temp); if (abrt) return 0;
14 if (flags & D_FLAG) { EDI--; ESI--; }
15 else { EDI++; ESI++; }
16 cycles -= 7;
17 return 0;
18 }
20 static int opMOVSW_a16(uint32_t fetchdat)
21 {
22 uint16_t temp = readmemw(ea_seg->base, SI); if (abrt) return 0;
23 writememw(es, DI, temp); if (abrt) return 0;
24 if (flags & D_FLAG) { DI -= 2; SI -= 2; }
25 else { DI += 2; SI += 2; }
26 cycles -= 7;
27 return 0;
28 }
29 static int opMOVSW_a32(uint32_t fetchdat)
30 {
31 uint16_t temp = readmemw(ea_seg->base, ESI); if (abrt) return 0;
32 writememw(es, EDI, temp); if (abrt) return 0;
33 if (flags & D_FLAG) { EDI -= 2; ESI -= 2; }
34 else { EDI += 2; ESI += 2; }
35 cycles -= 7;
36 return 0;
37 }
39 static int opMOVSL_a16(uint32_t fetchdat)
40 {
41 uint32_t temp = readmeml(ea_seg->base, SI); if (abrt) return 0;
42 writememl(es, DI, temp); if (abrt) return 0;
43 if (flags & D_FLAG) { DI -= 4; SI -= 4; }
44 else { DI += 4; SI += 4; }
45 cycles -= 7;
46 return 0;
47 }
48 static int opMOVSL_a32(uint32_t fetchdat)
49 {
50 uint32_t temp = readmeml(ea_seg->base, ESI); if (abrt) return 0;
51 writememl(es, EDI, temp); if (abrt) return 0;
52 if (flags & D_FLAG) { EDI -= 4; ESI -= 4; }
53 else { EDI += 4; ESI += 4; }
54 cycles -= 7;
55 return 0;
56 }
59 static int opCMPSB_a16(uint32_t fetchdat)
60 {
61 uint8_t src = readmemb(ea_seg->base, SI);
62 uint8_t dst = readmemb(es, DI); if (abrt) return 0;
63 setsub8(src, dst);
64 if (flags & D_FLAG) { DI--; SI--; }
65 else { DI++; SI++; }
66 cycles -= (is486) ? 8 : 10;
67 return 0;
68 }
69 static int opCMPSB_a32(uint32_t fetchdat)
70 {
71 uint8_t src = readmemb(ea_seg->base, ESI);
72 uint8_t dst = readmemb(es, EDI); if (abrt) return 0;
73 setsub8(src, dst);
74 if (flags & D_FLAG) { EDI--; ESI--; }
75 else { EDI++; ESI++; }
76 cycles -= (is486) ? 8 : 10;
77 return 0;
78 }
80 static int opCMPSW_a16(uint32_t fetchdat)
81 {
82 uint16_t src = readmemw(ea_seg->base, SI);
83 uint16_t dst = readmemw(es, DI); if (abrt) return 0;
84 setsub16(src, dst);
85 if (flags & D_FLAG) { DI -= 2; SI -= 2; }
86 else { DI += 2; SI += 2; }
87 cycles -= (is486) ? 8 : 10;
88 return 0;
89 }
90 static int opCMPSW_a32(uint32_t fetchdat)
91 {
92 uint16_t src = readmemw(ea_seg->base, ESI);
93 uint16_t dst = readmemw(es, EDI); if (abrt) return 0;
94 setsub16(src, dst);
95 if (flags & D_FLAG) { EDI -= 2; ESI -= 2; }
96 else { EDI += 2; ESI += 2; }
97 cycles -= (is486) ? 8 : 10;
98 return 0;
99 }
101 static int opCMPSL_a16(uint32_t fetchdat)
102 {
103 uint32_t src = readmeml(ea_seg->base, SI);
104 uint32_t dst = readmeml(es, DI); if (abrt) return 0;
105 setsub32(src, dst);
106 if (flags & D_FLAG) { DI -= 4; SI -= 4; }
107 else { DI += 4; SI += 4; }
108 cycles -= (is486) ? 8 : 10;
109 return 0;
110 }
111 static int opCMPSL_a32(uint32_t fetchdat)
112 {
113 uint32_t src = readmeml(ea_seg->base, ESI);
114 uint32_t dst = readmeml(es, EDI); if (abrt) return 0;
115 setsub32(src, dst);
116 if (flags & D_FLAG) { EDI -= 4; ESI -= 4; }
117 else { EDI += 4; ESI += 4; }
118 cycles -= (is486) ? 8 : 10;
119 return 0;
120 }
122 static int opSTOSB_a16(uint32_t fetchdat)
123 {
124 writememb(es, DI, AL); if (abrt) return 0;
125 if (flags & D_FLAG) DI--;
126 else DI++;
127 cycles -= 4;
128 return 0;
129 }
130 static int opSTOSB_a32(uint32_t fetchdat)
131 {
132 writememb(es, EDI, AL); if (abrt) return 0;
133 if (flags & D_FLAG) EDI--;
134 else EDI++;
135 cycles -= 4;
136 return 0;
137 }
139 static int opSTOSW_a16(uint32_t fetchdat)
140 {
141 writememw(es, DI, AX); if (abrt) return 0;
142 if (flags & D_FLAG) DI -= 2;
143 else DI += 2;
144 cycles -= 4;
145 return 0;
146 }
147 static int opSTOSW_a32(uint32_t fetchdat)
148 {
149 writememw(es, EDI, AX); if (abrt) return 0;
150 if (flags & D_FLAG) EDI -= 2;
151 else EDI += 2;
152 cycles -= 4;
153 return 0;
154 }
156 static int opSTOSL_a16(uint32_t fetchdat)
157 {
158 writememl(es, DI, EAX); if (abrt) return 0;
159 if (flags & D_FLAG) DI -= 4;
160 else DI += 4;
161 cycles -= 4;
162 return 0;
163 }
164 static int opSTOSL_a32(uint32_t fetchdat)
165 {
166 writememl(es, EDI, EAX); if (abrt) return 0;
167 if (flags & D_FLAG) EDI -= 4;
168 else EDI += 4;
169 cycles -= 4;
170 return 0;
171 }
174 static int opLODSB_a16(uint32_t fetchdat)
175 {
176 uint8_t temp = readmemb(ea_seg->base, SI); if (abrt) return 0;
177 AL = temp;
178 if (flags & D_FLAG) SI--;
179 else SI++;
180 cycles -= 5;
181 return 0;
182 }
183 static int opLODSB_a32(uint32_t fetchdat)
184 {
185 uint8_t temp = readmemb(ea_seg->base, ESI); if (abrt) return 0;
186 AL = temp;
187 if (flags & D_FLAG) ESI--;
188 else ESI++;
189 cycles -= 5;
190 return 0;
191 }
193 static int opLODSW_a16(uint32_t fetchdat)
194 {
195 uint16_t temp = readmemw(ea_seg->base, SI); if (abrt) return 0;
196 AX = temp;
197 if (flags & D_FLAG) SI -= 2;
198 else SI += 2;
199 cycles -= 5;
200 return 0;
201 }
202 static int opLODSW_a32(uint32_t fetchdat)
203 {
204 uint16_t temp = readmemw(ea_seg->base, ESI); if (abrt) return 0;
205 AX = temp;
206 if (flags & D_FLAG) ESI -= 2;
207 else ESI += 2;
208 cycles -= 5;
209 return 0;
210 }
212 static int opLODSL_a16(uint32_t fetchdat)
213 {
214 uint32_t temp = readmeml(ea_seg->base, SI); if (abrt) return 0;
215 EAX = temp;
216 if (flags & D_FLAG) SI -= 4;
217 else SI += 4;
218 cycles -= 5;
219 return 0;
220 }
221 static int opLODSL_a32(uint32_t fetchdat)
222 {
223 uint32_t temp = readmeml(ea_seg->base, ESI); if (abrt) return 0;
224 EAX = temp;
225 if (flags & D_FLAG) ESI -= 4;
226 else ESI += 4;
227 cycles -= 5;
228 return 0;
229 }
232 static int opSCASB_a16(uint32_t fetchdat)
233 {
234 uint8_t temp = readmemb(es, DI); if (abrt) return 0;
235 setsub8(AL, temp);
236 if (flags & D_FLAG) DI--;
237 else DI++;
238 cycles -= 7;
239 return 0;
240 }
241 static int opSCASB_a32(uint32_t fetchdat)
242 {
243 uint8_t temp = readmemb(es, EDI); if (abrt) return 0;
244 setsub8(AL, temp);
245 if (flags & D_FLAG) EDI--;
246 else EDI++;
247 cycles -= 7;
248 return 0;
249 }
251 static int opSCASW_a16(uint32_t fetchdat)
252 {
253 uint16_t temp = readmemw(es, DI); if (abrt) return 0;
254 setsub16(AX, temp);
255 if (flags & D_FLAG) DI -= 2;
256 else DI += 2;
257 cycles -= 7;
258 return 0;
259 }
260 static int opSCASW_a32(uint32_t fetchdat)
261 {
262 uint16_t temp = readmemw(es, EDI); if (abrt) return 0;
263 setsub16(AX, temp);
264 if (flags & D_FLAG) EDI -= 2;
265 else EDI += 2;
266 cycles -= 7;
267 return 0;
268 }
270 static int opSCASL_a16(uint32_t fetchdat)
271 {
272 uint32_t temp = readmeml(es, DI); if (abrt) return 0;
273 setsub32(EAX, temp);
274 if (flags & D_FLAG) DI -= 4;
275 else DI += 4;
276 cycles -= 7;
277 return 0;
278 }
279 static int opSCASL_a32(uint32_t fetchdat)
280 {
281 uint32_t temp = readmeml(es, EDI); if (abrt) return 0;
282 setsub32(EAX, temp);
283 if (flags & D_FLAG) EDI -= 4;
284 else EDI += 4;
285 cycles -= 7;
286 return 0;
287 }
289 static int opINSB_a16(uint32_t fetchdat)
290 {
291 uint8_t temp;
292 check_io_perm(DX);
293 temp = inb(DX);
294 writememb(es, DI, temp); if (abrt) return 0;
295 if (flags & D_FLAG) DI--;
296 else DI++;
297 cycles -= 15;
298 return 0;
299 }
300 static int opINSB_a32(uint32_t fetchdat)
301 {
302 uint8_t temp;
303 check_io_perm(DX);
304 temp = inb(DX);
305 writememb(es, EDI, temp); if (abrt) return 0;
306 if (flags & D_FLAG) EDI--;
307 else EDI++;
308 cycles -= 15;
309 return 0;
310 }
312 static int opINSW_a16(uint32_t fetchdat)
313 {
314 uint16_t temp;
315 check_io_perm(DX);
316 check_io_perm(DX + 1);
317 temp = inw(DX);
318 writememw(es, DI, temp); if (abrt) return 0;
319 if (flags & D_FLAG) DI -= 2;
320 else DI += 2;
321 cycles -= 15;
322 return 0;
323 }
324 static int opINSW_a32(uint32_t fetchdat)
325 {
326 uint16_t temp;
327 check_io_perm(DX);
328 check_io_perm(DX + 1);
329 temp = inw(DX);
330 writememw(es, EDI, temp); if (abrt) return 0;
331 if (flags & D_FLAG) EDI -= 2;
332 else EDI += 2;
333 cycles -= 15;
334 return 0;
335 }
337 static int opINSL_a16(uint32_t fetchdat)
338 {
339 uint32_t temp;
340 check_io_perm(DX);
341 check_io_perm(DX + 1);
342 check_io_perm(DX + 2);
343 check_io_perm(DX + 3);
344 temp = inl(DX);
345 writememl(es, DI, temp); if (abrt) return 0;
346 if (flags & D_FLAG) DI -= 4;
347 else DI += 4;
348 cycles -= 15;
349 return 0;
350 }
351 static int opINSL_a32(uint32_t fetchdat)
352 {
353 uint32_t temp;
354 check_io_perm(DX);
355 check_io_perm(DX + 1);
356 check_io_perm(DX + 2);
357 check_io_perm(DX + 3);
358 temp = inl(DX);
359 writememl(es, EDI, temp); if (abrt) return 0;
360 if (flags & D_FLAG) EDI -= 4;
361 else EDI += 4;
362 cycles -= 15;
363 return 0;
364 }
366 static int opOUTSB_a16(uint32_t fetchdat)
367 {
368 uint8_t temp = readmemb(ea_seg->base, SI); if (abrt) return 0;
369 check_io_perm(DX);
370 if (flags & D_FLAG) SI--;
371 else SI++;
372 outb(DX, temp);
373 cycles -= 14;
374 return 0;
375 }
376 static int opOUTSB_a32(uint32_t fetchdat)
377 {
378 uint8_t temp = readmemb(ea_seg->base, ESI); if (abrt) return 0;
379 check_io_perm(DX);
380 if (flags & D_FLAG) ESI--;
381 else ESI++;
382 outb(DX, temp);
383 cycles -= 14;
384 return 0;
385 }
387 static int opOUTSW_a16(uint32_t fetchdat)
388 {
389 uint16_t temp = readmemw(ea_seg->base, SI); if (abrt) return 0;
390 check_io_perm(DX);
391 check_io_perm(DX + 1);
392 if (flags & D_FLAG) SI -= 2;
393 else SI += 2;
394 outw(DX, temp);
395 cycles -= 14;
396 return 0;
397 }
398 static int opOUTSW_a32(uint32_t fetchdat)
399 {
400 uint16_t temp = readmemw(ea_seg->base, ESI); if (abrt) return 0;
401 check_io_perm(DX);
402 check_io_perm(DX + 1);
403 if (flags & D_FLAG) ESI -= 2;
404 else ESI += 2;
405 outw(DX, temp);
406 cycles -= 14;
407 return 0;
408 }
410 static int opOUTSL_a16(uint32_t fetchdat)
411 {
412 uint32_t temp = readmeml(ea_seg->base, SI); if (abrt) return 0;
413 check_io_perm(DX);
414 check_io_perm(DX + 1);
415 check_io_perm(DX + 2);
416 check_io_perm(DX + 3);
417 if (flags & D_FLAG) SI -= 4;
418 else SI += 4;
419 outl(EDX, temp);
420 cycles -= 14;
421 return 0;
422 }
423 static int opOUTSL_a32(uint32_t fetchdat)
424 {
425 uint32_t temp = readmeml(ea_seg->base, ESI); if (abrt) return 0;
426 check_io_perm(DX);
427 check_io_perm(DX + 1);
428 check_io_perm(DX + 2);
429 check_io_perm(DX + 3);
430 if (flags & D_FLAG) ESI -= 4;
431 else ESI += 4;
432 outl(EDX, temp);
433 cycles -= 14;
434 return 0;
435 }
