예제 #1
0
        MixByte GetFieldSpecValue(AssemblingStatus status, MixInstruction mixInstruction)
        {
            var fieldValue = mField.GetValue(status.LocationCounter);

            switch (mixInstruction.MetaFieldSpec.Presence)
            {
            case MetaFieldSpec.Presences.Forbidden:
                if (fieldValue == long.MinValue)
                {
                    return(mixInstruction.FieldSpec.MixByteValue);
                }

                status.ReportParsingError(LineSection.AddressField, mFieldPartCharIndex, mTextLength - mFieldPartCharIndex, "fieldspec forbidden for this instruction");
                return(null);

            case MetaFieldSpec.Presences.Optional:
                if (fieldValue == long.MinValue)
                {
                    return(mixInstruction.MetaFieldSpec.DefaultFieldSpec.MixByteValue);
                }

                return((int)fieldValue);

            case MetaFieldSpec.Presences.Mandatory:
                if (fieldValue != long.MinValue)
                {
                    return((int)fieldValue);
                }

                status.ReportParsingError(LineSection.AddressField, mFieldPartCharIndex, mTextLength - mFieldPartCharIndex, "fieldspec mandatory for this instruction");
                return(null);
            }
            return(null);
        }
예제 #2
0
        bool AreValuesDefined(AssemblingStatus status)
        {
            if (!mAddress.IsValueDefined(status.LocationCounter))
            {
                status.ReportParsingError(LineSection.AddressField, 0, mIndexPartCharIndex, "address value undefined");
                return(false);
            }

            if (!mIndex.IsValueDefined(status.LocationCounter))
            {
                status.ReportParsingError(LineSection.AddressField, mIndexPartCharIndex, mFieldPartCharIndex - mIndexPartCharIndex, "index value undefined");
                return(false);
            }

            if (!mAddress.IsValueDefined(status.LocationCounter))
            {
                status.ReportParsingError(LineSection.AddressField, mFieldPartCharIndex, mTextLength - mFieldPartCharIndex, "field value undefined");
                return(false);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Create a loader instruction instance with the parameters contained in this object.
        /// </summary>
        /// <param name="instruction">LoaderInstruction to create an instance of. This method will throw an exception if this parameter is of a different instruction type.</param>
        /// <param name="status">AssemblingStatus object reflecting the current state of the assembly process</param>
        /// <returns></returns>
        public InstructionInstanceBase CreateInstance(InstructionBase instruction, AssemblingStatus status)
        {
            if (!(instruction is LoaderInstruction))
            {
                throw new ArgumentException("instruction must be a LoaderInstruction", nameof(instruction));
            }

            var loaderInstruction = (LoaderInstruction)instruction;

            if (!mValue.IsValueDefined(status.LocationCounter))
            {
                status.ReportParsingError(LineSection.AddressField, 0, mTextLength, "value is not defined");
                return(null);
            }

            return(new LoaderInstruction.Instance(loaderInstruction, mValue.GetSign(status.LocationCounter), mValue.GetMagnitude(status.LocationCounter)));
        }