/// <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> internal void Emit(LegacyOpCode opCode, Operand dest, Operand src) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); Debug.Assert(!(dest == null && src == null)); // Write the mod R/M byte 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?.IsResolvedConstant == true) { 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 dest.</param> /// <param name="src">The source.</param> /// <param name="third">The third.</param> internal void Emit(LegacyOpCode opCode, Operand dest, Operand src, Operand third) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); Debug.Assert(!(dest == null && src == null)); // Write the mod R/M byte byte?modRM = CalculateModRM(opCode.RegField, dest, src); if (modRM != null) { codeStream.WriteByte(modRM.Value); } // Add immediate bytes if (third?.IsConstant == true) { WriteImmediate(third); } }
/// <summary> /// Emits the specified op code. /// </summary> /// <param name="opCode">The op code.</param> /// <param name="dest">The destination operand.</param> internal void Emit(LegacyOpCode opCode, Operand dest) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); // Write the mod R/M byte 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> internal void Emit(LegacyOpCode opCode) { // Write the opcode codeStream.Write(opCode.Code, 0, opCode.Code.Length); }