VolksForth/8086/msdos/tests/log2file.fth
Philip Zembrod 64ed332b12 First build of v4th.com with compile log file written and
checked at the end of the Makefile recipe.
Also introduces a prebuilt metacompiler metafile.com with integrated fth file include
2022-03-01 14:02:46 +01:00

115 lines
1.5 KiB
Forth

\ *** Block No. 0, Hexblock 0
\ logging to a text file phz 03jan22
\ *** Block No. 1, Hexblock 1
\ load screen phz 25feb22
Code m+! ( 16b addr -- )
D W mov W inc W inc A pop A W ) add
CS ?[ W dec W dec W ) inc ]?
D pop Next end-code
: (blk blk @ 0= IF ascii ) parse 2drop THEN ;
(blk 1 2 +thru ( )
\ *** Block No. 2, Hexblock 2
\ log-type log-emit log-cr phz 25feb22
context @ dos also context !
\ vocabulary log dos also log definitions
file logfile
variable logfcb
variable logpos 0 ,
: log-type ( addr count -- ) dup logpos m+!
2dup (type ds@ -rot logfcb @ lfputs ;
: log-emit ( char -- ) 1 logpos m+!
dup (emit logfcb @ fputc ;
: log-cr ( -- ) 2 logpos m+!
(cr #cr logfcb @ fputc #lf logfcb @ fputc ;
\ *** Block No. 3, Hexblock 3
\ alsologtofile logopen logclose logreopen phz 25feb22
Output: alsologtofile
log-emit log-cr log-type (del (page (at (at? ;
: logopen ( -- )
isfile push logpos dup 2+ off off
logfile make isfile@ dup freset logfcb !
alsologtofile ;
: logclose ( -- ) display logfcb @ fclose ;
: logreopen ( -- )
logfcb @ freset logpos 2@ logfcb @ fseek
alsologtofile ;
\ *** Block No. 4, Hexblock 4
\ phz 25feb22
\ *** Block No. 5, Hexblock 5