src/emu/cpu/i86/instr286.c
| r12016 | r12017 | |
| 718 | 718 | |
| 719 | 719 | static void i80286_load_flags(i8086_state *cpustate, UINT16 flags, int cpl) |
| 720 | 720 | { |
| 721 | cpustate->flags = CompressFlags(); |
| 721 | 722 | if(PM && cpl) { |
| 722 | 723 | UINT16 mask = 0x3000; |
| 723 | 724 | if(cpl>IOPL) mask |= 0x200; |
| r12016 | r12017 | |
| 727 | 728 | else if(!PM) (flags &= ~0xf000); |
| 728 | 729 | ExpandFlags(flags); |
| 729 | 730 | cpustate->flags = flags; |
| 730 | | cpustate->flags = CompressFlags(); |
| 731 | 731 | |
| 732 | 732 | if (cpustate->TF) PREFIX(_trap)(cpustate); |
| 733 | 733 | /* if the IF is set, and an interrupt is pending, signal an interrupt */ |
| r12016 | r12017 | |
| 778 | 778 | else if (DPL(r)!=RPL(sel)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(sel)); |
| 779 | 779 | |
| 780 | 780 | if (!PRES(r)) throw TRAP(SEG_NOT_PRESENT,IDXTBL(sel)); |
| 781 | | if (off > LIMIT(desc)) throw TRAP(GENERAL_PROTECTION_FAULT, IDXTBL(sel)); |
| 781 | if (off > LIMIT(desc)) throw TRAP(GENERAL_PROTECTION_FAULT,0); |
| 782 | 782 | if (CPL<RPL(sel)) { |
| 783 | 783 | i80286_check_permission(cpustate, SS, cpustate->regs.w[SP]+(iret?6:4)+bytes, 4, I80286_READ); |
| 784 | 784 | newsp = ReadWord(spaddr+((iret?6:4)+bytes)); |
| r12016 | r12017 | |
| 792 | 792 | cpustate->limit[CS]=LIMIT(desc); |
| 793 | 793 | cpustate->base[CS]=BASE(desc); |
| 794 | 794 | cpustate->rights[CS]=RIGHTS(desc); |
| 795 | | cpustate->pc=(cpustate->base[CS]+off)&AMASK ; |
| 795 | cpustate->pc=(cpustate->base[CS]+off)&AMASK; |
| 796 | 796 | |
| 797 | 797 | // docs say check rpl but windows doesn't like it |
| 798 | | if (i80286_verify(cpustate, cpustate->sregs[DS], I80286_READ, cpustate->rights[DS]) || (DPL(cpustate->rights[DS]) < CPL)) |
| 798 | r = cpustate->rights[DS]; |
| 799 | if (i80286_verify(cpustate, cpustate->sregs[DS], I80286_READ, r) || (CODE(r) && CONF(r) ? 0 : (DPL(r) < CPL))) |
| 799 | 800 | i80286_data_descriptor(cpustate, DS, 0); |
| 800 | | |
| 801 | | if (i80286_verify(cpustate, cpustate->sregs[ES], I80286_READ, cpustate->rights[ES]) || (DPL(cpustate->rights[ES]) < CPL)) |
| 801 | r = cpustate->rights[ES]; |
| 802 | if (i80286_verify(cpustate, cpustate->sregs[ES], I80286_READ, r) || (CODE(r) && CONF(r) ? 0 : (DPL(r) < CPL))) |
| 802 | 803 | i80286_data_descriptor(cpustate, ES, 0); |
| 803 | 804 | } else { |
| 804 | 805 | cpustate->regs.w[SP] += (iret?6:4) + bytes; |
| 805 | 806 | cpustate->sregs[CS]=sel; |
| 806 | 807 | cpustate->base[CS]=sel<<4; |
| 807 | | cpustate->rights[CS]=0x93; |
| 808 | cpustate->rights[CS]=0x9a; |
| 808 | 809 | cpustate->limit[CS]=0xffff; |
| 809 | 810 | cpustate->pc=(cpustate->base[CS]+off)&AMASK; |
| 810 | 811 | } |