/// <summary> /// Emits the given code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The destination operand.</param> /// <param name="src">The source operand.</param> public void Emit(OpCode opCode, Operand dest, Operand src) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); Debug.Assert(!(dest == null && src == null)); byte? modRM = null; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, src); if (modRM != null) { codeStream.WriteByte(modRM.Value); } // Add immediate bytes if (dest.IsConstant) WriteImmediate(dest); else if (dest.IsSymbol) WriteDisplacement(dest); else if (src != null && src.IsResolvedConstant) WriteImmediate(src); else if (src != null && (src.IsSymbol || src.IsStaticField)) WriteDisplacement(src); }
/// <summary> /// Emits the given code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The destination operand.</param> /// <param name="src">The source operand.</param> public void Emit(OpCode opCode, Operand dest, Operand src) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); if (dest == null && src == null) return; byte? sib = null, modRM = null; Operand displacement = null; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, src, out sib, out displacement); if (modRM != null) { codeStream.WriteByte(modRM.Value); if (sib.HasValue) codeStream.WriteByte(sib.Value); } // Add displacement to the code if (displacement != null) WriteDisplacement(displacement); // Add immediate bytes if (dest.IsConstant) WriteImmediate(dest); else if (dest.IsSymbol) WriteDisplacement(dest); else if (src != null && src.IsConstant) WriteImmediate(src); else if (src != null && src.IsSymbol) WriteDisplacement(src); }
/// <summary> /// Emits the specified op code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The destination operand.</param> public void Emit(OpCode opCode, Operand dest) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); byte? modRM = null; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, null); if (modRM != null) { codeStream.WriteByte(modRM.Value); } // Add immediate bytes if (dest.IsConstant) WriteImmediate(dest); else if (dest.IsSymbol) WriteDisplacement(dest); }
/// <summary> /// Emits the specified op code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The dest.</param> public void Emit(OpCode opCode, Operand dest) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); byte? sib = null, modRM = null; Operand displacement = null; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, null, out sib, out displacement); if (modRM != null) { codeStream.WriteByte(modRM.Value); if (sib.HasValue) codeStream.WriteByte(sib.Value); } // Add displacement to the code if (displacement != null) WriteDisplacement(displacement); }
/// <summary> /// Emits the given code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The dest.</param> /// <param name="src">The source.</param> /// <param name="third">The third.</param> public void Emit(OpCode opCode, Operand dest, Operand src, Operand third) { byte? sib = null, modRM = null; Operand displacement = null; // Write the opcode _codeStream.Write(opCode.Code, 0, opCode.Code.Length); if (dest == null && src == null) return; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, src, out sib, out displacement); if (modRM != null) { _codeStream.WriteByte(modRM.Value); if (sib.HasValue) _codeStream.WriteByte(sib.Value); } // Add displacement to the code if (displacement != null) WriteDisplacement(displacement); // Add immediate bytes if (third is ConstantOperand) WriteImmediate(third); }
/// <summary> /// Emits the given code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The dest.</param> /// <param name="src">The source.</param> /// <param name="third">The third.</param> public void Emit(OpCode opCode, Operand dest, Operand src, Operand third) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); Debug.Assert(!(dest == null && src == null)); byte? modRM = null; // Write the mod R/M byte modRM = CalculateModRM(opCode.RegField, dest, src); if (modRM != null) { codeStream.WriteByte(modRM.Value); } // Add immediate bytes if (third != null && third.IsConstant) WriteImmediate(third); }
/// <summary> /// Emits the specified op code. /// </summary> /// <param name="opCode">The op code.</param> public void Emit(OpCode opCode) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); }