示例#1
0
        private string GetRasm(Rebop.Translation.ROF rof)
        {
            StringBuilder sb = new StringBuilder();


            sb.Append($"RASM v1.0{Environment.NewLine}");
            sb.Append($"Start:\t{rof.Start.ToString("X2")}{Environment.NewLine}");

            if (rof.Code != null)
            {
                string strCodeBinary = Convert.ToString(rof.Code.Value, 2).PadLeft(16, '0');
                for (int i = 4; i <= strCodeBinary.Length; i += 4)
                {
                    strCodeBinary = strCodeBinary.Insert(i, " ");
                    i++;
                }
                sb.Append($"Code:\t{rof.Code?.ToString("X2")}{Environment.NewLine}");
                sb.Append($"Switches:\t{strCodeBinary}{Environment.NewLine}");
            }

            sb.Append($"End:\t{rof.End.ToString("X2")}{Environment.NewLine}");

            int size = rof.End - rof.Start + 1;

            for (int i = 0; i < size; ++i)
            {
                sb.Append($"{rof.Image[i].ToString("X2")}{Environment.NewLine}");
            }

            return(sb.ToString());
        }
示例#2
0
        private void ParseSample()
        {
            ClearParserOutput();
            if (_parser == null || !_parser.Language.CanParse())
            {
                return;
            }
            _parseTree = null;
            GC.Collect(); //to avoid disruption of perf times with occasional collections
            _parser.Context.TracingEnabled = chkParserTrace.Checked;
            try {
                _parser.Parse(txtSource.Text, "<source>");
            } catch (Exception ex) {
                gridCompileErrors.Rows.Add(null, ex.Message, null);
                tabBottom.SelectedTab = pageParserOutput;
                throw;
            } finally {
                _parseTree = _parser.Context.CurrentParseTree;
                ShowCompilerErrors();
                if (chkParserTrace.Checked)
                {
                    ShowParseTrace();
                }
                ShowCompileStats();
                ShowParseTree();
                ShowAstTree();
            }

            //JOE

            txtRam.Text = "";
            var file = _parseTree.Root?.AstNode;

            if (file != null)
            {
                Rebop.Translation.ROF rof = Rebop.Translation.Rasm.Assembler.Assemble((Rebop.Translation.Rasm.Ast.FileAstNode)file);
                txtRasm.Text = GetRasm(rof);
                txtRam.Text  = GetRam(rof);
            }

            txtSource.Focus();
        }
示例#3
0
        private string GetRam(Rebop.Translation.ROF rof)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"BEBOPUTER RAM FILE Version 1.0.0.0{Environment.NewLine}");
            sb.Append($"{rof.Start.ToString()}{Environment.NewLine}");
            sb.Append($"{rof.End.ToString()}{Environment.NewLine}");
            sb.Append($"C:\\foo.asm{Environment.NewLine}");
            sb.Append($"GENERATED BY BEBOPUTER ASSEMBLER Version 1.0.0.0{Environment.NewLine}");
            sb.Append($"START OF DATA{Environment.NewLine}");

            int size = rof.End - rof.Start + 1;

            for (int i = 0; i < size; ++i)
            {
                sb.Append($"{rof.Image[i].ToString()}{Environment.NewLine}");
            }

            sb.Append($"END OF DATA");
            return(sb.ToString());
        }