Moved more variables into cpu_state structure.

This commit is contained in:
SarahW 2016-08-21 21:28:23 +01:00
commit eb126fd822
50 changed files with 1454 additions and 1481 deletions

View file

@ -473,17 +473,15 @@ void codegen_block_end_recompile(codeblock_t *block)
if (codegen_block_cycles)
{
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
addbyte(0x2c);
addbyte(0x25);
addlong((uint32_t)&cycles);
addbyte(0x6d);
addbyte(cpu_state_offset(_cycles));
addlong((uint32_t)codegen_block_cycles);
}
if (codegen_block_ins)
{
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
addbyte(0x04);
addbyte(0x25);
addlong((uint32_t)&cpu_recomp_ins);
addbyte(0x45);
addbyte(cpu_state_offset(cpu_recomp_ins));
addlong(codegen_block_ins);
}
#if 0
@ -612,7 +610,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
{
addbyte(0xC7); /*MOVL $0,(ssegs)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
addlong((fetchdat >> 8) & 0xffff);
(*op_pc) += 2;
}
@ -722,7 +720,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
}
addbyte(0x89); /*MOV eaaddr, EAX*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
if (mod1seg[cpu_rm] == &ss && !op_ssegs)
op_ea_seg = &_ss;
@ -877,7 +875,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
addbyte(0x89); /*MOV eaaddr, EAX*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
}
else
{
@ -888,7 +886,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
new_eaaddr = fastreadl(cs + (*op_pc) + 1);
addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
addlong(new_eaaddr);
(*op_pc) += 4;
return op_ea_seg;
@ -919,14 +917,14 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
}
addbyte(0x89); /*MOV eaaddr, EAX*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
}
else
{
addbyte(0x44); /*MOV eaaddr, base_reg*/
addbyte(0x89);
addbyte(0x45 | (base_reg << 3));
addbyte((uintptr_t)&cpu_state.eaaddr - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(eaaddr));
}
}
return op_ea_seg;
@ -1074,7 +1072,7 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t
}
fetchdat = fastreadl(cs + op_pc);
codegen_timing_prefix(opcode, fetchdat);
if (abrt)
if (cpu_state.abrt)
return;
opcode = fetchdat & 0xff;
if (!pc_off)
@ -1095,18 +1093,16 @@ generate_call:
if (codegen_block_cycles)
{
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
addbyte(0x2c);
addbyte(0x25);
addlong((uint32_t)&cycles);
addbyte(0x6d);
addbyte(cpu_state_offset(_cycles));
addlong((uint32_t)codegen_block_cycles);
codegen_block_cycles = 0;
}
if (codegen_block_ins)
{
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
addbyte(0x04);
addbyte(0x25);
addlong((uint32_t)&cpu_recomp_ins);
addbyte(0x45);
addbyte(cpu_state_offset(cpu_recomp_ins));
addlong(codegen_block_ins);
codegen_block_ins = 0;
}
@ -1147,7 +1143,7 @@ generate_call:
last_ssegs = op_ssegs;
addbyte(0xC6); /*MOVB $0,(ssegs)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.ssegs - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(ssegs));
addbyte(op_ssegs);
}
//#if 0
@ -1166,7 +1162,7 @@ generate_call:
addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.rm_data.rm_mod_reg_data - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(rm_data.rm_mod_reg_data));
addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16));
op_pc += pc_off;
@ -1182,25 +1178,25 @@ generate_call:
// last_ea_seg = op_ea_seg;
addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.ea_seg - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(ea_seg));
addlong((uint32_t)op_ea_seg);
}
addbyte(0xC7); /*MOVL [pc],new_pc*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.pc - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(pc));
addlong(op_pc + pc_off);
addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.oldpc - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(oldpc));
addlong(old_pc);
if (op_32 != last_op32)
{
last_op32 = op_32;
addbyte(0xC7); /*MOVL $use32,(op32)*/
addbyte(0x45);
addbyte((uintptr_t)&cpu_state.op32 - (uintptr_t)&cpu_state);
addbyte(cpu_state_offset(op32));
addlong(op_32);
}
@ -1221,15 +1217,4 @@ generate_call:
codegen_endpc = (cs + cpu_state.pc) + 8;
}
void codegen_check_abrt()
{
codeblock_t *block = &codeblock[block_current];
// pclog("Generate check abrt at %08X\n", &codeblock[block_current][block_pos]);
addbyte(0xf7); addbyte(0x04); /*TESTL $-1, (abrt)*/
addbyte(0x25);
addlong((uint32_t)&abrt); addlong(0xffffffff);
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
}
#endif