- added some missing strings to resources
[wine.git] / memory / instr.c
blob4beb0fb342e9c993685293cc58213ff5bfd85da9
1 /*
2 * Emulation of privileged instructions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "windef.h"
22 #include "wingdi.h"
23 #include "wine/winuser16.h"
24 #include "module.h"
25 #include "miscemu.h"
26 #include "selectors.h"
27 #include "wine/debug.h"
28 #include "callback.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(int);
31 WINE_DECLARE_DEBUG_CHANNEL(io);
33 #ifdef __i386__
35 /* macros to set parts of a DWORD */
36 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
37 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
38 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
40 inline static void add_stack( CONTEXT86 *context, int offset )
42 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
43 ADD_LOWORD( context->Esp, offset );
44 else
45 context->Esp += offset;
48 inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
50 if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
51 if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
52 if (!long_addr) off = LOWORD(off);
53 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
56 inline static void *get_stack( CONTEXT86 *context )
58 if (ISV86(context)) return PTR_REAL_TO_LIN( context->SegSs, context->Esp );
59 return wine_ldt_get_ptr( context->SegSs, context->Esp );
63 /***********************************************************************
64 * timer_thread
66 static DWORD CALLBACK timer_thread( void *dummy )
68 for (;;)
70 Sleep(55);
71 DOSMEM_Tick( 0 );
75 /***********************************************************************
76 * INSTR_ReplaceSelector
78 * Try to replace an invalid selector by a valid one.
79 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
80 * is the so called 'bimodal' selector 0x40, which points to the BIOS
81 * data segment. Used by (at least) Borland products (and programs compiled
82 * using Borland products).
84 * See Undocumented Windows, Chapter 5, __0040.
86 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
88 extern char Call16_Start, Call16_End;
90 if (IS_SELECTOR_SYSTEM(context->SegCs))
91 if ( (char *)context->Eip >= &Call16_Start
92 && (char *)context->Eip < &Call16_End )
94 /* Saved selector may have become invalid when the relay code */
95 /* tries to restore it. We simply clear it. */
96 *sel = 0;
97 return TRUE;
100 if (*sel == 0x40)
102 #if 0 /* hack until this is moved to kernel */
103 static WORD sys_timer = 0;
104 if (!sys_timer)
105 sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
106 #endif
107 static HANDLE sys_thread;
108 if (!sys_thread) sys_thread = CreateThread( NULL, 0, timer_thread, NULL, 0, NULL );
109 *sel = DOSMEM_BiosDataSeg;
110 return TRUE;
112 return FALSE; /* Can't replace selector, crashdump */
116 /***********************************************************************
117 * INSTR_GetOperandAddr
119 * Return the address of an instruction operand (from the mod/rm byte).
121 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
122 int long_addr, int segprefix, int *len )
124 int mod, rm, base, index = 0, ss = 0, seg = 0, off;
125 LDT_ENTRY entry;
127 #define GET_VAL(val,type) \
128 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
130 *len = 0;
131 GET_VAL( &mod, BYTE );
132 rm = mod & 7;
133 mod >>= 6;
135 if (mod == 3)
137 switch(rm)
139 case 0: return (BYTE *)&context->Eax;
140 case 1: return (BYTE *)&context->Ecx;
141 case 2: return (BYTE *)&context->Edx;
142 case 3: return (BYTE *)&context->Ebx;
143 case 4: return (BYTE *)&context->Esp;
144 case 5: return (BYTE *)&context->Ebp;
145 case 6: return (BYTE *)&context->Esi;
146 case 7: return (BYTE *)&context->Edi;
150 if (long_addr)
152 if (rm == 4)
154 BYTE sib;
155 GET_VAL( &sib, BYTE );
156 rm = sib & 7;
157 ss = sib >> 6;
158 switch(sib >> 3)
160 case 0: index = context->Eax; break;
161 case 1: index = context->Ecx; break;
162 case 2: index = context->Edx; break;
163 case 3: index = context->Ebx; break;
164 case 4: index = 0; break;
165 case 5: index = context->Ebp; break;
166 case 6: index = context->Esi; break;
167 case 7: index = context->Edi; break;
171 switch(rm)
173 case 0: base = context->Eax; seg = context->SegDs; break;
174 case 1: base = context->Ecx; seg = context->SegDs; break;
175 case 2: base = context->Edx; seg = context->SegDs; break;
176 case 3: base = context->Ebx; seg = context->SegDs; break;
177 case 4: base = context->Esp; seg = context->SegSs; break;
178 case 5: base = context->Ebp; seg = context->SegSs; break;
179 case 6: base = context->Esi; seg = context->SegDs; break;
180 case 7: base = context->Edi; seg = context->SegDs; break;
182 switch (mod)
184 case 0:
185 if (rm == 5) /* special case: ds:(disp32) */
187 GET_VAL( &base, DWORD );
188 seg = context->SegDs;
190 break;
192 case 1: /* 8-bit disp */
193 GET_VAL( &off, BYTE );
194 base += (signed char)off;
195 break;
197 case 2: /* 32-bit disp */
198 GET_VAL( &off, DWORD );
199 base += (signed long)off;
200 break;
203 else /* short address */
205 switch(rm)
207 case 0: /* ds:(bx,si) */
208 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
209 seg = context->SegDs;
210 break;
211 case 1: /* ds:(bx,di) */
212 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
213 seg = context->SegDs;
214 break;
215 case 2: /* ss:(bp,si) */
216 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
217 seg = context->SegSs;
218 break;
219 case 3: /* ss:(bp,di) */
220 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
221 seg = context->SegSs;
222 break;
223 case 4: /* ds:(si) */
224 base = LOWORD(context->Esi);
225 seg = context->SegDs;
226 break;
227 case 5: /* ds:(di) */
228 base = LOWORD(context->Edi);
229 seg = context->SegDs;
230 break;
231 case 6: /* ss:(bp) */
232 base = LOWORD(context->Ebp);
233 seg = context->SegSs;
234 break;
235 case 7: /* ds:(bx) */
236 base = LOWORD(context->Ebx);
237 seg = context->SegDs;
238 break;
241 switch(mod)
243 case 0:
244 if (rm == 6) /* special case: ds:(disp16) */
246 GET_VAL( &base, WORD );
247 seg = context->SegDs;
249 break;
251 case 1: /* 8-bit disp */
252 GET_VAL( &off, BYTE );
253 base += (signed char)off;
254 break;
256 case 2: /* 16-bit disp */
257 GET_VAL( &off, WORD );
258 base += (signed short)off;
259 break;
261 base &= 0xffff;
263 if (segprefix != -1) seg = segprefix;
265 /* Make sure the segment and offset are valid */
266 if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
267 if ((seg & 7) != 7) return NULL;
268 wine_ldt_get_entry( seg, &entry );
269 if (wine_ldt_is_empty( &entry )) return NULL;
270 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
271 return (char *)wine_ldt_get_base(&entry) + base + (index << ss);
272 #undef GET_VAL
276 /***********************************************************************
277 * INSTR_EmulateLDS
279 * Emulate the LDS (and LES,LFS,etc.) instruction.
281 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
282 int long_addr, int segprefix, int *len )
284 WORD seg;
285 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
286 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
287 long_addr, segprefix, len );
288 if (!addr)
289 return FALSE; /* Unable to emulate it */
290 seg = *(WORD *)(addr + (long_op ? 4 : 2));
292 if (!INSTR_ReplaceSelector( context, &seg ))
293 return FALSE; /* Unable to emulate it */
295 /* Now store the offset in the correct register */
297 switch((*regmodrm >> 3) & 7)
299 case 0:
300 if (long_op) context->Eax = *(DWORD *)addr;
301 else SET_LOWORD(context->Eax,*(WORD *)addr);
302 break;
303 case 1:
304 if (long_op) context->Ecx = *(DWORD *)addr;
305 else SET_LOWORD(context->Ecx,*(WORD *)addr);
306 break;
307 case 2:
308 if (long_op) context->Edx = *(DWORD *)addr;
309 else SET_LOWORD(context->Edx,*(WORD *)addr);
310 break;
311 case 3:
312 if (long_op) context->Ebx = *(DWORD *)addr;
313 else SET_LOWORD(context->Ebx,*(WORD *)addr);
314 break;
315 case 4:
316 if (long_op) context->Esp = *(DWORD *)addr;
317 else SET_LOWORD(context->Esp,*(WORD *)addr);
318 break;
319 case 5:
320 if (long_op) context->Ebp = *(DWORD *)addr;
321 else SET_LOWORD(context->Ebp,*(WORD *)addr);
322 break;
323 case 6:
324 if (long_op) context->Esi = *(DWORD *)addr;
325 else SET_LOWORD(context->Esi,*(WORD *)addr);
326 break;
327 case 7:
328 if (long_op) context->Edi = *(DWORD *)addr;
329 else SET_LOWORD(context->Edi,*(WORD *)addr);
330 break;
333 /* Store the correct segment in the segment register */
335 switch(*instr)
337 case 0xc4: context->SegEs = seg; break; /* les */
338 case 0xc5: context->SegDs = seg; break; /* lds */
339 case 0x0f: switch(instr[1])
341 case 0xb2: context->SegSs = seg; break; /* lss */
342 case 0xb4: context->SegFs = seg; break; /* lfs */
343 case 0xb5: context->SegGs = seg; break; /* lgs */
345 break;
348 /* Add the opcode size to the total length */
350 *len += 1 + (*instr == 0x0f);
351 return TRUE;
354 /***********************************************************************
355 * INSTR_inport
357 * input on a I/O port
359 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
361 DWORD res = IO_inport( port, size );
362 if (TRACE_ON(io))
364 switch(size)
366 case 1:
367 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
368 (WORD)context->SegCs, LOWORD(context->Eip));
369 break;
370 case 2:
371 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
372 (WORD)context->SegCs, LOWORD(context->Eip));
373 break;
374 case 4:
375 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
376 (WORD)context->SegCs, LOWORD(context->Eip));
377 break;
380 return res;
384 /***********************************************************************
385 * INSTR_outport
387 * output on a I/O port
389 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
391 IO_outport( port, size, val );
392 if (TRACE_ON(io))
394 switch(size)
396 case 1:
397 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
398 (WORD)context->SegCs, LOWORD(context->Eip));
399 break;
400 case 2:
401 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
402 (WORD)context->SegCs, LOWORD(context->Eip));
403 break;
404 case 4:
405 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
406 (WORD)context->SegCs, LOWORD(context->Eip));
407 break;
413 /***********************************************************************
414 * INSTR_EmulateInstruction
416 * Emulate a privileged instruction.
417 * Returns exception code, or 0 if emulation successful.
419 DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
421 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
422 BYTE *instr;
423 DWORD ret = EXCEPTION_PRIV_INSTRUCTION;
425 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
426 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
427 if (!instr) return ret;
429 /* First handle any possible prefix */
431 segprefix = -1; /* no prefix */
432 prefix = 1;
433 repX = 0;
434 prefixlen = 0;
435 while(prefix)
437 switch(*instr)
439 case 0x2e:
440 segprefix = context->SegCs;
441 break;
442 case 0x36:
443 segprefix = context->SegSs;
444 break;
445 case 0x3e:
446 segprefix = context->SegDs;
447 break;
448 case 0x26:
449 segprefix = context->SegEs;
450 break;
451 case 0x64:
452 segprefix = context->SegFs;
453 break;
454 case 0x65:
455 segprefix = context->SegGs;
456 break;
457 case 0x66:
458 long_op = !long_op; /* opcode size prefix */
459 break;
460 case 0x67:
461 long_addr = !long_addr; /* addr size prefix */
462 break;
463 case 0xf0: /* lock */
464 break;
465 case 0xf2: /* repne */
466 repX = 1;
467 break;
468 case 0xf3: /* repe */
469 repX = 2;
470 break;
471 default:
472 prefix = 0; /* no more prefixes */
473 break;
475 if (prefix)
477 instr++;
478 prefixlen++;
482 /* Now look at the actual instruction */
484 switch(*instr)
486 case 0x07: /* pop es */
487 case 0x17: /* pop ss */
488 case 0x1f: /* pop ds */
490 WORD seg = *(WORD *)get_stack( context );
491 if (INSTR_ReplaceSelector( context, &seg ))
493 switch(*instr)
495 case 0x07: context->SegEs = seg; break;
496 case 0x17: context->SegSs = seg; break;
497 case 0x1f: context->SegDs = seg; break;
499 add_stack(context, long_op ? 4 : 2);
500 context->Eip += prefixlen + 1;
501 return 0;
504 break; /* Unable to emulate it */
506 case 0x0f: /* extended instruction */
507 switch(instr[1])
509 case 0x22: /* mov eax, crX */
510 switch (instr[2]) {
511 case 0xc0:
512 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
513 context->Eip,context->Eax );
514 context->Eip += prefixlen+3;
515 return 0;
516 default:
517 break; /*fallthrough to bad instruction handling */
519 break; /*fallthrough to bad instruction handling */
520 case 0x20: /* mov crX, eax */
521 switch (instr[2]) {
522 case 0xe0: /* mov cr4, eax */
523 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
524 * bit 0: VME Virtual Mode Exception ?
525 * bit 1: PVI Protected mode Virtual Interrupt
526 * bit 2: TSD Timestamp disable
527 * bit 3: DE Debugging extensions
528 * bit 4: PSE Page size extensions
529 * bit 5: PAE Physical address extension
530 * bit 6: MCE Machine check enable
531 * bit 7: PGE Enable global pages
532 * bit 8: PCE Enable performance counters at IPL3
534 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
535 context->Eax = 0;
536 context->Eip += prefixlen+3;
537 return 0;
538 case 0xc0: /* mov cr0, eax */
539 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
540 context->Eax = 0x10; /* FIXME: set more bits ? */
541 context->Eip += prefixlen+3;
542 return 0;
543 default: /* fallthrough to illegal instruction */
544 break;
546 /* fallthrough to illegal instruction */
547 break;
548 case 0xa1: /* pop fs */
550 WORD seg = *(WORD *)get_stack( context );
551 if (INSTR_ReplaceSelector( context, &seg ))
553 context->SegFs = seg;
554 add_stack(context, long_op ? 4 : 2);
555 context->Eip += prefixlen + 2;
556 return 0;
559 break;
560 case 0xa9: /* pop gs */
562 WORD seg = *(WORD *)get_stack( context );
563 if (INSTR_ReplaceSelector( context, &seg ))
565 context->SegGs = seg;
566 add_stack(context, long_op ? 4 : 2);
567 context->Eip += prefixlen + 2;
568 return 0;
571 break;
572 case 0xb2: /* lss addr,reg */
573 case 0xb4: /* lfs addr,reg */
574 case 0xb5: /* lgs addr,reg */
575 if (INSTR_EmulateLDS( context, instr, long_op,
576 long_addr, segprefix, &len ))
578 context->Eip += prefixlen + len;
579 return 0;
581 break;
583 break; /* Unable to emulate it */
585 case 0x6c: /* insb */
586 case 0x6d: /* insw/d */
587 case 0x6e: /* outsb */
588 case 0x6f: /* outsw/d */
590 int typ = *instr; /* Just in case it's overwritten. */
591 int outp = (typ >= 0x6e);
592 unsigned long count = repX ?
593 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
594 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
595 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
596 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
598 if (outp)
599 /* FIXME: Check segment readable. */
600 (void)0;
601 else
602 /* FIXME: Check segment writeable. */
603 (void)0;
605 if (repX)
607 if (long_addr) context->Ecx = 0;
608 else SET_LOWORD(context->Ecx,0);
611 while (count-- > 0)
613 void *data;
614 WORD dx = LOWORD(context->Edx);
615 if (outp)
617 data = make_ptr( context, seg, context->Esi, long_addr );
618 if (long_addr) context->Esi += step;
619 else ADD_LOWORD(context->Esi,step);
621 else
623 data = make_ptr( context, seg, context->Edi, long_addr );
624 if (long_addr) context->Edi += step;
625 else ADD_LOWORD(context->Edi,step);
628 switch (typ)
630 case 0x6c:
631 *(BYTE *)data = INSTR_inport( dx, 1, context );
632 break;
633 case 0x6d:
634 if (long_op)
635 *(DWORD *)data = INSTR_inport( dx, 4, context );
636 else
637 *(WORD *)data = INSTR_inport( dx, 2, context );
638 break;
639 case 0x6e:
640 INSTR_outport( dx, 1, *(BYTE *)data, context );
641 break;
642 case 0x6f:
643 if (long_op)
644 INSTR_outport( dx, 4, *(DWORD *)data, context );
645 else
646 INSTR_outport( dx, 2, *(WORD *)data, context );
647 break;
650 context->Eip += prefixlen + 1;
652 return 0;
654 case 0x8e: /* mov XX,segment_reg */
656 WORD seg;
657 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
658 long_addr, segprefix, &len );
659 if (!addr)
660 break; /* Unable to emulate it */
661 seg = *(WORD *)addr;
662 if (!INSTR_ReplaceSelector( context, &seg ))
663 break; /* Unable to emulate it */
665 switch((instr[1] >> 3) & 7)
667 case 0:
668 context->SegEs = seg;
669 context->Eip += prefixlen + len + 1;
670 return 0;
671 case 1: /* cs */
672 break;
673 case 2:
674 context->SegSs = seg;
675 context->Eip += prefixlen + len + 1;
676 return 0;
677 case 3:
678 context->SegDs = seg;
679 context->Eip += prefixlen + len + 1;
680 return 0;
681 case 4:
682 context->SegFs = seg;
683 context->Eip += prefixlen + len + 1;
684 return 0;
685 case 5:
686 context->SegGs = seg;
687 context->Eip += prefixlen + len + 1;
688 return 0;
689 case 6: /* unused */
690 case 7: /* unused */
691 break;
694 break; /* Unable to emulate it */
696 case 0xc4: /* les addr,reg */
697 case 0xc5: /* lds addr,reg */
698 if (INSTR_EmulateLDS( context, instr, long_op,
699 long_addr, segprefix, &len ))
701 context->Eip += prefixlen + len;
702 return 0;
704 break; /* Unable to emulate it */
706 case 0xcd: /* int <XX> */
707 if (IS_SELECTOR_SYSTEM(context->SegCs))
709 /* Win32 applications cannot use interrupts */
710 ret = EXCEPTION_ACCESS_VIOLATION;
711 break;
713 else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
715 ERR("could not initialize interrupt handling\n");
717 else
719 context->Eip += prefixlen + 2;
720 Dosvm.EmulateInterruptPM( context, instr[1] );
721 return 0;
723 break; /* Unable to emulate it */
725 case 0xcf: /* iret */
726 if (long_op)
728 DWORD *stack = get_stack( context );
729 context->Eip = *stack++;
730 context->SegCs = *stack++;
731 context->EFlags = *stack;
732 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
734 else
736 WORD *stack = get_stack( context );
737 context->Eip = *stack++;
738 context->SegCs = *stack++;
739 SET_LOWORD(context->EFlags,*stack);
740 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
742 return 0;
744 case 0xe4: /* inb al,XX */
745 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
746 context->Eip += prefixlen + 2;
747 return 0;
749 case 0xe5: /* in (e)ax,XX */
750 if (long_op)
751 context->Eax = INSTR_inport( instr[1], 4, context );
752 else
753 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
754 context->Eip += prefixlen + 2;
755 return 0;
757 case 0xe6: /* outb XX,al */
758 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
759 context->Eip += prefixlen + 2;
760 return 0;
762 case 0xe7: /* out XX,(e)ax */
763 if (long_op)
764 INSTR_outport( instr[1], 4, context->Eax, context );
765 else
766 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
767 context->Eip += prefixlen + 2;
768 return 0;
770 case 0xec: /* inb al,dx */
771 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
772 context->Eip += prefixlen + 1;
773 return 0;
775 case 0xed: /* in (e)ax,dx */
776 if (long_op)
777 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
778 else
779 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
780 context->Eip += prefixlen + 1;
781 return 0;
783 case 0xee: /* outb dx,al */
784 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
785 context->Eip += prefixlen + 1;
786 return 0;
788 case 0xef: /* out dx,(e)ax */
789 if (long_op)
790 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
791 else
792 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
793 context->Eip += prefixlen + 1;
794 return 0;
796 case 0xfa: /* cli, ignored */
797 context->Eip += prefixlen + 1;
798 return 0;
800 case 0xfb: /* sti, ignored */
801 context->Eip += prefixlen + 1;
802 return 0;
806 /* Check for Win16 __GP handler */
807 if (!IS_SELECTOR_SYSTEM(context->SegCs))
809 SEGPTR gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) );
810 if (gpHandler)
812 WORD *stack = get_stack( context );
813 *--stack = context->SegCs;
814 *--stack = context->Eip;
815 add_stack(context, -2*sizeof(WORD));
817 context->SegCs = SELECTOROF( gpHandler );
818 context->Eip = OFFSETOF( gpHandler );
819 return 0;
822 return ret; /* Unable to emulate it */
825 #endif /* __i386__ */