Implemented a number of IMM functions.
[wine/multimedia.git] / memory / instr.c
blob74632ce7f2073fa184dd5d7fef935199a701834f
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 );
62 /***********************************************************************
63 * INSTR_ReplaceSelector
65 * Try to replace an invalid selector by a valid one.
66 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
67 * is the so called 'bimodal' selector 0x40, which points to the BIOS
68 * data segment. Used by (at least) Borland products (and programs compiled
69 * using Borland products).
71 * See Undocumented Windows, Chapter 5, __0040.
73 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
75 extern char Call16_Start, Call16_End;
77 if (IS_SELECTOR_SYSTEM(context->SegCs))
78 if ( (char *)context->Eip >= &Call16_Start
79 && (char *)context->Eip < &Call16_End )
81 /* Saved selector may have become invalid when the relay code */
82 /* tries to restore it. We simply clear it. */
83 *sel = 0;
84 return TRUE;
87 if (*sel == 0x40)
89 static WORD sys_timer = 0;
90 if (!sys_timer)
91 sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
92 *sel = DOSMEM_BiosDataSeg;
93 return TRUE;
95 return FALSE; /* Can't replace selector, crashdump */
99 /***********************************************************************
100 * INSTR_GetOperandAddr
102 * Return the address of an instruction operand (from the mod/rm byte).
104 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
105 int long_addr, int segprefix, int *len )
107 int mod, rm, base, index = 0, ss = 0, seg = 0, off;
108 LDT_ENTRY entry;
110 #define GET_VAL(val,type) \
111 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
113 *len = 0;
114 GET_VAL( &mod, BYTE );
115 rm = mod & 7;
116 mod >>= 6;
118 if (mod == 3)
120 switch(rm)
122 case 0: return (BYTE *)&context->Eax;
123 case 1: return (BYTE *)&context->Ecx;
124 case 2: return (BYTE *)&context->Edx;
125 case 3: return (BYTE *)&context->Ebx;
126 case 4: return (BYTE *)&context->Esp;
127 case 5: return (BYTE *)&context->Ebp;
128 case 6: return (BYTE *)&context->Esi;
129 case 7: return (BYTE *)&context->Edi;
133 if (long_addr)
135 if (rm == 4)
137 BYTE sib;
138 GET_VAL( &sib, BYTE );
139 rm = sib & 7;
140 ss = sib >> 6;
141 switch(sib >> 3)
143 case 0: index = context->Eax; break;
144 case 1: index = context->Ecx; break;
145 case 2: index = context->Edx; break;
146 case 3: index = context->Ebx; break;
147 case 4: index = 0; break;
148 case 5: index = context->Ebp; break;
149 case 6: index = context->Esi; break;
150 case 7: index = context->Edi; break;
154 switch(rm)
156 case 0: base = context->Eax; seg = context->SegDs; break;
157 case 1: base = context->Ecx; seg = context->SegDs; break;
158 case 2: base = context->Edx; seg = context->SegDs; break;
159 case 3: base = context->Ebx; seg = context->SegDs; break;
160 case 4: base = context->Esp; seg = context->SegSs; break;
161 case 5: base = context->Ebp; seg = context->SegSs; break;
162 case 6: base = context->Esi; seg = context->SegDs; break;
163 case 7: base = context->Edi; seg = context->SegDs; break;
165 switch (mod)
167 case 0:
168 if (rm == 5) /* special case: ds:(disp32) */
170 GET_VAL( &base, DWORD );
171 seg = context->SegDs;
173 break;
175 case 1: /* 8-bit disp */
176 GET_VAL( &off, BYTE );
177 base += (signed char)off;
178 break;
180 case 2: /* 32-bit disp */
181 GET_VAL( &off, DWORD );
182 base += (signed long)off;
183 break;
186 else /* short address */
188 switch(rm)
190 case 0: /* ds:(bx,si) */
191 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
192 seg = context->SegDs;
193 break;
194 case 1: /* ds:(bx,di) */
195 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
196 seg = context->SegDs;
197 break;
198 case 2: /* ss:(bp,si) */
199 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
200 seg = context->SegSs;
201 break;
202 case 3: /* ss:(bp,di) */
203 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
204 seg = context->SegSs;
205 break;
206 case 4: /* ds:(si) */
207 base = LOWORD(context->Esi);
208 seg = context->SegDs;
209 break;
210 case 5: /* ds:(di) */
211 base = LOWORD(context->Edi);
212 seg = context->SegDs;
213 break;
214 case 6: /* ss:(bp) */
215 base = LOWORD(context->Ebp);
216 seg = context->SegSs;
217 break;
218 case 7: /* ds:(bx) */
219 base = LOWORD(context->Ebx);
220 seg = context->SegDs;
221 break;
224 switch(mod)
226 case 0:
227 if (rm == 6) /* special case: ds:(disp16) */
229 GET_VAL( &base, WORD );
230 seg = context->SegDs;
232 break;
234 case 1: /* 8-bit disp */
235 GET_VAL( &off, BYTE );
236 base += (signed char)off;
237 break;
239 case 2: /* 16-bit disp */
240 GET_VAL( &off, WORD );
241 base += (signed short)off;
242 break;
244 base &= 0xffff;
246 if (segprefix != -1) seg = segprefix;
248 /* Make sure the segment and offset are valid */
249 if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
250 if ((seg & 7) != 7) return NULL;
251 wine_ldt_get_entry( seg, &entry );
252 if (wine_ldt_is_empty( &entry )) return NULL;
253 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
254 return (char *)wine_ldt_get_base(&entry) + base + (index << ss);
255 #undef GET_VAL
259 /***********************************************************************
260 * INSTR_EmulateLDS
262 * Emulate the LDS (and LES,LFS,etc.) instruction.
264 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
265 int long_addr, int segprefix, int *len )
267 WORD seg;
268 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
269 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
270 long_addr, segprefix, len );
271 if (!addr)
272 return FALSE; /* Unable to emulate it */
273 seg = *(WORD *)(addr + (long_op ? 4 : 2));
275 if (!INSTR_ReplaceSelector( context, &seg ))
276 return FALSE; /* Unable to emulate it */
278 /* Now store the offset in the correct register */
280 switch((*regmodrm >> 3) & 7)
282 case 0:
283 if (long_op) context->Eax = *(DWORD *)addr;
284 else SET_LOWORD(context->Eax,*(WORD *)addr);
285 break;
286 case 1:
287 if (long_op) context->Ecx = *(DWORD *)addr;
288 else SET_LOWORD(context->Ecx,*(WORD *)addr);
289 break;
290 case 2:
291 if (long_op) context->Edx = *(DWORD *)addr;
292 else SET_LOWORD(context->Edx,*(WORD *)addr);
293 break;
294 case 3:
295 if (long_op) context->Ebx = *(DWORD *)addr;
296 else SET_LOWORD(context->Ebx,*(WORD *)addr);
297 break;
298 case 4:
299 if (long_op) context->Esp = *(DWORD *)addr;
300 else SET_LOWORD(context->Esp,*(WORD *)addr);
301 break;
302 case 5:
303 if (long_op) context->Ebp = *(DWORD *)addr;
304 else SET_LOWORD(context->Ebp,*(WORD *)addr);
305 break;
306 case 6:
307 if (long_op) context->Esi = *(DWORD *)addr;
308 else SET_LOWORD(context->Esi,*(WORD *)addr);
309 break;
310 case 7:
311 if (long_op) context->Edi = *(DWORD *)addr;
312 else SET_LOWORD(context->Edi,*(WORD *)addr);
313 break;
316 /* Store the correct segment in the segment register */
318 switch(*instr)
320 case 0xc4: context->SegEs = seg; break; /* les */
321 case 0xc5: context->SegDs = seg; break; /* lds */
322 case 0x0f: switch(instr[1])
324 case 0xb2: context->SegSs = seg; break; /* lss */
325 case 0xb4: context->SegFs = seg; break; /* lfs */
326 case 0xb5: context->SegGs = seg; break; /* lgs */
328 break;
331 /* Add the opcode size to the total length */
333 *len += 1 + (*instr == 0x0f);
334 return TRUE;
337 /***********************************************************************
338 * INSTR_inport
340 * input on a I/O port
342 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
344 DWORD res = IO_inport( port, size );
345 if (TRACE_ON(io))
347 switch(size)
349 case 1:
350 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
351 (WORD)context->SegCs, LOWORD(context->Eip));
352 break;
353 case 2:
354 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
355 (WORD)context->SegCs, LOWORD(context->Eip));
356 break;
357 case 4:
358 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
359 (WORD)context->SegCs, LOWORD(context->Eip));
360 break;
363 return res;
367 /***********************************************************************
368 * INSTR_outport
370 * output on a I/O port
372 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
374 IO_outport( port, size, val );
375 if (TRACE_ON(io))
377 switch(size)
379 case 1:
380 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
381 (WORD)context->SegCs, LOWORD(context->Eip));
382 break;
383 case 2:
384 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
385 (WORD)context->SegCs, LOWORD(context->Eip));
386 break;
387 case 4:
388 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
389 (WORD)context->SegCs, LOWORD(context->Eip));
390 break;
396 /***********************************************************************
397 * INSTR_EmulateInstruction
399 * Emulate a privileged instruction. Returns TRUE if emulation successful.
401 BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
403 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
404 SEGPTR gpHandler;
405 BYTE *instr;
407 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
408 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
409 if (!instr) return FALSE;
411 /* First handle any possible prefix */
413 segprefix = -1; /* no prefix */
414 prefix = 1;
415 repX = 0;
416 prefixlen = 0;
417 while(prefix)
419 switch(*instr)
421 case 0x2e:
422 segprefix = context->SegCs;
423 break;
424 case 0x36:
425 segprefix = context->SegSs;
426 break;
427 case 0x3e:
428 segprefix = context->SegDs;
429 break;
430 case 0x26:
431 segprefix = context->SegEs;
432 break;
433 case 0x64:
434 segprefix = context->SegFs;
435 break;
436 case 0x65:
437 segprefix = context->SegGs;
438 break;
439 case 0x66:
440 long_op = !long_op; /* opcode size prefix */
441 break;
442 case 0x67:
443 long_addr = !long_addr; /* addr size prefix */
444 break;
445 case 0xf0: /* lock */
446 break;
447 case 0xf2: /* repne */
448 repX = 1;
449 break;
450 case 0xf3: /* repe */
451 repX = 2;
452 break;
453 default:
454 prefix = 0; /* no more prefixes */
455 break;
457 if (prefix)
459 instr++;
460 prefixlen++;
464 /* Now look at the actual instruction */
466 switch(*instr)
468 case 0x07: /* pop es */
469 case 0x17: /* pop ss */
470 case 0x1f: /* pop ds */
472 WORD seg = *(WORD *)get_stack( context );
473 if (INSTR_ReplaceSelector( context, &seg ))
475 switch(*instr)
477 case 0x07: context->SegEs = seg; break;
478 case 0x17: context->SegSs = seg; break;
479 case 0x1f: context->SegDs = seg; break;
481 add_stack(context, long_op ? 4 : 2);
482 context->Eip += prefixlen + 1;
483 return TRUE;
486 break; /* Unable to emulate it */
488 case 0x0f: /* extended instruction */
489 switch(instr[1])
491 case 0x22: /* mov eax, crX */
492 switch (instr[2]) {
493 case 0xc0:
494 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
495 context->Eip,context->Eax );
496 context->Eip += prefixlen+3;
497 return TRUE;
498 default:
499 break; /*fallthrough to bad instruction handling */
501 break; /*fallthrough to bad instruction handling */
502 case 0x20: /* mov crX, eax */
503 switch (instr[2]) {
504 case 0xe0: /* mov cr4, eax */
505 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
506 * bit 0: VME Virtual Mode Exception ?
507 * bit 1: PVI Protected mode Virtual Interrupt
508 * bit 2: TSD Timestamp disable
509 * bit 3: DE Debugging extensions
510 * bit 4: PSE Page size extensions
511 * bit 5: PAE Physical address extension
512 * bit 6: MCE Machine check enable
513 * bit 7: PGE Enable global pages
514 * bit 8: PCE Enable performance counters at IPL3
516 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
517 context->Eax = 0;
518 context->Eip += prefixlen+3;
519 return TRUE;
520 case 0xc0: /* mov cr0, eax */
521 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
522 context->Eax = 0x10; /* FIXME: set more bits ? */
523 context->Eip += prefixlen+3;
524 return TRUE;
525 default: /* fallthrough to illegal instruction */
526 break;
528 /* fallthrough to illegal instruction */
529 break;
530 case 0xa1: /* pop fs */
532 WORD seg = *(WORD *)get_stack( context );
533 if (INSTR_ReplaceSelector( context, &seg ))
535 context->SegFs = seg;
536 add_stack(context, long_op ? 4 : 2);
537 context->Eip += prefixlen + 2;
538 return TRUE;
541 break;
542 case 0xa9: /* pop gs */
544 WORD seg = *(WORD *)get_stack( context );
545 if (INSTR_ReplaceSelector( context, &seg ))
547 context->SegGs = seg;
548 add_stack(context, long_op ? 4 : 2);
549 context->Eip += prefixlen + 2;
550 return TRUE;
553 break;
554 case 0xb2: /* lss addr,reg */
555 case 0xb4: /* lfs addr,reg */
556 case 0xb5: /* lgs addr,reg */
557 if (INSTR_EmulateLDS( context, instr, long_op,
558 long_addr, segprefix, &len ))
560 context->Eip += prefixlen + len;
561 return TRUE;
563 break;
565 break; /* Unable to emulate it */
567 case 0x6c: /* insb */
568 case 0x6d: /* insw/d */
569 case 0x6e: /* outsb */
570 case 0x6f: /* outsw/d */
572 int typ = *instr; /* Just in case it's overwritten. */
573 int outp = (typ >= 0x6e);
574 unsigned long count = repX ?
575 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
576 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
577 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
578 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
580 if (outp)
581 /* FIXME: Check segment readable. */
582 (void)0;
583 else
584 /* FIXME: Check segment writeable. */
585 (void)0;
587 if (repX)
589 if (long_addr) context->Ecx = 0;
590 else SET_LOWORD(context->Ecx,0);
593 while (count-- > 0)
595 void *data;
596 WORD dx = LOWORD(context->Edx);
597 if (outp)
599 data = make_ptr( context, seg, context->Esi, long_addr );
600 if (long_addr) context->Esi += step;
601 else ADD_LOWORD(context->Esi,step);
603 else
605 data = make_ptr( context, seg, context->Edi, long_addr );
606 if (long_addr) context->Edi += step;
607 else ADD_LOWORD(context->Edi,step);
610 switch (typ)
612 case 0x6c:
613 *(BYTE *)data = INSTR_inport( dx, 1, context );
614 break;
615 case 0x6d:
616 if (long_op)
617 *(DWORD *)data = INSTR_inport( dx, 4, context );
618 else
619 *(WORD *)data = INSTR_inport( dx, 2, context );
620 break;
621 case 0x6e:
622 INSTR_outport( dx, 1, *(BYTE *)data, context );
623 break;
624 case 0x6f:
625 if (long_op)
626 INSTR_outport( dx, 4, *(DWORD *)data, context );
627 else
628 INSTR_outport( dx, 2, *(WORD *)data, context );
629 break;
632 context->Eip += prefixlen + 1;
634 return TRUE;
636 case 0x8e: /* mov XX,segment_reg */
638 WORD seg;
639 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
640 long_addr, segprefix, &len );
641 if (!addr)
642 break; /* Unable to emulate it */
643 seg = *(WORD *)addr;
644 if (!INSTR_ReplaceSelector( context, &seg ))
645 break; /* Unable to emulate it */
647 switch((instr[1] >> 3) & 7)
649 case 0:
650 context->SegEs = seg;
651 context->Eip += prefixlen + len + 1;
652 return TRUE;
653 case 1: /* cs */
654 break;
655 case 2:
656 context->SegSs = seg;
657 context->Eip += prefixlen + len + 1;
658 return TRUE;
659 case 3:
660 context->SegDs = seg;
661 context->Eip += prefixlen + len + 1;
662 return TRUE;
663 case 4:
664 context->SegFs = seg;
665 context->Eip += prefixlen + len + 1;
666 return TRUE;
667 case 5:
668 context->SegGs = seg;
669 context->Eip += prefixlen + len + 1;
670 return TRUE;
671 case 6: /* unused */
672 case 7: /* unused */
673 break;
676 break; /* Unable to emulate it */
678 case 0xc4: /* les addr,reg */
679 case 0xc5: /* lds addr,reg */
680 if (INSTR_EmulateLDS( context, instr, long_op,
681 long_addr, segprefix, &len ))
683 context->Eip += prefixlen + len;
684 return TRUE;
686 break; /* Unable to emulate it */
688 case 0xcd: /* int <XX> */
689 if(!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
690 ERR("could not initialize interrupt handling\n");
691 else {
692 context->Eip += prefixlen + 2;
693 Dosvm.EmulateInterruptPM( context, instr[1] );
694 return TRUE;
696 break; /* Unable to emulate it */
698 case 0xcf: /* iret */
699 if (long_op)
701 DWORD *stack = get_stack( context );
702 context->Eip = *stack++;
703 context->SegCs = *stack++;
704 context->EFlags = *stack;
705 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
707 else
709 WORD *stack = get_stack( context );
710 context->Eip = *stack++;
711 context->SegCs = *stack++;
712 SET_LOWORD(context->EFlags,*stack);
713 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
715 return TRUE;
717 case 0xe4: /* inb al,XX */
718 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
719 context->Eip += prefixlen + 2;
720 return TRUE;
722 case 0xe5: /* in (e)ax,XX */
723 if (long_op)
724 context->Eax = INSTR_inport( instr[1], 4, context );
725 else
726 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
727 context->Eip += prefixlen + 2;
728 return TRUE;
730 case 0xe6: /* outb XX,al */
731 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
732 context->Eip += prefixlen + 2;
733 return TRUE;
735 case 0xe7: /* out XX,(e)ax */
736 if (long_op)
737 INSTR_outport( instr[1], 4, context->Eax, context );
738 else
739 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
740 context->Eip += prefixlen + 2;
741 return TRUE;
743 case 0xec: /* inb al,dx */
744 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
745 context->Eip += prefixlen + 1;
746 return TRUE;
748 case 0xed: /* in (e)ax,dx */
749 if (long_op)
750 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
751 else
752 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
753 context->Eip += prefixlen + 1;
754 return TRUE;
756 case 0xee: /* outb dx,al */
757 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
758 context->Eip += prefixlen + 1;
759 return TRUE;
761 case 0xef: /* out dx,(e)ax */
762 if (long_op)
763 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
764 else
765 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
766 context->Eip += prefixlen + 1;
767 return TRUE;
769 case 0xfa: /* cli, ignored */
770 context->Eip += prefixlen + 1;
771 return TRUE;
773 case 0xfb: /* sti, ignored */
774 context->Eip += prefixlen + 1;
775 return TRUE;
779 /* Check for Win16 __GP handler */
780 gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) );
781 if (gpHandler)
783 WORD *stack = get_stack( context );
784 *--stack = context->SegCs;
785 *--stack = context->Eip;
786 add_stack(context, -2*sizeof(WORD));
788 context->SegCs = SELECTOROF( gpHandler );
789 context->Eip = OFFSETOF( gpHandler );
790 return TRUE;
792 return FALSE; /* Unable to emulate it */
795 #endif /* __i386__ */