public void PushPopArgument()
        {
            var path = Path.GetTempFileName();

            System.IO.File.WriteAllText(path, pushAndPop_Argument);

            var writer     = new testVMtoASMWriter(new int[] { 2000, 2000 });
            var translator = new vmtranslator.vmtranslator(path, writer);
            var assembly   = translator.TranslateToAssembly().ToList();

            //assembly.ForEach(x => Console.WriteLine(x));
            assembly.Add(assembler.CommandType.HALT.ToString());

            System.IO.File.WriteAllLines(path, assembly);

            var assemblerInstance = new assembler.Assembler(path);
            var assembledResult   = assemblerInstance.ConvertToBinary();

            var binaryProgram = assembledResult.Select(x => Convert.ToInt32(x, 16));

            var simulatorInstance = new simulator.eightChipsSimulator(16, (int)Math.Pow(2, 16));

            simulatorInstance.setUserCode(binaryProgram.ToArray());
            simulatorInstance.ProgramCounter = (int)MemoryMap[MemoryMapKeys.user_code].AbsoluteStart;


            var stackHandle = simulatorInstance.monitor(33040);
            var argument0   = simulatorInstance.monitor(200);
            var argument1   = simulatorInstance.monitor(201);

            //simulatorInstance.logger.enabled = true;

            simulatorInstance.runSimulation();
            var stackValues     = stackHandle.getValues();
            var argument0values = argument0.getValues();
            var argument1values = argument1.getValues();

            //simulatorInstance.printMemory(0);
            stackValues.ForEach(x => Console.WriteLine(x));
            Console.WriteLine("_____");
            argument0values.ForEach(x => Console.WriteLine(x));
            Console.WriteLine("_____");
            argument1values.ForEach(x => Console.WriteLine(x));
            Console.WriteLine("_____");

            var sp = simulatorInstance.mainMemory[simulatorInstance.mainMemory[256] - 1];

            Assert.AreEqual(10, sp);

            Assert.IsTrue(stackValues.SequenceEqual(new List <int>()
            {
                0, 638, 10
            }));
        }
        public void complexTest()
        {
            var path = Path.GetTempFileName();

            System.IO.File.WriteAllText(path, complexStack);

            var translator = new vmtranslator.vmtranslator(path);
            var assembly   = translator.TranslateToAssembly().ToList();

            assembly.Add(assembler.CommandType.HALT.ToString());

            System.IO.File.WriteAllLines(path, assembly);



            var assemblerInstance = new assembler.Assembler(path);
            var assembledResult   = assemblerInstance.ConvertToBinary();

            var binaryProgram = assembledResult.Select(x => Convert.ToInt32(x, 16));

            var simulatorInstance = new simulator.eightChipsSimulator(16, (int)Math.Pow(2, 16));

            simulatorInstance.setUserCode(binaryProgram.ToArray());
            simulatorInstance.ProgramCounter = (int)MemoryMap[MemoryMapKeys.user_code].AbsoluteStart;
            //setup a monitor
            var handle = simulatorInstance.monitor(33049 + 5);

            simulatorInstance.runSimulation();
            var values = handle.getValues();

            values.ForEach(x => Console.WriteLine(x));
            var sp = simulatorInstance.mainMemory[simulatorInstance.mainMemory[256] - 1];

            Assert.AreEqual(sp, -91);
        }
        public void popLocalSimple()
        {
            var path = Path.GetTempFileName();

            System.IO.File.WriteAllText(path, popLocalSimpleProgram);

            var translator = new vmtranslator.vmtranslator(path);
            var assembly   = translator.TranslateToAssembly().ToList();

            assembly.Add(assembler.CommandType.HALT.ToString());

            System.IO.File.WriteAllLines(path, assembly);
            assembly.ForEach(x => Console.WriteLine(x));

            var assemblerInstance = new assembler.Assembler(path);
            var assembledResult   = assemblerInstance.ConvertToBinary();

            var binaryProgram = assembledResult.Select(x => Convert.ToInt32(x, 16));

            var simulatorInstance = new simulator.eightChipsSimulator(16, (int)Math.Pow(2, 16));

            simulatorInstance.setUserCode(binaryProgram.ToArray());
            simulatorInstance.ProgramCounter = (int)MemoryMap[MemoryMapKeys.user_code].AbsoluteStart;

            //setup monitors:

            var stackHandle = simulatorInstance.monitor(33040 + 5);

            simulatorInstance.logger.enabled = true;
            simulatorInstance.runSimulation();
            var stackValues = stackHandle.getValues();


            simulatorInstance.printMemory(0);
            stackValues.ForEach(x => Console.WriteLine(x));
            Console.WriteLine("_____");

            Assert.IsTrue(stackValues.SequenceEqual(new List <int>()
            {
                0, 725, 2,
            }));
        }
        public void NOTTest()
        {
            var path = Path.GetTempFileName();

            System.IO.File.WriteAllText(path, NOTtestprogram1);

            var translator = new vmtranslator.vmtranslator(path);
            var assembly   = translator.TranslateToAssembly().ToList();

            assembly.Add(assembler.CommandType.HALT.ToString());

            System.IO.File.WriteAllLines(path, assembly);



            var assemblerInstance = new assembler.Assembler(path);
            var assembledResult   = assemblerInstance.ConvertToBinary();

            var binaryProgram = assembledResult.Select(x => Convert.ToInt32(x, 16));

            var simulatorInstance = new simulator.eightChipsSimulator(16, (int)Math.Pow(2, 16));

            simulatorInstance.logger.enabled = true;
            simulatorInstance.setUserCode(binaryProgram.ToArray());
            simulatorInstance.ProgramCounter = (int)MemoryMap[MemoryMapKeys.user_code].AbsoluteStart;

            //setup a monitor
            var handle = simulatorInstance.monitor(33040 + 5);

            simulatorInstance.runSimulation();
            var values = handle.getValues();

            values.ForEach(x => Console.WriteLine(x));
            //1 bitwise negated in 2's complement is -2
            Assert.IsTrue(values.SequenceEqual(new List <int>()
            {
                0, 725, -2
            }));
        }