Skip to content

Commit

Permalink
Use Merlin 32 "putbin" directive
Browse files Browse the repository at this point in the history
I had missed the existence of Merlin 32's PUTBIN directive, which
provides the binary include feature.
  • Loading branch information
fadden committed Jun 1, 2024
1 parent 4e5c34f commit 7ca11b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 13 additions & 4 deletions SourceGen/AsmGen/AsmMerlin32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public class GenMerlin32 : IGenerator {
// IGenerator
public int StartOffset { get { return 0; } }

/// <summary>
/// List of binary include sections found in the project.
/// </summary>
private List<BinaryInclude.Excision> mBinaryIncludes = new List<BinaryInclude.Excision>();

/// <summary>
/// Working directory, i.e. where we write our output file(s).
/// </summary>
Expand Down Expand Up @@ -133,7 +138,7 @@ public class GenMerlin32 : IGenerator {
{ "Uninit", "ds" },
//Junk
//Align
//BinaryInclude
{ "BinaryInclude", "putbin" },
{ "StrGeneric", "asc" },
{ "StrReverse", "rev" },
//StrNullTerm
Expand Down Expand Up @@ -244,8 +249,7 @@ public GenerationResults GenerateSource(BackgroundWorker worker) {
}
mOutStream = null;

return new GenerationResults(pathNames, string.Empty,
new List<BinaryInclude.Excision>());
return new GenerationResults(pathNames, string.Empty, mBinaryIncludes);
}

// IGenerator
Expand Down Expand Up @@ -318,7 +322,6 @@ public void OutputDataOp(int offset) {
break;
case FormatDescriptor.Type.Uninit:
case FormatDescriptor.Type.Junk:
case FormatDescriptor.Type.BinaryInclude: // not supported, gen minimal output
int fillVal = Helper.CheckRangeHoldsSingleValue(data, offset, length);
if (fillVal >= 0) {
opcodeStr = sDataOpNames.Fill;
Expand Down Expand Up @@ -350,6 +353,12 @@ public void OutputDataOp(int offset) {
OutputDenseHex(offset, length, labelStr, commentStr);
}
break;
case FormatDescriptor.Type.BinaryInclude:
opcodeStr = sDataOpNames.BinaryInclude;
string biPath = BinaryInclude.ConvertPathNameFromStorage(dfd.Extra);
operandStr = biPath; // no quotes
mBinaryIncludes.Add(new BinaryInclude.Excision(offset, length, biPath));
break;
case FormatDescriptor.Type.StringGeneric:
case FormatDescriptor.Type.StringReverse:
case FormatDescriptor.Type.StringNullTerm:
Expand Down
5 changes: 2 additions & 3 deletions SourceGen/SGTestData/Expected/20300-binary-include_merlin32.S
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ L1000 ldy #$28
lda done-1
jmp done

:L1017 hex 20212223242526272829303132333435363738394142434445464748494a5051
hex 5253545556575859
:L103F ds 32,$ff
:L1017 putbin 20300-1.bin
:L103F putbin 20300sub/20300-2.bin

done rts

0 comments on commit 7ca11b0

Please sign in to comment.