• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Framework.Operand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mosa.Compiler.Framework.Operand的典型用法代码示例。如果您正苦于以下问题:C# Operand类的具体用法?C# Operand怎么用?C# Operand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Operand类属于Mosa.Compiler.Framework命名空间,在下文中一共展示了Operand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ComputeOpCode

        /// <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 (source.IsMemoryAddress && third.IsRegister)
            {
                if (source.IsByte || third.IsByte)
                    return M_R_8;
                if (source.IsChar || third.IsChar)
                    return M_R_16;
                if (source.IsShort || third.IsShort)
                    return M_R_16;
                return M_R;
            }

            if (source.IsRegister && third.IsRegister) return R_R;

            if (source.IsMemoryAddress && third.IsConstant) return M_C;

            if (source.IsRegister && third.IsConstant)
            {
                if (third.IsByte || source.IsByte)
                    return R_C_8;
                if (third.IsChar || source.IsChar)
                    return R_C_16;
                if (third.IsShort || source.IsShort)
                    return R_C_16;
                return R_C;
            }

            throw new ArgumentException(String.Format(@"x86.Test: No opcode for operand types {0} and {1}.", source, third));
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:37,代码来源:Test.cs


示例2: ComputeOpCode

        /// <summary>
        /// Computes the opcode.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <param name="destination">The destination operand.</param>
        /// <param name="source">The source operand.</param>
        /// <returns></returns>
        /// <exception cref="NotImplementCompilerException"></exception>
        private OpCode ComputeOpCode(InstructionSize size, Operand destination, Operand source)
        {
            Debug.Assert(destination.IsConstant || destination.IsCPURegister);
            Debug.Assert(size != InstructionSize.None);
            Debug.Assert(size != InstructionSize.Native);

            //size = BaseMethodCompilerStage.GetInstructionSize(size, destination);

            if (destination.IsCPURegister)
            {
                if (size == InstructionSize.Size8)
                    return R_8;

                if (size == InstructionSize.Size16)
                    return R_16;

                return R_32;
            }

            if (destination.IsConstant)
            {
                if (size == InstructionSize.Size8)
                    return C_8;

                if (size == InstructionSize.Size16)
                    return C_16;

                return C_32;
            }

            throw new NotImplementCompilerException();
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:40,代码来源:In.cs


示例3: ComputeOpCode

 /// <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 ((source.IsRegister) && (third.IsRegister)) return opcode;
     if ((source.IsRegister) && (third.IsMemoryAddress)) return opcode;
     if ((source.IsRegister) && (third.IsConstant)) return opcode;
     throw new ArgumentException(@"No opcode for operand type.");
 }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:14,代码来源:Comiss.cs


示例4: ComputeOpCode

        /// <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() + ")");
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:38,代码来源:Movsx.cs


示例5: EmitConstant

        /// <summary>
        /// This function emits a constant variable into the read-only data section.
        /// </summary>
        /// <param name="op">The operand to emit as a constant.</param>
        /// <returns>An operand, which represents the reference to the read-only constant.</returns>
        /// <remarks>
        /// This function checks if the given operand needs to be moved into the read-only data
        /// section of the executable. For x86 this concerns only floating point operands, as these
        /// can't be specified in inline assembly.<para/>
        /// This function checks if the given operand needs to be moved and rewires the operand, if
        /// it must be moved.
        /// </remarks>
        protected Operand EmitConstant(Operand cop)
        {
            if (!cop.IsConstant)
                return cop;

            if (!(cop.StackType == StackTypeCode.F || cop.StackType == StackTypeCode.Int64))
                return cop;

            int size, alignment;
            architecture.GetTypeRequirements(cop.Type, out size, out alignment);

            string name = String.Format("C_{0}", Guid.NewGuid());
            using (Stream stream = methodCompiler.Linker.Allocate(name, SectionKind.ROData, size, alignment))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    switch (cop.Type.Type)
                    {
                        case CilElementType.R4: writer.Write((float)cop.Value); break;
                        case CilElementType.R8: writer.Write((double)cop.Value); break;
                        case CilElementType.I8: writer.Write((long)cop.Value); break;
                        case CilElementType.U8: writer.Write((ulong)cop.Value); break;
                        default: throw new NotSupportedException();
                    }
                }
            }
            // FIXME: Attach the label operand to the linker symbol
            // FIXME: Rename the operand to SymbolOperand
            // FIXME: Use the provided name to link
            return Operand.CreateLabel(cop.Type, name);
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:43,代码来源:BaseTransformationStage.cs


示例6: Emit

        /// <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);
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:40,代码来源:MachineCodeEmitter.cs


