Exemple #1
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            config.mForceAbsOpcodeSuffix         = string.Empty;
            config.mForceLongOpcodeSuffix        = string.Empty;
            config.mForceAbsOperandPrefix        = "a:"; // absolute
            config.mForceLongOperandPrefix       = "f:"; // far
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mAllowHighAsciiCharConst      = false;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Simple;
            SourceFormatter        = new Formatter(config);

            string msg = string.Format(Properties.Resources.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "@";
                mLocalizer.Analyze();
            }

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    //if (mAsmVersion.IsValid && mAsmVersion <= V2_17) {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                    //        "cc65", mAsmVersion.ToString()));
                    //} else {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_LATEST, "cc65"));
                    //}

                    // Currently generating code for v2.17.
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                                             "cc65", V2_17));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #2
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "@";
                mLocalizer.Analyze();
            }
            mLocalizer.FixOpcodeLabels();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "acme", V0_96_4, AsmAcme.OPTIONS));
                }

                if (HasNonZeroBankCode())
                {
                    // don't try
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               "ACME can't handle 65816 code that lives outside bank zero");
                    int orgAddr = Project.AddrMap.Get(0);
                    OutputOrgDirective(0, orgAddr);
                    OutputDenseHex(0, Project.FileData.Length, string.Empty, string.Empty);
                }
                else
                {
                    GenCommon.Generate(this, sw, worker);
                }

                if (mInPseudoPcBlock)
                {
                    OutputLine(string.Empty, CLOSE_PSEUDOPC, string.Empty, string.Empty);
                }
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #3
0
        // IGenerator
        public GenerationResults GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);

            // Configure delimiters for single-character operands.
            Formatter.DelimiterSet charDelimSet = new Formatter.DelimiterSet();
            charDelimSet.Set(CharEncoding.Encoding.C64Petscii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.C64ScreenCode, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.HighAscii,
                             new Formatter.DelimiterDef(string.Empty, '\'', '\'', " | $80"));

            config.mCharDelimiters = charDelimSet;

            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer                        = new LabelLocalizer(Project);
            mLocalizer.LocalPrefix            = "_";
            mLocalizer.QuirkNoOpcodeMnemonics = true;
            mLocalizer.Analyze();

            bool   needLongAddress = Project.FileDataLength > 65536 + (mHasPrgHeader ? 2 : 0);
            string extraOptions    = string.Empty +
                                     (needLongAddress ? AsmTass64.LONG_ADDRESS : string.Empty) +
                                     (mHasPrgHeader ? string.Empty : AsmTass64.NOSTART);

            mPcDepth     = 0;
            mFirstIsOpen = true;

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "64tass", mAsmVersion, AsmTass64.BASE_OPTIONS + extraOptions));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(new GenerationResults(pathNames, extraOptions));
        }
Exemple #4
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string pathName = Path.Combine(mWorkDirectory, mFileNameBase + ASM_FILE_SUFFIX);

            pathNames.Add(pathName);
            string cfgName = Path.Combine(mWorkDirectory, mFileNameBase + CFG_FILE_SUFFIX);

            pathNames.Add(cfgName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix            = "@";
                mLocalizer.QuirkVariablesEndScope = true;
                mLocalizer.Analyze();
            }
            mLocalizer.FixOpcodeLabels();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(cfgName, false, new UTF8Encoding(false))) {
                GenerateLinkerScript(sw);
            }
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    //if (mAsmVersion.IsValid && mAsmVersion <= V2_17) {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                    //        "cc65", mAsmVersion.ToString()));
                    //} else {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_LATEST, "cc65"));
                    //}

                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "cc65", V2_18,
                                             AsmCc65.OPTIONS + " -C " + Path.GetFileName(cfgName)));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #5
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);

            // Configure delimiters for single-character operands.
            Formatter.DelimiterSet charDelimSet = new Formatter.DelimiterSet();
            charDelimSet.Set(CharEncoding.Encoding.C64Petscii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.C64ScreenCode, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.HighAscii,
                             new Formatter.DelimiterDef(string.Empty, '\'', '\'', " | $80"));

            config.mCharDelimiters = charDelimSet;

            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer                        = new LabelLocalizer(Project);
            mLocalizer.LocalPrefix            = "_";
            mLocalizer.QuirkNoOpcodeMnemonics = true;
            mLocalizer.Analyze();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "64tass", V1_53, AsmTass64.OPTIONS));
                }

                GenCommon.Generate(this, sw, worker);

                if (mNeedHereOp)
                {
                    OutputLine(string.Empty, SourceFormatter.FormatPseudoOp(HERE_PSEUDO_OP),
                               string.Empty, string.Empty);
                }
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #6
0
        // IGenerator; executes on background thread
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            config.mForceAbsOpcodeSuffix         = ":";
            config.mForceLongOpcodeSuffix        = "l";
            config.mForceAbsOperandPrefix        = string.Empty;
            config.mForceLongOperandPrefix       = string.Empty;
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = string.Empty;
            config.mAllowHighAsciiCharConst      = true;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Merlin;
            SourceFormatter        = new Formatter(config);

            string msg = string.Format(Properties.Resources.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = ":";
                mLocalizer.Analyze();
            }

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    // No version-specific stuff yet.  We're generating code for v1.0.
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                                             "Merlin 32", new CommonUtil.Version(1, 0)));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #7
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Properties.Resources.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "_";
                mLocalizer.Analyze();
            }
            mLocalizer.MaskLeadingUnderscores();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                                             "64tass", V1_53, AsmTass64.OPTIONS));
                }

                GenCommon.Generate(this, sw, worker);

                if (mNeedHereOp)
                {
                    OutputLine(string.Empty, SourceFormatter.FormatPseudoOp(HERE_PSEUDO_OP),
                               string.Empty, string.Empty);
                }
            }
            mOutStream = null;

            return(pathNames);
        }
