BASIC: file dates and data files

DATE "YYYY-MM-DD[ HH:MM[:SS]]" sets a clock kept from the millisecond
counter, DATE prints it and DATE$ returns it. Directory entries now
record each file's creation date (format BFS2; a BFS1 directory is
widened when read), and DIR shows it. send-bas.py and get-bas.py set
the date from the PC when they connect (--no-date to skip).

Data files: OPEN "NAME" FOR INPUT|OUTPUT|APPEND AS #n (n = 1-3),
PRINT #n, INPUT #n, LINE INPUT [#n,], EOF(n), CLOSE [#n]. SAVE and LOAD
now use the same channel code. A written file replaces the old one only
at CLOSE; APPEND shares the old file's full blocks and copies the last
part block. New errors FILE ALREADY OPEN, FILE NOT OPEN, INPUT PAST END;
PROGRAM TOO BIG TO SAVE becomes FILE TOO BIG.

The program area shrinks from 23000 to 22100 bytes to keep the stack
at about 3 KB beside the file buffers. Code now ends at 7EBFh.

The simulation sets the date, checks it in DIR and round-trips a data
file, waiting for expected rows instead of fixed delays. Tested on the
board: dates, write/append/read, EOF, the BFS1 conversion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-28 08:50:15 -08:00
1 parent 29a15bf7c7
commit 767377f38d
9 files changed
+11631 -11174

No files matched your search

+5 -1
View File
@@ -4,7 +4,8 @@ BASIC a command and print what it answers.
The board needs SW15 and SW14 up (Z-80 mode, PC serial linked: the Z-80's
output is then copied to the PC), and nothing else may be using the port
(stop the getty first). The baud rate must match SW1:0.
(stop the getty first). The baud rate must match SW1:0. BASIC's clock is set
to the PC's first (unless --no-date), so files saved get today's date.
tools/get-bas.py myprog.bas --baud 9600 # LIST into myprog.bas
tools/get-bas.py --cmd 'LOAD "DEMO"' --baud 9600 # run a command, show output
@@ -25,6 +26,7 @@ ap.add_argument("--cmd", action="append", help="send this command instead (repea
ap.add_argument("--port", default="/dev/ttyUSB1")
ap.add_argument("--baud", type=int, default=115200, choices=sorted(BAUDS))
ap.add_argument("--timeout", type=float, default=30, help="seconds to wait for READY")
ap.add_argument("--no-date", action="store_true", help="don't set BASIC's clock")
a = ap.parse_args()
if not a.file and not a.cmd:
ap.error("give a file name or --cmd")
@@ -60,6 +62,8 @@ def run(cmd):
return "\n".join(l for l in lines if l != "READY").strip("\n")
if not a.no_date:
run(time.strftime('DATE "%Y-%m-%d %H:%M:%S"'))
if a.cmd:
for c in a.cmd:
print(run(c))