示例#1
0
        private static ushort EvaluateOperandIndex(ExecutionContext context, OperandIndex index)
        {
            var result = (ushort)index.Value;

            switch (index.Representation)
            {
            case OperandIndexRepresentation.Immediate32PlusRelative:
            case OperandIndexRepresentation.Immediate64PlusRelative:
            case OperandIndexRepresentation.Relative:
                var operandValue = GetOperandValue(context, index.Register, NumberType.UInt);
                switch (index.Register.SelectionMode)
                {
                case Operand4ComponentSelectionMode.Mask:
                    result += (ushort)operandValue.GetMaskedNumber(index.Register.ComponentMask).UInt;
                    break;

                case Operand4ComponentSelectionMode.Select1:
                    result += (ushort)operandValue.GetSwizzledNumber(index.Register.Swizzles[0]).UInt;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }
            return(result);
        }
示例#2
0
        private static string GetRegisterIndex(OperandIndex index)
        {
            switch (index.Representation)
            {
            case OperandIndexRepresentation.Immediate32:
            case OperandIndexRepresentation.Immediate64:
                return(index.Value.ToString());

            case OperandIndexRepresentation.Immediate32PlusRelative:
            case OperandIndexRepresentation.Immediate64PlusRelative:
                return(string.Format("{0} + {1}",
                                     GenerateGetOperandValue(index.Register, NumberType.Unknown, forUseInArrayIndex: true),
                                     index.Value));

            case OperandIndexRepresentation.Relative:
                return(string.Format("{0}",
                                     GenerateGetOperandValue(index.Register, NumberType.Unknown, forUseInArrayIndex: true)));

            default:
                throw new ArgumentOutOfRangeException("index");
            }
        }