mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-27 03:17:45 +00:00
Fix DCI string edge case
If a DCI string ended with a string delimiter or non-ASCII character (e.g. a PETSCII char with no ASCII equivalent), the code generator output the last byte as a hex value. This caused an error because it was outputting the raw hex value, with the high bit already set, which the assembler did not expect. This change corrects the behavior for code generation and on-screen display, and adds a few samples to the regression test suite. (see issue #102)
This commit is contained in:
1 parent
fa1b0af932
commit
635084db9d
27 files changed
+617
-89
No files matched your search
@@ -31,8 +31,17 @@ namespace Asm65 {
|
||||
/// </summary>
|
||||
public enum ReverseMode { Forward, LineReverse, FullReverse };
|
||||
|
||||
/// <summary>
|
||||
/// Character encoding conversion delegate. This function converts a raw byte value
|
||||
/// to a printable value, or CharEncoding.UNPRINTABLE_CHAR.
|
||||
/// </summary>
|
||||
public CharEncoding.Convert CharConv { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the input bytes are a DCI string. Only compatible with ReverseMode==Forward.
|
||||
/// </summary>
|
||||
public bool IsDciString { get; set; } = false;
|
||||
|
||||
// Output format for raw (non-printable) characters. Most assemblers use comma-separated
|
||||
// hex values, some allow dense hex strings.
|
||||
public enum RawOutputStyle { DenseHex, CommaSep };
|
||||
@@ -252,6 +261,8 @@ namespace Asm65 {
|
||||
/// </summary>
|
||||
public void FeedBytes(byte[] data, int offset, int length, int leadingBytes,
|
||||
ReverseMode revMode) {
|
||||
Debug.Assert(!IsDciString || revMode == ReverseMode.Forward);
|
||||
|
||||
int startOffset = offset;
|
||||
int strEndOffset = offset + length;
|
||||
|
||||
@@ -288,7 +299,11 @@ namespace Asm65 {
|
||||
} else {
|
||||
Debug.Assert(revMode == ReverseMode.Forward);
|
||||
for (; offset < strEndOffset; offset++) {
|
||||
WriteChar(data[offset]);
|
||||
byte val = data[offset];
|
||||
if (IsDciString && offset == strEndOffset - 1) {
|
||||
val ^= 0x80;
|
||||
}
|
||||
WriteChar(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user