// Extend Sign Half Word static bool extsh(PPCEmuAssembler& a, Instruction instr) { a.mov(a.eax, a.ppcgpr[instr.rS]); a.movsx(a.eax, a.eax.r16()); a.mov(a.ppcgpr[instr.rA], a.eax); if (instr.rc) { updateConditionRegister(a, a.eax, a.ecx, a.edx); } return true; }
static bool loadGeneric(PPCEmuAssembler& a, Instruction instr) { if ((flags & LoadZeroRA) && instr.rA == 0) { a.mov(a.ecx, 0u); } else { a.mov(a.ecx, a.ppcgpr[instr.rA]); } if (flags & LoadIndexed) { a.add(a.ecx, a.ppcgpr[instr.rB]); } else { a.add(a.ecx, sign_extend<16, int32_t>(instr.d)); } a.mov(a.zdx, a.zcx); a.add(a.zdx, a.membase); if (sizeof(Type) == 1) { a.mov(a.eax, 0); a.mov(a.eax.r8(), asmjit::X86Mem(a.zdx, 0)); } else if (sizeof(Type) == 2) { a.mov(a.eax, 0); a.mov(a.eax.r16(), asmjit::X86Mem(a.zdx, 0)); if (!(flags & LoadByteReverse)) { a.xchg(a.eax.r8Hi(), a.eax.r8Lo()); } } else if (sizeof(Type) == 4) { a.mov(a.eax, asmjit::X86Mem(a.zdx, 0)); if (!(flags & LoadByteReverse)) { a.bswap(a.eax); } } else if (sizeof(Type) == 8) { a.mov(a.zax, asmjit::X86Mem(a.zdx, 0)); if (!(flags & LoadByteReverse)) { a.bswap(a.zax); } } else { assert(0); } if (std::is_floating_point<Type>::value) { if (flags & LoadPairedSingles) { a.mov(a.ppcfprps[instr.rD][0], a.eax); a.mov(a.ppcfprps[instr.rD][1], a.eax); } else { assert(sizeof(Type) == 8); a.mov(a.ppcfpr[instr.rD], a.zax); } } else { if (flags & LoadSignExtend) { assert(sizeof(Type) == 2); a.movsx(a.eax, a.eax.r16()); } a.mov(a.ppcgpr[instr.rD], a.eax); } if (flags & LoadReserve) { a.mov(a.ppcreserve, 1u); a.mov(a.ppcreserveAddress, a.ecx); } if (flags & LoadUpdate) { a.mov(a.ppcgpr[instr.rA], a.ecx); } return true; }