Add Copy and Compare, which stream in both directions at once

Copy joins the read and write streaming services: source and destination are
both larger than Data Memory while the program owns one block. Compare reads
two files through separate blocks and ignores the bytes past a short final
block, which belong to neither file. Between them they exercise empty,
exact-block, part-block and 84,000 byte files, and the host extracts the copy
afterwards so that two native programs agreeing with each other is not the only
oracle.

Written by ChatGPT, as their headers record, along with the agree.sh section
and the manifest entry that drive them.

THIS SHOULD HAVE COME FIRST. The commit before it staged whole files rather
than the hunks it meant, so its manifest already names these two programs while
their source was still untracked - that commit will not build on its own. Left
in place rather than rewritten, since the pair is right and only their order is
wrong.

NOTES.md is their review of the streaming work. The first item in it is fixed
by the commit before this one; the rest are still open.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-25 20:21:43 -04:00
co-authored by Claude Opus 5
parent a7d3e09d94
commit 54f5cfe8a4
7 changed files with 731 additions and 0 deletions
+33
View File
@@ -142,6 +142,39 @@ else
report FAIL "and every block landed" "a block is not where it was written"
fi
# ---- A large file copied and compared on the machine ----
#
# Copy joins the read and write streaming services: the source and destination are both
# larger than Data Memory, while the application owns one block. Compare then reads both
# through separate blocks and must ignore bytes past the tail. The host extracts the copy
# afterwards, so two native programs agreeing with each other is not the only oracle.
"$ASM" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Copy.asm" -o Copy.sbx >/dev/null 2>&1
"$ASM" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Compare.asm" -o Compare.sbx >/dev/null 2>&1
"$TOOL" format copied.img 1024 4 >/dev/null
"$TOOL" mkdir copied.img /Apps >/dev/null
"$TOOL" mkdir copied.img /Input >/dev/null
"$TOOL" mkdir copied.img /Output >/dev/null
"$TOOL" put copied.img Copy.sbx /Apps/Copy.sbx >/dev/null
"$TOOL" put copied.img Compare.sbx /Apps/Compare.sbx >/dev/null
awk 'BEGIN { for (i = 0; i < 84000; i++) printf "%c", 65 + (i % 26) }' > toCopy.dat
"$TOOL" put copied.img toCopy.dat /Input/source.dat >/dev/null
printf 'Copy /Input/source.dat /Output/copy.dat\nCompare /Input/source.dat /Output/copy.dat\nexit\n' \
| "$EMU" cosmos.bin --fast --cycles 1000000000 --disk copied.img > copied.txt 2>&1
"$TOOL" get copied.img /Output/copy.dat copiedBack.dat >/dev/null 2>&1
if cmp -s toCopy.dat copiedBack.dat; then
report ok "large native copy" "84000 bytes, host-identical"
else
report FAIL "large native copy" "the host read back different bytes"
fi
if grep -q '^> the same$' copied.txt; then
report ok "native compare" "the streamed files agree"
else
report FAIL "native compare" "Compare did not call the copied files equal"
fi
# ---- And each can read what the other wrote ----
#
# Matching bytes and being readable are not the same claim. A field both of them write