public void TestPseudoOpBank()
        {
            string source = @"!bank 0, $20
                              !pseudopc $8000

                              !byte 20

                              !bank 1, $20
                              !pseudopc $8000

                              !byte 30

                              !bank 2, $20
                              !pseudopc $8000

                              !byte 40";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.crt";
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));
            Assert.AreEqual(0, parser.Messages.Count); // no warnings regarding overlapped segments

            var assembly = parser.AssembledOutput;

            Assert.AreEqual("008014000000000000000000000000000000000000000000000000000000000000001E0000000000000000000000000000000000000000000000000000000000000028", assembly.Assembly.ToString());
        }
        public void TestPseudoOpByteWordDWord()
        {
            string source = @"!to ""po_byte_word_dword.prg"",cbm
                * = $2000
                          !byte 1
                          !byte 2,3,4,5,6,7
                          !byte %...##...

                          !word 1
                          !16 2,3,4,5,6,7
                          !le16 2,3,4,5,6,7
                          !be16 1
                          !be16 2,3,4,5,6,7
          
                          !dword $01020304
                          !32 $05060708,$090a0b0c,$ffeeddcc
                          !le32 2,3,4,5,6,7
                          !be32 1";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.crt";
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));
            Assert.AreEqual(0, parser.Messages.Count); // no warnings regarding overlapped segments

            var assembly = parser.AssembledOutput;

            Assert.AreEqual("002001020304050607180100020003000400050006000700020003000400050006000700000100020003000400050006000704030201080706050C0B0A09CCDDEEFF02000000030000000400000005000000060000000700000000000001", assembly.Assembly.ToString());
        }
Example #3
0
        public void TestDASMSyntax()
        {
            string source = @"  ORG $2000
LABEL
                             dc.b  1,2,3,4,5,6,7,8";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.PDS);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.DASM;

            Assert.IsTrue(parser.Parse(source, null, config, null));

            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual(1, parser.Warnings);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.W1000_UNUSED_LABEL, parser.Messages.Values[0].Code);

            Assert.AreEqual("00200102030405060708", assembly.Assembly.ToString());
        }
Example #4
0
        public void TestStringLiteralWithMoreThanOneCharacter()
        {
            string source = @"* = $0801
                !byte 2,""http://www.georg-rottensteiner.de/test/haus1.html""
                !byte ""http://www.georg-rottensteiner.de/test/haus1.html""";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsFalse(parser.Parse(source, null, config, null));

            Assert.AreEqual(2, parser.Errors);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.ERROR, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.E1000_SYNTAX_ERROR, parser.Messages.Values[0].Code);
            Assert.IsTrue(parser.Messages.Values[0].Message.Contains("More than one"));

            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.ERROR, parser.Messages.Values[1].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.E1000_SYNTAX_ERROR, parser.Messages.Values[1].Code);
            Assert.IsTrue(parser.Messages.Values[1].Message.Contains("More than one"));
        }
        public override bool HandleImport(CharsetProject CharSet, CharsetEditor Editor)
        {
            Parser.ASMFileParser asmParser = new RetroDevStudio.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" + editInput.Text;

            if ((asmParser.Parse(temp, null, config, null)) &&
                (asmParser.Assemble(config)))
            {
                GR.Memory.ByteBuffer charData = asmParser.AssembledOutput.Assembly;

                int charsToImport = (int)charData.Length / 8;
                if (charsToImport > CharSet.TotalNumberOfCharacters)
                {
                    charsToImport = CharSet.TotalNumberOfCharacters;
                }

                for (int i = 0; i < charsToImport; ++i)
                {
                    charData.CopyTo(CharSet.Characters[i].Tile.Data, i * 8, 8);
                    Editor.CharacterChanged(i);
                }

                return(true);
            }
            return(false);
        }
Example #6
0
        public void TestPotentialWarningForIndirectJMPWithLateEvaluation()
        {
            string source = @"* = $2000

                             jmp (JUMP_ADDRESS )

                            JUMP_ADDRESS = $3fff";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));

            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual(1, parser.Warnings);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.W0007_POTENTIAL_PROBLEM, parser.Messages.Values[0].Code);

            Assert.AreEqual("00206CFF3F", assembly.Assembly.ToString());
        }
Example #7
0
        public void TestLocalLabelInLoop()
        {
            string source = @"!for j = 0 to 5
           *=$4000+256*j
.Einsprung   Lda #20
;.Zweisprung  Ldx $2000+8*j
            jsr .Einsprung
            inx
!end";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual("0040A914200040E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200041E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200042E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200043E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200044E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200045E8", assembly.Assembly.ToString());
        }
Example #8
0
        public void TestDASMLocalLabelScope()
        {
            string source = "  ORG $2000\r\n"
                            + "LABEL subroutine\r\n"
                            + ".locallabel\r\n"
                            + "  inc $d000\r\n"
                            + "  jmp .locallabel";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.DASM);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.DASM;

            Assert.IsTrue(parser.Parse(source, null, config, null));

            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual(1, parser.Warnings);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.W1000_UNUSED_LABEL, parser.Messages.Values[0].Code);

            Assert.AreEqual("0020EE00D04C0020", assembly.Assembly.ToString());
        }
