GeorgRottensteiner / C64Studio

C64Studio is a .NET based IDE specializing in game development for the C64 in assembler and BASIC
Other
260 stars 38 forks source link

Crash occurs when taking low or high byte of immediate forward label inside macro. #124

Closed Dart-Matter closed 3 months ago

Dart-Matter commented 3 months ago

Encountered this while porting asm code.

Assembling the following with a default setup

!macro mactest
    lda #<+
+   rts    
!end

results in:

An error occurred during building an element
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at RetroDevStudio.Parser.ASMFileParser.EvaluateTokens(Int32 LineIndex, List`1 Tokens, Int32 StartIndex, Int32 Count, Map`2 TextCodeMapping, SymbolInfo& ResultingToken, Int32& NumBytesGiven) in D:\projekte\C64Studio\C64Models\Parser\ASMFileParser.cs:line 1635
   at RetroDevStudio.Parser.ASMFileParser.EvaluateTokens(Int32 LineIndex, List`1 Tokens, Int32 StartIndex, Int32 Count, Map`2 TextCodeMapping, SymbolInfo& ResultingToken, Int32& NumBytesGiven) in D:\projekte\C64Studio\C64Models\Parser\ASMFileParser.cs:line 1999
   at RetroDevStudio.Parser.ASMFileParser.EstimateOpcode(Int32 LineIndex, List`1 LineTokens, List`1 PossibleOpcodes, LineInfo& info, List`1& OpcodeExpressions, UInt64& ResultingOpcodePatchValue, Boolean& HadError) in D:\projekte\C64Studio\C64Models\Parser\ASMFileParser.cs:line 12704
   at RetroDevStudio.Parser.ASMFileParser.PreProcess(String[] Lines, String ParentFilename, ProjectConfig Configuration, String AdditionalPredefines, Boolean& HadFatalError) in D:\projekte\C64Studio\C64Models\Parser\ASMFileParser.cs:line 5520
   at RetroDevStudio.Parser.ASMFileParser.Parse(String Content, ProjectConfig Configuration, CompileConfig Config, String AdditionalPredefines, FileInfo& ASMFileInfo) in D:\projekte\C64Studio\C64Models\Parser\ASMFileParser.cs:line 10628
   at RetroDevStudio.MainForm.ParseFile(ParserBase Parser, DocumentInfo Document, ProjectConfig Configuration, String AdditionalPredefines, Boolean OutputMessages, Boolean CreatePreProcessedFile, Boolean CreateRelocationFile, FileInfo& ASMFileInfo) in D:\projekte\C64Studio\C64Studio\MainForm.cs:line 5807
   at RetroDevStudio.Tasks.TaskCompile.BuildElement(DocumentInfo Doc, String ConfigSetting, String AdditionalPredefines, Boolean OutputMessages, SingleBuildInfo& BuildInfo, FileInfo& FileInfo) in D:\projekte\C64Studio\C64Studio\Tasks\TaskCompile.cs:line 820
GeorgRottensteiner commented 3 months ago

Nice catch!

Fixed with commit 405cb6aea11770fc7269bac3afccd12fc9113442, uploaded WIP version at https://www.georg-rottensteiner.de/webmisc/C64StudioRelease.zip

Dart-Matter commented 3 months ago

Verified.