From f28bdda7b1f32415069f70c06f162e6f0e19fb97 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Wed, 5 Nov 2003 19:45:07 +0000 Subject: [PATCH] Far jmps/calls interrupts restart the core Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1402 --- src/cpu/core_full.cpp | 5 ++-- src/cpu/core_full/load.h | 62 +++++++++++++++++----------------------- src/cpu/core_full/op.h | 48 +++++++++++-------------------- 3 files changed, 45 insertions(+), 70 deletions(-) diff --git a/src/cpu/core_full.cpp b/src/cpu/core_full.cpp index 803457c4..a6658cfe 100644 --- a/src/cpu/core_full.cpp +++ b/src/cpu/core_full.cpp @@ -63,13 +63,14 @@ typedef PhysPt EAPoint; Bit8u new_num=blah; \ IPPoint=inst.start_entry; \ LEAVECORE; \ - Interrupt(new_num); \ + CPU_Exception(new_num,0); \ LoadIP(); \ goto nextopcode; \ } Bits Full_DeCode(void) { FullData inst; +restart_core: if (!cpu.code.big) { inst.start_prefix=0x0;; inst.start_entry=0x0; @@ -83,6 +84,7 @@ Bits Full_DeCode(void) { while (CPU_Cycles>0) { #if C_DEBUG cycle_count++; + CPU_Cycles--; #if C_HEAVY_DEBUG SaveIP(); if (DEBUG_HeavyIsBreakpoint()) { @@ -101,7 +103,6 @@ restartopcode: #include "core_full/op.h" #include "core_full/save.h" nextopcode:; - CPU_Cycles--; } LEAVECORE; return CBRET_NONE; diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index 6fd52404..1acb09af 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -273,49 +273,41 @@ l_M_Ed: inst.op1.d=4; break; case D_IRETw: - lflags.type=t_UNKNOWN; - if (!CPU_IRET(false)) return CBRET_NONE; + LEAVECORE; + CPU_IRET(false); if (GETFLAG(IF) && PIC_IRQCheck) { return CBRET_NONE; } - LoadIP(); - goto nextopcode; + goto restart_core; case D_IRETd: - lflags.type=t_UNKNOWN; - if (!CPU_IRET(true)) return CBRET_NONE; + LEAVECORE; + CPU_IRET(true); if (GETFLAG(IF) && PIC_IRQCheck) { return CBRET_NONE; } - LoadIP(); - goto nextopcode; + goto restart_core; case D_RETFwIw: - if (!CPU_RET(false,Fetchw())) { - FillFlags(); - return CBRET_NONE; + { + Bitu words=Fetchw(); + LEAVECORE; + CPU_RET(false,words); + goto restart_core; } - LoadIP(); - goto nextopcode; case D_RETFw: - if (!CPU_RET(false,0)) { - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; + LEAVECORE; + CPU_RET(false,0); + goto restart_core; case D_RETFdIw: - if (!CPU_RET(true,Fetchw())) { - FillFlags(); - return CBRET_NONE; + { + Bitu words=Fetchw(); + LEAVECORE; + CPU_RET(true,words); + goto restart_core; } - LoadIP(); - goto nextopcode; case D_RETFd: - if (!CPU_RET(true,0)) { - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; + LEAVECORE; + CPU_RET(true,0); + goto restart_core; /* Direct operations */ case L_STRING: #include "string.h" @@ -378,16 +370,14 @@ l_M_Ed: } goto nextopcode; case D_STC: - SETFLAGBIT(CF,true); - SetTypeCF(); + FillFlags();SETFLAGBIT(CF,true); goto nextopcode; case D_CLC: - SETFLAGBIT(CF,false); - SetTypeCF(); + FillFlags();SETFLAGBIT(CF,false); goto nextopcode; case D_CMC: - SETFLAGBIT(CF,!get_CF()); - SetTypeCF(); + FillFlags(); + SETFLAGBIT(CF,!(reg_flags & FLAG_CF)); goto nextopcode; case D_CLD: SETFLAGBIT(DF,false); diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 84bccea9..6137cd6a 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -33,14 +33,14 @@ switch (inst.code.op) { lflags.type=inst.code.op; break; case t_ADCb: case t_ADCw: case t_ADCd: - lflags.oldcf=get_CF(); + lflags.oldcf=get_CF()!=0; lf_var1d=inst.op1.d; lf_var2d=inst.op2.d; inst.op1.d=lf_resd=lf_var1d + lf_var2d + lflags.oldcf; lflags.type=inst.code.op; break; case t_SBBb: case t_SBBw: case t_SBBd: - lflags.oldcf=get_CF(); + lflags.oldcf=get_CF()!=0; lf_var1d=inst.op1.d; lf_var2d=inst.op2.d; inst.op1.d=lf_resd=lf_var1d - lf_var2d - lflags.oldcf; @@ -320,45 +320,29 @@ switch (inst.code.op) { Push_32(reg_eip); break; case O_CALLFw: - SaveIP(); - if (!CPU_CALL(false,inst.op2.d,inst.op1.d)) { - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; + LEAVECORE; + CPU_CALL(false,inst.op2.d,inst.op1.d); + goto restart_core; case O_CALLFd: - SaveIP(); - if (!CPU_CALL(true,inst.op2.d,inst.op1.d)) { - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; + LEAVECORE; + CPU_CALL(true,inst.op2.d,inst.op1.d); + goto restart_core; case O_JMPFw: - if (!CPU_JMP(false,inst.op2.d,inst.op1.d)){ - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; + LEAVECORE; + CPU_JMP(false,inst.op2.d,inst.op1.d); + goto restart_core; case O_JMPFd: - if (!CPU_JMP(true,inst.op2.d,inst.op1.d)) { - FillFlags(); - return CBRET_NONE; - } - LoadIP(); - goto nextopcode; - + LEAVECORE; + CPU_JMP(true,inst.op2.d,inst.op1.d); + goto restart_core; case O_INT: LEAVECORE; #if C_DEBUG if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return debugCallback; else if (DEBUG_IntBreakpoint(inst.op1.b)) return debugCallback; #endif - if (!Interrupt(inst.op1.b)) return CBRET_NONE; - LoadIP(); - break; + Interrupt(inst.op1.b); + goto restart_core; case O_INb: reg_al=IO_Read(inst.op1.d); goto nextopcode;