Example #9
0
        public void TestOverlappingSegmentWarning()
        {
            string source = @"* = $2000

                             !fill 256
                             * = $20fe
                             rts";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));

            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual(1, parser.Warnings);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.W0001_SEGMENT_OVERLAP, parser.Messages.Values[0].Code);

            Assert.AreEqual("002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000", assembly.Assembly.ToString());
        }
Example #10
0
        private GR.Memory.ByteBuffer TestAssembleC64Studio(string Source, out RetroDevStudio.Types.ASM.FileInfo Info)
        {
            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            bool parseResult = parser.Parse(Source, null, config, null);

            if (!parseResult)
            {
                Debug.Log("Testassemble failed:");
                foreach (var msg in parser.Messages.Values)
                {
                    Debug.Log(msg.Message);
                }
            }


            Assert.IsTrue(parseResult);
            Assert.IsTrue(parser.Assemble(config));

            Info = parser.ASMFileInfo;

            return(parser.AssembledOutput.Assembly);
        }
        private void editASMDirArt_TextChanged(object sender, EventArgs e)
        {
            Parser.ASMFileParser asmParser = new RetroDevStudio.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" + editASMDirArt.Text;

            if ((asmParser.Parse(temp, null, config, null)) &&
                (asmParser.Assemble(config)))
            {
                GR.Memory.ByteBuffer data = asmParser.AssembledOutput.Assembly;

                ResultingData = data;

                labelASMInfo.Text      = "Data is valid";
                labelASMInfo.ForeColor = System.Drawing.SystemColors.ControlText;
            }
            else
            {
                labelASMInfo.Text      = "Invalid ASM Data (expect !byte statements)";
                labelASMInfo.ForeColor = System.Drawing.Color.Red;
            }
        }
Example #12
0
        private void btnImportFromAssembly_Click(object sender, EventArgs e)
        {
            Parser.ASMFileParser asmParser = new RetroDevStudio.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" + editDataImport.Text;

            if ((asmParser.Parse(temp, null, config, null)) &&
                (asmParser.Assemble(config)))
            {
                ImportFromData(asmParser.AssembledOutput.Assembly, checkImportSwizzle.Checked, checkImportColorsSorted.Checked);
            }
        }
Example #13
0
        public void TestAssemblyOpcodeDetectionNoZeropageRelativeY()
        {
            string source = @"* = $1000
                            lda ($1234),y";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            bool parseResult = parser.Parse(source, null, config, null);

            Assert.IsFalse(parseResult);
        }
        private void btnFromASM_Click(object sender, EventArgs e)
        {
            Parser.ASMFileParser asmParser = new RetroDevStudio.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" + textBinaryData.Text;

            if ((asmParser.Parse(temp, null, config, null)) &&
                (asmParser.Assemble(config)))
            {
                SetHexData(asmParser.AssembledOutput.Assembly);
            }
        }
Example #15
0
        public void TestHugeFile()
        {
            string source = @"* = $2000
                             !fill $80000";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));

            Assert.AreEqual(0x80002, (int)parser.AssembledOutput.Assembly.Length);
        }
Example #16
0
        public void TestAssemblyOpcodeDetectionNoIndirectAbsoluteX()
        {
            string source = @"* = $1000
                            lda ($1234),x";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            bool parseResult = parser.Parse(source, null, config, null);

            Assert.IsFalse(parseResult);
            //var assembly = TestAssembleC64Studio( source, out RetroDevStudio.Types.ASM.FileInfo info );
            //Assert.AreEqual( "0010BD3412", assembly.ToString() );
        }
Example #17
0
        public void TestValueOutOfBoundsLiteral()
        {
            string source = @"* = $ff00
                             jmp $12345";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsFalse(parser.Parse(source, null, config, null));

            Assert.AreEqual(1, parser.Errors);
            Assert.AreEqual(RetroDevStudio.Parser.ParserBase.ParseMessage.LineType.ERROR, parser.Messages.Values[0].Type);
            Assert.AreEqual(RetroDevStudio.Types.ErrorCode.E1003_VALUE_OUT_OF_BOUNDS_WORD, parser.Messages.Values[0].Code);
        }
Example #18
0
        public void TestNoDiscardVirtualSection()
        {
            string source = @"* = $1f00
                                        !byte $17
                              * = $2000  ";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.crt";
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual("001F17", assembly.Assembly.ToString());
        }
