Files
R8Forge/examples
dsh ae268b9442 Interactive I/O: teach the VMs INP, and let examples declare their input
The library can read characters now that the viz defaults to serial ASCII, but
R8Forge's own machines could not: r8forge_derive, r8forge_tape_run and the
examples harness all skipped ',' ("input is not modelled"), so an interactive
program could only be run through ROT-8-viz -- the wrong end of the dev loop,
and nothing in CI could cover it.

Three small pieces:

  * INP (',') reads the next scripted character (low 7 bits) and 0 once the
    text runs out, in tests/tape_run.cc, src/derive.cc and the examples VM.
    r8forge_tape_run and r8forge_derive take -i/--input "<text>", so an
    interactive program is run and checked exactly like any other:
        r8forge_tape_run t.rot8 -i "12+34="
        r8forge_derive calc.r8asm 0 -i "12+34="
  * examples_test learns an optional `;   in ...` header next to `;   out`:
    the characters after the marker are fed to INP before the run.  The marker
    must be the first word after ';' so "include" in a comment is not eaten.
  * examples/echo_chars.r8asm: the smallest interactive program -- read four
    characters, print them back.  in R8F! -> out 82 56 70 33, 8 characters,
    8 steps.

Verified the same tape three ways: tape_run -i "R8F!" -> 82 56 70 33,
derive 0 -i "R8F!" -> same, rot8_test --input R8F! -> prints R8F.  With no
input at all INP reads 0, which is how every non-interactive example keeps
running unchanged.

Baseline: examples_test is now 15 examples + asm/test.r8asm.
2026-11-09 17:14:12 +08:00
..