public void TestNoValueAfterSeparatorPOWord() { string source = @"* = $2000 !word 0,0,0,"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; C64Studio.Types.ErrorCode code = C64Studio.Types.ErrorCode.OK; Assert.IsFalse(parser.Parse(source, null, config)); foreach (var entry in parser.Messages.Values) { code = entry.Code; break; } Assert.AreEqual(1, parser.Errors); Assert.AreEqual(C64Studio.Types.ErrorCode.E1000_SYNTAX_ERROR, code); }
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"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); Assert.IsTrue(parser.Assemble(config)); var assembly = parser.AssembledOutput; Assert.AreEqual("0040A914200040E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200041E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200042E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200043E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200044E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A914200045E8", assembly.Assembly.ToString()); }
private GR.Memory.ByteBuffer TestAssemblePDS(string Source) { C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.PDS); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.PDS; bool parseResult = parser.Parse(Source, null, config); 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)); return(parser.AssembledOutput.Assembly); }
public void TestPotentialWarningForIndirectJMPWithLateEvaluation() { string source = @"* = $2000 jmp (JUMP_ADDRESS ) JUMP_ADDRESS = $3fff"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); Assert.IsTrue(parser.Assemble(config)); var assembly = parser.AssembledOutput; Assert.AreEqual(1, parser.Warnings); Assert.AreEqual(C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type); Assert.AreEqual(C64Studio.Types.ErrorCode.W0007_POTENTIAL_PROBLEM, parser.Messages.Values[0].Code); Assert.AreEqual("00206CFF3F", assembly.Assembly.ToString()); }
public void TestOverlappingSegmentWarning() { string source = @"* = $2000 !fill 256 * = $20fe rts"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); Assert.IsTrue(parser.Assemble(config)); var assembly = parser.AssembledOutput; Assert.AreEqual(1, parser.Warnings); Assert.AreEqual(C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING, parser.Messages.Values[0].Type); Assert.AreEqual(C64Studio.Types.ErrorCode.W0001_SEGMENT_OVERLAP, parser.Messages.Values[0].Code); Assert.AreEqual("002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000", assembly.Assembly.ToString()); }
public void TestDASMLocalLabelScope() { string source = @"ORG $2000 LABEL subroutine .locallabel inc $d000 jmp .locallabel"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.DASM); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.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(C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type); Assert.AreEqual(C64Studio.Types.ErrorCode.W1000_UNUSED_LABEL, parser.Messages.Values[0].Code); Assert.AreEqual("0020EE00D04C0020", assembly.Assembly.ToString()); }
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"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.crt"; config.Assembler = C64Studio.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"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.crt"; config.Assembler = C64Studio.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()); }
public void TestMacroWithImmediateForwardLabels() { string source = @"*=$0801 !basic !macro name lda #0 beq + lda #1 jmp ++ + lda #2 ++ !end +name"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; var assembly = TestAssembleC64Studio(source); //Assert.IsTrue( parser.Parse( source, null, config, null ) ); //Assert.IsTrue( parser.Assemble( config ) ); //var assembly = parser.AssembledOutput; Assert.AreEqual("01080B080A009E32303631000000A900F005A9014C1808A902", assembly.ToString()); }
public void TestBinaryLiteralsOutOfBounds() { string source = @" * = $c000 !byte %#...##... !byte %101000010"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; C64Studio.Types.ErrorCode code = C64Studio.Types.ErrorCode.OK; Assert.IsFalse(parser.Parse(source, null, config)); foreach (var entry in parser.Messages.Values) { code = entry.Code; break; } Assert.AreEqual(2, parser.Errors); Assert.AreEqual(C64Studio.Types.ErrorCode.E1002_VALUE_OUT_OF_BOUNDS_BYTE, code); }
public void TestDASMSyntax() { string source = @"ORG $2000 LABEL dc.b 1,2,3,4,5,6,7,8"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.PDS); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.PDS; Assert.IsTrue(parser.Parse(source, null, config)); Assert.IsTrue(parser.Assemble(config)); var assembly = parser.AssembledOutput; Assert.AreEqual(1, parser.Warnings); Assert.AreEqual(C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING, parser.Messages.Values[0].Type); Assert.AreEqual(C64Studio.Types.ErrorCode.W1000_UNUSED_LABEL, parser.Messages.Values[0].Code); Assert.AreEqual("00200102030405060708", assembly.Assembly.ToString()); }
protected override bool ProcessTask() { if (m_Document.Type != ProjectElement.ElementType.ASM_SOURCE) { return(true); } Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); if (m_Document.Element != null) { compileConfig.Assembler = m_Document.Element.AssemblerType; } string sourceCode = ""; if (m_Document.BaseDoc != null) { if (m_Document.Type == ProjectElement.ElementType.ASM_SOURCE) { sourceCode = ((SourceASMEx)m_Document.BaseDoc).editSource.Text; } else if (m_Document.Type == ProjectElement.ElementType.BASIC_SOURCE) { sourceCode = ((SourceBasicEx)m_Document.BaseDoc).editSource.Text; } } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig, null); if ((compileConfig.Assembler != C64Studio.Types.AssemblerType.AUTO) && (m_Document.BaseDoc != null) && (m_Document.Element != null)) { if (m_Document.Element.AssemblerType != compileConfig.Assembler) { m_Document.Element.AssemblerType = compileConfig.Assembler; m_Document.BaseDoc.SetModified(); } } ((SourceASMEx)m_Document.BaseDoc).SetLineInfos(parser.ASMFileInfo); var knownTokens = parser.KnownTokens(); GR.Collections.MultiMap <string, C64Studio.Types.SymbolInfo> knownTokenInfos = parser.KnownTokenInfo(); m_Document.SetASMFileInfo(parser.ASMFileInfo, knownTokens, knownTokenInfos); var task = new Tasks.TaskUpdateKeywords(m_Document.BaseDoc); task.Core = Core; task.RunTask(); return(true); }
protected override bool ProcessTask() { Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); compileConfig.Assembler = m_Document.Element.AssemblerType; parser.ParseFile(m_Document, m_Configuration, compileConfig); return(true); }
private GR.Memory.ByteBuffer TestCompile(string Source) { C64Studio.Parser.BasicFileParser parser = new C64Studio.Parser.BasicFileParser(); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(Source, null, config)); Assert.IsTrue(parser.Assemble(config)); return(parser.AssembledOutput.Assembly); }
public void TestRenumberWithSpaces() { string source = @"20 IFA=1THEN 20"; var parser = CreateParser("BASIC V2"); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config, null)); string result = parser.Renumber(10, 3, 0, 64000); Assert.AreEqual("10IFA=1THEN 10", result); }
public void TestRenumberWithSpaces() { string source = @"20 ifa=1then 20"; C64Studio.Parser.BasicFileParser parser = new C64Studio.Parser.BasicFileParser(); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); string result = parser.Renumber(10, 3); Assert.AreEqual("10IFA=1THEN10", result); }
public void TestAssemblyOpcodeDetectionNoZeropageRelativeY() { string source = @"* = $1000 lda ($1234),y"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; bool parseResult = parser.Parse(source, null, config, null); Assert.IsFalse(parseResult); }
public void TestRenumberOverLines() { string source = @"10 goto 300 300 goto 10"; C64Studio.Parser.BasicFileParser parser = new C64Studio.Parser.BasicFileParser(); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); string result = parser.Renumber(10, 3); Assert.AreEqual(@"10GOTO13 13GOTO10", result); }
public void TestRenumberOverLines() { string source = @"10 GOTO 300 300 GOTO 10"; var parser = CreateParser(C64Studio.Parser.BasicFileParser.BasicVersion.C64_BASIC_V2); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config, null)); string result = parser.Renumber(10, 3, 0, 64000); Assert.AreEqual(@"10GOTO13 13GOTO10", result); }
public void TestOpcodeFallbackToAbsolute() { string source = @"* = $2000 Zeropage_Routine = $0020 jmp Zeropage_Routine"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; var assembly = TestAssemble(source); Assert.AreEqual("00204C2000", assembly.ToString()); }
public void TestHugeFile() { string source = @"* = $2000 !fill $80000"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); Assert.IsTrue(parser.Assemble(config)); Assert.AreEqual(0x80002, (int)parser.AssembledOutput.Assembly.Length); }
public void TestValueOutOfBoundsLiteral() { string source = @"* = $ff00 jmp $12345"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsFalse(parser.Parse(source, null, config)); Assert.AreEqual(1, parser.Errors); Assert.AreEqual(C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR, parser.Messages.Values[0].Type); Assert.AreEqual(C64Studio.Types.ErrorCode.E1003_VALUE_OUT_OF_BOUNDS_WORD, parser.Messages.Values[0].Code); }
public void TestNoDiscardVirtualSection() { string source = @"* = $1f00 !byte $17 * = $2000 "; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.crt"; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config, null)); Assert.IsTrue(parser.Assemble(config)); var assembly = parser.AssembledOutput; Assert.AreEqual("001F17000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", assembly.Assembly.ToString()); }
public void TestMacroWithLocalLabels() { string source = @"* = $0801 !basic LABEL_POS = $2000 ; add immediate 16bit value to memory !macro add16im .dest, .val { lda #<.val clc adc .dest sta .dest lda #>.val adc .dest + 1 sta .dest + 1 } +add16im LABEL_POS, 256 rts"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; var assembly = TestAssembleC64Studio(source); //Assert.IsTrue( parser.Parse( source, null, config, null ) ); //Assert.IsTrue( parser.Assemble( config ) ); //var assembly = parser.AssembledOutput; Assert.AreEqual("01080B080A009E32303631000000A900186D00208D0020A9016D01208D012060", assembly.ToString()); }
public void TestErrorOnIndirectAddressingForNOnSupportingOpCodes() { string source = @"* = $2000 SCREEN = $0400 lda (SCREEN) sta (SCREEN) jsr (TEST) lda #1 bne (THEEND) THEEND TEST rts"; C64Studio.Parser.ASMFileParser parser = new C64Studio.Parser.ASMFileParser(); parser.SetAssemblerType(C64Studio.Types.AssemblerType.C64_STUDIO); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; C64Studio.Types.ErrorCode code = C64Studio.Types.ErrorCode.OK; Assert.IsFalse(parser.Parse(source, null, config)); foreach (var entry in parser.Messages.Values) { code = entry.Code; break; } Assert.AreEqual(4, parser.Errors); Assert.AreEqual(C64Studio.Types.ErrorCode.E1105_INVALID_OPCODE, code); }
public void TestRenumberOnGosub() { string source = @"10 onxgosub100,400,700 100printa 400 printb 700 printc"; C64Studio.Parser.BasicFileParser parser = new C64Studio.Parser.BasicFileParser(); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config)); string result = parser.Renumber(10, 3); Assert.AreEqual(@"10ONXGOSUB13,16,19 13PRINTA 16PRINTB 19PRINTC", result); }
private GR.Memory.ByteBuffer TestCompile(string Source, C64Studio.Parser.BasicFileParser.BasicVersion Version) { var parser = CreateParser(Version); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; 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(parser.Assemble(config)); return(parser.AssembledOutput.Assembly); }
public void TestEncodeToLabels() { string source = @"10 PRINT ""HALLO"" 20 GOTO 10"; var parser = CreateParser("BASIC V2"); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config, null)); string encoded = parser.EncodeToLabels(); Assert.AreEqual(@" LABEL10 PRINT ""HALLO"" GOTO LABEL10 ", encoded); }
public void TestRenumberOnGosub() { string source = @"10 ONXGOSUB100,400,700 100PRINTA 400 PRINTB 700 PRINTC"; var parser = CreateParser("BASIC V2"); C64Studio.Parser.CompileConfig config = new C64Studio.Parser.CompileConfig(); config.OutputFile = "test.prg"; config.TargetType = C64Studio.Types.CompileTargetType.PRG; config.Assembler = C64Studio.Types.AssemblerType.C64_STUDIO; Assert.IsTrue(parser.Parse(source, null, config, null)); string result = parser.Renumber(10, 3, 0, 64000); Assert.AreEqual(@"10ONXGOSUB13,16,19 13PRINTA 16PRINTB 19PRINTC", result); }
protected override bool ProcessTask() { Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new C64Studio.Parser.CompileConfig(); compileConfig.Assembler = m_Document.Element.AssemblerType; string sourceCode = ""; if (m_Document.BaseDoc != null) { if (m_Document.Type == ProjectElement.ElementType.ASM_SOURCE) { sourceCode = ((SourceASMEx)m_Document.BaseDoc).editSource.Text; } else if (m_Document.Type == ProjectElement.ElementType.BASIC_SOURCE) { sourceCode = ((SourceBasicEx)m_Document.BaseDoc).editSource.Text; } } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig); if ((compileConfig.Assembler != C64Studio.Types.AssemblerType.AUTO) && (m_Document.BaseDoc != null) && (m_Document.Element != null)) { if (m_Document.Element.AssemblerType != compileConfig.Assembler) { m_Document.Element.AssemblerType = compileConfig.Assembler; m_Document.BaseDoc.SetModified(); } } return(true); }