Example #19
0
        public void TestNoVirtualSectionAt840()
        {
            string source = @"!to ""lady-bug.prg"",cbm
        *=$0801   : !BASIC          ; Basiczeile erzeugen

        BLOCK     = 33            ; Spriteblock -> Block*64 = Spritedaten
        MATRIX    = $0400         ; Bildschirmspeicher
        POINTER_0   = MATRIX+$03F8        ; Spritepointer

              SEI           ; IRQ sperren

              LDA #$B0          ; X-Koordinate
              STA $D000         ; Sprite 0

              LDA #$81          ; Y-Koordinate
              STA $D001         ; Sprite 0

              LDA #BLOCK          ; Spriteblock
              STA POINTER_0       ; Spritepointer 0

              LDA #%00000001        ; Sprite Nr. 0
              STA $D015         ; Sprite-DMA Register

        -     JMP -           ; Warten

              !FILL $19,$EA       ; Code bis $083E bis 083F = Kein Sprite

        *=BLOCK*64                ; Adresse der Spritedaten -> Ballon

              !BYTE %00000011,%11111000,%00000000
              !BYTE %00001111,%11111110,%00000000
              !BYTE %00011111,%11111111,%00000000
              !BYTE %00011111,%00111111,%00000000
              !BYTE %00111110,%11001111,%10000000
              !BYTE %00111110,%11111111,%10000000
              !BYTE %00111110,%11001111,%10000000
              !BYTE %00011111,%00111111,%00000000
              !BYTE %00011111,%11111111,%00000000
              !BYTE %00011111,%11111111,%00000000
              !BYTE %00010111,%11111101,%00000000
              !BYTE %00001011,%11111010,%00000000
              !BYTE %00001001,%11110010,%00000000
              !BYTE %00000100,%11100100,%00000000
              !BYTE %00000100,%11100100,%00000000
              !BYTE %00000010,%01001000,%00000000
              !BYTE %00000010,%01001000,%00000000
              !BYTE %00000001,%11110000,%00000000
              !BYTE %00000001,%11110000,%00000000
              !BYTE %00000001,%11110000,%00000000
              !BYTE %00000000,%11100000,%00000000
              !BYTE $00";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));
            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            Assert.AreEqual("01080B080A009E3230363100000078A9B08D00D0A9818D01D0A9218DF807A9018D15D04C2208EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEA000003F8000FFE001FFF001F3F003ECF803EFF803ECF801F3F001FFF001FFF0017FD000BFA0009F20004E40004E40002480002480001F00001F00001F00000E00000", assembly.Assembly.ToString());
        }
        public void TestC64StudioPseudoOpMacroAndSourceInfo1()
        {
            string source = @"
                !to ""macro_macro.prg"",cbm

            ;* = $1000
            ;MACRO_START

            !macro fill5bytes v1,v2,v3,v4,v5
                      lda #v1
                      sta 1024
                      lda #v2
                      sta 1025
                      lda #v3
                      sta 1026
                      lda #v4
                      sta 1027
                      lda #v5
                      sta 1028
            !end



            ;MACRO_END

            ;!if ( MACRO_START != MACRO_END ) {
            ;!error Macro has size!
            ;}

            * = $2000
                      lda #$01
                      sta 53281
            CALLEDLED_MACRO
                      +fill5bytes 10,20,30,40,50
            CALLEDLED_MACRO_END
                      inc 53280
                      +fill5bytes 1,2,3,4,5

                      rts";

            RetroDevStudio.Parser.ASMFileParser parser = new RetroDevStudio.Parser.ASMFileParser();
            parser.SetAssemblerType(RetroDevStudio.Types.AssemblerType.C64_STUDIO);

            RetroDevStudio.Parser.CompileConfig config = new RetroDevStudio.Parser.CompileConfig();
            config.OutputFile = "test.prg";
            config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
            config.Assembler  = RetroDevStudio.Types.AssemblerType.C64_STUDIO;

            Assert.IsTrue(parser.Parse(source, null, config, null));

            Assert.IsTrue(parser.Assemble(config));

            var assembly = parser.AssembledOutput;

            string file;
            int    lineIndex;

            parser.ASMFileInfo.DocumentAndLineFromAddress(0x2000, out file, out lineIndex);

            Assert.IsTrue(parser.ASMFileInfo.Labels.ContainsKey("CALLEDLED_MACRO"));
            Assert.IsTrue(parser.ASMFileInfo.Labels.ContainsKey("CALLEDLED_MACRO_END"));

            Assert.AreEqual(28, lineIndex);

            var label  = parser.ASMFileInfo.Labels["CALLEDLED_MACRO"];
            var label2 = parser.ASMFileInfo.Labels["CALLEDLED_MACRO_END"];

            Assert.AreEqual(30, label.LocalLineIndex);
            Assert.AreEqual(32, label2.LocalLineIndex);

            Assert.AreEqual(0x2005, label.AddressOrValue);
            Assert.AreEqual(0x201e, label2.AddressOrValue);

            var tokenInfo = parser.ASMFileInfo.TokenInfoFromName("CALLEDLED_MACRO", "", "");

            Assert.IsNotNull(tokenInfo);
            Assert.AreEqual(30, tokenInfo.LocalLineIndex);

            tokenInfo = parser.ASMFileInfo.TokenInfoFromName("CALLEDLED_MACRO_END", "", "");
            Assert.IsNotNull(tokenInfo);
            Assert.AreEqual(32, tokenInfo.LocalLineIndex);
        }