1
0
Fork 0

Some cleanups

Callbacks now return from the decoder
Stacks are now read using a mask.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1156
This commit is contained in:
Sjoerd van der Berg 2003-07-26 10:39:01 +00:00
parent 3070b19d73
commit 8ca9fc4faa
5 changed files with 53 additions and 100 deletions

View file

@ -1,3 +1,21 @@
/*
* Copyright (C) 2002-2003 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dosbox.h"
#include "pic.h"
@ -11,17 +29,9 @@
#include "callback.h"
Bit8u PAGE_Readb(PhysPt address);
Bit16u PAGE_Readw(PhysPt address);
Bit32u PAGE_Readd(PhysPt address);
void PAGE_Writeb(PhysPt address,Bit8u val);
void PAGE_Writew(PhysPt address,Bit16u val);
void PAGE_Writed(PhysPt address,Bit32u val);
typedef PhysPt EAPoint;
#define SegBase(c) SegPhys(c)
#if 1
#define LoadMb(off) mem_readb_inline(off)
#define LoadMw(off) mem_readw_inline(off)
#define LoadMd(off) mem_readd_inline(off)
@ -34,22 +44,6 @@ typedef PhysPt EAPoint;
#define SaveMw(off,val) mem_writew_inline(off,val)
#define SaveMd(off,val) mem_writed_inline(off,val)
#else
#define LoadMb(off) PAGE_Readb(off)
#define LoadMw(off) PAGE_Readw(off)
#define LoadMd(off) PAGE_Readd(off)
#define LoadMbs(off) (Bit8s)(LoadMb(off))
#define LoadMws(off) (Bit16s)(LoadMw(off))
#define LoadMds(off) (Bit32s)(LoadMd(off))
#define SaveMb(off,val) PAGE_Writeb(off,val)
#define SaveMw(off,val) PAGE_Writew(off,val)
#define SaveMd(off,val) PAGE_Writed(off,val)
#endif
#define LoadD(reg) reg
#define SaveD(reg,val) reg=val
@ -84,7 +78,7 @@ static INLINE void DecodeModRM(void) {
goto nextopcode; \
}
Bitu Full_DeCode(void) {
Bits Full_DeCode(void) {
LoadIP();
flags.type=t_UNKNOWN;
@ -100,8 +94,8 @@ Bitu Full_DeCode(void) {
#endif
#endif
inst.start=IPPoint;
inst.entry=cpu.full.entry;
inst.prefix=cpu.full.prefix;
inst.entry=inst.start_entry;
inst.prefix=inst.start_prefix;
restartopcode:
inst.entry=(inst.entry & 0xffffff00) | Fetchb();
@ -117,6 +111,13 @@ nextopcode:;
}
void CPU_Core_Full_Start(void) {
void CPU_Core_Full_Start(bool big) {
if (!big) {
inst.start_prefix=0x0;;
inst.start_entry=0x0;
} else {
inst.start_prefix=PREFIX_ADDR;
inst.start_entry=0x200;
}
cpudecoder=&Full_DeCode;
}

View file

@ -383,7 +383,7 @@ l_M_Ed:
{
Bitu bytes=Fetchw();Bitu level=Fetchb() & 0x1f;
Bitu frame_ptr=reg_esp-2;
if (cpu.state & STATE_STACK32) {
if (cpu.stack.big) {
reg_esp-=2;
mem_writew(SegBase(ss)+reg_esp,reg_bp);
for (Bitu i=1;i<level;i++) {
@ -415,7 +415,7 @@ l_M_Ed:
{
Bitu bytes=Fetchw();Bitu level=Fetchb() & 0x1f;
Bitu frame_ptr=reg_esp-4;
if (cpu.state & STATE_STACK32) {
if (cpu.stack.big) {
reg_esp-=4;
mem_writed(SegBase(ss)+reg_esp,reg_ebp);
for (Bitu i=1;i<level;i++) {
@ -444,19 +444,13 @@ l_M_Ed:
goto nextopcode;
}
case D_LEAVEw:
if (cpu.state & STATE_STACK32) {
reg_esp=reg_ebp;
} else {
reg_sp=reg_bp;
}
reg_esp&=~cpu.stack.mask;
reg_esp|=(reg_ebp&cpu.stack.mask);
reg_bp=Pop_16();
goto nextopcode;
case D_LEAVEd:
if (cpu.state & STATE_STACK32) {
reg_esp=reg_ebp;
} else {
reg_sp=reg_bp;
}
reg_esp&=~cpu.stack.mask;
reg_esp|=(reg_ebp&cpu.stack.mask);
reg_ebp=Pop_32();
goto nextopcode;
case D_DAA:
@ -477,7 +471,7 @@ l_M_Ed:
case D_HLT:
LEAVECORE;
CPU_HLT();
return 0x0;
return CBRET_NONE;
default:
LOG(LOG_CPU,LOG_ERROR)("LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry);
break;

View file

@ -37,55 +37,24 @@ static INLINE Bit32s Fetchds() {
}
static INLINE void Push_16(Bit16u blah) {
if (cpu.state & STATE_STACK32) {
reg_esp-=2;
SaveMw(SegBase(ss)+reg_esp,blah);
} else {
reg_sp-=2;
SaveMw(SegBase(ss)+reg_sp,blah);
}
reg_esp-=2;
SaveMw(SegBase(ss) + (reg_esp & cpu.stack.mask),blah);
}
static INLINE void Push_32(Bit32u blah) {
if (cpu.state & STATE_STACK32) {
reg_esp-=4;
SaveMd(SegBase(ss)+reg_esp,blah);
} else {
reg_sp-=4;
SaveMd(SegBase(ss)+reg_sp,blah);
}
reg_esp-=4;
SaveMd(SegBase(ss) + (reg_esp & cpu.stack.mask),blah);
}
static INLINE Bit16u Pop_16(void) {
if (cpu.state & STATE_STACK32) {
Bit16u temp=LoadMw(SegBase(ss)+reg_esp);
reg_esp+=2;
return temp;
} else {
Bit16u temp=LoadMw(SegBase(ss)+reg_sp);
reg_sp+=2;
return temp;
}
Bit16u temp=LoadMw(SegBase(ss) + (reg_esp & cpu.stack.mask));
reg_esp+=2;
return temp;
}
static INLINE Bit32u Pop_32(void) {
if (cpu.state & STATE_STACK32) {
Bit32u temp=LoadMd(SegBase(ss)+reg_esp);
reg_esp+=4;
return temp;
} else {
Bit32u temp=LoadMd(SegBase(ss)+reg_sp);
reg_sp+=4;
return temp;
}
Bit32u temp=LoadMd(SegBase(ss) + (reg_esp & cpu.stack.mask));
reg_esp+=4;
return temp;
}
#if 0
if (flags.intf && PIC_IRQCheck) { \
LEAVECORE; \
PIC_runIRQs(); \
LoadIP(); \
} \
}
#endif

View file

@ -341,8 +341,8 @@ switch (inst.code.op) {
case O_INT:
LEAVECORE;
#if C_DEBUG
if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return 1;
else if (DEBUG_IntBreakpoint(inst.op1.b)) return 1;
if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return -1;
else if (DEBUG_IntBreakpoint(inst.op1.b)) return -1;
#endif
Interrupt(inst.op1.b);
LoadIP();
@ -370,21 +370,8 @@ switch (inst.code.op) {
IO_Write(inst.op1.d+3,(Bit8u)(reg_eax >> 24));
goto nextopcode;
case O_CBACK:
if (inst.op1.d<CB_MAX) {
LEAVECORE;
Bitu ret=CallBack_Handlers[inst.op1.d]();
switch (ret) {
case CBRET_NONE:
LoadIP();
goto nextopcode;
case CBRET_STOP:
return ret;
default:
E_Exit("CPU:Callback %d returned illegal %d code",inst.op1.d,ret);
}
} else {
E_Exit("Too high CallBack Number %d called",inst.op1.d);
}
LEAVECORE;
return inst.op1.d;
case O_GRP6w:
case O_GRP6d:
switch (inst.rm_index) {

View file

@ -176,6 +176,8 @@ static struct {
Bitu cond;
bool repz;
Bitu prefix;
Bitu start_prefix;
Bitu start_entry;
} inst;