Skip to content

Commit

Permalink
cleaner way to do vm rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
GliGli committed Oct 18, 2012
1 parent 8b3af3f commit fdce2c0
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions source/r4300/ppc/MIPS-to-PPC.c
Expand Up @@ -3931,21 +3931,25 @@ static int genCallDynaMemVM(int rs_reg, int rt_reg, memType type, int immed){

void * rewriteDynaMemVM(void* fault_addr)
{
// enabling slow access by noping out the mem access code and the jump over slow access code
// enabling slow access by adding a jump from the fault address to the slow mem access code

PowerPC_instr * cur_op=(PowerPC_instr*)fault_addr;

while((*cur_op>>PPC_OPCODE_SHIFT)!=PPC_OPCODE_B || (*cur_op&1)!=0)
PowerPC_instr * fault_op=(PowerPC_instr*)fault_addr;

PowerPC_instr * op=fault_op;

while((*op>>PPC_OPCODE_SHIFT)!=PPC_OPCODE_B || (*op&1)!=0)
{
*cur_op=PPC_NOP;
++cur_op;
++op;
}

// branch op
*cur_op=PPC_NOP;
++cur_op;

memicbi(fault_addr,(unsigned int)cur_op-(unsigned int)fault_addr);
++op;

PowerPC_instr * first_slow_op=op;

GEN_B(*fault_op,first_slow_op-fault_op,0,0);

memicbi(fault_op,4);

return cur_op;
return first_slow_op;
}

0 comments on commit fdce2c0

Please sign in to comment.