From 415fd869e16933040fcf2077018069760eb0de38 Mon Sep 17 00:00:00 2001 From: Philip Zembrod Date: Sat, 1 Jul 2023 20:15:57 +0200 Subject: [PATCH] First working Forth log2file.fb for CPM VolksForth --- 8080/CPM/Makefile | 32 +++++++++++-- 8080/CPM/tests/log2file.fb | 1 + 8080/CPM/tests/log2file.fth | 95 +++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 8080/CPM/tests/log2file.fb create mode 100644 8080/CPM/tests/log2file.fth diff --git a/8080/CPM/Makefile b/8080/CPM/Makefile index 46ba482..6e719ff 100644 --- a/8080/CPM/Makefile +++ b/8080/CPM/Makefile @@ -1,6 +1,9 @@ -fbfiles = $(wildcard src/*.fb) -fthfiles = $(patsubst src/%.fb, src/%.fth, $(fbfiles)) +srcfbfiles = $(wildcard src/*.fb) +srcfthfiles = $(patsubst src/%.fb, src/%.fth, $(srcfbfiles)) +testsfbfiles = $(wildcard tests/*.fb) +testsfthfiles = $(patsubst tests/%.fb, tests/%.fth, $(testsfbfiles)) +fthfiles = $(srcfthfiles) $(testsfthfiles) whitch_runcpm = $(shell which RunCPM) runcpmdir = runcpm @@ -14,7 +17,8 @@ clean: rm -f msdos run-editor: | msdos - FORTHPATH="f:\\src;f:\\msdos" ../../8086/msdos/emulator/run-in-dosbox.sh f:\\msdos\\volks4th.com + FORTHPATH="f:\\src;f:\\tests;f:\\msdos" \ + ../../8086/msdos/emulator/run-in-dosbox.sh f:\\msdos\\volks4th.com msdos: ln -s ../../8086/msdos msdos @@ -22,6 +26,9 @@ msdos: src/%.fth: src/%.fb ../../tools/fb2fth.py ../../tools/fb2fth.py $< $@ +tests/%.fth: tests/%.fb ../../tools/fb2fth.py + ../../tools/fb2fth.py $< $@ + inctest.log: $(patsubst %, $(cpmfilesdir)/%, volks4th.com) \ $(patsubst src/%, $(cpmfilesdir)/%, \ src/include.fb src/inctest.fth) \ @@ -34,6 +41,21 @@ inctest.log: $(patsubst %, $(cpmfilesdir)/%, volks4th.com) \ ./emulator/run-in-runcpm.sh volks4th cp $(runcpmdir)/output.log $@ +logtest.log: $(patsubst %, $(cpmfilesdir)/%, volks4th.com) \ + $(patsubst tests/%, $(cpmfilesdir)/%, \ + tests/log2file.fb) \ + | emu + echo "volks4th" > $(runcpmdir)/input.script + echo "include log2file.fb" >> $(runcpmdir)/input.script + echo "logopen" >> $(runcpmdir)/input.script + echo ".( hello world) cr" >> $(runcpmdir)/input.script + echo "logclose" >> $(runcpmdir)/input.script + echo "bye" >> $(runcpmdir)/input.script + echo "exit" >> $(runcpmdir)/input.script + ./emulator/run-in-runcpm.sh volks4th + cp $(runcpmdir)/output.log output.log + cp $(runcpmdir)/A/0/LOGFILE.TXT $@ + emu: $(runcpmdir)/RunCPM $(runcpmdir)/RunCPM: $(whitch_runcpm) @@ -44,6 +66,10 @@ $(cpmfilesdir)/%: src/% test -d $(cpmfilesdir) || mkdir -p $(cpmfilesdir) cp $< $@ +$(cpmfilesdir)/%: tests/% + test -d $(cpmfilesdir) || mkdir -p $(cpmfilesdir) + cp $< $@ + $(cpmfilesdir)/%: % test -d $(cpmfilesdir) || mkdir -p $(cpmfilesdir) cp $< $@ diff --git a/8080/CPM/tests/log2file.fb b/8080/CPM/tests/log2file.fb new file mode 100644 index 0000000..aa22479 --- /dev/null +++ b/8080/CPM/tests/log2file.fb @@ -0,0 +1 @@ + \ log2file loadscreen phz 01jun23 1 3 +thru \ logfile phz 01jul23 Dos also Forth definitions $18 constant fcb\nam create logfile ," LOGFILE TXT" fcb\nam allot 1 logfile c! create logdma b/rec allot variable logoffset 0 logoffset ! : logflush logdma dma! logfile write-seq ; : logc! ( c -- ) logoffset @ dup >r logdma + c! r> 1+ dup logoffset ! b/rec = IF logflush 0 logoffset ! THEN ; \ log-emit log-type log-cr alsologtofile pphz 01jul23 : log-emit ( char -- ) dup (emit logc! ; : log-type ( addr count -- ) 2dup (type 0 ?DO count logc! LOOP drop ; : log-cr ( -- ) (cr #cr logc! #lf logc! ; Output: alsologtofile log-emit log-cr log-type (del (page (at (at? ; \ logopen phz 01jul23 : logopen ( -- ) logfile filenamelen + 1+ fcb\nam erase logfile killfile logfile createfile alsologtofile ; : logclose ( -- ) cr display logflush logfile closefile ; \ No newline at end of file diff --git a/8080/CPM/tests/log2file.fth b/8080/CPM/tests/log2file.fth new file mode 100644 index 0000000..b6cd84a --- /dev/null +++ b/8080/CPM/tests/log2file.fth @@ -0,0 +1,95 @@ + +\ *** Block No. 0, Hexblock 0 + + + + + + + + + + + + + + + + + + +\ *** Block No. 1, Hexblock 1 + +\ log2file loadscreen phz 01jun23 + + 1 3 +thru + + + + + + + + + + + + + + +\ *** Block No. 2, Hexblock 2 + +\ logfile phz 01jul23 + + Dos also Forth definitions + + $18 constant fcb\nam + create logfile ," LOGFILE TXT" fcb\nam allot 1 logfile c! + create logdma b/rec allot + variable logoffset 0 logoffset ! + + : logflush logdma dma! logfile write-seq ; + + : logc! ( c -- ) + logoffset @ dup >r logdma + c! r> 1+ + dup logoffset ! b/rec = + IF logflush 0 logoffset ! THEN ; + + +\ *** Block No. 3, Hexblock 3 + +\ log-emit log-type log-cr alsologtofile pphz 01jul23 + + : log-emit ( char -- ) + dup (emit logc! ; + + : log-type ( addr count -- ) + 2dup (type 0 ?DO count logc! LOOP drop ; + + : log-cr ( -- ) + (cr #cr logc! #lf logc! ; + +Output: alsologtofile + log-emit log-cr log-type (del (page (at (at? ; + + + + +\ *** Block No. 4, Hexblock 4 + +\ logopen phz 01jul23 + + : logopen ( -- ) + logfile filenamelen + 1+ fcb\nam erase + logfile killfile + logfile createfile + alsologtofile ; + + : logclose ( -- ) + cr display logflush logfile closefile ; + + + + + +