Add a mode switch and a getting-started section

%synth used to always run both searches, so every assembly of the full adder
sat there for twenty minutes.  A block can now say 'mode layers' to stop after
the layer search (7.7 seconds) or 'mode tape' (the default) to pay for the
shortest tape.  examples/full_add_layers.r8asm is the fast one, 95 characters
and still checked on the machine.

The lexer also no longer chokes on a UTF-8 BOM.  Every Windows editor writes
one, and the first token came out as a garbage prefix, which crashed the
assembler with an access violation rather than saying anything useful.

README grew a getting-started walkthrough: build, a complete adder.r8asm, what
the two stderr lines mean, how to drop a synth block into a library, and the
three things that bite (inputs first, don't call them in/out, map length).
This commit is contained in:
starcells committed 2026-11-06 10:14:58 +08:00
1 parent 388c2b7dbd
commit 6fcdc4a1ea
5 files changed
+129 -12

No files matched your search

+3 -1
View File
@@ -18,7 +18,8 @@
std::vector<std::array<int, 3>>
r8asm_synth_program(int params, const std::vector<int> &in,
const std::vector<int> &out, const std::vector<int> &map,
const std::string &name, const std::vector<int> &layout);
const std::string &name, const std::vector<int> &layout,
int mode);
class r8asm {
using data = int16_t;
@@ -123,6 +124,7 @@ private:
std::vector<int> out; // param index per output bit, bit 0 first
std::vector<int> map; // 2^|in| entries: output bits of that input
std::vector<int> layout; // optional: cell address of each parameter
int mode = 0; // 0 = shortest tape, 1 = fewest layers only
};
private: