public string DisassembleFileSim8051(string m_currentfile) { Sim8051Dasm dasm = new Sim8051Dasm(); frmProgress progress = new frmProgress(); string outputfilename = Path.Combine(Path.GetDirectoryName(m_currentfile), Path.GetFileNameWithoutExtension(m_currentfile) + ".asm"); progress.SetProgress("Initializing disassembler"); progress.SetProgressPercentage(10); progress.Show(); try { dasm.Initialize(readdatafromfile(m_currentfile, 0, 0x10000)); SimError err; progress.SetProgress("Running disassembler"); progress.SetProgressPercentage(20); string[] result = dasm.Disassemble(true, 0, out err); progress.SetProgress("Outputting data"); progress.SetProgressPercentage(10); int linecount = 0; if (File.Exists(outputfilename)) { File.Delete(outputfilename); } using (StreamWriter sw = new StreamWriter(outputfilename)) { foreach (string s in result) { progress.SetProgressPercentage(((linecount++ *80) / result.Length) + 20); sw.WriteLine(s); } } } catch (Exception E) { Console.WriteLine(E.Message); } progress.Close(); return(outputfilename); }
public string DisassembleFileSim8051(string m_currentfile) { Sim8051Dasm dasm = new Sim8051Dasm(); frmProgress progress = new frmProgress(); string outputfilename = Path.Combine(Path.GetDirectoryName(m_currentfile), Path.GetFileNameWithoutExtension(m_currentfile) + ".asm"); progress.SetProgress("Initializing disassembler"); progress.SetProgressPercentage(10); progress.Show(); try { dasm.Initialize(readdatafromfile(m_currentfile, 0, 0x10000)); SimError err; progress.SetProgress("Running disassembler"); progress.SetProgressPercentage(20); string[] result = dasm.Disassemble(true, 0, out err); progress.SetProgress("Outputting data"); progress.SetProgressPercentage(10); int linecount = 0; if (File.Exists(outputfilename)) { File.Delete(outputfilename); } using (StreamWriter sw = new StreamWriter(outputfilename)) { foreach (string s in result) { progress.SetProgressPercentage(((linecount++ * 80) / result.Length) + 20); sw.WriteLine(s); } } } catch (Exception E) { Console.WriteLine(E.Message); } progress.Close(); return outputfilename; }