示例7: ComputeOpCode

        /// <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 && third.IsConstant) return R_C;
            if (destination.IsCPURegister && third.IsCPURegister) return R_R;

            throw new ArgumentException(@"No opcode for operand type.");
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:14,代码来源:Add.cs


示例8: ComputeOpCode

        /// <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() + ")");
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:14,代码来源:Movsd.cs


示例9: ComputeOpCode

 /// <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 (third.IsConstant)
         return RM_C;
     else
         return RM_R;
 }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:14,代码来源:Btr.cs


示例10: ComputeOpCode

        /// <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.Register is ControlRegister) return CR_R;
            if (source.Register is ControlRegister) return R_CR;

            throw new ArgumentException(@"No opcode for operand type. [" + destination + ", " + source + ")");
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:14,代码来源:MovCR.cs


示例11: ComputeOpCode

        /// <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 (source.Type.Type == CilElementType.R4) return DIVSS;
            return opcode;

            //return DIVSD;
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:14,代码来源:DivSS.cs


示例12: GetMove

 public static X86Instruction GetMove(Operand Destination, Operand Source)
 {
     if (Source.IsR8 && Destination.IsR8)
     {
         return X86.Movsd;
     }
     else if (Source.IsR4 && Destination.IsR4)
     {
         return X86.Movss;
     }
     else if (Source.IsR4 && Destination.IsR8)
     {
         return X86.Cvtss2sd;
     }
     else if (Source.IsR8 && Destination.IsR4)
     {
         return X86.Cvtsd2ss;
     }
     else if (Source.IsR8 && Destination.IsMemoryAddress)
     {
         return X86.Movsd;
     }
     else if (Source.IsR4 && Destination.IsMemoryAddress)
     {
         return X86.Movss;
     }
     else
     {
         return X86.Mov;
     }
 }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:31,代码来源:BaseTransformationStage.cs


示例13: BaseMethodCompiler

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler" /> class.
        /// </summary>
        /// <param name="compiler">The assembly compiler.</param>
        /// <param name="method">The method to compile by this instance.</param>
        /// <param name="basicBlocks">The basic blocks.</param>
        /// <param name="threadID">The thread identifier.</param>
        protected BaseMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID)
        {
            Compiler = compiler;
            Method = method;
            Type = method.DeclaringType;
            Scheduler = compiler.CompilationScheduler;
            Architecture = compiler.Architecture;
            TypeSystem = compiler.TypeSystem;
            TypeLayout = compiler.TypeLayout;
            Trace = compiler.CompilerTrace;
            Linker = compiler.Linker;
            BasicBlocks = basicBlocks ?? new BasicBlocks();
            Pipeline = new CompilerPipeline();
            LocalStack = new List<Operand>();

            ConstantZero = Operand.CreateConstant(TypeSystem, 0);
            StackFrame = Operand.CreateCPURegister(TypeSystem.BuiltIn.Pointer, Architecture.StackFrameRegister);

            Parameters = new Operand[method.Signature.Parameters.Count + (method.HasThis || method.HasExplicitThis ? 1 : 0)];
            VirtualRegisters = new VirtualRegisters(Architecture);
            LocalVariables = emptyOperandList;
            ThreadID = threadID;
            DominanceAnalysis = new Dominance(Compiler.CompilerOptions.DominanceAnalysisFactory, BasicBlocks);
            PluggedMethod = compiler.PlugSystem.GetPlugMethod(Method);
            stop = false;

            MethodData = compiler.CompilerData.GetCompilerMethodData(Method);
            MethodData.Counters.Clear();

            EvaluateParameterOperands();
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:38,代码来源:BaseMethodCompiler.cs


示例14: Emit

        public void Emit(OpcodeEncoder opcode, Operand symbolOperand, int symbolOffset)
        {
            int pos = (int)codeStream.Position + symbolOffset;

            Emit(opcode);

            if (symbolOperand.IsLabel)
            {
                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, MethodName, SectionKind.Text, pos, 0, symbolOperand.Name, SectionKind.ROData, 0);
            }
            else if (symbolOperand.IsField)
            {
                var section = symbolOperand.Field.Data != null ? SectionKind.ROData : SectionKind.BSS;

                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, MethodName, SectionKind.Text, pos, 0, symbolOperand.Field.FullName, section, (int)symbolOperand.Displacement);
            }
            else if (symbolOperand.IsSymbol)
            {
                var section = symbolOperand.Method != null ? SectionKind.Text : SectionKind.ROData;

                var symbol = linker.GetSymbol(symbolOperand.Name, section);

                if (symbol == null)
                {
                    symbol = linker.FindSymbol(symbolOperand.Name);
                }

                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, MethodName, SectionKind.Text, pos, 0, symbol, 0);
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:30,代码来源:BaseCodeEmitter.cs


