Пример #1
0
        private void ToolStripButtonCompileCode_Click(object sender, EventArgs e)
        {
            var PROG = Strings.Split(SAL_TextBoxCodeInput.Text.Replace(Constants.vbCrLf, " "), " ");

            SAL_RichTextBoxProgram.Text = PROG.ToJson();
            var InstructionLst = new List <string>();
            var ROOT           = new TreeNode();

            ROOT.Text = "ASSEMBLY_CODE";
            int Count = 0;

            foreach (var item in PROG)
            {
                Count += 1;
                if (!string.IsNullOrEmpty(item))
                {
                    var NDE = new TreeNode();
                    NDE.Text = Count + ": " + item;
                    ROOT.Nodes.Add(NDE);
                    InstructionLst.Add(Strings.UCase(item));
                }
            }
            // cpu - START

            // Dim CPU As ZX81_CPU = New ZX81_CPU(InstructionLst)
            // CPU.Run()
            string argThreadName = "Test";
            var    CPU           = new ZX81_CPU(ref argThreadName, ref InstructionLst);
            string argOutputStr  = "CURRENT POINTER = " + CPU.Get_Instruction_Pointer_Position + Constants.vbNewLine + "CONTAINED DATA = " + CPU.Peek();

            DisplayOutput(ref argOutputStr);
            SAL_AST.Nodes.Add(ROOT);
        }
Пример #2
0
        public static string RunMachineCode(ref string Code)
        {
            Code = Strings.UCase(Code);
            var PROG           = Strings.Split(Code.Replace(Constants.vbCrLf, " "), " ");
            var InstructionLst = new List <string>();
            var ROOT           = new TreeNode();

            ROOT.Text = "ASSEMBLY_CODE";
            int Count = 0;

            foreach (var item in PROG)
            {
                Count += 1;
                if (!string.IsNullOrEmpty(item))
                {
                    var NDE = new TreeNode();
                    NDE.Text = Count + ": " + item;
                    ROOT.Nodes.Add(NDE);
                    InstructionLst.Add(item);
                }
            }
            // cpu - START



            string argThreadName = "Test";
            var    CPU           = new ZX81_CPU(ref argThreadName, ref InstructionLst);

            CPU.RUN();
            Tree = ROOT;
            return("CURRENT POINTER = " + CPU.Get_Instruction_Pointer_Position + Constants.vbCr + "CONTAINED DATA = " + CPU.Peek());
        }