From 9aae1ad4c48f7290eb26115f47a751849107f1dd Mon Sep 17 00:00:00 2001 From: Adrian Matoga Date: Sun, 14 Mar 2021 23:32:32 +0100 Subject: [PATCH] Instruction pairing extended to more than two instructions. --- source/app.d | 25 ++++++++++++++++++++----- xasm.1.asciidoc | 7 ++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source/app.d b/source/app.d index 1f5e980..54743c6 100644 --- a/source/app.d +++ b/source/app.d @@ -2664,19 +2664,24 @@ unittest { void assemblyPair() { assert(!inOpcode); string instruction = readInstruction(); - if (!eol() && line[column] == ':') { + string[] extraInstructions; + while (!eol() && line[column] == ':') { pairing = true; column++; - string instruction2 = readInstruction(); + extraInstructions ~= readInstruction(); + } + if (!extraInstructions.empty) { int savedColumn = column; if (willSkip) warning("Skipping only the first instruction"); assemblyInstruction(instruction); checkNoExtraCharacters(); - column = savedColumn; wereManyInstructions = false; - assemblyInstruction(instruction2); - wereManyInstructions = true; + foreach (instruction2; extraInstructions) { + column = savedColumn; + assemblyInstruction(instruction2); + wereManyInstructions = true; + } } else { pairing = false; assemblyInstruction(instruction); @@ -2847,6 +2852,16 @@ void assemblyFile(string filename) { lineNo = oldLineNo; } +unittest { + sourceFiles[""] = " lda:sne:ldy:inx $1234".representation; + assemblyFile(""); + pass2 = true; + objectBuffer.length = 0; + assemblyFile(""); + writefln!"%(%02x%)"(objectBuffer); + assert(objectBuffer == [0xad, 0x34, 0x12, 0xd0, 0x03, 0xac, 0x34, 0x12, 0xe8]); +} + void assemblyPass() { origin = -1; loadOrigin = -1; diff --git a/xasm.1.asciidoc b/xasm.1.asciidoc index edf5177..b1765fc 100644 --- a/xasm.1.asciidoc +++ b/xasm.1.asciidoc @@ -160,7 +160,7 @@ to start a comment. ------------------------------------------------------------- [[new_pairing]] -You may put two instructions in one line so they share their operand. +You may put two or more instructions in one line so they share their operand. For example: ------------ eor:sta foo @@ -173,9 +173,9 @@ is equivalent to Note that ------------ - lda:tax #0 + lda:tax:tay #0 ------------ -is allowed because `#0` is treated as a comment for `tax`. +is allowed because `#0` is treated as a comment for `tax` and `tay`. EXPRESSIONS ----------- @@ -716,6 +716,7 @@ Version 3.x.x (20xx-xx-xx) ~~~~~~~~~~~~~~~~~~~~~~~~~~ - source can optionally be read from standard input, and object can be written to standard output instead of files (by Adrian Matoga) +- <> (by Adrian Matoga) Version 3.2.0 (2021-06-22) ~~~~~~~~~~~~~~~~~~~~~~~~~~