Skip to content

Commit 40bb516

Browse files
committed
simx86: fix Sim_helper regressions in 16726e7 and a640538
First one set ESP before the fault, it should be the other way around, and cause a GPF in BC31, because the stack was wrong after the first fault. Second one was calling SetSegProt for real mode segments which I noticed looking at that code. Fixes dosemu2#2659
1 parent 6c68c64 commit 40bb516

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/base/emu-i386/simx86/codegen-sim.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,14 +3142,16 @@ static unsigned int _Sim_helper(unsigned int mem_ref, unsigned int data, int mod
31423142
sp += arg;
31433143
sp &= TheCPU.StackMask;
31443144
}
3145-
rESP = sp | (rESP&~TheCPU.StackMask);
31463145
if (REALADDR()) {
31473146
TheCPU.cs = cs;
31483147
LONG_CS = cs << 4;
31493148
}
3150-
SetSegProt(Ofs_CS, cs);
3151-
if (TheCPU.err)
3152-
break;
3149+
else {
3150+
SetSegProt(Ofs_CS, cs);
3151+
if (TheCPU.err)
3152+
break;
3153+
}
3154+
rESP = sp | (rESP&~TheCPU.StackMask);
31533155
/* eax used by JMP_INDIRECT */
31543156
data = eip;
31553157
}

0 commit comments

Comments
 (0)