master
19
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1e7acc018e |
hardware: the 74LS machine gets a period bill of materials, and a mechanics plan
Two things: the TTL build is now the main target (Tang Nano looks too modern), and the packer learned the format that makes the TTL build simple. Format: r8forge_tape_pack --eprom writes one byte per instruction with the opcode in the low three bits. Then ip is the EPROM address and D2..D0 are the opcode -- no shift register, no 16 bit window, no decoder. It wastes five bits per instruction, and a 27C512 is exactly 64K, which is the historical instruction budget: the 8 bit calculator (51378) and the flagship (43676) both fit. Both formats live in the same .r8t trailer now (format byte 1 = packed, 2 = one byte per instruction), decode dispatches on it, and the test runs both and requires the same output and step count. Carrier: 74LS DIPs on a green board, 27C512 in a socket with its quartz window, 6116 SRAM, 74LS299 for the rotate, 6850 ACIA for serial, 74LS47 and four seven segment displays on the panel, 1 MHz can oscillator. About 31 to 40 chips, 400 to 700 CNY, a few weeks. The FPGA stays as a bench-only stepping stone. hardware/mechanics.md: where mechanics actually pays. The program must stay electronic (130 metres of paper tape for the calculator), and 512 relays for the data ring are out, but the pointer is worth it -- > and < are 71 to 73 percent of all steps, so a 64 position ratchet or uniselector makes the machine physically walk the ring. Also listed: an electromagnetic step counter (10 to 20 Hz, so only in single step mode, with a clutch for free running), a paper tape punch or plotter for output, a tape/card reader or plain keypad for input, and a hand crank as the clock. The rule that keeps this safe: mechanics only ever sit on sensor and actuator pins and never in the logic path, and the handshake just stops the sequencer while something moves -- since nothing in the ISA can observe time, slower is not different. A relay-only machine is priced honestly too: 60 to 120 relays, 10 to 50 Hz, hello in 10 to 40 seconds, the calculator in four hours, so that one is an exhibit. Also fixed: the synthesised macro fallback file name now carries a per-run token. When the system temp directory is not writable every r8asm falls back to the same working directory, so parallel ctest runs could write and import the same file -- which showed up as a random one-test failure in 0.39 seconds and nothing else. |
||
|
|
9b31a51fec |
hardware: M0 -- the packer, the RTL, and a simulator that agrees byte for byte
The two things software cannot check by reading its own source are the 3 bit
packing and the bracket strategy, so both got a tool and a test.
New in the library (r8forge/tape.hh, src/tape.cc): the opcode numbering (taken
from ROT-8-viz enum, so the packed image and the hardware decoder cannot drift),
text <-> opcodes, opcodes <-> 3 bit bytes, the .r8t image with its trailer and
crc32, and a machine model that runs a packed tape the way a board would. The
model takes the bracket strategy as an option: backward scan with loop stack or
not, and jump-back-onto-the-[ (the contract) or past it (what the interpreters
do). All four combinations print the same thing, and the step count differs by
exactly the number of taken ] instructions -- which is what the test asserts.
Found and fixed while writing it: the loop stack discipline depends on the jump
convention. Jumping onto the [ means the [ re-pushes, so ] must pop on the jump;
jumping past it means the entry must stay until the loop exits. Mixing them up
emptied the stack on the second iteration of the calculator main loop -- caught
by the equivalence test on examples/calc.r8asm, not by reading the code.
Tools: r8forge_tape_pack (text tape -> image + --hex for $readmemh + --verify,
727 instructions become 273 bytes for hello, 62%, and the trailer sits past the
halt so address 0 of a ROM is instruction 0), and r8forge_tape_run now reads an
image directly and takes --loop-stack / --retest.
hardware/rot8.v: the 8 bit / 64 cell machine -- 3 bit opcodes from a byte
addressed memory read as a 16 bit window, a 6 bit dp with free wrap, the loop
stack bracket jump, blocking input, halt on ip == length, and a step counter that
counts instructions rather than cycles. hardware/tb_rot8.v loads a --hex image
and prints the OUT stream in tape_run format.
Verified with Icarus Verilog 14 (the RTL against tape_run --loop-stack --retest):
hello 577 instructions 417 steps 10 outs
term 16414 17643 11 (fed "lhi")
calc 51378 166741 19 (fed "12 34 + .": prints the prompt,
046 and the next prompt)
flagship 43676 100142 93
Every OUT stream identical. ctest -R rtl_sim runs that comparison from an 8 bit
build (11 tests in the default build now, where the RTL test self-skips because
the RTL is the 8 bit machine).
Two traps worth remembering: Icarus passes plusargs through as raw bytes, so an
absolute +HEX path containing non-ASCII (this checkout is under a Chinese
directory name) arrives mangled, $readmemh silently leaves the memory empty and
the machine obediently runs LEN steps of opcode 0 printing nothing -- run vvp
from the directory holding the hex with a relative name. And in_ready must not
be qualified with !in_valid or the input handshake deadlocks.
|
||
|
|
0c7d0c8754 |
hardware: the point is Harvard, not "no RAM" -- two ways to hold the program
Restating the constraint correctly: program and data must not share storage. That is already guaranteed by the instruction set, not by wiring -- none of the eight instructions can read or write the program memory, ip only moves by one or by a bracket jump, so there is no self modifying code and no way for data to become instructions. The two also wrap differently: the tape is linear and halts at the end, the data is a ring of 64 cells. Given a strict Harvard split, the program side has two ordinary implementations: * in place ROM: ip is the address of a parallel EEPROM or flash (28C256, 29C010, 39SF010), fifteen to seventeen address lines and eight data lines, no glue logic; the chip in a wide socket is the cartridge and there is no boot step; * on board program RAM plus a one shot load: a separate RAM or block RAM is filled at reset from any small source (serial flash, microSD, UART, even a 24C512) and then executed in place. Swapping tapes no longer means burning a chip; the price is a boot state machine and one more chip. It is still not the data RAM -- only the boot logic can write it, so the Harvard property holds. Both give random access, so the bracket scan question stays about speed only, and the loop stack is still the default because the calculator main loop wraps the whole tape. Media that cannot be addressed at all (mechanical tape, serial only flash, floppy) remain useful as the source for the second variant. |
||
|
|
96ef30304a |
hardware: execute in place -- the machine does not get a program RAM or a loader
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. |
||
|
|
e5a63d0196 |
hardware: the medium only has to fit in a hand -- rank the candidates by size
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. |
||
|
|
9d9d64a1d9 |
hardware: LOAD then RUN -- which makes a floppy a perfectly good tape
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. |
||
|
|
4f7fa63048 |
hardware: the medium needs +-1 iteration, not random access -- but our loops are long
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. |
||
|
|
6185f39f34 |
hardware: spell out what the program medium has to satisfy
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. |
||
|
|
0c75772cbb |
geometry: the ring size becomes a build option, and the machine takes 64 cells
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. |
||
|
|
d1939a687c |
hardware: the machine is 8 bits, and that fixes the budget too
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. |
||
|
|
12a2254078 |
docs: a design note for building the machine out of silicon
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. |
||
|
|
1513111689 |
synth: measure whether the address-aware metric can shrink a real program
It cannot. The calculator assembles to 73624 characters in the default flat metric and 73940 with --synth-chars (identity layout), 316 more. Three reasons, now written down in SPEC section 3.7: * the travel term 2*(hi-lo) is translation invariant, so moving a group of cells farther or nearer changes nothing; only a permutation or a spread can, and the contiguous identity layout is already the tightest of those; * the library blocks are expanded at dozens of call sites with different addresses, so a single layout line is a guess that the real sites rarely match; * the model still ignores the hop between blocks, and the exact metric tends to pick programs with more blocks (six blocks for the adder table against five, 82 emitted characters against 87 -- five characters, which the other tables give back and more). Cell placement is the lever that works, and it is already spent: the terminal front end first put its borrowed classifier cells at 52..57 (77164 characters) and moving them into 20..29 gave 73624, minus 3540. Five single-cell moves on the current map were measured too (T and DEPTH to 17, HAVE and CNT to 52, S2 back to 52) and every one is longer: +182, +2900, +92, +134, +3810. So the map is a local optimum and the only way down from 73.6k is to drop features. The experiment left three metric-0 cache entries behind; they were deleted, so the committed cache still holds only what the flat metric needs. |
||
|
|
5c414292d2 |
calc: a terminal front end -- echo, backspace editing and a prompt
The calculator now behaves like the terminal tape from the previous commit:
every character is echoed, backspace edits the digit window, Enter commits the
line and prints the next prompt, and '.' puts its result on its own line:
> 12 34 + .
0046
> 12<BS>3 .
0013
> ^D
It is not the terminal's line buffer moved over: the calculator consumes one
character at a time, and replaying a buffered line would mean unrolling the
engine once per buffer cell, which does not fit. Line editing here is the
digit window: backspace shifts it right by one, pads a '0' in front, echoes
"space, backspace" and keeps accumulating.
Three things had to be learned the hard way, all recorded in docs/calc.md ?8:
* a borrowed constant cell gets eaten. KBS (the 8 that backspace subtracts)
lived in SC+5, and the operator step erases SC..SC+6 wholesale, so the first
byte after an operator was treated as a backspace -- every character of
"12 34 + ." came out as an erase. It is now loaded right before each use.
It also must not borrow R: the EOF test writes R every round.
* set_1 only forces the low bit; cells lent to the classifier have to be
re-initialised each round rather than assumed clean.
* the prompt after Enter has to be printed before the command dispatch and the
operators run, because EH (the "this was Enter" flag) borrows SC+3, which
mul uses as scratch -- the first version printed a prompt after every
multiplication.
The tape went 64983 -> 73624 characters (+8.6k: three copies for the window
shift alone are ~4.4k, the two subtracts ~3k). That is past the old
ROT-8-viz INS_SIZE of 65536; the current VM sizes its buffer from the tape and
runs 112802 characters at 16 bits and 336304 at 32 bits, so only the
historical budget is gone, not the ability to run it. Ducking under 65536
again would mean dropping line editing: echo plus the Enter prompt alone is
about +2.5k, still over.
Verified: ctest 8/8 (examples_test checks the new header stream), the width
matrix at 11, 16 and 32 bits (calc stream, terminal tape and the viz's serial
output all agree; 73624 / 112802 / 336304 characters), and docs/calc.md records
step counts for the whole session list -- "12 34 + ." is 287589 steps, about
17% more than before the front end.
|
||
|
|
0c218abf32 |
calc: a 3 cell RPN stack -- nesting now works
The two register machine (A accumulator + P pending operand) could not nest:
"1 2 + 3 4 * + ." printed 0007 because the second operator overwrote the
first. The calculator now keeps a 3 cell stack (S0 is the top), operators run
immediately (pop two, push one), '.' is a real peek (repeated '.' shows the
same value, and it no longer flushes anything), and ',' clears both the stack
and the depth.
Depth is counted in DEPTH because the unary minus rule needs it: '-' is unary
iff the stack is empty. The previous "the previous character was an operator"
rule is wrong for a stack machine -- in "1 2 + -" the minus has to be a binary
subtraction (popping an empty cell yields 0, and 0 - top is exactly a
negation); treating it as unary would silently swallow the sign. The
"have == 0" rule from the original plan was already wrong for the old machine
("2 * -5" would lose its minus).
Sizing was driven by the tape: every push/pop is one copy per stack cell
(~500 characters), and the file has to stay under 65536. So 3 cells instead
of the 16 the TODO dreamed of: push is two copies (S2<-S1, S1<-S0), an
operator is two more (S1<-S2, then the result), and the new number is written
straight into clb_undigits' target cell (it erases N itself) so the extra
"result -> top" copy disappears -- that one was worth 540 characters. S2 sits
in cell 33, the freed OP cell: putting it at 51 cost 3.7k in walking alone.
64983 characters (was 62624) and 246142 steps for "12 34 + ." (was 280645 --
the old settle-the-pending-OP block is gone). The file header carries the
measured session list, the nesting cases, the stack move order (high to low,
or the source gets overwritten) and the older "2047 3 / ." caveat; docs/calc.md
gets the stack section, and SPEC 5.4/7.10 now point at DEPTH instead of NEED.
|
||
|
|
10f164b480 |
docs: the signed wrappers in SPEC, AGENTS, README and TODO
SPEC gains 7.10 with both contracts, the five design points and the measured tape lengths; 5.4 stops saying "implementation pending" and spells out why the range is asymmetric -- |N| can be outside the signed range while still fitting unsigned, so 1024 has to print -1024 and the absolute value cannot be done by clearing the sign bit. Numbers re-measured on this machine, because some had drifted: the flagship is 62351 characters / 202159 steps (documented as 62513 / 206491), --opt takes it to 56338, the calculator is 62624, the byte level test is 23 items over 22 macros, and asm/ has 55 macros in 23 files. tests/widths.ps1 no longer compares the viz's serial output below 8 bit cells: the viz prints one number per OUT there, so the 7 bit "viz FAILED" was the script's expectation, not the tape -- the calculator itself passes at 7 bits through r8forge_derive, and the same failure reproduces with the previous calculator (checked against HEAD in a temp worktree). The TODO gains the open question of whether the flagship should keep the 65536 limit at all, plus the evidence that a 16 bit tape of 96052 characters runs fine in the viz. |
||
|
|
3543003a78 |
digits: reorder the scratch block -- 22% fewer steps, 15% less tape
The profile said 77% of clb_digits' steps are pointer moves, so the layout of its 13 cell scratch block (S..S+12) is the cost. The block is one rigid 7 cell unit (clb_divmod owns its internal order: Rhi,Sd,Bo,Cm=Bc,Ci,buf,NR) plus six free units, so the legal space is 5040 permutations. All 5040 were assembled and run (minimal driver, value 2047): old: TEN Q R [block] counter T F new: T1 R [block] TEN Q F counter tape 13,717 -> 11,717 chars (-14.6%) steps 145,114 -> 113,264 (-21.9%) pointer moves 111,958 -> 80,108 (-28.4%) non-move steps identical (33,156) Full 2048 value sweep: worst 164,843 -> 123,731 (-24.9%), mean 144,904 -> 112,552 (-22.3%), better on all 2048 values. The old layout ranked 3459/5040. Two things worth remembering. First, ordering the units by the wrapper's first visit order is *worse* than the old layout (150,748 steps): first visit ignores revisit frequency -- the counter is touched once per round, TEN is copied into Bc every round, T1 is hammered by clb_add_ip's carry chain. Second, the n-1 lower bound is not reachable here: 74% of the steps still execute inside clb_divmod's block, whose order is not clb_digits' to choose, so this lever is now exhausted (that is what the exhaustive search proves). Min tape is not min steps either: block-first BQTRT1F1C gives the shortest tape (10,713) but 123,890 steps. Tape counts a .tp once, steps count its execution. Ripple: asm/test.r8asm 64,513 -> 62,513 chars, 236,439 -> 206,491 steps, INS_SIZE headroom ~1k -> ~3k; --opt 58,060 -> 56,350; calc --opt 52,857; calc_op 77,356 -> 69,324 chars / 599,090 -> 476,170 steps. Verified: ctest 8/8, byte_op_test 21 items (digits 2048/2048), examples_test 18, --opt assembles, SPEC 7.7/10.2 + AGENTS + README + docs/calc.md + docs/divmod.md numbers updated. New driver drv/digits_layout.r8asm keeps the measurement honest (one clb_digits call, no output, value fed as 0=2047). |
||
|
|
b2ba20b885 |
vms: raise the step cap from 5M to 20M
5 million steps was picked when the worst macro (clb_add_ip with B=2047) sat just under a million, so it caught hangs quickly. The interactive programs changed the arithmetic: one printed line of the desk calculator costs about 225k steps (40k for clb_undigits, up to 32k for the operation, ~141k for clb_digits), which is only about twenty lines before the cap, and examples_test applies the same cap to every example. At roughly 2.3e8 steps per second a 20M cap costs 0.09 s when a program really does run away, and byte_op_test (the only place that runs 465k programs) is unchanged -- so the safety net stays cheap while a session gets four times the room. docs/calc.md, docs/divmod.md, docs/byte-ops.md and SPEC's "500 ?" mentions now say 2000 ?. |
||
|
|
692995af59 |
docs: the desk calculator's design and the order to build it in
ci / wide sweep (manual) (11) (push) Skipped
ci / wide sweep (manual) (24) (push) Skipped
ci / wide sweep (manual) (16) (push) Skipped
ci / wide sweep (manual) (32) (push) Skipped
ci / wide sweep (manual) (8) (push) Skipped
ci / cold cache (manual) (push) Skipped
ci / baseline (11 bit) (push) Canceled after 0s
ci / cell 8 (push) Canceled after 0s
ci / cell 16 (push) Canceled after 0s
ci / cell 32 (push) Canceled after 0s
Back to the RPN idea, but written down before any code: the command protocol (* + , - . / are exactly 0x2A..0x2F, digits 0x30..0x39, so one bit 4 test splits them and t = C - 0x2A is the command index), the memory map (working cells, a fixed 4 deep stack, library scratch, a pre-seeded constant block), the step budget per token, and the five stages with the driver each one gets verified by. Two decisions recorded there: EOF (0) ends the loop by erasing its counter, and the stack stays a fixed 4 cells -- .tp is an assembly time constant, so a moving stack pointer is the one thing this machine cannot do cheaply. |
||
|
|
a82d95658e |
docs: one home per fact -- README as the front door, SPEC as the contract, AGENTS as the manual
The three documents had grown to 2038 lines and quoted each other: 2199 appeared
seven times, 3977 ten times, AGENTS carried a 200-line copy of SPEC's byte-level
tables while README carried another 155-line copy still showing 8-bit-era numbers
(clb_add_nc 688, clb_not_ip 17, ...) that are wrong at 11 bits.
Split by responsibility, keep every fact exactly once:
README.md front door: what it is, 30-second build+run, directory map, where
to read next 547 -> 143 lines
SPEC.md the contract: %synth, geometry, every macro's signature / cells /
tape length / who verifies it, test matrix, boundaries, maintenance
901 -> 807 lines
AGENTS.md the manual: hard rules, build and self-check commands, the traps,
current state, next candidates, do-not-touch list
590 -> 132 lines
Long-form reasoning moves into docs/ instead of being dropped:
docs/divmod.md the shift-restore division story (was SPEC 14, 102 lines;
renumbered 1..6, SPEC keeps a pointer and the references in
SPEC 7.6 and asm/divmod.r8asm now point there)
docs/byte-ops.md the byte-level design history (was README's 155-line section,
rewritten with 11-bit numbers since the old ones were
measured at 8 bits)
Also fixes what the dedupe exposed: SPEC no longer claims only the multiplier has
a step bound, and raw_sub's comment no longer repeats the retracted "1.48M steps"
figure. Every section reference in the tree resolves; the baseline still passes
(asm/test.r8asm 64513 characters, 21 byte-op items, 14 examples, 48 macros).
|