1
0
Fork 0

Changes for new flags

Opcodes moved into instructions.h
Added support for a load of protected mode related opcodes.
Fixed some opcodes.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@920
This commit is contained in:
Sjoerd van der Berg 2003-04-13 18:36:20 +00:00
parent 4826bf78e0
commit bb7bd6c3be
9 changed files with 423 additions and 383 deletions

View file

@ -32,6 +32,7 @@ static EAPoint IPPoint;
#include "core_full/ea_lookup.h"
#include "instructions.h"
static INLINE void DecodeModRM(void) {
inst.rm=Fetchb();
inst.rm_index=(inst.rm >> 3) & 7;
@ -41,14 +42,25 @@ static INLINE void DecodeModRM(void) {
if (inst.rm<0xc0) inst.rm_eaa=(inst.prefix & PREFIX_ADDR) ? RMAddress_32() : RMAddress_16();
}
#define EXCEPTION(blah) \
{ \
Bit8u new_num=blah; \
SaveIP(); \
Interrupt(new_num); \
LoadIP(); \
goto nextopcode; \
}
Bitu Full_DeCode(void) {
LoadIP();
while (CPU_Cycles>0) {
#if C_DEBUG
cycle_count++;
#endif
CPU_Cycles--;
inst.entry=cpu.full.entry;
inst.prefix=cpu.full.prefix;
restartopcode:
inst.entry=(inst.entry & 0xffffff00) | Fetchb();
@ -56,9 +68,7 @@ restartopcode:
#include "core_full/load.h"
#include "core_full/op.h"
#include "core_full/save.h"
nextopcode:
inst.prefix=0;
inst.entry=0;
nextopcode:;
}
SaveIP();
return 0;
@ -67,4 +77,4 @@ nextopcode:
void CPU_Core_Full_Start(void) {
cpudecoder=&Full_DeCode;
}
}

View file

@ -213,10 +213,8 @@ l_M_Ed:
inst.op1.d=reg_32(inst.code.extra);
break;
case L_FLG:
inst.op1.d= (get_CF() << 0) | (get_PF() << 2) | (get_AF() << 4) |
(get_ZF() << 6) | (get_SF() << 7) | (flags.tf << 8) |
(flags.intf << 9) |(flags.df << 10) | (get_OF() << 11) |
(flags.io << 12) | (flags.nt <<14);
FILLFLAGS;
inst.op1.d = flags.word;
break;
case L_SEG:
inst.op1.d=SegValue((SegNames)inst.code.extra);
@ -263,25 +261,47 @@ l_M_Ed:
if (!get_OF()) goto nextopcode;
inst.op1.d=4;
break;
case L_IRETw:
inst.op1.d=Pop_16();
inst.op2.d=Pop_16();
{
Bitu temp=Pop_16();
Save_Flagsw(temp);
}
break;
case D_IRETw:
CPU_IRET(false);
LoadIP();
goto nextopcode;
case D_IRETd:
CPU_IRET(true);
LoadIP();
goto nextopcode;
case D_RETFwIw:
CPU_RET(false,Fetchw());
LoadIP();
goto nextopcode;
case D_RETFw:
CPU_RET(false,0);
LoadIP();
goto nextopcode;
case D_RETFdIw:
CPU_RET(true,Fetchw());
LoadIP();
goto nextopcode;
case D_RETFd:
CPU_RET(true,0);
LoadIP();
goto nextopcode;
/* Direct operations */
case L_STRING:
#include "string.h"
goto nextopcode;
goto nextopcode;
case D_PUSHAw:
Push_16(reg_ax);Push_16(reg_cx);Push_16(reg_dx);Push_16(reg_bx);
Push_16(reg_sp);Push_16(reg_bp);Push_16(reg_si);Push_16(reg_di);
{
Bit16u old_sp=reg_sp;
Push_16(reg_ax);Push_16(reg_cx);Push_16(reg_dx);Push_16(reg_bx);
Push_16(old_sp);Push_16(reg_bp);Push_16(reg_si);Push_16(reg_di);
}
goto nextopcode;
case D_PUSHAd:
Push_32(reg_eax);Push_32(reg_ecx);Push_32(reg_edx);Push_32(reg_ebx);
Push_32(reg_esp);Push_32(reg_ebp);Push_32(reg_esi);Push_32(reg_edi);
{
Bit32u old_esp=reg_esp;
Push_32(reg_eax);Push_32(reg_ecx);Push_32(reg_edx);Push_32(reg_ebx);
Push_32(old_esp);Push_32(reg_ebp);Push_32(reg_esi);Push_32(reg_edi);
}
goto nextopcode;
case D_POPAw:
reg_di=Pop_16();reg_si=Pop_16();reg_bp=Pop_16();Pop_16();//Don't save SP
@ -310,36 +330,36 @@ l_M_Ed:
else reg_edx=0;
goto nextopcode;
case D_CLI:
flags.intf=false;
SETFLAGBIT(IF,false);
goto nextopcode;
case D_STI:
flags.intf=true;
if (flags.intf && PIC_IRQCheck) {
SETFLAGBIT(IF,true);
if (PIC_IRQCheck) {
SaveIP();
PIC_runIRQs();
LoadIP();
}
goto nextopcode;
case D_STC:
flags.cf=true;
SETFLAGBIT(CF,true);
if (flags.type!=t_CF) flags.prev_type=flags.type;
flags.type=t_CF;
goto nextopcode;
case D_CLC:
flags.cf=false;
SETFLAGBIT(CF,false);
if (flags.type!=t_CF) flags.prev_type=flags.type;
flags.type=t_CF;
goto nextopcode;
case D_CMC:
flags.cf=!get_CF();
SETFLAGBIT(CF,!get_CF());
if (flags.type!=t_CF) flags.prev_type=flags.type;
flags.type=t_CF;
goto nextopcode;
case D_CLD:
flags.df=false;
SETFLAGBIT(DF,false);
goto nextopcode;
case D_STD:
flags.df=true;
SETFLAGBIT(DF,true);
goto nextopcode;
case D_NOP:
goto nextopcode;
@ -357,63 +377,16 @@ l_M_Ed:
reg_bp=Pop_16();
goto nextopcode;
case D_DAA:
if (((reg_al & 0x0F)>0x09) || get_AF()) {
reg_al+=0x06;
flags.af=true;
} else {
flags.af=false;
}
flags.cf=get_CF();
if ((reg_al > 0x9F) || flags.cf) {
reg_al+=0x60;
flags.cf=true;
} else {
flags.cf=false;
}
flags.sf=(reg_al&0x80)>0;
flags.zf=(reg_al==0);
flags.type=t_UNKNOWN;
DAA();
goto nextopcode;
case D_DAS:
if (((reg_al & 0x0f) > 9) || get_AF()) {
reg_al-=6;
flags.af=true;
} else {
flags.af=false;
}
if ((reg_al>0x9f) || get_CF()) {
reg_al-=0x60;
flags.cf=true;
} else {
flags.cf=false;
}
flags.type=t_UNKNOWN;
DAS();
goto nextopcode;
case D_AAA:
if (get_AF() || ((reg_al & 0xf) > 9))
{
reg_al += 6;
reg_ah += 1;
flags.af=true;
flags.cf=true;
} else {
flags.af=false;
flags.cf=false;
}
reg_al &= 0x0F;
flags.type=t_UNKNOWN;
AAA();
goto nextopcode;
case D_AAS:
if (((reg_al & 0x0f)>9) || get_AF()) {
reg_ah--;
if (reg_al < 6) reg_ah--;
reg_al=(reg_al-6) & 0xF;
flags.af=flags.cf=true;
} else {
flags.af=flags.cf=false;
}
reg_al&=0xf;
flags.type=t_UNKNOWN;
AAS();
goto nextopcode;
default:
LOG(LOG_CPU|LOG_ERROR,"LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry);

View file

@ -13,7 +13,7 @@ static INLINE Bit8u Fetchb() {
IPPoint+=1;
return temp;
}
static INLINE Bit16u Fetchw() {
Bit16u temp=LoadMw(IPPoint);
IPPoint+=2;
@ -37,39 +37,50 @@ static INLINE Bit32s Fetchds() {
}
static INLINE void Push_16(Bit16u blah) {
reg_sp-=2;
SaveMw(SegBase(ss)+reg_sp,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);
}
}
static INLINE void Push_32(Bit32u blah) {
reg_sp-=4;
SaveMd(SegBase(ss)+reg_sp,blah);
};
static INLINE Bit16u Pop_16() {
Bit16u temp=LoadMw(SegBase(ss)+reg_sp);
reg_sp+=2;
return temp;
};
static INLINE Bit32u Pop_32() {
Bit32u temp=LoadMd(SegBase(ss)+reg_sp);
reg_sp+=4;
return temp;
};
#define Save_Flagsw(FLAGW) \
{ \
flags.type=t_UNKNOWN; \
flags.cf =(FLAGW & 0x001)>0;flags.pf =(FLAGW & 0x004)>0; \
flags.af =(FLAGW & 0x010)>0;flags.zf =(FLAGW & 0x040)>0; \
flags.sf =(FLAGW & 0x080)>0;flags.tf =(FLAGW & 0x100)>0; \
flags.intf =(FLAGW & 0x200)>0; \
flags.df =(FLAGW & 0x400)>0;flags.of =(FLAGW & 0x800)>0; \
flags.io =(FLAGW >> 12) & 0x03; \
flags.nt =(FLAGW & 0x4000)>0; \
if (cpu.state & STATE_STACK32) {
reg_esp-=4;
SaveMd(SegBase(ss)+reg_esp,blah);
} else {
reg_sp-=4;
SaveMd(SegBase(ss)+reg_sp,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;
}
}
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;
}
}
#if 0
if (flags.intf && PIC_IRQCheck) { \
SaveIP(); \

View file

@ -47,12 +47,12 @@ switch (inst.code.op) {
flags.type=inst.code.op;
break;
case t_INCb: case t_INCw: case t_INCd:
flags.cf=get_CF();
SETFLAGBIT(CF,get_CF());
inst.op1.d=flags.result.d=inst.op1.d+1;
flags.type=inst.code.op;
break;
case t_DECb: case t_DECw: case t_DECd:
flags.cf=get_CF();
SETFLAGBIT(CF,get_CF());
inst.op1.d=flags.result.d=inst.op1.d-1;
flags.type=inst.code.op;
break;
@ -170,150 +170,52 @@ switch (inst.code.op) {
/* Special instructions */
case O_IMULRw:
inst.op1.ds=inst.op1.ds*inst.op2.ds;
flags.type=t_MUL;
if ((inst.op1.ds> -32768) && (inst.op1.ds<32767)) {
flags.cf=false;flags.of=false;
} else {
flags.cf=true;flags.of=true;
}
DIMULW(inst.op1.ws,inst.op1.ws,inst.op2.ws,LoadD,SaveD);
break;
case O_IMULRd:
{
Bit64s res=(Bit64s)inst.op1.ds*(Bit64s)inst.op2.ds;
inst.op1.ds=(Bit32s)res;
flags.type=t_MUL;
if ((res>-((Bit64s)(2147483647)+1)) && (res<(Bit64s)2147483647)) {
flags.cf=false;flags.of=false;
} else {
flags.cf=true;flags.of=true;
}
break;
}
DIMULD(inst.op1.ds,inst.op1.ds,inst.op2.ds,LoadD,SaveD);
break;
case O_MULb:
flags.type=t_MUL;
reg_ax=reg_al*inst.op1.b;
flags.cf=flags.of=((reg_ax & 0xff00) !=0);
MULB(inst.op1.b,LoadD,0);
goto nextopcode;
case O_MULw:
{
Bit32u tempu=(Bit32u)reg_ax*(Bit32u)inst.op1.w;
reg_ax=(Bit16u)(tempu);
reg_dx=(Bit16u)(tempu >> 16);
flags.type=t_MUL;
flags.cf=flags.of=(reg_dx !=0);
goto nextopcode;
}
MULW(inst.op1.w,LoadD,0);
goto nextopcode;
case O_MULd:
{
Bit64u tempu=(Bit64u)reg_eax*(Bit64u)inst.op1.d;
reg_eax=(Bit32u)(tempu);
reg_edx=(Bit32u)(tempu >> 32);
flags.type=t_MUL;
flags.cf=flags.of=(reg_edx !=0);
goto nextopcode;
}
MULD(inst.op1.d,LoadD,0);
goto nextopcode;
case O_IMULb:
flags.type=t_MUL;
reg_ax=((Bit8s)reg_al)*inst.op1.bs;
flags.cf=flags.of=!((reg_ax & 0xff80)==0xff80 || (reg_ax & 0xff80)==0x0000);
IMULB(inst.op1.b,LoadD,0);
goto nextopcode;
case O_IMULw:
{
Bit32s temps=(Bit16s)reg_ax*inst.op1.ws;
reg_ax=(Bit16s)(temps);
reg_dx=(Bit16s)(temps >> 16);
flags.type=t_MUL;
flags.cf=flags.of=!((temps & 0xffffff80)==0xffffff80 || (temps & 0xffffff80)==0x0000);
goto nextopcode;
}
IMULW(inst.op1.w,LoadD,0);
goto nextopcode;
case O_IMULd:
{
Bit64s temps=(Bit64s)((Bit32s)reg_eax)*(Bit64s)inst.op1.ds;
reg_eax=(Bit32u)(temps);
reg_edx=(Bit32u)(temps >> 32);
flags.type=t_MUL;
if ( (reg_edx==0xffffffff) && (reg_eax & 0x80000000) ) {
flags.cf=flags.of=false;
} else if ( (reg_edx==0x00000000) && (reg_eax<0x80000000) ) {
flags.cf=flags.of=false;
} else {
flags.cf=flags.of=true;
}
goto nextopcode;
}
IMULD(inst.op1.d,LoadD,0);
goto nextopcode;
case O_DIVb:
{
if (!inst.op1.b) goto doint;
Bitu val=reg_ax;Bitu quo=val/inst.op1.b;
reg_ah=(Bit8u)(val % inst.op1.b);
reg_al=(Bit8u)quo;
if (quo!=reg_al) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
DIVB(inst.op1.b,LoadD,0);
goto nextopcode;
case O_DIVw:
{
if (!inst.op1.w) goto doint;
Bitu val=(reg_dx<<16)|reg_ax;Bitu quo=val/inst.op1.w;
reg_dx=(Bit16u)(val % inst.op1.w);
reg_ax=(Bit16u)quo;
if (quo!=reg_ax) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
DIVW(inst.op1.w,LoadD,0);
goto nextopcode;
case O_DIVd:
{
if (!inst.op1.d) goto doint;
Bit64u val=(((Bit64u)reg_edx)<<32)|reg_eax;
Bit64u quo=val/inst.op1.d;
reg_edx=(Bit32u)(val % inst.op1.d);
reg_eax=(Bit32u)quo;
if (quo!=(Bit64u)reg_eax) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
DIVD(inst.op1.d,LoadD,0);
goto nextopcode;
case O_IDIVb:
{
if (!inst.op1.b) goto doint;
Bits val=(Bit16s)reg_ax;Bits quo=val/inst.op1.bs;
reg_ah=(Bit8s)(val % inst.op1.bs);
reg_al=(Bit8s)quo;
if (quo!=(Bit8s)reg_al) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
IDIVB(inst.op1.b,LoadD,0);
goto nextopcode;
case O_IDIVw:
{
if (!inst.op1.w) goto doint;
Bits val=(Bit32s)((reg_dx<<16)|reg_ax);Bits quo=val/inst.op1.ws;
reg_dx=(Bit16u)(val % inst.op1.ws);
reg_ax=(Bit16s)quo;
if (quo!=(Bit16s)reg_ax) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
IDIVW(inst.op1.w,LoadD,0);
goto nextopcode;
case O_IDIVd:
{
if (!inst.op1.d) goto doint;
Bit64s val=(((Bit64u)reg_edx)<<32)|reg_eax;
Bit64s quo=val/inst.op1.ds;
reg_edx=(Bit32s)(val % inst.op1.ds);
reg_eax=(Bit32s)(quo);
if (quo!=(Bit64s)((Bit32s)reg_eax)) { inst.op1.b=0;goto doint;}
goto nextopcode;
}
IDIVD(inst.op1.d,LoadD,0);
goto nextopcode;
case O_AAM:
reg_ah=reg_al / inst.op1.b;
reg_al=reg_al % inst.op1.b;
flags.type=t_UNKNOWN;
flags.sf=(reg_ah & 0x80) > 0;
flags.zf=(reg_ax == 0);
//TODO PF
flags.pf=0;
AAM(inst.op1.b);
goto nextopcode;
case O_AAD:
reg_al=reg_ah*inst.op1.b+reg_al;
reg_ah=0;
flags.cf=(reg_al>=0x80);
flags.zf=(reg_al==0);
//TODO PF
flags.type=t_UNKNOWN;
AAD(inst.op1.b);
goto nextopcode;
case O_C_O: inst.cond=get_OF(); break;
@ -363,19 +265,37 @@ switch (inst.code.op) {
case O_SEGGS:
inst.code.extra=gs;
break;
case O_SEGSS:
inst.code.extra=ss;
break;
case O_LOOP:
if (--reg_cx) break;
if (inst.prefix & PREFIX_ADDR) {
if (--reg_ecx) break;
} else {
if (--reg_cx) break;
}
goto nextopcode;
case O_LOOPZ:
if (--reg_cx && get_ZF()) break;
if (inst.prefix & PREFIX_ADDR) {
if (--reg_ecx && get_ZF()) break;
} else {
if (--reg_cx && get_ZF()) break;
}
goto nextopcode;
case O_LOOPNZ:
if (--reg_cx && !get_ZF()) break;
if (inst.prefix & PREFIX_ADDR) {
if (--reg_ecx && !get_ZF()) break;
} else {
if (--reg_cx && !get_ZF()) break;
}
goto nextopcode;
case O_JCXZ:
if (reg_cx) goto nextopcode;
if (inst.prefix & PREFIX_ADDR) {
if (reg_ecx) goto nextopcode;
} else {
if (reg_cx) goto nextopcode;
}
break;
case O_XCHG_AX:
{
@ -391,16 +311,28 @@ switch (inst.code.op) {
inst.op1.d=temp;
break;
}
case O_CALL_N:
case O_CALLNw:
SaveIP();
Push_16(reg_ip);
break;
case O_CALL_F:
Push_16(SegValue(cs));
case O_CALLNd:
SaveIP();
Push_16(reg_ip);
Push_32(reg_eip);
break;
doint:
case O_CALLFw:
SaveIP();
CPU_CALL(false,inst.op2.d,inst.op1.d);
LoadIP();
goto nextopcode;
case O_CALLFd:
SaveIP();
CPU_CALL(true,inst.op2.d,inst.op1.d);
LoadIP();
goto nextopcode;
case O_JMPFw:
CPU_JMP(false,inst.op2.d,inst.op1.d);
LoadIP();
goto nextopcode;
case O_INT:
SaveIP();
#if C_DEBUG
@ -448,6 +380,95 @@ doint:
} else {
E_Exit("Too high CallBack Number %d called",inst.op1.d);
}
case O_GRP6w:
case O_GRP6d:
switch (inst.rm_index) {
case 0x02: /* LLDT */
CPU_LLDT(inst.op1.d);
goto nextopcode; /* Else value will saved */
default:
LOG(LOG_ERROR|LOG_CPU,"Group 6 Illegal subfunction %X",inst.rm_index);
}
break;
case O_GRP7w:
case O_GRP7d:
switch (inst.rm_index) {
case 0: /* SGDT */
{
Bitu limit,base;
CPU_SGDT(limit,base);
SaveMw(inst.rm_eaa,limit);
SaveMd(inst.rm_eaa+2,base);
break;
}
case 1: /* SIDT */
{
Bitu limit,base;
CPU_SIDT(limit,base);
SaveMw(inst.rm_eaa,limit);
SaveMd(inst.rm_eaa+2,base);
break;
}
case 2: /* LGDT */
CPU_LGDT(LoadMw(inst.rm_eaa),LoadMd(inst.rm_eaa+2)&((inst.code.op == O_GRP7w) ? 0xFFFFFF : 0xFFFFFFFF));
break;
case 3: /* LIDT */
CPU_LIDT(LoadMw(inst.rm_eaa),LoadMd(inst.rm_eaa+2)&((inst.code.op == O_GRP7w) ? 0xFFFFFF : 0xFFFFFFFF));
break;
case 4: /* SMSW */
{
Bitu word;CPU_SMSW(word);
SaveMw(inst.rm_eaa,word);
break;
}
case 6: /* LMSW */
{
Bitu word=LoadMw(inst.rm_eaa);
CPU_LMSW(word);
break;
}
default:
LOG(LOG_ERROR|LOG_CPU,"Group 7 Illegal subfunction %X",inst.rm_index);
}
break;
case O_M_Cd_Rd:
CPU_SET_CRX(inst.rm_index,inst.op1.d);
break;
case O_M_Rd_Cd:
inst.op1.d=CPU_GET_CRX(inst.rm_index);
break;
case O_LAR:
{
Bitu ar;CPU_LAR(inst.op1.d,ar);
inst.op2.d=ar;
}
break;
case O_BTd:
case O_BTSd:
case O_BTCd:
case O_BTRd:
{
Bitu val;PhysPt read;
Bitu mask=1 << (inst.op1.d & 31);
FILLFLAGS;
if (inst.rm<0xc0) {
read=inst.rm_eaa+4*(inst.op1.d / 32);
val=mem_readd(read);
} else {
val=reg_32(inst.rm_eai);
}
SETFLAGBIT(CF,(val&mask)>0);
if (inst.code.op==O_BTSd) val|=mask;
if (inst.code.op==O_BTRd) val&=~mask;
if (inst.code.op==O_BTCd) val^=mask;
if (inst.code.op==O_BTd) break;
if (inst.rm<0xc0) {
mem_writed(read,val);
} else {
reg_32(inst.rm_eai)=val;
}
}
break;
case 0:
break;
default:

View file

@ -80,15 +80,15 @@ static OpCode OpCodeTable[1024]={
/* 0x70 - 0x77 */
{L_Ibx ,O_C_O ,S_C_ADDIP,0 },{L_Ibx ,O_C_NO ,S_C_ADDIP,0 },
{L_Ibx ,O_C_B ,S_C_ADDIP,0 },{L_Ibx ,O_C_NB ,S_C_ADDIP,0 },
{L_Ibx ,O_C_Z ,S_C_ADDIP,0 },{L_Ibx ,O_C_NZ ,S_C_ADDIP,0 },
{L_Ibx ,O_C_BE ,S_C_ADDIP,0 },{L_Ibx ,O_C_NBE ,S_C_ADDIP,0 },
{L_Ibx ,O_C_O ,S_C_AIPw,0 },{L_Ibx ,O_C_NO ,S_C_AIPw,0 },
{L_Ibx ,O_C_B ,S_C_AIPw,0 },{L_Ibx ,O_C_NB ,S_C_AIPw,0 },
{L_Ibx ,O_C_Z ,S_C_AIPw,0 },{L_Ibx ,O_C_NZ ,S_C_AIPw,0 },
{L_Ibx ,O_C_BE ,S_C_AIPw,0 },{L_Ibx ,O_C_NBE ,S_C_AIPw,0 },
/* 0x78 - 0x7f */
{L_Ibx ,O_C_S ,S_C_ADDIP,0 },{L_Ibx ,O_C_NS ,S_C_ADDIP,0 },
{L_Ibx ,O_C_P ,S_C_ADDIP,0 },{L_Ibx ,O_C_NP ,S_C_ADDIP,0 },
{L_Ibx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 },{0 ,0 ,0 ,0 },
{0 ,O_BTw ,0 ,M_Ib },{0 ,O_BTSw ,0 ,M_Ib },
{0 ,O_BTRw ,0 ,M_Ib },{0 ,O_BTCw ,0 ,M_Ib },
},{ /* 0x0f Group 8 Ed */
{0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 },
{0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 },
{0 ,O_BTd ,0 ,M_Ib },{0 ,O_BTSd ,0 ,M_Ib },
{0 ,O_BTRd ,0 ,M_Ib },{0 ,O_BTCd ,0 ,M_Ib },

View file

@ -52,14 +52,14 @@ switch (inst.code.save) {
reg_32(inst.code.extra)=inst.op1.d;
break;
case S_SEGI:
SegSet16(inst.code.extra,inst.op1.w);
CPU_SetSegGeneral((SegNames)inst.code.extra,inst.op1.w);
break;
case S_SEGm:
SegSet16(inst.rm_index,inst.op1.w);
CPU_SetSegGeneral((SegNames)inst.rm_index,inst.op1.w);
break;
case S_SEGGw:
reg_16(inst.rm_index)=inst.op1.w;
SegSet16(inst.code.extra,inst.op2.w);
CPU_SetSegGeneral((SegNames)inst.code.extra,inst.op2.w);
break;
case S_PUSHw:
Push_16(inst.op1.w);
@ -68,19 +68,19 @@ switch (inst.code.save) {
Push_32(inst.op1.d);
break;
case S_C_ADDIP:
case S_C_AIPw:
if (!inst.cond) goto nextopcode;
case S_ADDIP:
case S_AIPw:
SaveIP();
reg_eip+=inst.op1.d;
reg_eip&=0xffff;
LoadIP();
break;
case S_CSIPIw:
reg_esp+=Fetchw();
case S_CSIP:
reg_eip=inst.op1.d;
SegSet16(cs,inst.op2.w);
case S_C_AIPd:
if (!inst.cond) goto nextopcode;
case S_AIPd:
SaveIP();
reg_eip+=inst.op1.d;
LoadIP();
break;
case S_IPIw:
@ -91,15 +91,13 @@ switch (inst.code.save) {
LoadIP();
break;
case S_FLGb:
flags.of =get_OF();
flags.type=t_UNKNOWN;
flags.cf =(inst.op1.d & 0x001)>0;flags.pf =(inst.op1.d & 0x004)>0;
flags.af =(inst.op1.d & 0x010)>0;flags.zf =(inst.op1.d & 0x040)>0;
flags.sf =(inst.op1.d & 0x080)>0;
SETFLAGSb(inst.op1.d);
break;
case S_FLGw:
case S_FLGd: //TODO Check full 32bit flags one day
Save_Flagsw(inst.op1.w);
SETFLAGSw(inst.op1.d);
break;
case S_FLGd:
SETFLAGSd(inst.op1.d);
break;
case 0:
break;

View file

@ -10,8 +10,9 @@
else si_base=SegBase(ds);
di_base=SegBase(es);
if (inst.prefix & PREFIX_ADDR) {
add_mask=0;
si_index=reg_esi;di_index=reg_edi;
add_mask=0xFFFFFFFF;
si_index=reg_esi;
di_index=reg_edi;
count=reg_ecx;
} else {
add_mask=0xFFFF;
@ -23,7 +24,7 @@
count=1;
}
add_index=flags.df ? -1 : 1;
add_index=GETFLAG(DF) ? -1 : 1;
if (count) switch (inst.code.op) {
case R_OUTSB:
for (;count>0;count--) {

View file

@ -25,8 +25,8 @@ enum {
L_PREOP,L_PREADD,L_PREREP,L_PREREPNE,
L_STRING,
L_IRETw,L_IRETd,
/* Direct ones */
D_IRETw,D_IRETd,
D_PUSHAw,D_PUSHAd,
D_POPAw,D_POPAd,
D_DAA,D_DAS,
@ -39,6 +39,9 @@ enum {
D_ENTERw,D_ENTERd,
D_LEAVEw,D_LEAVEd,
L_ERROR,
D_RETFw,D_RETFd,
D_RETFwIw,D_RETFdIw,
};
@ -48,12 +51,15 @@ enum {
O_XCHG_AX,O_XCHG_EAX,
O_IMULRw,O_IMULRd,
O_BOUNDw,O_BOUNDd,
O_CALL_N,O_CALL_F,
O_CALLNw,O_CALLNd,
O_CALLFw,O_CALLFd,
O_JMPFw,O_JMPFd,
O_OPAL,O_ALOP,
O_OPAX,O_AXOP,
O_OPEAX,O_EAXOP,
O_INT,
O_SEGDS,O_SEGES,O_SEGFS,O_SEGGS,
O_SEGDS,O_SEGES,O_SEGFS,O_SEGGS,O_SEGSS,
O_LOOP,O_LOOPZ,O_LOOPNZ,O_JCXZ,
O_INb,O_INw,O_INd,
O_OUTb,O_OUTw,O_OUTd,
@ -70,6 +76,18 @@ enum {
O_DSHRw,O_DSHRd,
O_C_O ,O_C_NO ,O_C_B ,O_C_NB ,O_C_Z ,O_C_NZ ,O_C_BE ,O_C_NBE,
O_C_S ,O_C_NS ,O_C_P ,O_C_NP ,O_C_L ,O_C_NL ,O_C_LE ,O_C_NLE,
O_GRP6w,O_GRP6d,
O_GRP7w,O_GRP7d,
O_M_Cd_Rd,O_M_Rd_Cd,
O_LAR,
O_BTw,O_BTSw,O_BTRw,O_BTCw,
O_BTd,O_BTSd,O_BTRd,O_BTCd,
O_BSFw,O_BSRw,
};
enum {
@ -87,12 +105,11 @@ enum {
S_SEGGw,S_SEGGd,
S_ADDIP,S_C_ADDIP,
S_AIPw,S_C_AIPw,
S_AIPd,S_C_AIPd,
S_FLGb,S_FLGw,S_FLGd,
S_IP,S_IPIw,
S_CSIP,S_CSIPIw,
};
enum {
@ -134,7 +151,7 @@ struct OpCode {
static struct {
Bitu entry;
Bitu entry_default;
Bit8u rm;
Bitu rm;
EAPoint rm_eaa;
Bitu rm_off;
Bitu rm_eai;
@ -150,7 +167,7 @@ static struct {
struct {
EAPoint base;
} seg;
bool cond;
Bitu cond;
bool repz;
Bitu prefix;
} inst;