示例#1
0
        public MixInstruction GetInstruction(byte opcode, FieldSpec fieldSpec)
        {
            if (!mOpcodeInstructionMap.TryGetValue(opcode, out List <MixInstruction> instructions))
            {
                return(null);
            }

            int            startIndex         = 0;
            MixInstruction defaultInstruction = null;

            if (instructions[0].FieldSpec == null)
            {
                defaultInstruction = instructions[0];
                startIndex         = 1;
            }

            for (int index = startIndex; index < instructions.Count; index++)
            {
                if (instructions[index].FieldSpec == fieldSpec)
                {
                    return(instructions[index]);
                }
            }

            return(defaultInstruction);
        }
示例#2
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);
        }
示例#3
0
        void AddInstruction(string mnemonic, MixInstruction instruction)
        {
            mMnemonicInstructionMap.Add(mnemonic, instruction);
            var list = mOpcodeInstructionMap.GetOrCreate(instruction.Opcode);

            if (instruction.FieldSpec == null)
            {
                list.Insert(0, instruction);
            }
            else
            {
                list.Add(instruction);
            }
        }