Exemple #8
0
        // IGenerator
        public GenerationResults GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string pathName = Path.Combine(mWorkDirectory, mFileNameBase + ASM_FILE_SUFFIX);

            pathNames.Add(pathName);
            string cfgName = Path.Combine(mWorkDirectory, mFileNameBase + CFG_FILE_SUFFIX);

            pathNames.Add(cfgName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer                        = new LabelLocalizer(Project);
            mLocalizer.LocalPrefix            = "@";
            mLocalizer.QuirkVariablesEndScope = true;   // https://github.com/cc65/cc65/issues/938
            mLocalizer.QuirkNoOpcodeMnemonics = true;
            mLocalizer.Analyze();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(cfgName, false, new UTF8Encoding(false))) {
                GenerateLinkerScript(sw);
            }
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "cc65", mAsmVersion,
                                             AsmCc65.OPTIONS + " -C " + Path.GetFileName(cfgName)));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(new GenerationResults(pathNames, string.Empty));
        }
        // IGenerator; executes on background thread
        public GenerationResults GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer             = new LabelLocalizer(Project);
            mLocalizer.LocalPrefix = ":";
            // don't need to set QuirkNoOpcodeMnemonics
            mLocalizer.Analyze();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    // No version-specific stuff yet.  We're generating code for v1.0.
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "Merlin 32", new CommonUtil.Version(1, 0), string.Empty));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(new GenerationResults(pathNames, string.Empty));
        }
Exemple #10
0
        // IGenerator
        public GenerationResults GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            // While '.' labels are limited to the current zone, '@' labels are visible
            // between global labels.  (This is poorly documented.)
            mLocalizer.LocalPrefix            = "@";
            mLocalizer.QuirkNoOpcodeMnemonics = true;
            mLocalizer.ReservedWords          = new List <string>()
            {
                "NOT"
            };
            mLocalizer.Analyze();

            mPcDepth     = 0;
            mFirstIsOpen = true;

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "acme", mAsmVersion, AsmAcme.OPTIONS));
                }

                if (HasNonZeroBankCode())
                {
                    // don't try
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               "ACME can't handle 65816 code that lives outside bank zero");
                    int firstAddr = Project.AddrMap.OffsetToAddress(0);
                    AddressMap.AddressRegion fakeRegion = new AddressMap.AddressRegion(0,
                                                                                       Project.FileData.Length, firstAddr);
                    OutputArDirective(new AddressMap.AddressChange(true,
                                                                   0, firstAddr, fakeRegion, true));
                    OutputDenseHex(0, Project.FileData.Length, string.Empty, string.Empty);
                    OutputArDirective(new AddressMap.AddressChange(false,
                                                                   0, firstAddr, fakeRegion, true));
                }
                else
                {
                    GenCommon.Generate(this, sw, worker);
                }
            }
            mOutStream = null;

            return(new GenerationResults(pathNames, string.Empty));
        }