1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 22:50:35 +00:00

Fix Merlin code gen issue with '{'

Merlin 1.0 chokes on "LDA #'{'".
This commit is contained in:
Andy McFadden 2021-10-21 12:43:13 -07:00
parent cd937709fa
commit fa0d88c069
3 changed files with 8 additions and 3 deletions

View File

@ -265,6 +265,10 @@ namespace SourceGen.AsmGen {
} }
private void GenerateLinkerScript(StreamWriter sw) { private void GenerateLinkerScript(StreamWriter sw) {
// Use a generic linker script. Note the start address is "%S", which uses the
// command line argument, with a default value of $0200. If we wanted to support
// PRG-style files, with the load address output by the assembler, we'd need to
// add a LOADADDR segment.
sw.WriteLine("# 6502bench SourceGen generated linker script for " + mFileNameBase); sw.WriteLine("# 6502bench SourceGen generated linker script for " + mFileNameBase);
sw.WriteLine("MEMORY {"); sw.WriteLine("MEMORY {");

View File

@ -454,9 +454,10 @@ namespace SourceGen.AsmGen {
// IGenerator // IGenerator
public FormatDescriptor ModifyInstructionOperandFormat(int offset, FormatDescriptor dfd, public FormatDescriptor ModifyInstructionOperandFormat(int offset, FormatDescriptor dfd,
int operand) { int operand) {
string badChars = ",{}";
if (dfd.FormatType == FormatDescriptor.Type.NumericLE && dfd.IsStringOrCharacter && if (dfd.FormatType == FormatDescriptor.Type.NumericLE && dfd.IsStringOrCharacter &&
(operand & 0x7f) == (byte)',') { badChars.IndexOf((char)(operand & 0x7f)) >= 0) {
// Merlin throws an error on comma operands, e.g. LDA #',' // Merlin throws an error on certain ASCII operands, e.g. LDA #','
dfd = FormatDescriptor.Create(dfd.Length, dfd = FormatDescriptor.Create(dfd.Length,
FormatDescriptor.Type.NumericLE, FormatDescriptor.SubType.None); FormatDescriptor.Type.NumericLE, FormatDescriptor.SubType.None);
} }

View File

@ -6,7 +6,7 @@
"Text" : "Many disassemblers assume everything is code, and ask you to separate out the data. SourceGen automatically finds all reachable code, so you just need to identify the places where the code starts." "Text" : "Many disassemblers assume everything is code, and ask you to separate out the data. SourceGen automatically finds all reachable code, so you just need to identify the places where the code starts."
}, },
{ {
"Text" : "Data that follows a JSR or JSL should be marked as \"inline data\". This allows the code analyzer to skip over it. Common situations, such as null-terminated strings and addresses, can be handled automatically.", "Text" : "Data that follows a JSR or JSL should be marked as \"inline data\". This allows the code analyzer to skip over it. Common situations, such as null-terminated strings and addresses, can be handled automatically with an extension script.",
"Image" : "print-inline-sample.png" "Image" : "print-inline-sample.png"
}, },
{ {