Skip to content

Commit c0d5110

Browse files
committed
simx86: _LONG_CS->LONG_CS and LONG_CS->static Interp_LONG_CS
To avoid confusion between these two. SPEC_PREJIT can only use Interp_LONG_CS.
1 parent 66b17c7 commit c0d5110

File tree

8 files changed

+62
-66
lines changed

8 files changed

+62
-66
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ static unsigned int Gen_sim(const IGen *IG, dosaddr_t mem_ref)
14781478
}
14791479
}
14801480
if (TheCPU.err2 == EXCP00_DIVZ)
1481-
P0 = _LONG_CS + (dosaddr_t)IG->p0;
1481+
P0 = LONG_CS + (dosaddr_t)IG->p0;
14821482
break;
14831483
case O_IDIV: // no flags
14841484
GTRACE0("O_IDIV");
@@ -1537,7 +1537,7 @@ static unsigned int Gen_sim(const IGen *IG, dosaddr_t mem_ref)
15371537
}
15381538
}
15391539
if (TheCPU.err2 == EXCP00_DIVZ)
1540-
P0 = _LONG_CS + (dosaddr_t)IG->p0;
1540+
P0 = LONG_CS + (dosaddr_t)IG->p0;
15411541
break;
15421542
case O_CBWD:
15431543
GTRACE0("O_CBWD");
@@ -2728,7 +2728,7 @@ static unsigned int Gen_sim(const IGen *IG, dosaddr_t mem_ref)
27282728
break;
27292729

