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.
This commit is contained in:
dsh committed 2026-11-20 15:58:39 +08:00
1 parent 4f7fa63048
commit 9d9d64a1d9
1 file changed
+32 -1
+32 -1
View File
@@ -250,5 +250,36 @@ rnz, 最低位 == 1: ip-- ; 深度=0
| 纸带 / 卡带 / 转鼓 | C、演示 | 正/反向 | 演示级:`hello` 577 条可以,计算器 5 万条不行 |
* **要不要"纸带"这个物理形态**:演示级纸带(≤ ~2000 条,2.54 mm 孔距约 5 m)可以做,
大程序进 ROM(8 位全家桶 16.4 KB)。
### 装载架构:从介质装进 RAM,再从 RAM 跑(推荐)
上面那张速度表说明"直接拿机械介质当执行存储器"不划算,但它**不该**判软盘/卡带死刑 ——
真实机器都是 **LOAD → RUN**:介质只负责把镜像送进 64 KB RAM(几十毫秒到几秒都无所谓),
执行永远在 RAM 里(零遍历成本)。这样:
* 介质只需要"能顺序读出字节",速度只要 ≥ 几十 KB/s;
* 括号栈、`ip` 计数器、64 格数据环都不变;
* 机器开机跑一小段 ROM 里的 loader(或面板上一个 LOAD 键),之后就是纯 RAM 执行。
按这个架构,**软盘是完全合格的介质**,而且今天的可得性比想象中好:
| 选项 | 现在的可得性 | 说明 |
|---|---|---|
| USB 软驱(3.5",1.44 MB) | 仍在量产,¥50~120 | 走 USB 大容量存储(UFI),只给**整扇区**读写,所以要一个 µC/树莓派当 host 把扇区喂给机器 —— "介质是真的,读盘的是现代小板" |
| 内置 34 pin 软驱 + N82077AA 一类控制器 | 二手/NOS,驱动器 ¥50~200,控制器芯片更少 | 全部复古件,接口是并行的(数据 + 寄存器),要自己写 MFM 扇区状态机;坏了难修 |
| Gotek / USB 软驱模拟器 | 新货,¥100~200 | 插 34 pin,放 .img 文件;**没有真介质**,但最可靠 |
| 音频卡带 | 空白带仍在卖,随身听遍地 | 1200 baud ≈ 150 B/s:19 KB 镜像装 2 分钟 ✓ 装载体完全够用;执行仍在 RAM |
| EEPROM + 面板"选程序" | 一直好买 | 内置程序(monitor / 计算器 / hello)走它,不需要"换带" |
**软盘作为"直接执行的纸带"也不是不行**:300 rpm、18 扇区/轨 → 46 KB/s 的顺序流;
5 万条(19 KB)的纸带一轮 0.4 s,配循环栈(只往前流)就能跑 —— 代价是每读一个字符要等
0.4 s,而且必须自己做 MFM 解码/扇区同步。相比之下 **LOAD→RUN** 简单一个量级,还快 100 倍。
软盘的真实风险不在买不到驱动机,而在**介质**:20~30 年的 3.5" 盘会发霉、掉磁;NOS 盘
¥5~10 一片,多备几片、存两份镜像就没事。配套的软件工具很轻:`tape pack` 加一个
`--fat12 disk.img` 输出,把 `HELLO.R8T`、`CALC.R8T` 写进一张标准 1.44 MB 镜像,
PC 上用任何 USB 软驱把它写进真盘,机器上的 loader 读回来即可。
* **第一步**:M0 —— `r8forge tape pack` + `hardware/rot8.v` 的 testbench 对拍。不依赖任何
硬件采购,也不需要先定介质(打包输出同时喂 BRAM 初始化、EEPROM 烧写器和 testbench)。
硬件采购,也不需要先定介质(打包输出同时喂 BRAM 初始化、EEPROM 烧写器、FAT12 镜像和
testbench)。