The shell remembers what was typed before it

Up walks back through the last eight lines and Down forward again. It exists
only because the keys reach the system now: until A1 and A2 there was nothing to
press Up at, and the line was assembled somewhere the shell could not see.

A RING RATHER THAN A LIST. A ninth line pushes the oldest out by moving where
the ring starts, not by moving any of the lines - so keeping a line costs a copy
of that line and nothing else, however full the history is. Eight is a power of
two, so which slot an entry lives in is an AND. The ISA had the awkward part
already: A and B are a sixteen bit shift register, so one SHR with B empty turns
a slot number into the offset of a 128 byte slot, high byte and low, ready for
DPUW.

A NINTH SLOT HOLDS WHAT WAS BEING TYPED when Up left it, and Down brings it
back. Losing a half written line to a keypress is the sort of small rudeness
that makes a thing unpleasant to use, and it costs one slot to avoid.

An empty line is not kept, and neither is one the same as the line already at the
top. The test proves the second by looking one further back: if a repeated
command were kept twice, the line behind the newest would be the same line
again.

The redraw had to learn to rub out. One space was enough while the only thing
that shortened a line was taking one character out of it; a recalled line
replaces the whole of it, and a short line over a long one left the tail of the
long one on screen looking like part of what you were typing. It now covers
exactly what was lost - which turned out to be one space fewer than before in
the cases that GREW, so two lines of cosmosEditKeys lost a trailing space that
was never doing anything.

Costs 1157 bytes of Data Memory, taking CosmOS to 6220 of the 8192 it has before
a loaded program's data begins. Worth writing down: that is the budget, and this
is the largest single thing in it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-01 12:24:23 -04:00
co-authored by Claude Opus 5
parent 81e544eb3d
commit 71f6e215f9
7 changed files with 409 additions and 9 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
CosmOS
> eco okecho ok 
> eco okecho ok
ok
> Xecho okecho ok 
ok
@@ -7,7 +7,7 @@ ok
ok
> echo okX 
ok
> echo kecho ok 
> echo kecho ok
ok
> Xecho aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaecho aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
+33
View File
@@ -0,0 +1,33 @@
CosmOS
> echo a
a
> echo b
b
> echo c
c
> echo d
d
> echo e
e
> echo f
f
> echo g
g
> echo h
h
> echo i
i
> echo iecho hecho gecho fecho eecho decho cecho b
b
> echo zecho becho z
z
> echo z
z
> echo zecho b
b
> echo yyyyyyyyyyyyyyyyyyyyecho b echo yyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyy
> exit
halted
Execution halted.
[exit 0]
+15
View File
@@ -0,0 +1,15 @@
echo a
echo b
echo c
echo d
echo e
echo f
echo g
echo h
echo i
€€€€€€€€€
echo z€
€€
echo yyyyyyyyyyyyyyyyyyyy€
exit
+10
View File
@@ -326,6 +326,16 @@ cosmosNoData | CosmOS/Source/cosmos.asm | run | cosmosNoD
# is. The last line is eighty five characters at a prompt in column two, so the cursor has to
# be found on the row below - the one case the arithmetic exists for.
cosmosEditKeys | CosmOS/Source/cosmos.asm | run | cosmosEditKeys.in | - | disks/cosmos.img
# And the shell remembering what was typed before it. Nine lines against eight slots, so the
# oldest is pushed out and nine presses of Up can only walk back eight; then the line being
# typed is kept when Up leaves it and comes back on Down; then a line run twice is not kept
# twice, which the LAST case is what proves - if it were, one further back would be the same
# line again instead of the one before it.
#
# The long line at the end is the rubbing out. A short line recalled over a long one leaves
# the tail of the long one on the screen unless something covers it, and one space - which
# is all a Delete ever needs - covers nothing.
cosmosHistory | CosmOS/Source/cosmos.asm | run | cosmosHistory.in | - | disks/cosmos.img
# The shell taking things off a disk and calling them something else, which is the last of
# CosmOS's original four verbs to be built and the first time anything has changed a disk
# from the shell. Its own image, because it changes what is on it: a fixture named with a