diff --git a/source/xasm/package.d b/source/xasm/package.d index 08b7eb4..329eaa0 100644 --- a/source/xasm/package.d +++ b/source/xasm/package.d @@ -860,10 +860,19 @@ private: version (unittest) int testValue(string l) { line = l; column = 0; + inOpcode = false; readValue(); return value; } + version (unittest) string testValueError(string l) { + try + testValue(l); + catch (Exception e) + return e.msg; + return null; + } + unittest { auto a = testAssembler(); with (a) { @@ -884,6 +893,9 @@ private: assert(testValue("{nop}") == 0xea); assert(testValue("{CLC}+{sec}") == 0x50); assert(testValue("{Jsr}") == 0x20); + assert(testValueError("{lda <") == "Unexpected end of line"); + assert(testValue("{bne $12}") == 0xd0); + assert(testValue("{Jsr $1234}") == 0x20); assert(testValue("{bit a:}") == 0x2c); assert(testValue("{bIt $7d}") == 0x24); } @@ -945,7 +957,7 @@ private: case '<': case '>': addrMode = AddrMode.IMMEDIATE; - if (inOpcode && line[column] == '}') + if (inOpcode && !eol() && line[column] == '}') return; readWord(); final switch (c) { @@ -1117,9 +1129,7 @@ private: } void readAbsoluteAddrMode() { - if (inOpcode && readChar() == '}') { - column--; - } else { + if (!(inOpcode && !eol() && line[column] == '}')) { readAddrMode(); switch (addrMode) { case AddrMode.ABSOLUTE: diff --git a/xasm.1.asciidoc b/xasm.1.asciidoc index a9c3178..6311937 100644 --- a/xasm.1.asciidoc +++ b/xasm.1.asciidoc @@ -743,6 +743,9 @@ Version 3.3.0 (2026-09-??) - fixed writing the */t* label table: it no longer closes standard output when the listing goes to `-`, nor overwrites the listing file when both */l* and */t* name the same file (by Adrian Matoga) +- fixed parsing of opcode values: an operand such as in `{jsr $1234}` + is no longer misread, and a line ending with `{lda <` no longer crashes + (by Adrian Matoga) Version 3.2.1 (2022-12-08) ~~~~~~~~~~~~~~~~~~~~~~~~~~