Example #1
0
 public TestSimulator()
 {
     e = new ELFReader();
     mem = new Memory(32768);
     comp = new Computer();
     reg = new Register[16];
     resultHash = "";
     hash = "";
 }
Example #2
0
        // write to the trace
        // formatted to (hopefully) look exactly like the test
        public void writeTrace(Computer comp)
        {
            lock (thisLock)
            {
                if (trace_is_open)
                {
                    // build NZCF to ease later code
                    string nzcf = Convert.ToInt32(comp.getFlag('N')).ToString() 
                        + Convert.ToInt32(comp.getFlag('Z')).ToString()
                        + Convert.ToInt32(comp.getFlag('C')).ToString() 
                        + Convert.ToInt32(comp.getFlag('F')).ToString(); 

                    // build trace string and objects
                    object[] objects = { (comp.getStepNumber()).ToString().PadLeft(6, '0') //0
                                           , useThisValueForBranchedr15 //1
                                           , "[sys]" //2
                                           , nzcf //3
                                           , "0=" + comp.getReg(0).getRegString().ToUpper().Trim() //4
                                           , "1=" + comp.getReg(1).getRegString().ToUpper().Trim() //5
                                           , "2=" + comp.getReg(2).getRegString().ToUpper().Trim() //6
                                           , "3=" + comp.getReg(3).getRegString().ToUpper().Trim() //7
                                           , Environment.NewLine //8
                                           , "\t" //9
                                           , "4=" + comp.getReg(4).getRegString().ToUpper().Trim() //10
                                           , " 5=" + comp.getReg(5).getRegString().ToUpper().Trim() //11
                                           , " 6=" + comp.getReg(6).getRegString().ToUpper().Trim() //12
                                           , " 7=" + comp.getReg(7).getRegString().ToUpper().Trim() //13
                                           , " 8=" + comp.getReg(8).getRegString().ToUpper().Trim() //14
                                           , "9=" + comp.getReg(9).getRegString().ToUpper().Trim() //15
                                           , "10=" + comp.getReg(10).getRegString().ToUpper().Trim() //16
                                           , " 11=" + comp.getReg(11).getRegString().ToUpper().Trim() //17
                                           , " 12=" + comp.getReg(12).getRegString().ToUpper().Trim() //18
                                           , " 13=" + comp.getReg(13).getRegString().ToUpper().Trim() //19
                                           , " 14=" + comp.getReg(14).getRegString().ToUpper().Trim() //20
                                           , "\t" //21
                                           };
                    // I know I'm going to lose points for this line of code
                    // but I'm honestly just happy that it works
                    this.trace.WriteLine(String.Format(@"{0} {1} {2} {3} {4} {5} {6} {7}{8}{9}{10} {11} {12} {13} {14} {15}{8}{21}{16}{17}{18}{19}{20}", objects));                    
                    this.trace.Flush();
                    lastInstructionWasBranch = false;
                }
            }
        }