Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Configures the assembler-specific format items.
        /// </summary>
        private void SetFormatConfigValues(ref Formatter.FormatConfig config)
        {
            config.mSuppressImpliedAcc = true;

            config.mOperandWrapLen               = 64;
            config.mForceDirectOpcodeSuffix      = "+1";
            config.mForceAbsOpcodeSuffix         = "+2";
            config.mForceLongOpcodeSuffix        = "+3";
            config.mForceDirectOperandPrefix     = string.Empty;
            config.mForceAbsOperandPrefix        = string.Empty;
            config.mForceLongOperandPrefix       = string.Empty;
            config.mLocalVariableLabelPrefix     = ".";
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mNonUniqueLabelPrefix         = "@";
            config.mCommaSeparatedDense          = false;
            config.mExpressionMode               = Formatter.FormatConfig.ExpressionMode.Common;

            Formatter.DelimiterSet charSet = new Formatter.DelimiterSet();
            charSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charSet.Set(CharEncoding.Encoding.HighAscii,
                        new Formatter.DelimiterDef(string.Empty, '\'', '\'', " | $80"));
            config.mCharDelimiters = charSet;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Configures some common format config items from the app settings.  Uses a
        /// passed-in object, rather than the global settings.
        /// </summary>
        /// <param name="settings">Application settings.</param>
        /// <param name="config">Format config struct.</param>
        public static void ConfigureFormatterFromSettings(AppSettings settings,
                                                          ref Formatter.FormatConfig config)
        {
            config.mUpperHexDigits =
                settings.GetBool(AppSettings.FMT_UPPER_HEX_DIGITS, false);
            config.mUpperOpcodes =
                settings.GetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, false);
            config.mUpperPseudoOpcodes =
                settings.GetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, false);
            config.mUpperOperandA =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_A, false);
            config.mUpperOperandS =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_S, false);
            config.mUpperOperandXY =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_XY, false);
            config.mAddSpaceLongComment =
                settings.GetBool(AppSettings.FMT_ADD_SPACE_FULL_COMMENT, true);

            config.mForceAbsOpcodeSuffix =
                settings.GetString(AppSettings.FMT_OPCODE_SUFFIX_ABS, string.Empty);
            config.mForceLongOpcodeSuffix =
                settings.GetString(AppSettings.FMT_OPCODE_SUFFIX_LONG, string.Empty);
            config.mForceAbsOperandPrefix =
                settings.GetString(AppSettings.FMT_OPERAND_PREFIX_ABS, string.Empty);
            config.mForceLongOperandPrefix =
                settings.GetString(AppSettings.FMT_OPERAND_PREFIX_LONG, string.Empty);

            string exprMode = settings.GetString(AppSettings.FMT_EXPRESSION_MODE, string.Empty);

            config.mExpressionMode = Formatter.FormatConfig.ParseExpressionMode(exprMode);
        }
