- Implemented semi-stubs for GetOpenFileNamePreviewA/W and
[wine/multimedia.git] / memory / instr.c
blobc5212ac2b52b6acc73e24482222490ea7d7ea756
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"
29 #include "thread.h"
30 #include "wine/exception.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(int);
33 WINE_DECLARE_DEBUG_CHANNEL(io);
35 #ifdef __i386__
37 /* macros to set parts of a DWORD */
38 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
39 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
40 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
42 inline static void add_stack( CONTEXT86 *context, int offset )
44 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
45 ADD_LOWORD( context->Esp, offset );
46 else
47 context->Esp += offset;
50 inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
52 if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
53 if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
54 if (!long_addr) off = LOWORD(off);
55 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
58 inline static void *get_stack( CONTEXT86 *context )
60 if (ISV86(context)) return PTR_REAL_TO_LIN( context->SegSs, context->Esp );
61 return wine_ldt_get_ptr( context->SegSs, context->Esp );
65 /***********************************************************************
66 * timer_thread
68 static DWORD CALLBACK timer_thread( void *dummy )
70 for (;;)
72 Sleep(55);
73 DOSMEM_Tick( 0 );
77 /***********************************************************************
78 * INSTR_ReplaceSelector
80 * Try to replace an invalid selector by a valid one.
81 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
82 * is the so called 'bimodal' selector 0x40, which points to the BIOS
83 * data segment. Used by (at least) Borland products (and programs compiled
84 * using Borland products).
86 * See Undocumented Windows, Chapter 5, __0040.
88 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
90 if (*sel == 0x40)
92 #if 0 /* hack until this is moved to kernel */
93 static WORD sys_timer = 0;
94 if (!sys_timer)
95 sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
96 #endif
97 static HANDLE sys_thread;
98 if (!sys_thread) sys_thread = CreateThread( NULL, 0, timer_thread, NULL, 0, NULL );
99 *sel = DOSMEM_BiosDataSeg;
100 return TRUE;
102 return FALSE; /* Can't replace selector, crashdump */
106 /***********************************************************************
107 * INSTR_GetOperandAddr
109 * Return the address of an instruction operand (from the mod/rm byte).
111 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
112 int long_addr, int segprefix, int *len )
114 int mod, rm, base, index = 0, ss = 0, seg = 0, off;
115 LDT_ENTRY entry;
117 #define GET_VAL(val,type) \
118 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
120 *len = 0;
121 GET_VAL( &mod, BYTE );
122 rm = mod & 7;
123 mod >>= 6;
125 if (mod == 3)
127 switch(rm)
129 case 0: return (BYTE *)&context->Eax;
130 case 1: return (BYTE *)&context->Ecx;
131 case 2: return (BYTE *)&context->Edx;
132 case 3: return (BYTE *)&context->Ebx;
133 case 4: return (BYTE *)&context->Esp;
134 case 5: return (BYTE *)&context->Ebp;
135 case 6: return (BYTE *)&context->Esi;
136 case 7: return (BYTE *)&context->Edi;
140 if (long_addr)
142 if (rm == 4)
144 BYTE sib;
145 GET_VAL( &sib, BYTE );
146 rm = sib & 7;
147 ss = sib >> 6;
148 switch(sib >> 3)
150 case 0: index = context->Eax; break;
151 case 1: index = context->Ecx; break;
152 case 2: index = context->Edx; break;
153 case 3: index = context->Ebx; break;
154 case 4: index = 0; break;
155 case 5: index = context->Ebp; break;
156 case 6: index = context->Esi; break;
157 case 7: index = context->Edi; break;
161 switch(rm)
163 case 0: base = context->Eax; seg = context->SegDs; break;
164 case 1: base = context->Ecx; seg = context->SegDs; break;
165 case 2: base = context->Edx; seg = context->SegDs; break;
166 case 3: base = context->Ebx; seg = context->SegDs; break;
167 case 4: base = context->Esp; seg = context->SegSs; break;
168 case 5: base = context->Ebp; seg = context->SegSs; break;
169 case 6: base = context->Esi; seg = context->SegDs; break;
170 case 7: base = context->Edi; seg = context->SegDs; break;
172 switch (mod)
174 case 0:
175 if (rm == 5) /* special case: ds:(disp32) */
177 GET_VAL( &base, DWORD );
178 seg = context->SegDs;
180 break;
182 case 1: /* 8-bit disp */
183 GET_VAL( &off, BYTE );
184 base += (signed char)off;
185 break;
187 case 2: /* 32-bit disp */
188 GET_VAL( &off, DWORD );
189 base += (signed long)off;
190 break;
193 else /* short address */
195 switch(rm)
197 case 0: /* ds:(bx,si) */
198 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
199 seg = context->SegDs;
200 break;
201 case 1: /* ds:(bx,di) */
202 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
203 seg = context->SegDs;
204 break;
205 case 2: /* ss:(bp,si) */
206 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
207 seg = context->SegSs;
208 break;
209 case 3: /* ss:(bp,di) */
210 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
211 seg = context->SegSs;
212 break;
213 case 4: /* ds:(si) */
214 base = LOWORD(context->Esi);
215 seg = context->SegDs;
216 break;
217 case 5: /* ds:(di) */
218 base = LOWORD(context->Edi);
219 seg = context->SegDs;
220 break;
221 case 6: /* ss:(bp) */
222 base = LOWORD(context->Ebp);
223 seg = context->SegSs;
224 break;
225 case 7: /* ds:(bx) */
226 base = LOWORD(context->Ebx);
227 seg = context->SegDs;
228 break;
231 switch(mod)
233 case 0:
234 if (rm == 6) /* special case: ds:(disp16) */
236 GET_VAL( &base, WORD );
237 seg = context->SegDs;
239 break;
241 case 1: /* 8-bit disp */
242 GET_VAL( &off, BYTE );
243 base += (signed char)off;
244 break;
246 case 2: /* 16-bit disp */
247 GET_VAL( &off, WORD );
248 base += (signed short)off;
249 break;
251 base &= 0xffff;
253 if (segprefix != -1) seg = segprefix;
255 /* Make sure the segment and offset are valid */
256 if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
257 if ((seg & 7) != 7) return NULL;
258 wine_ldt_get_entry( seg, &entry );
259 if (wine_ldt_is_empty( &entry )) return NULL;
260 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
261 return (char *)wine_ldt_get_base(&entry) + base + (index << ss);
262 #undef GET_VAL
266 /***********************************************************************
267 * INSTR_EmulateLDS
269 * Emulate the LDS (and LES,LFS,etc.) instruction.
271 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
272 int long_addr, int segprefix, int *len )
274 WORD seg;
275 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
276 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
277 long_addr, segprefix, len );
278 if (!addr)
279 return FALSE; /* Unable to emulate it */
280 seg = *(WORD *)(addr + (long_op ? 4 : 2));
282 if (!INSTR_ReplaceSelector( context, &seg ))
283 return FALSE; /* Unable to emulate it */
285 /* Now store the offset in the correct register */
287 switch((*regmodrm >> 3) & 7)
289 case 0:
290 if (long_op) context->Eax = *(DWORD *)addr;
291 else SET_LOWORD(context->Eax,*(WORD *)addr);
292 break;
293 case 1:
294 if (long_op) context->Ecx = *(DWORD *)addr;
295 else SET_LOWORD(context->Ecx,*(WORD *)addr);
296 break;
297 case 2:
298 if (long_op) context->Edx = *(DWORD *)addr;
299 else SET_LOWORD(context->Edx,*(WORD *)addr);
300 break;
301 case 3:
302 if (long_op) context->Ebx = *(DWORD *)addr;
303 else SET_LOWORD(context->Ebx,*(WORD *)addr);
304 break;
305 case 4:
306 if (long_op) context->Esp = *(DWORD *)addr;
307 else SET_LOWORD(context->Esp,*(WORD *)addr);
308 break;
309 case 5:
310 if (long_op) context->Ebp = *(DWORD *)addr;
311 else SET_LOWORD(context->Ebp,*(WORD *)addr);
312 break;
313 case 6:
314 if (long_op) context->Esi = *(DWORD *)addr;
315 else SET_LOWORD(context->Esi,*(WORD *)addr);
316 break;
317 case 7:
318 if (long_op) context->Edi = *(DWORD *)addr;
319 else SET_LOWORD(context->Edi,*(WORD *)addr);
320 break;
323 /* Store the correct segment in the segment register */
325 switch(*instr)
327 case 0xc4: context->SegEs = seg; break; /* les */
328 case 0xc5: context->SegDs = seg; break; /* lds */
329 case 0x0f: switch(instr[1])
331 case 0xb2: context->SegSs = seg; break; /* lss */
332 case 0xb4: context->SegFs = seg; break; /* lfs */
333 case 0xb5: context->SegGs = seg; break; /* lgs */
335 break;
338 /* Add the opcode size to the total length */
340 *len += 1 + (*instr == 0x0f);
341 return TRUE;
344 /***********************************************************************
345 * INSTR_inport
347 * input on a I/O port
349 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
351 DWORD res = IO_inport( port, size );
352 if (TRACE_ON(io))
354 switch(size)
356 case 1:
357 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
358 (WORD)context->SegCs, LOWORD(context->Eip));
359 break;
360 case 2:
361 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
362 (WORD)context->SegCs, LOWORD(context->Eip));
363 break;
364 case 4:
365 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
366 (WORD)context->SegCs, LOWORD(context->Eip));
367 break;
370 return res;
374 /***********************************************************************
375 * INSTR_outport
377 * output on a I/O port
379 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
381 IO_outport( port, size, val );
382 if (TRACE_ON(io))
384 switch(size)
386 case 1:
387 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
388 (WORD)context->SegCs, LOWORD(context->Eip));
389 break;
390 case 2:
391 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
392 (WORD)context->SegCs, LOWORD(context->Eip));
393 break;
394 case 4:
395 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
396 (WORD)context->SegCs, LOWORD(context->Eip));
397 break;
403 /***********************************************************************
404 * INSTR_EmulateInstruction
406 * Emulate a privileged instruction.
407 * Returns exception code, or 0 if emulation successful.
409 DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
411 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
412 BYTE *instr;
413 DWORD ret = EXCEPTION_PRIV_INSTRUCTION;
415 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
416 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
417 if (!instr) return ret;
419 /* First handle any possible prefix */
421 segprefix = -1; /* no prefix */
422 prefix = 1;
423 repX = 0;
424 prefixlen = 0;
425 while(prefix)
427 switch(*instr)
429 case 0x2e:
430 segprefix = context->SegCs;
431 break;
432 case 0x36:
433 segprefix = context->SegSs;
434 break;
435 case 0x3e:
436 segprefix = context->SegDs;
437 break;
438 case 0x26:
439 segprefix = context->SegEs;
440 break;
441 case 0x64:
442 segprefix = context->SegFs;
443 break;
444 case 0x65:
445 segprefix = context->SegGs;
446 break;
447 case 0x66:
448 long_op = !long_op; /* opcode size prefix */
449 break;
450 case 0x67:
451 long_addr = !long_addr; /* addr size prefix */
452 break;
453 case 0xf0: /* lock */
454 break;
455 case 0xf2: /* repne */
456 repX = 1;
457 break;
458 case 0xf3: /* repe */
459 repX = 2;
460 break;
461 default:
462 prefix = 0; /* no more prefixes */
463 break;
465 if (prefix)
467 instr++;
468 prefixlen++;
472 /* Now look at the actual instruction */
474 switch(*instr)
476 case 0x07: /* pop es */
477 case 0x17: /* pop ss */
478 case 0x1f: /* pop ds */
480 WORD seg = *(WORD *)get_stack( context );
481 if (INSTR_ReplaceSelector( context, &seg ))
483 switch(*instr)
485 case 0x07: context->SegEs = seg; break;
486 case 0x17: context->SegSs = seg; break;
487 case 0x1f: context->SegDs = seg; break;
489 add_stack(context, long_op ? 4 : 2);
490 context->Eip += prefixlen + 1;
491 return 0;
494 break; /* Unable to emulate it */
496 case 0x0f: /* extended instruction */
497 switch(instr[1])
499 case 0x22: /* mov eax, crX */
500 switch (instr[2]) {
501 case 0xc0:
502 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
503 context->Eip,context->Eax );
504 context->Eip += prefixlen+3;
505 return 0;
506 default:
507 break; /*fallthrough to bad instruction handling */
509 break; /*fallthrough to bad instruction handling */
510 case 0x20: /* mov crX, eax */
511 switch (instr[2]) {
512 case 0xe0: /* mov cr4, eax */
513 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
514 * bit 0: VME Virtual Mode Exception ?
515 * bit 1: PVI Protected mode Virtual Interrupt
516 * bit 2: TSD Timestamp disable
517 * bit 3: DE Debugging extensions
518 * bit 4: PSE Page size extensions
519 * bit 5: PAE Physical address extension
520 * bit 6: MCE Machine check enable
521 * bit 7: PGE Enable global pages
522 * bit 8: PCE Enable performance counters at IPL3
524 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
525 context->Eax = 0;
526 context->Eip += prefixlen+3;
527 return 0;
528 case 0xc0: /* mov cr0, eax */
529 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
530 context->Eax = 0x10; /* FIXME: set more bits ? */
531 context->Eip += prefixlen+3;
532 return 0;
533 default: /* fallthrough to illegal instruction */
534 break;
536 /* fallthrough to illegal instruction */
537 break;
538 case 0xa1: /* pop fs */
540 WORD seg = *(WORD *)get_stack( context );
541 if (INSTR_ReplaceSelector( context, &seg ))
543 context->SegFs = seg;
544 add_stack(context, long_op ? 4 : 2);
545 context->Eip += prefixlen + 2;
546 return 0;
549 break;
550 case 0xa9: /* pop gs */
552 WORD seg = *(WORD *)get_stack( context );
553 if (INSTR_ReplaceSelector( context, &seg ))
555 context->SegGs = seg;
556 add_stack(context, long_op ? 4 : 2);
557 context->Eip += prefixlen + 2;
558 return 0;
561 break;
562 case 0xb2: /* lss addr,reg */
563 case 0xb4: /* lfs addr,reg */
564 case 0xb5: /* lgs addr,reg */
565 if (INSTR_EmulateLDS( context, instr, long_op,
566 long_addr, segprefix, &len ))
568 context->Eip += prefixlen + len;
569 return 0;
571 break;
573 break; /* Unable to emulate it */
575 case 0x6c: /* insb */
576 case 0x6d: /* insw/d */
577 case 0x6e: /* outsb */
578 case 0x6f: /* outsw/d */
580 int typ = *instr; /* Just in case it's overwritten. */
581 int outp = (typ >= 0x6e);
582 unsigned long count = repX ?
583 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
584 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
585 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
586 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
588 if (outp)
589 /* FIXME: Check segment readable. */
590 (void)0;
591 else
592 /* FIXME: Check segment writeable. */
593 (void)0;
595 if (repX)
597 if (long_addr) context->Ecx = 0;
598 else SET_LOWORD(context->Ecx,0);
601 while (count-- > 0)
603 void *data;
604 WORD dx = LOWORD(context->Edx);
605 if (outp)
607 data = make_ptr( context, seg, context->Esi, long_addr );
608 if (long_addr) context->Esi += step;
609 else ADD_LOWORD(context->Esi,step);
611 else
613 data = make_ptr( context, seg, context->Edi, long_addr );
614 if (long_addr) context->Edi += step;
615 else ADD_LOWORD(context->Edi,step);
618 switch (typ)
620 case 0x6c:
621 *(BYTE *)data = INSTR_inport( dx, 1, context );
622 break;
623 case 0x6d:
624 if (long_op)
625 *(DWORD *)data = INSTR_inport( dx, 4, context );
626 else
627 *(WORD *)data = INSTR_inport( dx, 2, context );
628 break;
629 case 0x6e:
630 INSTR_outport( dx, 1, *(BYTE *)data, context );
631 break;
632 case 0x6f:
633 if (long_op)
634 INSTR_outport( dx, 4, *(DWORD *)data, context );
635 else
636 INSTR_outport( dx, 2, *(WORD *)data, context );
637 break;
640 context->Eip += prefixlen + 1;
642 return 0;
644 case 0x8e: /* mov XX,segment_reg */
646 WORD seg;
647 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
648 long_addr, segprefix, &len );
649 if (!addr)
650 break; /* Unable to emulate it */
651 seg = *(WORD *)addr;
652 if (!INSTR_ReplaceSelector( context, &seg ))
653 break; /* Unable to emulate it */
655 switch((instr[1] >> 3) & 7)
657 case 0:
658 context->SegEs = seg;
659 context->Eip += prefixlen + len + 1;
660 return 0;
661 case 1: /* cs */
662 break;
663 case 2:
664 context->SegSs = seg;
665 context->Eip += prefixlen + len + 1;
666 return 0;
667 case 3:
668 context->SegDs = seg;
669 context->Eip += prefixlen + len + 1;
670 return 0;
671 case 4:
672 context->SegFs = seg;
673 context->Eip += prefixlen + len + 1;
674 return 0;
675 case 5:
676 context->SegGs = seg;
677 context->Eip += prefixlen + len + 1;
678 return 0;
679 case 6: /* unused */
680 case 7: /* unused */
681 break;
684 break; /* Unable to emulate it */
686 case 0xc4: /* les addr,reg */
687 case 0xc5: /* lds addr,reg */
688 if (INSTR_EmulateLDS( context, instr, long_op,
689 long_addr, segprefix, &len ))
691 context->Eip += prefixlen + len;
692 return 0;
694 break; /* Unable to emulate it */
696 case 0xcd: /* int <XX> */
697 if (IS_SELECTOR_SYSTEM(context->SegCs))
699 /* Win32 applications cannot use interrupts */
700 ret = EXCEPTION_ACCESS_VIOLATION;
701 break;
703 else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
705 ERR("could not initialize interrupt handling\n");
707 else
709 context->Eip += prefixlen + 2;
710 Dosvm.EmulateInterruptPM( context, instr[1] );
711 return 0;
713 break; /* Unable to emulate it */
715 case 0xcf: /* iret */
716 if (long_op)
718 DWORD *stack = get_stack( context );
719 context->Eip = *stack++;
720 context->SegCs = *stack++;
721 context->EFlags = *stack;
722 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
724 else
726 WORD *stack = get_stack( context );
727 context->Eip = *stack++;
728 context->SegCs = *stack++;
729 SET_LOWORD(context->EFlags,*stack);
730 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
732 return 0;
734 case 0xe4: /* inb al,XX */
735 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
736 context->Eip += prefixlen + 2;
737 return 0;
739 case 0xe5: /* in (e)ax,XX */
740 if (long_op)
741 context->Eax = INSTR_inport( instr[1], 4, context );
742 else
743 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
744 context->Eip += prefixlen + 2;
745 return 0;
747 case 0xe6: /* outb XX,al */
748 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
749 context->Eip += prefixlen + 2;
750 return 0;
752 case 0xe7: /* out XX,(e)ax */
753 if (long_op)
754 INSTR_outport( instr[1], 4, context->Eax, context );
755 else
756 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
757 context->Eip += prefixlen + 2;
758 return 0;
760 case 0xec: /* inb al,dx */
761 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
762 context->Eip += prefixlen + 1;
763 return 0;
765 case 0xed: /* in (e)ax,dx */
766 if (long_op)
767 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
768 else
769 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
770 context->Eip += prefixlen + 1;
771 return 0;
773 case 0xee: /* outb dx,al */
774 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
775 context->Eip += prefixlen + 1;
776 return 0;
778 case 0xef: /* out dx,(e)ax */
779 if (long_op)
780 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
781 else
782 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
783 context->Eip += prefixlen + 1;
784 return 0;
786 case 0xfa: /* cli */
787 NtCurrentTeb()->dpmi_vif = 0;
788 context->Eip += prefixlen + 1;
789 return 0;
791 case 0xfb: /* sti */
792 NtCurrentTeb()->dpmi_vif = 1;
793 context->Eip += prefixlen + 1;
794 if (NtCurrentTeb()->vm86_pending)
796 NtCurrentTeb()->vm86_pending = 0;
797 return EXCEPTION_VM86_STI;
799 return 0;
801 return ret; /* Unable to emulate it */
804 #endif /* __i386__ */