private static byte?CalculateRexPrefix(InstructionDefinition def, Operand op1, Operand op2) { var rexB = GetRexBit(op1); var rexR = GetRexBit(op2); if (def.W || rexB || rexR) { var rex = 0b01000000; if (rexB) { rex |= 0b00000001; } // SIB index //if (rexX) //{ // rex |= 0b00000010; //} if (rexR) { rex |= 0b00000100; } if (def.W) { rex |= 0b00001000; } return((byte)rex); } return(null); }
private static bool Matches(InstructionDefinition definition, Instruction instruction) { if (definition.Operands.Length != instruction.Operands.Length) { return(false); } return(instruction.Operands .Zip(definition.Operands, (op, def) => (op, def)) .All(((Operand op, OperandDefinition opDef)tuple) => OperandMatches(tuple.opDef, tuple.op))); }