/// <summary> /// Emits the given code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="result">The destination operand.</param> /// <param name="leftOperand">The source operand.</param> /// <param name="rightOperand">The third operand.</param> public void Emit(OpCode opCode, Operand result, Operand leftOperand, Operand rightOperand) { byte? sib = null, modRM = null; MemoryOperand displacement = null; // Write the opcode _codeStream.Write (opCode.Code, 0, opCode.Code.Length); if (null == result && null == leftOperand) return; // Write the mod R/M byte modRM = CalculateModRM (opCode.RegField, result, leftOperand, out sib, out displacement); if (null != modRM) { _codeStream.WriteByte (modRM.Value); if (sib.HasValue) { _codeStream.WriteByte (sib.Value); } } // Add displacement to the code if (null != displacement) WriteDisplacement (displacement); // Add immediate bytes if (rightOperand is ConstantOperand) WriteImmediate (rightOperand); }
/// <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) { byte? sib, modRM; MemoryOperand displacement; // Write the opcode _codeStream.Write (opCode.Code, 0, opCode.Code.Length); if (null == dest && null == src) return; // Write the mod R/M byte modRM = CalculateModRM (opCode.RegField, dest, src, out sib, out displacement); if (null != modRM) { _codeStream.WriteByte (modRM.Value); if (sib.HasValue) { _codeStream.WriteByte (sib.Value); } } // Add displacement to the code if (null != displacement) WriteDisplacement (displacement); // Add immediate bytes if (dest is ConstantOperand) WriteImmediate (dest); if (src is ConstantOperand) WriteImmediate (src); }
/// <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; MemoryOperand 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 specified op code. /// </summary> /// <param name="dest">The dest.</param> /// <param name="src">The SRC.</param> /// <param name="opCode">The op code.</param> public void Emit(Operand dest, Operand src, OpCode opCode) { Emit (opCode.Code, opCode.RegField, dest, src); }
public void Emit(OpCode opCode, Operand dest) { byte? sib, modRM; Operand displacement; // Write the opcode _codeStream.Write(opCode.Code, 0, opCode.Code.Length); // 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); } }