Esempio n. 1
0
        //--------------------------------------------------------------
        // Purpose: Runs loader tests
        // Returns: nothing
        //--------------------------------------------------------------
        public static void TestLoader()
        {
            Computer comp = new Computer();

            Console.WriteLine("Testing loader...");
            // Loader tests
            string elfpath = "test3.exe";

            comp.ReadELF(elfpath);
            int checksum = calculateChecksum(Computer.GetCPU().progRAM.memory);

            Debug.Assert(checksum == 536860694);

            comp.ResetRam();
            elfpath = "test2.exe";
            comp.ReadELF(elfpath);
            checksum = calculateChecksum(Computer.GetCPU().progRAM.memory);
            Debug.Assert(checksum == 536864418);

            comp.ResetRam();
            elfpath = "test1.exe";
            comp.ReadELF(elfpath);
            checksum = calculateChecksum(Computer.GetCPU().progRAM.memory);
            Debug.Assert(checksum == 536861081);
            Trace.WriteLine("Loader tests passed!");
        }
Esempio n. 2
0
 //--------------------------------------------------------------
 // Purpose: Loads the file <fileToLoad> and reads it into RAM
 // Returns: nothing
 //--------------------------------------------------------------
 private void LoadFile(string fileToLoad)
 {
     try
     {
         comp.ResetRam();
         comp.ResetEnd();
         Computer.GetCPU().ClearFlags();
         Memory ram = comp.progRAM;
         filename = fileToLoad;
         if (comp.ReadELF(fileToLoad))
         {
             origPC = Computer.GetCPU().registers.ReadWord((uint)regs.PC);
             findAddressTxtBox.Text = "0x" + Computer.GetCPU().registers.ReadWord((uint)regs.PC).ToString("x8");
             initializeDisassemblyPanel();
             initializeMemoryPanel();
             updateGUI();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }