code cleanup: clarify comparison against null (doesn't fix GCC warning

about type-punning though). remove two unused functions in fpu DH
dynamic core. add default clause to switch statements.
This commit is contained in:
Jonathan Campbell
2014-05-17 10:04:37 -07:00
parent 5dd614b622
commit d7f8157040
6 changed files with 44 additions and 67 deletions

View File

@@ -136,7 +136,7 @@ public:
addr&=4095;
if (host_readw(hostmem+addr)==(Bit16u)val) return;
host_writew(hostmem+addr,val);
if (!*(Bit16u*)&write_map[addr]) {
if ((*(Bit16u*)&write_map[addr]) == 0) {
if (active_blocks) return;
active_count--;
if (!active_count) Release();
@@ -156,7 +156,7 @@ public:
addr&=4095;
if (host_readd(hostmem+addr)==(Bit32u)val) return;
host_writed(hostmem+addr,val);
if (!*(Bit32u*)&write_map[addr]) {
if ((*(Bit32u*)&write_map[addr]) == 0) {
if (active_blocks) return;
active_count--;
if (!active_count) Release();
@@ -201,7 +201,7 @@ public:
}
addr&=4095;
if (host_readw(hostmem+addr)==(Bit16u)val) return false;
if (!*(Bit16u*)&write_map[addr]) {
if ((*(Bit16u*)&write_map[addr]) == 0) {
if (!active_blocks) {
active_count--;
if (!active_count) Release();
@@ -227,7 +227,7 @@ public:
}
addr&=4095;
if (host_readd(hostmem+addr)==(Bit32u)val) return false;
if (!*(Bit32u*)&write_map[addr]) {
if ((*(Bit32u*)&write_map[addr]) == 0) {
if (!active_blocks) {
active_count--;
if (!active_count) Release();

View File

@@ -955,9 +955,9 @@ static void dyn_fill_ea(bool addseg=true, DynReg * reg_ea=DREG(EA)) {
if (!decode.big_addr) {
Bits imm;
switch (decode.modrm.mod) {
case 0:imm=0;break;
case 1:imm=(Bit8s)decode_fetchb();break;
case 2:imm=(Bit16s)decode_fetchw();break;
case 1:imm=(Bit8s)decode_fetchb();break;
case 2:imm=(Bit16s)decode_fetchw();break;
default:imm=0;break;
}
DynReg * extend_src=reg_ea;
switch (decode.modrm.rm) {
@@ -1763,15 +1763,6 @@ static void dyn_closeblock(void) {
cache_closeblock();
}
static void dyn_normal_exit(BlockReturn code) {
gen_protectflags();
dyn_reduce_cycles();
dyn_set_eip_last();
dyn_save_critical_regs();
gen_return(code);
dyn_closeblock();
}
static void dyn_exit_link(Bits eip_change) {
gen_protectflags();
gen_dop_word_imm(DOP_ADD,decode.big_op,DREG(EIP),(decode.code-decode.code_start)+eip_change);
@@ -1826,29 +1817,33 @@ static void dyn_loop(LoopTypes type) {
Bit8u * branch1=0;Bit8u * branch2=0;
dyn_save_critical_regs();
switch (type) {
case LOOP_E:
gen_needflags();
branch1=gen_create_branch(BR_NZ);
break;
case LOOP_NE:
gen_needflags();
branch1=gen_create_branch(BR_Z);
break;
case LOOP_E:
gen_needflags();
branch1=gen_create_branch(BR_NZ);
break;
case LOOP_NE:
gen_needflags();
branch1=gen_create_branch(BR_Z);
break;
default:
break;
}
gen_protectflags();
switch (type) {
case LOOP_E:
case LOOP_NE:
case LOOP_NONE:
gen_sop_word(SOP_DEC,decode.big_addr,DREG(ECX));
gen_releasereg(DREG(ECX));
branch2=gen_create_branch(BR_Z);
break;
case LOOP_JCXZ:
gen_dop_word(DOP_OR,decode.big_addr,DREG(ECX),DREG(ECX));
gen_releasereg(DREG(ECX));
branch2=gen_create_branch(BR_NZ);
break;
case LOOP_E:
case LOOP_NE:
case LOOP_NONE:
gen_sop_word(SOP_DEC,decode.big_addr,DREG(ECX));
gen_releasereg(DREG(ECX));
branch2=gen_create_branch(BR_Z);
break;
case LOOP_JCXZ:
gen_dop_word(DOP_OR,decode.big_addr,DREG(ECX),DREG(ECX));
gen_releasereg(DREG(ECX));
branch2=gen_create_branch(BR_NZ);
break;
default:
break;
}
gen_lea(DREG(EIP),DREG(EIP),0,0,eip_base+eip_add);
gen_releasereg(DREG(EIP));
@@ -1940,17 +1935,6 @@ static void dyn_iret(void) {
dyn_closeblock();
}
static void dyn_interrupt(Bitu num) {
gen_protectflags();
dyn_flags_gen_to_host();
dyn_reduce_cycles();
dyn_set_eip_last_end(DREG(TMPW));
dyn_save_critical_regs();
gen_call_function((void*)&CPU_Interrupt,"%Id%Id%Drd",num,CPU_INT_SOFTWARE,DREG(TMPW));
gen_return_fast(BR_Normal);
dyn_closeblock();
}
static void dyn_add_iocheck(Bitu access_size) {
gen_call_function((void *)&CPU_IO_Exception,"%Dw%Id",DREG(EDX),access_size);
dyn_check_bool_exception_al();
@@ -1983,7 +1967,6 @@ static CacheBlock * CreateCacheBlock(CodePageHandler * codepage,PhysPt start,Bit
/* Init a load of variables */
decode.code_start=start;
decode.code=start;
Bitu cycles=0;
decode.page.code=codepage;
decode.page.index=start&4095;
decode.page.wmap=codepage->write_map;
@@ -2360,8 +2343,6 @@ restart_prefix:
//RET far Iw / Ret
case 0xca:dyn_ret_far(decode_fetchw());goto finish_block;
case 0xcb:dyn_ret_far(0);goto finish_block;
/* Interrupt */
// case 0xcd:dyn_interrupt(decode_fetchb());goto finish_block;
/* IRET */
case 0xcf:dyn_iret();goto finish_block;

View File

@@ -98,7 +98,6 @@ static void dyn_fpu_esc0(){
if (decode.modrm.val >= 0xc0) {
dyn_fpu_top();
Bitu group=(decode.modrm.val >> 3) & 7;
Bitu sub=(decode.modrm.val & 7);
switch (group){
case 0x00: //FADD ST,STi /
gen_call_function((void*)&FPU_FADD,"%Ddr%Ddr",DREG(TMPB),DREG(EA));
@@ -424,7 +423,6 @@ static void dyn_fpu_esc3(){
static void dyn_fpu_esc4(){
dyn_get_modrm();
Bitu group=(decode.modrm.val >> 3) & 7;
Bitu sub=(decode.modrm.val & 7);
if (decode.modrm.val >= 0xc0) {
dyn_fpu_top();
switch(group){

View File

@@ -314,8 +314,6 @@ static void dh_fpu_esc3(){
static void dh_fpu_esc4(){
dyn_get_modrm();
Bitu group=(decode.modrm.val >> 3) & 7;
Bitu sub=(decode.modrm.val & 7);
if (decode.modrm.val >= 0xc0) {
cache_addb(0xdc);
cache_addb(decode.modrm.val);
@@ -387,8 +385,6 @@ static void dh_fpu_esc5(){
static void dh_fpu_esc6(){
dyn_get_modrm();
Bitu group=(decode.modrm.val >> 3) & 7;
Bitu sub=(decode.modrm.val & 7);
if (decode.modrm.val >= 0xc0) {
cache_addb(0xde);
cache_addb(decode.modrm.val);

View File

@@ -979,7 +979,7 @@ static Bit8u * gen_create_branch_long(BranchTypes type) {
}
static void gen_fill_branch_long(Bit8u * data,Bit8u * from=cache.pos) {
*(Bit32u*)data=(from-data-4);
*((Bit32u*)data) = (from-data-4);
}
static Bit8u * gen_create_jump(Bit8u * to=0) {

View File

@@ -79,7 +79,7 @@ static void dyn_string(STRING_OP op) {
DynState rep_state;
dyn_savestate(&rep_state);
Bit8u * rep_start=cache.pos;
Bit8u * rep_ecx_jmp;
Bit8u * rep_ecx_jmp=NULL;
/* Check if ECX!=zero */
if (decode.rep) {
gen_dop_word(DOP_OR,decode.big_addr,DREG(ECX),DREG(ECX));
@@ -93,17 +93,19 @@ static void dyn_string(STRING_OP op) {
gen_lea(DREG(EA),si_base,DREG(ESI),0,0);
}
switch (op&3) {
case 0:dyn_read_byte(DREG(EA),tmp_reg,false);break;
case 1:dyn_read_word(DREG(EA),tmp_reg,false);break;
case 2:dyn_read_word(DREG(EA),tmp_reg,true);break;
case 0:dyn_read_byte(DREG(EA),tmp_reg,false);break;
case 1:dyn_read_word(DREG(EA),tmp_reg,false);break;
case 2:dyn_read_word(DREG(EA),tmp_reg,true);break;
}
switch (op) {
case STR_OUTSB:
gen_call_function((void*)&IO_WriteB,"%Id%Dl",DREG(EDX),tmp_reg);break;
case STR_OUTSW:
gen_call_function((void*)&IO_WriteW,"%Id%Dw",DREG(EDX),tmp_reg);break;
case STR_OUTSD:
gen_call_function((void*)&IO_WriteD,"%Id%Dd",DREG(EDX),tmp_reg);break;
case STR_OUTSB:
gen_call_function((void*)&IO_WriteB,"%Id%Dl",DREG(EDX),tmp_reg);break;
case STR_OUTSW:
gen_call_function((void*)&IO_WriteW,"%Id%Dw",DREG(EDX),tmp_reg);break;
case STR_OUTSD:
gen_call_function((void*)&IO_WriteD,"%Id%Dd",DREG(EDX),tmp_reg);break;
default:
break;
}
}
if (usedi) {