io: INP writes the whole cell -- the calculator now runs in this machine
The serial INP deliberately kept bits 7 and above ("they belong to the frame,
leave everything above alone"). That made a tape depend on whatever happened to
be in the cell before the read, and the two R8Forge machines do not do it: their
-i assignment replaces the whole cell. Measured consequence: examples/calc.r8asm
(a 62585 character tape, cell 11, well inside the limit) printed
> 0000 / > 0000 / > 0000
here instead of "> 0046", while r8forge_tape_run and r8forge_derive agreed on
62 32 48 48 52 54 10. The digit window and the display were not at fault:
drv/calc_disp.r8asm already printed correctly in both machines.
INP now writes `frame` (character + parity/stop if framing is on, zeros above)
and no longer ORs the old cell back in. With that:
rot8_test --cell 11 --input "12 34 + ." calc.rot8 -> > 0046
and the smoke checks are unchanged: serial R8F, -n 512 1536 512, 7E1 A. README
and docs/serial.md said bits above the character stay untouched; they now say INP
writes the whole cell, which is what every implementation does.
This commit is contained in:
1 parent
c3ab2f1ac0
commit
e2faeba011
2 files changed
+5
-5
No files matched your search
+4
-4
@@ -3,11 +3,11 @@
|
||||
契约(默认模式、选项、`--input` 的两种含义)在 [`README.md`](../README.md) 的「I/O 模式」;
|
||||
这里放细节和"为什么"。
|
||||
|
||||
## 1. 字符占低 7 位,高位不归 I/O 管
|
||||
## 1. `INP` 写整格:字符占低 7 位,其余清零
|
||||
|
||||
串行模式下一个 cell 的低 7 位(bit 0..6)是字符,**bit 7 以及更高的位不归 I/O 管**:
|
||||
`INP` 只改低 7 位,把原来的高半个 cell 原样留着。所以 tape 可以拿 bit 7 当标志位、长度位或者
|
||||
别的什么,而读写字符时它不会被冲掉。想要 char 以外的数据,就放在那上面。
|
||||
串行模式下一个 cell 的低 7 位(bit 0..6)是字符,**`INP` 写整格**:bit 7 及以上清零(开了
|
||||
parity/stop 时,对应的帧位由 `INP` 填)。早先的版本是"只改低 7 位、高位原样留着",那让纸带的
|
||||
行为取决于格子里的旧值 —— 同一份程序在这台机器和 R8Forge 的两台机器上就不一样了。
|
||||
|
||||
验证方法:把 cell 预置成 `0x80` 再读一个 `A`,cell 会是 `0xC1`(`-+` 在 8 位下就是把 bit0
|
||||
的 1 转到 bit7,然后 `,.` 读一个字符再打出来,`--dump` 能看到)。
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ void rot8_inp_io(rot8_iter *it) {
|
||||
frame |= (rot8_data)1u << ROT8_STOP_BIT;
|
||||
framed |= (rot8_data)1u << ROT8_STOP_BIT;
|
||||
}
|
||||
rot8_inp(it, (rot8_data)((rot8_out(it) & ~framed) | frame));
|
||||
rot8_inp(it, frame);
|
||||
return;
|
||||
}
|
||||
rot8_inp(it, value);
|
||||
|
||||
Reference in new issue
Block a user