Remove test-USE32-and-mask-PC operation following code block execution. Instead, ensure that all recompiled instructions mask PC correctly.

This commit is contained in:
SarahW 2019-01-27 20:54:22 +00:00
commit ee186dbb0d
3 changed files with 79 additions and 46 deletions

View file

@ -12,22 +12,30 @@
uint32_t ropJMP_r8(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
{
uint32_t offset = (int32_t)(int8_t)fastreadb(cs + op_pc);
uint32_t dest_addr = op_pc+1+offset;
uop_MOV_IMM(ir, IREG_pc, op_pc+1+offset);
if (!(op_32 & 0x100))
dest_addr &= 0xffff;
uop_MOV_IMM(ir, IREG_pc, dest_addr);
return -1;
}
uint32_t ropJMP_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
{
uint32_t offset = (int32_t)(int16_t)fastreadw(cs + op_pc);
uint32_t dest_addr = op_pc+2+offset;
dest_addr &= 0xffff;
uop_MOV_IMM(ir, IREG_pc, op_pc+2+offset);
uop_MOV_IMM(ir, IREG_pc, dest_addr);
return -1;
}
uint32_t ropJMP_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
{
uint32_t offset = fastreadl(cs + op_pc);
uop_MOV_IMM(ir, IREG_pc, op_pc+4+offset);
uint32_t dest_addr = op_pc+4+offset;
uop_MOV_IMM(ir, IREG_pc, dest_addr);
return -1;
}
@ -65,6 +73,8 @@ uint32_t ropCALL_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
uint16_t dest_addr = ret_addr + offset;
int sp_reg;
dest_addr &= 0xffff;
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
sp_reg = LOAD_SP_WITH_OFFSET(ir, -2);
uop_MEM_STORE_IMM_16(ir, IREG_SS_base, sp_reg, ret_addr);