Exemplo n.º 1
0
        public Form1()
        {
            try
            {
                DescFile = Path.GetTempFileName();
                byte[] tmpBytes          = Resources.asmDesc;
                var    streamWithASMDesc = new FileStream(DescFile, FileMode.OpenOrCreate);
                streamWithASMDesc.Write(tmpBytes, 0, tmpBytes.Length);
                streamWithASMDesc.Close();
            }
            catch (Exception)
            {
                DescFile = null;
            }

            try
            {
                SLoader = Path.GetTempFileName();
                byte[] tmpBytes          = Resources.ReallySmallProgramLoader;
                var    streamWithASMDesc = new FileStream(SLoader, FileMode.OpenOrCreate);
                streamWithASMDesc.Write(tmpBytes, 0, tmpBytes.Length);
                streamWithASMDesc.Close();
            }
            catch (Exception)
            {
                SLoader = null;
            }

            InitializeComponent();

            PS = new ComPortSettings();
            PS.SetPortSet();

            SFD = new SaveFileDialog
            {
                InitialDirectory = Directory.GetCurrentDirectory(),
                Filter           = "asm files (*.asm)|*.asm",
                FilterIndex      = 2,
                RestoreDirectory = true,
            };
            OFD = new OpenFileDialog
            {
                InitialDirectory = Directory.GetCurrentDirectory(),
                FilterIndex      = 2,
                RestoreDirectory = true,
            };
            BinGen       = new BinaryGenerator();
            tsFiles.Dock = DockStyle.Fill;
            panel1.Dock  = DockStyle.Fill;
            stStrip.Items.Add("Start work with opening or creating new file");
            stStrip.Items.Add("");
            //stStrip.Items.Add("          Current COM-Port: ");
            //stStrip.Items[2].TextAlign = ContentAlignment.MiddleRight;
        }
Exemplo n.º 2
0
        private BinaryGenerator GetBinary(string s, int startAddr)
        {
            if (string.IsNullOrEmpty(CurrentTB.Text))
            {
                return(null);
            }

            s = s.Replace("?", "0x00");
            //var nocomments = new Regex(@";(?:\S| )*", RegexOptions.Multiline);
            //s = Regex.Replace(s, @";(?:\S| )*", "", RegexOptions.Multiline);
            //s = Regex.Replace(s, @"\s+$[\r\n]*", "\r\n", RegexOptions.Multiline);
            if (s[s.Length - 2].Equals('\r') && s[s.Length - 1].Equals('\n'))
            {
                s = s.Remove(s.Length - 2, 2);
            }
            if (BinGen == null)
            {
                BinGen = new BinaryGenerator();
            }
            CurrentTB.Hints.Clear();
            try
            {
                BinGen.generateBinary(s, startAddr);
                Dictionary <int, string> warnings = new Dictionary <int, string>();
                warnings = BinGen.getWarnings();
                if (warnings.Count > 0)
                {
                    foreach (var warning in warnings)
                    {
                        var r    = new Range(CurrentTB, 0, warning.Key, CurrentTB.Lines[warning.Key].Length, warning.Key);
                        var hint = new Hint(r, warning.Value, true, true);
                        hint.BackColor = Color.Yellow;
                        CurrentTB.Hints.Add(hint);
                        CurrentTB.Navigate(warning.Key);
                    }
                }
            }
            catch (BinaryGeneratorException e)
            {
                BinGen = null;
                var r    = new Range(CurrentTB, 0, e.line, CurrentTB.Lines[e.line].Length, e.line);
                var hint = new Hint(r, e.Message, true, true);
                hint.BackColor = Color.Red;
                CurrentTB.Hints.Add(hint);
                CurrentTB.Navigate(e.line);
            }

            return(BinGen);
        }
Exemplo n.º 3
0
        public void viewBinaryDump(BinaryGenerator binGen)
        {
            //if (string.IsNullOrEmpty(source)) return;
            //this.binGen = binGen;
            var tmp = binGen.getBinaryDump();

            if (tmp[tmp.Count - 1] == null)
            {
                tmp.RemoveAt(tmp.Count - 1);
            }
            bytes = (byte[])tmp.ToArray(typeof(byte));
            string[] dump      = binGen.getBinaryDumpToString(len);
            string[] ASCIIDump = binGen.getACIIDumpToString(len);
            updateDataGrid(dump, ASCIIDump, binGen.getStartAddress());
        }