bool operator()(X86_Bit Bit, Instruction& rInsn, Operand* pOprd) { static OperandReg16<Reg16> OpReg16; static OperandReg32<Reg32> OpReg32; static OperandReg64<Reg64> OpReg64; bool Res = false; switch (Bit) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) { Res = OpReg32(pOprd); pOprd->Type() |= O_MEM32; break; } else { Res = OpReg16(pOprd); pOprd->Type() |= O_MEM16; break; } case X86_Bit_64: if ((rInsn.GetPrefix() & X86_Prefix_REX_w) == X86_Prefix_REX_w) { Res = OpReg64(pOprd); pOprd->Type() |= O_MEM64; break; } case X86_Bit_32: if (rInsn.GetPrefix() & X86_Prefix_OpSize) { Res = OpReg16(pOprd); pOprd->Type() |= O_MEM16; break; } else { Res = OpReg32(pOprd); pOprd->Type() |= O_MEM32; break; } default: return false; } return Res; }
bool operator()(BinaryStream const& rBinStrm, X86_Bit Bit, TOffset Offset, Instruction& rInsn, Operand* pOprd) { OperandIw OpIw; OperandId OpId; switch (Bit) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpId(rBinStrm, Offset, rInsn, pOprd); else return OpIw(rBinStrm, Offset, rInsn, pOprd); case X86_Bit_32: case X86_Bit_64: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpIw(rBinStrm, Offset, rInsn, pOprd); else return OpId(rBinStrm, Offset, rInsn, pOprd); default: return false; } }
bool X86Architecture::Decode_Ap(BinaryStream const& rBinStrm, TOffset Offset, Instruction& rInsn, Operand* pOprd) { OperandLogicAddr16 OpLogicAddr16; OperandLogicAddr32 OpLogicAddr32; switch (static_cast<X86_Bit>(m_Cfg.Get("Bit"))) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpLogicAddr32(rBinStrm, Offset, pOprd); else return OpLogicAddr16(rBinStrm, Offset, pOprd); case X86_Bit_32: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpLogicAddr16(rBinStrm, Offset, pOprd); else return OpLogicAddr32(rBinStrm, Offset, pOprd); default: return false; } }
bool operator()(X86_Bit Bit, Instruction& rInsn, Operand* pOprd) { OperandReg16<Reg16> OpReg16; OperandReg32<Reg32> OpReg32; switch (Bit) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpReg32(pOprd); else return OpReg16(pOprd); case X86_Bit_32: case X86_Bit_64: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpReg16(pOprd); else return OpReg32(pOprd); default: return false; } }
bool operator()(BinaryStream const& rBinStrm, X86_Bit Bit, TOffset Offset, Instruction& rInsn, Operand* pOprd) { OperandOw OpOw; OperandOd OpOd; OperandOq OpOq; switch (Bit) { case X86_Bit_16: if (!OpOw(rBinStrm, Offset, rInsn, pOprd)) return false; break; case X86_Bit_32: if (!OpOd(rBinStrm, Offset, rInsn, pOprd)) return false; break; case X86_Bit_64: if (!OpOq(rBinStrm, Offset, rInsn, pOprd)) return false; break; default: return false; } u32 Mem = O_NONE; switch (Bit) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) Mem = O_MEM32; else Mem = O_MEM16; break; case X86_Bit_64: if ((rInsn.GetPrefix() & X86_Prefix_REX_w) == X86_Prefix_REX_w) { Mem = O_MEM64; break; } case X86_Bit_32: if (rInsn.GetPrefix() & X86_Prefix_OpSize) Mem = O_MEM16; else Mem = O_MEM32; break; default: break; } pOprd->Type() |= Mem; return true; }
bool operator()(BinaryStream const& rBinStrm, X86_Bit Bit, TOffset Offset, Instruction& rInsn, Operand* pOprd) { static OperandJw OpJw; static OperandJd OpJd; static OperandJqs OpJqs; switch (Bit) { case X86_Bit_16: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpJd(rBinStrm, Offset, rInsn, pOprd); else return OpJw(rBinStrm, Offset, rInsn, pOprd); case X86_Bit_32: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpJw(rBinStrm, Offset, rInsn, pOprd); else return OpJd(rBinStrm, Offset, rInsn, pOprd); case X86_Bit_64: if (rInsn.GetPrefix() & X86_Prefix_OpSize) return OpJw(rBinStrm, Offset, rInsn, pOprd); else return OpJqs(rBinStrm, Offset, rInsn, pOprd); default: return false; } }
bool X86Architecture::Decode_Dy(BinaryStream const& rBinStrm, TOffset Offset, Instruction& rInsn, Operand* pOprd) { static u16 aReg [] = { X86_Reg_Dr0, X86_Reg_Dr1, X86_Reg_Dr2, X86_Reg_Dr3, X86_Reg_Dr4, X86_Reg_Dr5, X86_Reg_Dr6, X86_Reg_Dr7 }; static u16 aRegR[] = { X86_Reg_Dr8, X86_Reg_Dr9, X86_Reg_Dr10, X86_Reg_Dr11, X86_Reg_Dr12, X86_Reg_Dr13, X86_Reg_Dr14, X86_Reg_Dr15 }; x86::ModRM ModRm = GetModRm(rBinStrm, Offset); pOprd->Type() |= static_cast<X86_Bit>(m_Cfg.Get("Bit")) == X86_Bit_64 ? O_REG64 : O_REG32; if (rInsn.GetPrefix() & X86_Prefix_REX_r) pOprd->Reg() = aRegR[ModRm.Reg()]; else pOprd->Reg() = aReg[ModRm.Reg()]; return true; }