27302730
case JMP_INDIRECT:
2731-
P0 = _LONG_CS + ((mode & DATA16) ? DR1.w.l : DR1.d);
2731+
P0 = LONG_CS + ((mode & DATA16) ? DR1.w.l : DR1.d);
27322732
if (debug_level('e')>2)
27332733
dbug_printf("** Jump taken to %08x\n",P0);
27342734
break;
@@ -2900,14 +2900,13 @@ static void emu_pagefault_handler(dosaddr_t addr, int err, uint32_t op, int len)
29002900
return;
29012901
}
29022902
/* trigger an exception in DPMI */
2903-
/* Need to shutdown prejitter to touch LONG_CS and TheCPU.err
2903+
/* Need to shutdown prejitter to touch TheCPU.err
29042904
to return to _Interp86() */
29052905
prejit_sync();
29062906
TheCPU.err = EXCP0E_PAGE;
29072907
TheCPU.scp_err = err;
29082908
TheCPU.cr[2] = addr;
29092909
if (currentIG) {
2910-
LONG_CS = _LONG_CS;
29112910
unsigned int P0 = FindPC(currentIG);
29122911
TheCPU.eip = P0 - LONG_CS;
29132912
EFLAGS = (EFLAGS & ~EFLAGS_CC) | FlagSync_All();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static CodeBuf *ProduceCode(unsigned int PC, IMeta *I0)
518518
*
519519
*/
520520

521-
TNode *Close(unsigned int PC, int mode)
521+
TNode *Close(unsigned int PC, unsigned int Interp_LONG_CS, int mode)
522522
{
523523
IMeta *I0;
524524
TNode *G;
@@ -551,7 +551,7 @@ TNode *Close(unsigned int PC, int mode)
551551
* if some other code tries to write over the page including
552552
* this node */
553553
e_markpage(G->seqbase, G->seqlen);
554-
G->cs = LONG_CS;
554+
G->cs = Interp_LONG_CS;
555555
G->mode = mode;
556556
/* check links INSIDE current node */
557557
if (0 == (EFLAGS & EFLAGS_TF) ) {

src/base/emu-i386/simx86/codegen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ extern int CurrIMeta;
270270
extern void Gen(int op, int mode, ...);
271271
extern void AddrGen(int op, int mode, ...);
272272
extern int (*Fp87_op)(int exop, int reg, unsigned mem_ref);
273-
TNode *Close(unsigned int PC, int mode);
273+
TNode *Close(unsigned int PC, unsigned int Interp_LONGCS, int mode);
274274
extern unsigned char * (*CodeGen)(unsigned char *CodePtr,
275275
unsigned char *BaseGenBuf, const IGen *IG);
276276
extern unsigned (*Exec)(unsigned *mem_ref, unsigned long *flg,

src/base/emu-i386/simx86/cpu-emu.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static inline void exprintb(unsigned char val,char *bf,unsigned int pos)
235235
while (v) { *p-- = ehextab[v&15]; v>>=4; }
236236
}
237237

238-
char *e_print_regs(void)
238+
char *e_print_regs(unsigned int Interp_LONG_CS)
239239
{
240240
static char buf[sizeof(eregbuf) + 300];
241241
char *p = buf;
@@ -261,7 +261,7 @@ char *e_print_regs(void)
261261
exprintl(TheCPU.eip,buf,(ERB_L4+ERB_LEFTM)+39);
262262
{
263263
int i;
264-
dosaddr_t csp = LONG_CS+TheCPU.eip;
264+
dosaddr_t csp = Interp_LONG_CS+TheCPU.eip;
265265
dosaddr_t st = LONG_SS+TheCPU.esp;
266266
if (csp < 0xa0000 - 256 || dpmi_is_valid_range(csp, 256)) {
267267
unsigned char *op = EMU_BASE32(csp);
@@ -548,11 +548,10 @@ static void Reg2Cpu(struct vm86_struct *info)
548548

549549
/* FPU state is loaded later on demand for JIT, not used for simulator */
550550
TheCPU.fpstate = &vm86_fpu_state;
551-
LONG_CS = _LONG_CS;
552551
if (debug_level('e')>1) {
553552
if (debug_level('e')==9) e_printf("Reg2Cpu< vm86=%08x dpm=%08x emu=%08x\n%s\n",
554553
regs->eflags,get_FLAGS(TheCPU.eflags),TheCPU.eflags,
555-
e_print_regs());
554+
e_print_regs(LONG_CS));
556555
else e_printf("Reg2Cpu< vm86=%08x dpm=%08x emu=%08x\n",
557556
regs->eflags,get_FLAGS(TheCPU.eflags),TheCPU.eflags);
558557
}
@@ -725,10 +724,9 @@ static void Scp2CpuD(cpuctx_t *scp)
725724
e_printf("Scp2CpuD%s: CS:IP=%08x:%08x\n%s\n",
726725
(TheCPU.err? " ERR":""),
727726
LONG_CS, _eip,
728-
e_print_regs());
727+
e_print_regs(LONG_CS));
729728
}
730729
TheCPU.mode = mode;
731-
LONG_CS = _LONG_CS;
732730
}
733731

734732

@@ -1131,7 +1129,7 @@ static int e_dpmi_tail(cpuctx_t *scp)
11311129
/* 0 if ok, else exception code+1 or negative if dosemu err */
11321130
if (xval < 0) {
11331131
error("DPM86: error %d\n", -xval);
1134-
error("@\n%s",e_print_regs());
1132+
error("@\n%s",e_print_regs(LONG_CS));
11351133
leavedos_main(0);
11361134
return -1;
11371135
}

src/base/emu-i386/simx86/emu86.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ int _ModRMSim(unsigned int PC, int mode, signed char overr_ds, signed char overr
743743
int ModGetReg1(unsigned int PC, int mode);
744744
//
745745
char *e_emu_disasm(unsigned char *org, int is32, unsigned int refseg);
746-
char *e_print_regs(void);
746+
char *e_print_regs(unsigned int Interp_LONGCS);
747747
char *e_print_scp_regs(cpuctx_t *scp, int pmode);
748748
const char *e_trace_fp(void);
749749
void GCPrint(unsigned char *cp, unsigned char *cbase, int len);

0 commit comments

Comments
 (0)