当前位置: 首页>>代码示例>>C#>>正文


C# MachineCodeEmitter.EmitTwoRegistersAndK16方法代码示例

本文整理汇总了C#中MachineCodeEmitter.EmitTwoRegistersAndK16方法的典型用法代码示例。如果您正苦于以下问题:C# MachineCodeEmitter.EmitTwoRegistersAndK16方法的具体用法?C# MachineCodeEmitter.EmitTwoRegistersAndK16怎么用?C# MachineCodeEmitter.EmitTwoRegistersAndK16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MachineCodeEmitter的用法示例。


在下文中一共展示了MachineCodeEmitter.EmitTwoRegistersAndK16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Emit

        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context context, MachineCodeEmitter emitter)
        {
            // TODO: Remove
            if (context.Operand1 is MemberOperand)
                return;
            if (context.Result is RegisterOperand && context.Operand1 is MemoryOperand)
            {
                RegisterOperand result = context.Result as RegisterOperand;
                MemoryOperand operand = context.Operand1 as MemoryOperand;

                int displacement = operand.Offset.ToInt32();

                if (IsBetween(displacement, 0, 7))
                {
                    emitter.EmitTwoRegisterInstructions((byte)(0x0C & displacement),  (byte)operand.Base.RegisterCode, (byte)result.Register.RegisterCode);
                }
                else
                    if (IsBetween(displacement, -32768, 32767))
                    {
                        emitter.EmitTwoRegistersAndK16(0x13, (byte)operand.Base.RegisterCode, (byte)result.Register.RegisterCode, (short)displacement);
                    }
                    else
                        throw new OverflowException();
            }
            else
                throw new Exception("Not supported combination of operands");
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:32,代码来源:LdubInstruction.cs

示例2: Emit

        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context context, MachineCodeEmitter emitter)
        {
            if (context.Result.IsMemoryAddress && context.Operand1.IsRegister)
            {
                Operand destination = context.Result;

                if (IsBetween(destination.Offset.ToInt32(), 0, 60))
                {
                    emitter.EmitTwoRegistersWithK4((byte)destination.Base.RegisterCode, (byte)context.Operand1.Register.RegisterCode, (sbyte)destination.Offset.ToInt32());
                }
                else if (IsBetween(destination.Offset.ToInt32(), -32768, 32767))
                {
                    emitter.EmitTwoRegistersAndK16(0x14, (byte)destination.Base.RegisterCode, (byte)context.Operand1.Register.RegisterCode, (short)destination.Offset.ToInt32());
                }
                else
                    throw new OverflowException();
            }
            else
                throw new Exception("Not supported combination of operands");
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:25,代码来源:St.cs

示例3: Emit

        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context context, MachineCodeEmitter emitter)
        {
            if (context.Result.IsRegister && context.Operand1.IsMemoryAddress)
            {
                int displacement = context.Operand1.Offset.ToInt32();

                if (IsBetween(displacement, 0, 124))
                {
                    emitter.EmitDisplacementLoadWithK5Immediate((byte)context.Result.Register.RegisterCode, (sbyte)displacement, (byte)context.Operand1.Base.RegisterCode);
                }
                else
                    if (IsBetween(displacement, -32768, 32767))
                    {
                        emitter.EmitTwoRegistersAndK16(0x0F, (byte)context.Operand1.Base.RegisterCode, (byte)context.Result.Register.RegisterCode, (short)displacement);
                    }
                    else
                        throw new OverflowException();
            }
            else
                throw new Exception("Not supported combination of operands");
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:26,代码来源:Ld.cs

示例4: Emit

        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context context, MachineCodeEmitter emitter)
        {
            if (context.Result.IsRegister && context.Operand1.IsConstant)
            {
                int value = 0;

                if (context.Result.Register.RegisterCode == GeneralPurposeRegister.SP.Index)
                {
                    if (IsConstantBetween(context.Operand1, -512, 508, out value))
                    {
                        emitter.EmitK8immediateAndSingleRegister(0x00, (sbyte)(value >> 2), (byte)context.Result.Register.RegisterCode); // sub Sp, Imm (k8)
                    }
                    else if (IsConstantBetween(context.Operand1, -1048576, 1048575, out value))
                    {
                        emitter.EmitRegisterOrConditionCodeAndK21(0x01, (byte)context.Result.Register.RegisterCode, value); // sub Sp, Imm (k21)
                    }
                    else
                        throw new OverflowException();
                }
                else
                {
                    if (IsConstantBetween(context.Operand1, -128, 127, out value))
                    {
                        emitter.EmitK8immediateAndSingleRegister(0x00, (sbyte)value, (byte)context.Result.Register.RegisterCode); // sub Rd, Imm (k8)
                    }
                    else if (IsConstantBetween(context.Operand1, -1048576, 1048575, out value))
                    {
                        emitter.EmitRegisterOrConditionCodeAndK21(0x01, (byte)context.Result.Register.RegisterCode, value); // sub Rd, Imm (k21)
                    }
                    else
                        throw new OverflowException();
                }
            }
            else if (context.Result.IsRegister && context.Operand1.IsRegister && context.Operand2.IsConstant)
            {
                int value = 0;

                if (IsConstantBetween(context.Operand2, -32768, 32767, out value))
                {
                    emitter.EmitTwoRegistersAndK16(0x0C, (byte)context.Operand1.Register.RegisterCode, (byte)context.Result.Register.RegisterCode, (short)value); // sub Rd, Rs, Imm (k16)
                }
                else
                    throw new OverflowException();
            }
            else if ((context.Result.IsRegister) && (context.Operand1.IsRegister))
            {
                emitter.EmitTwoRegisterInstructions(0x01, (byte)context.Result.Register.RegisterCode, (byte)context.Operand1.Register.RegisterCode); // sub Rd, Rs
            }
            else
                throw new Exception("Not supported combination of operands");
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:56,代码来源:Sub.cs


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