private Instruction DecodeFormat(uint InstructionWord, Instruction InstructionToDecode)
 {
     if (InstructionToDecode.OpCode == 0)
     {
         return(RFormat.CreateInstruction(InstructionWord, InstructionToDecode.Address));
     }
     else if (InstructionToDecode.OpCode == 2 || InstructionToDecode.OpCode == 3)
     {
         return(JFormat.CreateInstruction(InstructionWord, InstructionToDecode.Address));
     }
     else
     {
         return(IFormat.CreateInstruction(InstructionWord, InstructionToDecode.Address));
     }
 }
Пример #2
0
        private void FillInstructionDictionary(Dictionary <int, Instruction> DictionaryToFill, MemoryStream FStream)
        {
            uint InstructionCounter = 0x00400000;

            if (FStream.Length % 4 == 0)
            {
                using (BinaryReader Reader = new BinaryReader(FStream))
                {
                    while (FStream.Position != FStream.Length)
                    {
                        uint        InstructionWord = Reader.ReadUInt32();
                        Instruction ReadInstruction = instructionFactory.CreateInstruction(InstructionWord, InstructionCounter);
                        DictionaryToFill.Add((int)ReadInstruction.Address, ReadInstruction);
                        InstructionCounter += 4;
                    }
                }
            }
            else
            {
                throw new ArgumentException("Invalid MIPS file");
            }
        }