/// <summary> /// Computes the opcode. /// </summary> /// <param name="destination">The destination operand.</param> /// <param name="source">The source operand.</param> /// <param name="third">The third operand.</param> /// <returns></returns> protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third) { if (destination.IsRegister) return R_RM; if (destination.IsMemoryAddress) return RM_R; throw new ArgumentException(@"No opcode for operand type. [" + destination.GetType() + ", " + source.GetType() + ")"); }
/// <summary> /// Computes the opcode. /// </summary> /// <param name="destination">The destination operand.</param> /// <param name="source">The source operand.</param> /// <param name="third">The third operand.</param> /// <returns></returns> protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third) { if (!(destination.IsRegister)) throw new ArgumentException(@"Destination must be RegisterOperand.", @"destination"); if (source.IsConstant) throw new ArgumentException(@"Source must not be ConstantOperand.", @"source"); if (source.IsByte || source.IsBoolean) { if (destination.IsRegister && source.IsRegister) return R_X8; if (destination.IsRegister && source.IsMemoryAddress) return R_X8; } if (source.IsShort || source.IsChar) { if (destination.IsRegister && source.IsRegister) return R_X16; if (destination.IsRegister && source.IsMemoryAddress) return R_X16; } throw new ArgumentException(@"No opcode for operand type. [" + destination.GetType() + ", " + source.GetType() + ")"); }
/// <summary> /// Computes the opcode. /// </summary> /// <param name="destination">The destination operand.</param> /// <param name="source">The source operand.</param> /// <param name="third">The third operand.</param> /// <returns></returns> protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third) { if (!(destination.IsRegister)) throw new ArgumentException(@"Destination must be RegisterOperand.", @"destination"); if (source.IsConstant) throw new ArgumentException(@"Source must not be ConstantOperand.", @"source"); switch (source.Type.Type) { case CilElementType.Boolean: goto case CilElementType.I1; case CilElementType.U1: goto case CilElementType.I1; case CilElementType.I1: { if ((destination.IsRegister) && (source.IsRegister)) return R_X8; if ((destination.IsRegister) && (source.IsMemoryAddress)) return R_X8; } break; case CilElementType.Char: goto case CilElementType.U2; case CilElementType.U2: goto case CilElementType.I2; case CilElementType.I2: if ((destination.IsRegister) && (source.IsRegister)) return R_X16; if ((destination.IsRegister) && (source.IsMemoryAddress)) return R_X16; break; default: break; } throw new ArgumentException(@"No opcode for operand type. [" + destination.GetType() + ", " + source.GetType() + ")"); }
/// <summary> /// Computes the opcode. /// </summary> /// <param name="destination">The destination operand.</param> /// <param name="source">The source operand.</param> /// <param name="third">The third operand.</param> /// <returns></returns> protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third) { if ((destination.IsCPURegister) && (source.IsCPURegister)) return R; throw new ArgumentException(@"No opcode for operand type. [" + destination.GetType() + ", " + source.GetType() + ")"); }