internal static ByteBuffer FromASMData(string Text) { var asmParser = new Parser.ASMFileParser(); var config = new Parser.CompileConfig(); config.TargetType = CompileTargetType.PLAIN; config.OutputFile = "temp.bin"; config.Assembler = AssemblerType.C64_STUDIO; string temp = "* = $0801\n" + Text; if (Text.Contains(".BYTE")) { config.Assembler = AssemblerType.DASM; // DASM requires pseudo ops to be not at the left most border temp = " ORG $0801\n" + Text.Replace(".BYTE", " .BYTE"); } if ((asmParser.Parse(temp, null, config, null)) && (asmParser.Assemble(config))) { return(asmParser.AssembledOutput.Assembly); } return(null); }
private void btnImportFromASM_Click(object sender, EventArgs e) { var parser = new Parser.ASMFileParser(); Parser.CompileConfig config = new Parser.CompileConfig(); config.TargetType = Types.CompileTargetType.PLAIN; config.OutputFile = "temp.bin"; config.Assembler = Types.AssemblerType.C64_STUDIO; string temp = "* = $0801\n" + editDataExport.Text; if ((!parser.Parse(temp, new ProjectConfig(), config)) || (!parser.Assemble(config))) { return; } var output = parser.AssembledOutput; m_Project.ValueTable.Data.Clear(); m_Project.ValueTable.Values.Clear(); listValues.Items.Clear(); for (int i = 0; i < output.Assembly.Length; ++i) { byte nextValue = output.Assembly.ByteAt(i); m_Project.ValueTable.Values.Add(nextValue.ToString()); m_Project.ValueTable.Data.AppendU8(nextValue); listValues.Items.Add(nextValue.ToString()); } SetModified(); }
protected override bool ProcessTask() { if (m_Document.Type != ProjectElement.ElementType.ASM_SOURCE) { return(true); } Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); if (m_Document.Element != null) { compileConfig.Assembler = m_Document.Element.AssemblerType; } string sourceCode = ""; if (m_Document.BaseDoc != null) { if (m_Document.Type == ProjectElement.ElementType.ASM_SOURCE) { sourceCode = ((SourceASMEx)m_Document.BaseDoc).editSource.Text; } else if (m_Document.Type == ProjectElement.ElementType.BASIC_SOURCE) { sourceCode = ((SourceBasicEx)m_Document.BaseDoc).editSource.Text; } } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig, null); if ((compileConfig.Assembler != C64Studio.Types.AssemblerType.AUTO) && (m_Document.BaseDoc != null) && (m_Document.Element != null)) { if (m_Document.Element.AssemblerType != compileConfig.Assembler) { m_Document.Element.AssemblerType = compileConfig.Assembler; m_Document.BaseDoc.SetModified(); } } ((SourceASMEx)m_Document.BaseDoc).SetLineInfos(parser.ASMFileInfo); var knownTokens = parser.KnownTokens(); GR.Collections.MultiMap <string, C64Studio.Types.SymbolInfo> knownTokenInfos = parser.KnownTokenInfo(); m_Document.SetASMFileInfo(parser.ASMFileInfo, knownTokens, knownTokenInfos); var task = new Tasks.TaskUpdateKeywords(m_Document.BaseDoc); task.Core = Core; task.RunTask(); return(true); }
protected override bool ProcessTask() { Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); compileConfig.Assembler = m_Document.Element.AssemblerType; parser.ParseFile(m_Document, m_Configuration, compileConfig); return(true); }
protected override bool ProcessTask() { Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); compileConfig.Assembler = m_Document.Element.AssemblerType; string sourceCode = ""; if (m_Document.BaseDoc != null) { if (m_Document.Type == ProjectElement.ElementType.ASM_SOURCE) { sourceCode = ((SourceASMEx)m_Document.BaseDoc).editSource.Text; } else if (m_Document.Type == ProjectElement.ElementType.BASIC_SOURCE) { sourceCode = ((SourceBasicEx)m_Document.BaseDoc).editSource.Text; } } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig); if ((compileConfig.Assembler != C64Studio.Types.AssemblerType.AUTO) && (m_Document.BaseDoc != null) && (m_Document.Element != null)) { if (m_Document.Element.AssemblerType != compileConfig.Assembler) { m_Document.Element.AssemblerType = compileConfig.Assembler; m_Document.BaseDoc.SetModified(); } } return(true); }
private void GenerateValues() { m_Parser = new Parser.ASMFileParser(); m_Parser.AddExtFunction("sin", 1, 1, ExtSinus); m_Parser.AddExtFunction("cos", 1, 1, ExtCosinus); m_Parser.AddExtFunction("tan", 1, 1, ExtTan); double startValue = Util.StringToDouble(m_Project.ValueTable.StartValue); double endValue = Util.StringToDouble(m_Project.ValueTable.EndValue); double stepValue = Util.StringToDouble(m_Project.ValueTable.StepValue); if ((startValue != endValue) && (stepValue == 0)) { SetError("Step value must not be equal zero"); return; } if ((startValue <= endValue) && (stepValue < 0)) { SetError("Step value must be positive"); return; } if ((startValue >= endValue) && (stepValue > 0)) { SetError("Step value must be negative"); return; } if (checkClearPreviousValues.Checked) { m_Project.ValueTable.Values.Clear(); listValues.Items.Clear(); } double curValue = startValue; bool completed = false; bool firstValue = true; double lastValue = curValue; do { m_Parser.AddConstantF("x", curValue, 0, "", 0, 1); var tokens = m_Parser.ParseTokenInfo(m_Project.ValueTable.Formula, 0, m_Project.ValueTable.Formula.Length); if (tokens == null) { SetError(m_Parser.GetError().Code.ToString()); return; } double result = 0.0; if (!m_Parser.EvaluateTokensNumeric(0, tokens, out result)) { SetError(m_Parser.GetError().Code.ToString()); return; } if (m_Project.ValueTable.GenerateDeltas) { if (!firstValue) { m_Project.ValueTable.Values.Add((result - lastValue).ToString()); listValues.Items.Add((result - lastValue).ToString()); } firstValue = false; } else { m_Project.ValueTable.Values.Add(result.ToString()); listValues.Items.Add(result.ToString()); } lastValue = result; curValue += stepValue; if (startValue == endValue) { completed = true; } if ((stepValue > 0) && (curValue > endValue)) { completed = true; } if ((stepValue < 0) && (curValue < endValue)) { completed = true; } }while (!completed); SetError("OK"); m_Project.ValueTable.Data = new ByteBuffer((uint)m_Project.ValueTable.Values.Count); int index = 0; foreach (var entry in m_Project.ValueTable.Values) { m_Project.ValueTable.Data.SetU8At(index, GR.Convert.ToU8(entry)); ++index; } }
private void GenerateValues() { m_Parser = new Parser.ASMFileParser(); m_Parser.AddExtFunction("sin", 1, 1, ExtSinus); double startValue = Util.StringToDouble(m_Project.ValueTable.StartValue); double endValue = Util.StringToDouble(m_Project.ValueTable.EndValue); double stepValue = Util.StringToDouble(m_Project.ValueTable.StepValue); if ((startValue != endValue) && (stepValue == 0)) { SetError("Step value must not be equal zero"); return; } if ((startValue <= endValue) && (stepValue < 0)) { SetError("Step value must be positive"); return; } if ((startValue >= endValue) && (stepValue > 0)) { SetError("Step value must be negative"); return; } if (checkClearPreviousValues.Checked) { m_Project.ValueTable.Values.Clear(); listValues.Items.Clear(); } double curValue = startValue; bool completed = false; do { m_Parser.AddConstantF("x", curValue, 0, "", 0, 1); var tokens = m_Parser.ParseTokenInfo(m_Project.ValueTable.Formula, 0, m_Project.ValueTable.Formula.Length); if (tokens == null) { SetError(m_Parser.GetError().Code.ToString()); return; } double result = 0.0; if (!m_Parser.EvaluateTokensNumeric(0, tokens, out result)) { SetError(m_Parser.GetError().Code.ToString()); return; } m_Project.ValueTable.Values.Add(result.ToString()); listValues.Items.Add(result.ToString()); curValue += stepValue; if (startValue == endValue) { completed = true; } if ((stepValue > 0) && (curValue > endValue)) { completed = true; } if ((stepValue < 0) && (curValue < endValue)) { completed = true; } }while (!completed); SetError("OK"); }