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.
16 lines
356 B
Plaintext
16 lines
356 B
Plaintext
; in R8F!
|
|
; out 82 56 70 33
|
|
;
|
|
; 最小的交互程序:读一个字符(`inp`)、原样打出来(`out`),重复 4 次.
|
|
; 输入是序列的,由运行器喂:r8forge_tape_run t.rot8 -i "R8F!"
|
|
; (实时终端那一侧在 ROT-8-viz,它的默认 I/O 就是串行字符.)
|
|
%include "asm/lib.r8asm"
|
|
|
|
.var C 0
|
|
|
|
%rep 4
|
|
.tp C
|
|
inp
|
|
output C
|
|
%endrep
|