Exemplo n.º 1
0
        public void FileManagerTester_WriteWritable_Success()
        {
            AssemblyLogger logger = new AssemblyLogger("ASM");

            string txt  = "Started Parsing.";
            string msg  = "Memory Overwrite";
            string adrs = "0x45";
            string old  = "3524";
            string line = "54";

            logger.StatusUpdate(txt);
            logger.Warning(msg, line, adrs, old);
            logger.Error("Wrong syntax", "34", "JUMP");

            var result = FileManager.Instance.ToWriteFile(logger, workingDir);

            Console.WriteLine(result);

            Assert.IsTrue(result);

            string filepath = System.IO.Path.Combine(workingDir, logger.FileName);

            string[] logLines = FileManager.Instance.ToReadFile(filepath);

            Assert.AreEqual(4, logLines.Length);

            foreach (string log in logLines)
            {
                Console.WriteLine(log);
            }
        }
Exemplo n.º 2
0
        public void InitializeMicroASM(string[] asmCodeLines, string asmFileName)
        {
            Clear();

            if (asmFileName == null)
            {
                AssemblyLogger = new AssemblyLogger("Assembly");
            }
            else
            {
                AssemblyLogger = new AssemblyLogger(asmFileName);
            }


            Lexer lexer = new Lexer(asmCodeLines);

            Parser parser = new Parser(lexer);

            Compiler compiler = new Compiler(parser, AssemblyLogger);

            compiler.Compile();

            OBJFileLines = compiler.GetOutput();

            //Micro simulator setup
            VirtualMemory = new VirtualMemory(OBJFileLines);

            // state the last port for the micro
            IoManager = new IOManager(VirtualMemory.VirtualMemorySize - 1);

            Micro = new MicroSimulator(VirtualMemory, IoManager);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Two pass Assembler
 /// <paramref name="parser"/>
 /// <paramref name="logger"/>
 /// </summary>
 public Compiler(Parser parser, AssemblyLogger logger, int sizeInKiloBytes = 4)
 {
     currentAddress     = 0;
     constants          = new Dictionary <string, int>();
     labels             = new Dictionary <string, int>();
     variables          = new Dictionary <string, int>();
     vMemory            = new Dictionary <string, int>();
     this.parser        = parser;
     decimalInstuctions = new int[10];
     this.AsmLogger     = logger;
     size             = 0;
     totalAddressesKB = sizeInKiloBytes * 1024;  // 1024 Equals 1KB
 }
Exemplo n.º 4
0
 public Shell(string filePath)
 {
     this.fullFilePath = @filePath;
     try
     {
         this.logger   = new AssemblyLogger(Path.GetFileNameWithoutExtension(fullFilePath));
         this.lexer    = new Lexer(FileManager.Instance.ToReadFile(fullFilePath));
         this.parser   = new Parser(this.lexer);
         this.compiler = new Compiler(parser, logger);
         this.compiler.Compile();
     }
     catch (FileNotFoundException)
     {
         Console.WriteLine("File Not Found...");
     }
 }
Exemplo n.º 5
0
 public void TestCleanUp()
 {
     logger = null;
 }
Exemplo n.º 6
0
 public void TestInit()
 {
     logger = new AssemblyLogger("TEST");
 }