1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-01-16 19:32:31 +00:00

Improve 64tass output

DCI is handled with the ".shift" pseudo-op.  The .null, .ptext,
and .shift operators all work correctly with escaped characters,
so we no longer redo those.
This commit is contained in:
Andy McFadden 2019-08-09 19:13:58 -07:00
parent dae76d9b45
commit a4f5d19295
3 changed files with 21 additions and 17 deletions

View File

@ -543,7 +543,7 @@ namespace SourceGen.AsmGen {
StringOpFormatter.RawOutputStyle.DenseHex, MAX_OPERAND_LEN, charConv);
if (dfd.FormatType == FormatDescriptor.Type.StringDci) {
// DCI is awkward because the character encoding flips on the last byte. Rather
// than clutter up StringOpFormatter for this rare item, we just accept both
// than clutter up StringOpFormatter for this rare item, we just accept low/high
// throughout.
stropf.CharConv = CharEncoding.ConvertLowAndHighAscii;
}

View File

@ -128,7 +128,7 @@ namespace SourceGen.AsmGen {
StrNullTerm = ".null",
StrLen8 = ".ptext",
//StrLen16
//StrDci
StrDci = ".shift"
};
private const string HERE_PSEUDO_OP = ".here";
@ -522,7 +522,7 @@ namespace SourceGen.AsmGen {
// We could probably do something fancy with the character encoding options to
// make high-ASCII work nicely.
//
// We might be able to define a macro for DCI and Reverse.
// We might be able to define a macro for Reverse.
Formatter formatter = SourceFormatter;
byte[] data = Project.FileData;
@ -541,7 +541,6 @@ namespace SourceGen.AsmGen {
switch (dfd.FormatType) {
case FormatDescriptor.Type.StringGeneric:
case FormatDescriptor.Type.StringReverse:
case FormatDescriptor.Type.StringDci:
opcodeStr = sDataOpNames.StrGeneric;
highAscii = (data[offset] & 0x80) != 0;
break;
@ -564,6 +563,10 @@ namespace SourceGen.AsmGen {
}
shownLeadingBytes = 2;
break;
case FormatDescriptor.Type.StringDci:
opcodeStr = sDataOpNames.StrDci;
highAscii = (data[offset] & 0x80) != 0;
break;
default:
Debug.Assert(false);
return;
@ -577,6 +580,12 @@ namespace SourceGen.AsmGen {
StringOpFormatter stropf = new StringOpFormatter(SourceFormatter, '"',
StringOpFormatter.RawOutputStyle.CommaSep, MAX_OPERAND_LEN,
CharEncoding.ConvertLowAscii);
if (dfd.FormatType == FormatDescriptor.Type.StringDci) {
// DCI is awkward because the character encoding flips on the last byte. Rather
// than clutter up StringOpFormatter for this rare item, we just accept low/high
// throughout.
stropf.CharConv = CharEncoding.ConvertLowAndHighAscii;
}
// Feed bytes in, skipping over hidden bytes (leading L8, trailing null).
stropf.FeedBytes(data, offset + hiddenLeadingBytes,
@ -589,20 +598,15 @@ namespace SourceGen.AsmGen {
case FormatDescriptor.Type.StringGeneric:
case FormatDescriptor.Type.StringReverse:
case FormatDescriptor.Type.StringL16:
case FormatDescriptor.Type.StringDci:
// All good the first time.
break;
case FormatDescriptor.Type.StringNullTerm:
if (stropf.Lines.Count != 1 || stropf.HasEscapedText) {
// Must be single-line without quoted chars.
opcodeStr = sDataOpNames.StrGeneric;
redo = true;
}
break;
case FormatDescriptor.Type.StringL8:
if (stropf.Lines.Count != 1 || stropf.HasEscapedText) {
// Must be single-line without quoted chars.
case FormatDescriptor.Type.StringDci:
if (stropf.Lines.Count != 1) {
// Must be single-line.
opcodeStr = sDataOpNames.StrGeneric;
stropf.CharConv = CharEncoding.ConvertLowAscii; // undo DCI hack
redo = true;
}
break;

View File

@ -65,7 +65,7 @@
.byte $80
.byte $e8,$e9,$e7,$e8,$a0,$c1,$d3,$c3,$c9,$c9,$a0,$f3,$f4,$f2,$fa,$00
.byte $80
.text "'low'quoted",$22,"''text",$00
.null "'low'quoted",$22,"''text"
.byte $80
.byte $a2,$e8,$e9,$e7,$e8,$a2,$f1,$f5,$ef,$f4,$e5,$e4,$a7,$a2,$a2,$f4
.byte $e5,$f8,$f4,$00
@ -82,7 +82,7 @@
.byte $80
.byte $0f,$e8,$e9,$e7,$e8,$a0,$c1,$d3,$c3,$c9,$c9,$a0,$f3,$f4,$f2,$b1
.byte $80
.text $12,"'low'quoted",$22,"''text"
.ptext "'low'quoted",$22,"''text"
.byte $80
.byte $13,$a2,$e8,$e9,$e7,$e8,$a2,$f1,$f5,$ef,$f4,$e5,$e4,$a7,$a2,$a2
.byte $f4,$e5,$f8,$f4
@ -119,11 +119,11 @@
.text "n mankind, and therefore never send to know for whom the bell "
.text "tolls; it tolls for thee."
.byte $81
.text "low ASCII dc",$e9
.shift "low ASCII dci"
.byte $80
.byte $e8,$e9,$e7,$e8,$a0,$c1,$d3,$c3,$c9,$c9,$a0,$e4,$e3,$69
.byte $80
.text "'low'quoted",$22,"''tex",$f4
.shift "'low'quoted",$22,"''text"
.byte $80
.byte $a2,$e8,$e9,$e7,$e8,$a2,$f1,$f5,$ef,$f4,$e5,$e4,$a7,$a2,$a2,$f4
.byte $e5,$f8,$74