The data ring is part of the ISA and cannot go away (64 addressable cells, one 6116
or 512 flip flops), but the program RAM and the loader are not part of the
machine: copying the tape into RAM would put another machine inside this one and
lose the premise that the tape is the program. So the default architecture is now
execute in place: ip is the address of the tape memory, the fetched byte yields
three bits of opcode, and the bracket scans are address increments and decrements.
That works with a parallel EEPROM or flash (28C256, 29C010, 39SF010): fifteen
address lines, eight data lines, no glue logic, and the chip in a socket is the
cartridge. On an FPGA the tape is block RAM initialised from the bitstream, which
also needs no loading step and no external chip. LOAD then RUN stays in the
document only as an optional peripheral for media that cannot be addressed:
mechanical tape, serial SPI flash, floppy.
One consequence is now stated as a requirement rather than an option: with in
place execution a bracket scan costs a clock per instruction, and the calculator
main loop wraps almost the whole 51378 instruction tape, so a scanning ] would
cost 51 k clocks per round -- 51 ms at 1 MHz, paid on every character read. The
loop stack implementation (pop on ], no rescan) is therefore the default, and it
is also what makes mechanical media viable at all.
The packer output is correspondingly simpler: the .bin is literally the memory
contents, ready for a programmer or a block RAM init file. No image layout, no
FAT, no loader to write.
With LOAD then RUN settled, the medium only has to deliver 19 to 51 KB once, so a
floppy is pure overkill and the useful axis is size. Section 9 now ranks the
candidates by area:
* a DIP-8 EEPROM or SPI flash (24C512, 25Q64) is a 10 mm square in an 8 pin socket
-- the ROM cartridge model, no filesystem at all because the chip is the address
space, about 3-10 CNY, writable with any CH341A class programmer;
* microSD is 15 by 11 mm and holds the whole tape library; the loader reads raw
sectors from LBA 0, so no FAT parser is needed either (dd from a PC writes the
card);
* a credit-card punched card at 2 mm pitch holds about 1000 instructions, which
runs hello (577) or full_add (95) but none of the big programs -- good as an art
cartridge, not as the main medium;
* a microcassette is 50 by 33 by 8 mm, a real small tape, 150 B/s so a 19 KB image
loads in two minutes, drives second hand;
* the 3.5 inch floppy, 90 by 94 mm, stays only if you want the clack.
Both small options also drop the filesystem question: one reads raw blocks, the
other is memory. A small AVR can act as the tape drive for a TTL machine behind a
DATA/STROBE handshake, and on an FPGA the loader is a few dozen lines. The packer
gains --at-lba 0 for the card case and --i2c-image for the programmer case; only
the floppy route would need --fat12.
A mechanical medium is only a bad *execution* memory; real machines loaded from the
medium into RAM and ran from there. That decouples the medium speed from the
machine: the medium just has to deliver tens of KB/s once, and execution costs no
traversal at all. With that architecture a 3.5 inch floppy is fine, and the note
now records what is still buyable: USB floppy drives are still made (about 50-120
CNY) but only expose whole 512 byte sectors, so a small microcontroller or a Pi
acts as the host and feeds them to the machine; a 34 pin drive plus an N82077AA
class controller is the all period correct route and much more work; Gotek style
emulators are the reliable but media-less option; audio cassettes are still
sold and load the 19 KB image in about two minutes, which is plenty when the
program then runs from RAM.
A floppy can even be the executing tape: at 300 rpm and 18 sectors per track it
streams 46 KB/s, so the 51378 instruction tape goes round in 0.4 s and with the
loop stack it only ever streams forward -- but you have to do MFM decoding and
sector framing yourself, and every input character waits 0.4 s. LOAD then RUN is
an order of magnitude simpler and a hundred times faster.
The real floppy risk is not the drive, it is the media: 20 to 30 year old disks
grow mould and lose their field, so keep several NOS disks and two copies of each
image. The software side is small: a --fat12 disk.img output on the packer,
writing HELLO.R8T and CALC.R8T into a standard 1.44 MB image that any USB drive
can put on a real disk.
Correcting an over-specification: ip only ever moves by one, and a bracket scan is
made of one-step moves, so any medium that can be iterated forwards and backwards
will do. Taking that further, the backward half is removable too: keep a five bit
LIFO of loop entry positions, push on [ when the low bit is one, and on ] always
pop -- the popped position is the matching [, and if the low bit is one we jump
back to it (it re-runs) and otherwise carry on. [ with a zero low bit still scans
forward, which it would anyway. That is equivalent to the reference scan for
well formed tapes, and since scans do not count as steps the four VMs still agree
on step counts. So a forward-only medium can execute directly.
What actually rules media out is speed. The runtime loops in our programs are
enormous: the calculator main loop wraps almost the whole 51378 instruction tape,
so every character read walks the entire tape. A paper tape reader at 50-300
characters per second would need 170-1000 seconds per keystroke; an audio
cassette around 130 s; magnetic tape or floppy class (30-500 k chars/s) gives 0.1
to 1.7 s; RAM needs no walk at all. So paper tape is a demo medium (the 577
instruction hello tape is about two seconds), and the practical machine stores
the tape in RAM or block RAM. The medium table and this analysis are in section
9, the loop-stack variant in section 4.
Nothing is committed to flash yet, so section 9 now records the constraint that
decides it: the [ skip scans forward but the ] jump scans backward, so whatever
holds the tape must support random access, or the machine has to copy the whole
tape into RAM at boot. That is why a serial SPI flash cannot execute directly:
it only streams forward. A parallel flash or EEPROM with an address bus can be
the tape itself (29C010 at 70-150 ns is comfortable at 1 MHz), and on an FPGA the
tape simply lives in block RAM next to the bitstream, no external chip at all.
The packed image the taper pack tool will emit is medium independent on purpose:
the same bytes initialise block RAM, program an EEPROM and drive the RTL
testbench, so M0 does not have to wait for the medium decision. Paper tape stays
a demo medium only: at 2.54 mm pitch the 577 instruction hello tape is about
1.5 m, and the calculator tape would be 130 m.
259 was never part of the machine, just the historical default, so
kDefaultMemoryCells is now R8FORGE_MEMORY_CELLS (1..65536, default 259) with a
range guard in CMake, the same way the cell width already worked. All five VMs
read it from geometry.hh, so nothing else had to change.
Measured the highest cell each tape in the tree actually touches by walking its
> and < and recording the peak (no tape does a < at cell 0, so none of them
depend on wrapping): calc 51, hello 49, signed_demo 34, term 27, and the
asm/test.r8asm self test 155, because it lays every macro cell block out side by
side. So a 64 cell ring runs every program we ship; only the self test needs
the default.
Verified: the full ctest suite is 8/8 at both 128 and 64 cells (11 bit); at the
hardware geometry of 8 bit plus 64 cells the widthfree label is 5/5, and the
calculator tape is byte for byte identical to the 259 cell build and its
sessions take the same 166348 steps. The self test also produces identical
output at 64 cells but 216 more steps, because its high cells fold back onto low
ones -- which is why SPEC section 1.2 states the rule: ring size must be at
least the highest cell a program touches plus one.
Hardware payoff: at 64 cells dp is a 6 bit counter whose wrap is free, so the
TTL build loses its modulo-259 comparator logic (four to five chips), the RAM
needs 64 bytes, and the drum shrinks to 8 tracks by 64 cells (at 3000 rpm that
is 52 s for a calculator session, so it wants to spin faster). hardware.md is
updated to the 8 bit / 64 cell machine throughout.
Decision: the physical machine uses 8 bit cells. 11 bits is half decimal
semantics and half superstition; at 8 bits a cell is a byte, so , and . are
plain byte I/O, the whole 259 cell ring is 259 bytes and fits one 6116, and the
datapath is one 74HC299 plus an XOR.
It also settles the instruction pointer problem: the 8 bit calculator is 51378
instructions, back under the historical 65536, where the 11 bit one had grown
to 73624 with its terminal front end. Measured tape sizes and step counts at 8
bits (build8, MSVC):
full_add 95 instructions, 36 bytes
hello 577 instructions, 217 bytes
term 16414 instructions, 6.2 KB
signed_demo 37511 instructions, 14.1 KB
asm/test.r8asm 43676 instructions, 16.4 KB, 99824 steps, 52 OUTs
calc 51378 instructions, 19.3 KB, 166348 steps for "12 34 + ."
The note now records the 8 bit numbers next to the 11/16/32 ones, recomputes the
TTL bill of materials (20-28 chips instead of 25-35: one RAM, one shift
register, four or five ip counters), gives the drum 8 tracks instead of 11, and
adds an optional M4 that widens the machine back to 11 bits by swapping the ROM
to demonstrate that width is a build parameter rather than runtime state.
Milestone M2 now expects exactly 99824 steps and M3 expects "046" from the
calculator, both of which the software side already produces.
docs/hardware.md turns the ISA into hardware requirements and works out what a
physical ROT-8 needs. The load-bearing observation is that nothing in the
instruction set can observe time -- no counters, no interrupts, and the I/O
behaviours are "block until a character" and "latch the cell" -- so any
implementation that reproduces the same sequence of (ip, dp, cells, output) is
the same machine, at any clock rate and any number of cycles per instruction.
That is what makes the build tractable: a microcoded sequencer, slow memory or
even a drum are all legal.
The note pins the parts that are easy to get wrong: the exact scan boundaries
for [ and ] (the ] case jumps back onto the [ itself so it re-tests, which the
reference rot8.c gets right and a naive implementation gets wrong), the halt
condition, cells starting at zero, and the input convention -- , blocks until a
character arrives and an explicit EOF reads as 0, otherwise every interactive
read would return zero and the program would exit at once.
Budget: 3 bits per instruction, so the flagship tape is 23.4 KB of ROM and the
calculator at 11 bits is 27.6 KB; the data ring is 259 cells by W bits at most
518 bytes. Two consequences: the instruction pointer needs at least 17 bits
because the calculator now assembles to 73624, past the historical INS_SIZE of
65536, and the 32 bit calculator (126 KB) does not fit the block RAM of the
small boards.
Three carriers are compared: FPGA first (Tang Nano 9K, about 58 KB of BSRAM, a
weekend of work), discrete TTL as the real machine (25-35 chips, 0.25-0.5 M
instructions per second, a few weeks) and electromechanical as the showpiece
(a drum with 11 tracks and 259 cells per track, read and write heads one cell
apart so a read-modify-write costs one cell time: 22 s for a whole calculator
session at 3000 rpm). The verification plan leans on what already exists: a
packer into the 3 bit format, the RTL testbench compared against tape_run step
by step, then the panel single-stepped against an exported trace.
Nothing is implemented; the note ends with the decisions that come first --
which carrier, which width (8, 11 or 16), program storage, and whether the
physical tape form matters. The first concrete step would be M0: the packer
plus a rot8.v testbench, which needs no hardware purchase and gives all three
carriers the same golden model.