示例15: ComputeOpCode

        /// <summary>
        /// Computes the opcode.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <param name="destination">The destination operand.</param>
        /// <param name="source">The source operand.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">@No opcode for operand type. [ + destination + ,  + source + )</exception>
        private OpCode ComputeOpCode(InstructionSize size, Operand destination, Operand source)
        {
            Debug.Assert(destination.IsMemoryAddress);
            Debug.Assert(source.IsRegister || source.IsConstant || source.IsSymbol);

            size = BaseMethodCompilerStage.GetInstructionSize(size, destination);

            if (source.IsSymbol)
                return RM_C;

            if (source.IsConstant)
            {
                if (size == InstructionSize.Size8)
                    return RM_C_U8;

                if (size == InstructionSize.Size16)
                    return M_C_16;

                return RM_C;
            }

            if (source.IsRegister)
            {
                if (size == InstructionSize.Size8)
                    return RM_R_U8;

                if (size == InstructionSize.Size16)
                    return M_R_16;

                return M_R;
            }

            throw new ArgumentException(@"No opcode for operand type. [" + destination + ", " + source + ")");
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:42,代码来源:Mov_store.cs


示例16: Emit

        /// <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);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:32,代码来源:MachineCodeEmitter.cs


示例17: ComputeOpCode

        /// <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 (IsByte(destination)) return DEC8;
            if (IsShort(destination) || IsChar(destination)) return DEC16;
            if (IsInt(destination)) return DEC32;

            throw new ArgumentException(@"No opcode for operand type.");
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:15,代码来源:Dec.cs


示例18: ComputeOpCode

        /// <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.IsByte) return INC8;
            if (destination.IsShort || destination.IsChar) return INC16;
            if (destination.IsInt) return INC32;

            throw new ArgumentException(@"No opcode for operand type.");
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:15,代码来源:Inc.cs


示例19: ComputeOpCode

        /// <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.IsShort && source.IsShort && destination.IsRegister && source.IsRegister) return R_R_16;
            if (destination.IsRegister && source.IsMemoryAddress) return R_M;
            if (destination.IsRegister && source.IsRegister) return R_R;
            if (destination.IsMemoryAddress && source.IsRegister) return M_R;

            throw new ArgumentException(@"No opcode for operand type.");
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:16,代码来源:Xchg.cs


示例20: ComputeOpCode

        /// <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 && destination.Register is SegmentRegister) return SR_R;

            if (source.IsRegister && source.Register is SegmentRegister)
                throw new ArgumentException(@"TODO: No opcode for move sourcee segment register");

            if (destination.IsRegister && source.IsConstant) return RM_C;

            if (destination.IsMemoryAddress && source.IsConstant)
            {
                if (destination.IsByte || destination.IsBoolean) return RM_C_U8;
                if (destination.IsChar || destination.IsShort) return M_C_16;
                return RM_C;
            }

            if (destination.IsRegister && source.IsSymbol) return RM_C;

            if (destination.IsMemoryAddress && source.IsSymbol) return RM_C;

            if (destination.IsRegister && source.IsRegister)
            {
                Debug.Assert(!((source.IsByte || destination.IsByte) && (source.Register == GeneralPurposeRegister.ESI || source.Register == GeneralPurposeRegister.EDI)), source.ToString());

                if (source.IsByte || destination.IsByte) return R_M_U8;
                if (source.IsChar || destination.IsChar || source.IsShort || destination.IsShort) return R_RM_16;
                return R_RM;
            }

            if (destination.IsRegister && source.IsMemoryAddress)
            {
                if (destination.IsByte) return R_M_U8;
                if (destination.IsChar || destination.IsShort) return R_RM_16;
                return R_RM;
            }

            if (destination.IsMemoryAddress && source.IsRegister)
            {
                if (destination.IsPointer && !source.IsPointer && destination.Type.ElementType != null)
                {
                    if (destination.Type.ElementType.IsUI1 || destination.Type.ElementType.IsBoolean) return RM_R_U8;
                    if (destination.Type.ElementType.IsChar || destination.Type.ElementType.IsUI2) return M_R_16;
                }
                if (destination.IsByte) return RM_R_U8;
                if (destination.IsChar || destination.IsShort) return M_R_16;
                return M_R;
            }

            if (destination.IsSymbol && source.IsRegister)
            {
                if (destination.IsByte || destination.IsBoolean) return RM_C_U8;
                if (destination.IsChar || destination.IsShort) return M_C_16;
                return RM_C;
            }

            throw new ArgumentException(@"No opcode for operand type. [" + destination + ", " + source + ")");
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:64,代码来源:Mov.cs



注:本文中的Mosa.Compiler.Framework.Operand类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Operands.RegisterOperand类代码示例发布时间:2022-05-26
下一篇:
C# Framework.InstructionNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap