From a6db12b48f2afd8f2a44eb56feb79be531ff6b3f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 26 May 2013 17:19:13 -0700 Subject: [PATCH] ldx/ldux. --- src/xenia/cpu/ppc/disasm_memory.cc | 14 ++++++++---- src/xenia/cpu/x64/x64_emit_memory.cc | 32 ++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/xenia/cpu/ppc/disasm_memory.cc b/src/xenia/cpu/ppc/disasm_memory.cc index 4ac138a57..ec0bd87ac 100644 --- a/src/xenia/cpu/ppc/disasm_memory.cc +++ b/src/xenia/cpu/ppc/disasm_memory.cc @@ -81,13 +81,19 @@ XEDISASMR(ldu, 0xE8000001, DS )(InstrData& i, InstrDisasm& d) { } XEDISASMR(ldux, 0x7C00006A, X )(InstrData& i, InstrDisasm& d) { - XEINSTRNOTIMPLEMENTED(); - return 1; + d.Init("ldux", "Load Doubleword with Update Indexed", 0); + d.AddRegOperand(InstrRegister::kGPR, i.X.RT, InstrRegister::kWrite); + d.AddRegOperand(InstrRegister::kGPR, i.X.RA, InstrRegister::kReadWrite); + d.AddRegOperand(InstrRegister::kGPR, i.X.RB, InstrRegister::kRead); + return d.Finish(); } XEDISASMR(ldx, 0x7C00002A, X )(InstrData& i, InstrDisasm& d) { - XEINSTRNOTIMPLEMENTED(); - return 1; + d.Init("ldx", "Load Doubleword Indexed", 0); + d.AddRegOperand(InstrRegister::kGPR, i.X.RT, InstrRegister::kWrite); + d.AddRegOperand(InstrRegister::kGPR, i.X.RA, InstrRegister::kRead); + d.AddRegOperand(InstrRegister::kGPR, i.X.RB, InstrRegister::kRead); + return d.Finish(); } XEDISASMR(lha, 0xA8000000, D )(InstrData& i, InstrDisasm& d) { diff --git a/src/xenia/cpu/x64/x64_emit_memory.cc b/src/xenia/cpu/x64/x64_emit_memory.cc index b53cd3015..8fcfccea7 100644 --- a/src/xenia/cpu/x64/x64_emit_memory.cc +++ b/src/xenia/cpu/x64/x64_emit_memory.cc @@ -132,13 +132,37 @@ XEEMITTER(ldu, 0xE8000001, DS )(X64Emitter& e, X86Compiler& c, InstrDat } XEEMITTER(ldux, 0x7C00006A, X )(X64Emitter& e, X86Compiler& c, InstrData& i) { - XEINSTRNOTIMPLEMENTED(); - return 1; + // EA <- (RA) + (RB) + // RT <- MEM(EA, 8) + // RA <- EA + + GpVar ea(c.newGpVar()); + c.mov(ea, e.gpr_value(i.X.RA)); + c.add(ea, e.gpr_value(i.X.RB)); + e.update_gpr_value(i.X.RA, ea); + GpVar v = e.ReadMemory(i.address, ea, 8, false); + e.update_gpr_value(i.X.RT, v); + + return 0; } XEEMITTER(ldx, 0x7C00002A, X )(X64Emitter& e, X86Compiler& c, InstrData& i) { - XEINSTRNOTIMPLEMENTED(); - return 1; + // if RA = 0 then + // b <- 0 + // else + // b <- (RA) + // EA <- b + (RB) + // RT <- MEM(EA, 8) + + GpVar ea(c.newGpVar()); + c.mov(ea, e.gpr_value(i.X.RB)); + if (i.X.RA) { + c.add(ea, e.gpr_value(i.X.RA)); + } + GpVar v = e.ReadMemory(i.address, ea, 8, false); + e.update_gpr_value(i.X.RT, v); + + return 0; } XEEMITTER(lha, 0xA8000000, D )(X64Emitter& e, X86Compiler& c, InstrData& i) {