Ejemplo n.º 4
0
        // IGenerator
        public void GetDefaultDisplayFormat(out PseudoOp.PseudoOpNames pseudoOps,
                                            out Formatter.FormatConfig formatConfig)
        {
            // This is not intended to match up with the Merlin generator, which uses
            // the same pseudo-op for low/high ASCII but different string delimiters.  We
            // don't change the delimiters for the display list, so instead we tweak the
            // opcode slightly.
            char hiAscii = '\u2191';

            pseudoOps = new PseudoOp.PseudoOpNames()
            {
                EquDirective   = "equ",
                OrgDirective   = "org",
                DefineData1    = "dfb",
                DefineData2    = "dw",
                DefineData3    = "adr",
                DefineData4    = "adrl",
                DefineBigData2 = "ddb",
                Fill           = "ds",
                Dense          = "hex",
                StrGeneric     = "asc",
                StrGenericHi   = "asc" + hiAscii,
                StrReverse     = "rev",
                StrReverseHi   = "rev" + hiAscii,
                StrLen8        = "str",
                StrLen8Hi      = "str" + hiAscii,
                StrLen16       = "strl",
                StrLen16Hi     = "strl" + hiAscii,
                StrDci         = "dci",
                StrDciHi       = "dci" + hiAscii,
            };

            formatConfig = new Formatter.FormatConfig();
            SetFormatConfigValues(ref formatConfig);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Configures the assembler-specific format items.  May be called without a Project.
        /// </summary>
        private void SetFormatConfigValues(ref Formatter.FormatConfig config)
        {
            // Must be lower case when --case-sensitive is used.
            config.mUpperOpcodes       = false;
            config.mUpperPseudoOpcodes = false;
            config.mUpperOperandA      = false;
            config.mUpperOperandS      = false;
            config.mUpperOperandXY     = false;
            config.mOperandWrapLen     = 64;

            config.mBankSelectBackQuote = true;

            config.mForceDirectOpcodeSuffix      = string.Empty;
            config.mForceAbsOpcodeSuffix         = string.Empty;
            config.mForceLongOpcodeSuffix        = string.Empty;
            config.mForceDirectOperandPrefix     = string.Empty;
            config.mForceAbsOperandPrefix        = "@w"; // word
            config.mForceLongOperandPrefix       = "@l"; // long
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mNonUniqueLabelPrefix         = ""; // should be '_', but that's a valid label char
            config.mCommaSeparatedDense          = true;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Common;
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Replaces the Formatter with a new one, using the current dialog configuration.
        /// </summary>
        private void ReplaceFormatter()
        {
            Formatter.FormatConfig config = mFormatter.Config;

            config.mHexDumpAsciiOnly = mAsciiOnlyDump;

            CharConvMode mode = (CharConvMode)charConvComboBox.SelectedIndex;

            switch (mode)
            {
            case CharConvMode.PlainAscii:
                config.mHexDumpCharConvMode = Formatter.FormatConfig.CharConvMode.PlainAscii;
                break;

            case CharConvMode.HighLowAscii:
                config.mHexDumpCharConvMode = Formatter.FormatConfig.CharConvMode.HighLowAscii;
                break;

            case (CharConvMode)(-1):
                // this happens during dialog init, before combo box is configured
                break;

            default:
                Debug.Assert(false);
                break;
            }

            mFormatter = new Formatter(config);
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        // IGenerator
        public void GetDefaultDisplayFormat(out PseudoOp.PseudoOpNames pseudoOps,
                                            out Formatter.FormatConfig formatConfig)
        {
            pseudoOps = sDataOpNames;

            formatConfig = new Formatter.FormatConfig();
            SetFormatConfigValues(ref formatConfig);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Configures the assembler-specific format items.
 /// </summary>
 private void SetFormatConfigValues(ref Formatter.FormatConfig config)
 {
     config.mForceAbsOpcodeSuffix         = ":";
     config.mForceLongOpcodeSuffix        = "l";
     config.mForceDirectOperandPrefix     = string.Empty;
     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;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Configures the assembler-specific format items.
 /// </summary>
 private void SetFormatConfigValues(ref Formatter.FormatConfig config)
 {
     config.mForceAbsOpcodeSuffix         = string.Empty;
     config.mForceLongOpcodeSuffix        = string.Empty;
     config.mForceDirectOperandPrefix     = "z:"; // zero
     config.mForceAbsOperandPrefix        = "a:"; // absolute
     config.mForceLongOperandPrefix       = "f:"; // far
     config.mEndOfLineCommentDelimiter    = ";";
     config.mFullLineCommentDelimiterBase = ";";
     config.mBoxLineCommentDelimiter      = ";";
     config.mAllowHighAsciiCharConst      = false;
     config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Cc65;
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Configures the assembler-specific format items.
        /// </summary>
        private void SetFormatConfigValues(ref Formatter.FormatConfig config)
        {
            config.mForceDirectOpcodeSuffix      = string.Empty;
            config.mForceAbsOpcodeSuffix         = string.Empty;
            config.mForceLongOpcodeSuffix        = string.Empty;
            config.mForceDirectOperandPrefix     = "z:"; // zero
            config.mForceAbsOperandPrefix        = "a:"; // absolute
            config.mForceLongOperandPrefix       = "f:"; // far
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Cc65;

            Formatter.DelimiterSet charSet = new Formatter.DelimiterSet();
            charSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charSet.Set(CharEncoding.Encoding.HighAscii,
                        new Formatter.DelimiterDef(string.Empty, '\'', '\'', " | $80"));
            config.mCharDelimiters = charSet;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Configures the assembler-specific format items.
        /// </summary>
        private void SetFormatConfigValues(ref Formatter.FormatConfig config)
        {
            config.mForceDirectOpcodeSuffix      = string.Empty;
            config.mForceAbsOpcodeSuffix         = ":";
            config.mForceLongOpcodeSuffix        = "l";
            config.mForceDirectOperandPrefix     = string.Empty;
            config.mForceAbsOperandPrefix        = string.Empty;
            config.mForceLongOperandPrefix       = string.Empty;
            config.mLocalVariableLablePrefix     = "]";
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = string.Empty;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Merlin;

            Formatter.DelimiterSet charSet = new Formatter.DelimiterSet();
            charSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charSet.Set(CharEncoding.Encoding.HighAscii, Formatter.DOUBLE_QUOTE_DELIM);
            config.mCharDelimiters = charSet;
        }
Ejemplo n.º 19
0
        // IGenerator
        public void GetDefaultDisplayFormat(out PseudoOp.PseudoOpNames pseudoOps,
                                            out Formatter.FormatConfig formatConfig)
        {
            pseudoOps = new PseudoOp.PseudoOpNames()
            {
                EquDirective   = "=",
                OrgDirective   = ".org",
                DefineData1    = ".byte",
                DefineData2    = ".word",
                DefineData3    = ".faraddr",
                DefineData4    = ".dword",
                DefineBigData2 = ".dbyt",
                Fill           = ".res",
                StrGeneric     = ".byte",
                StrNullTerm    = ".asciiz",
            };

            formatConfig = new Formatter.FormatConfig();
            SetFormatConfigValues(ref formatConfig);
        }
Ejemplo n.º 20
0
        // 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));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Configures some common format config items from the app settings.  Uses a
        /// passed-in settings object, rather than the global settings.
        /// </summary>
        /// <param name="settings">Application settings.</param>
        /// <param name="config">Format config struct.</param>
        public static void ConfigureFormatterFromSettings(AppSettings settings,
                                                          ref Formatter.FormatConfig config)
        {
            config.mUpperHexDigits =
                settings.GetBool(AppSettings.FMT_UPPER_HEX_DIGITS, false);
            config.mUpperOpcodes =
                settings.GetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, false);
            config.mUpperPseudoOpcodes =
                settings.GetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, false);
            config.mUpperOperandA =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_A, false);
            config.mUpperOperandS =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_S, false);
            config.mUpperOperandXY =
                settings.GetBool(AppSettings.FMT_UPPER_OPERAND_XY, false);
            config.mSpacesBetweenBytes =
                settings.GetBool(AppSettings.FMT_SPACES_BETWEEN_BYTES, false);
            config.mAddSpaceLongComment =
                settings.GetBool(AppSettings.FMT_ADD_SPACE_FULL_COMMENT, true);
            config.mOperandWrapLen =
                settings.GetInt(AppSettings.FMT_OPERAND_WRAP_LEN, 0);

            config.mForceAbsOpcodeSuffix =
                settings.GetString(AppSettings.FMT_OPCODE_SUFFIX_ABS, string.Empty);
            config.mForceLongOpcodeSuffix =
                settings.GetString(AppSettings.FMT_OPCODE_SUFFIX_LONG, string.Empty);
            config.mForceAbsOperandPrefix =
                settings.GetString(AppSettings.FMT_OPERAND_PREFIX_ABS, string.Empty);
            config.mForceLongOperandPrefix =
                settings.GetString(AppSettings.FMT_OPERAND_PREFIX_LONG, string.Empty);

            string exprMode = settings.GetString(AppSettings.FMT_EXPRESSION_MODE, string.Empty);

            config.mExpressionMode = Formatter.FormatConfig.ParseExpressionMode(exprMode);

            // Not doing the delimiter patterns here, because what's in the config file is
            // intended for on-screen display, and hence likely to be unsuited for an assembler.

            // Ditto for the local variable prefix.
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Configures the assembler-specific format items.
        /// </summary>
        private void SetFormatConfigValues(ref Formatter.FormatConfig config)
        {
            // Must be lower case when --case-sensitive is used.
            config.mUpperOpcodes       = false;
            config.mUpperPseudoOpcodes = false;
            config.mUpperOperandA      = false;
            config.mUpperOperandS      = false;
            config.mUpperOperandXY     = false;

            config.mBankSelectBackQuote = true;

            config.mForceAbsOpcodeSuffix         = string.Empty;
            config.mForceLongOpcodeSuffix        = string.Empty;
            config.mForceDirectOperandPrefix     = string.Empty;
            config.mForceAbsOperandPrefix        = "@w"; // word
            config.mForceLongOperandPrefix       = "@l"; // long
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mAllowHighAsciiCharConst      = false;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Common;
        }
Ejemplo n.º 23
0
        private void ReplaceFormatter()
        {
            Formatter.FormatConfig config = mFormatter.Config;

            CharConvItem item = (CharConvItem)charConvComboBox.SelectedItem;

            if (item == null)
            {
                // initializing
                return;
            }
            config.mHexDumpCharConvMode = item.Mode;

            config.mHexDumpAsciiOnly = AsciiOnlyDump;

            // Keep app settings up to date.
            AppSettings.Global.SetBool(AppSettings.HEXD_ASCII_ONLY, mAsciiOnlyDump);
            AppSettings.Global.SetEnum(AppSettings.HEXD_CHAR_CONV, typeof(CharConvMode),
                                       (int)item.Mode);

            mFormatter = new Formatter(config);
            HexDumpLines.Reformat(mFormatter);
        }
Ejemplo n.º 24
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));
        }