Migrate .fth include into v4th.com kernel; adapt test-min.log rule

This commit is contained in:
Philip Zembrod 2022-03-15 00:39:21 +01:00
parent a7ef2d0e64
commit 9c2a761894
5 changed files with 119 additions and 3 deletions

View File

@ -25,7 +25,7 @@ metafile.com: v4thfile.com src/meta.fb src/mk-meta.fth tests/log2file.fb
grep -F 'Metacompiler saved as metafile.com' metafile.log
v4th.com: metafile.com src/meta.fb src/mk-v4th.fth \
src/vf86core.fth src/vf86dos.fth
src/vf86core.fth src/vf86dos.fth src/vf86file.fth
rm -f v4th.com V4TH.COM OUTPUT.LOG
FORTHPATH="f:\\;f:\\src;f:\\tests" ./emulator/run-in-dosbox.sh \
metafile.com "include mk-v4th.fth"
@ -73,7 +73,7 @@ test-min.log: \
$(patsubst tests/%, dosfiles/%, $(wildcard tests/*.*))
rm -f dosfiles/OUTPUT.LOG
(cd dosfiles && ../emulator/run-in-dosbox.sh v4th.com \
"include testprep.fb include test-min.fth")
"include logprep.fth include test-min.fth")
dos2unix -n dosfiles/OUTPUT.LOG $@

View File

@ -20,6 +20,8 @@
\ &112 &146 thru \ MS-DOS interface
include vf86dos.fth
include vf86file.fth
: forth-83 ; \ last word in Dictionary
0 ' limit >body ! $DFF6 s0 ! $E77C r0 !

View File

@ -819,8 +819,9 @@ Label domove I W cmp moveup CS ?]
\ input strings ks 23 dez 87
$84 Constant /tib
Variable #tib #tib off
Variable >tib here >tib ! $50 allot
Variable >tib here >tib ! /tib allot
Variable >in >in off
Variable blk blk off
Variable span span off

108
8086/msdos/src/vf86file.fth Normal file
View File

@ -0,0 +1,108 @@
variable tibeof tibeof off
: eolf? ( c -- f )
\ f=-1: not yet eol; store c and continue
\ f=0: eol but not yet eof; return line and flag continue
\ f=1: eof: return line and flag eof
tibeof off
dup #lf = IF drop 0 exit THEN
-1 = IF tibeof on 1 ELSE -1 THEN ;
\ *** Block No. 3, Hexblock 3
\ incfile incpos inc-fgetc phz 06feb22
variable incfile
variable incpos 2 allot
: inc-fgetc ( -- c )
incfile @ f.handle @ 0= IF
incpos 2@ incfile @ fseek THEN
incfile @ fgetc
incpos 2@ 1. d+ incpos 2! ;
\ *** Block No. 4, Hexblock 4
\ freadline probe-for-fb phz 06feb22
: freadline ( -- eof )
tib /tib bounds DO
inc-fgetc dup eolf? under 0< IF I c! ELSE drop THEN
0< 0= IF I tib - #tib ! ENDLOOP tibeof @ exit THEN
LOOP /tib #tib !
." warning: line exteeds max " /tib . cr
." extra chars ignored" cr
BEGIN inc-fgetc eolf? 1+ UNTIL tibeof @ ;
| : probe-for-fb ( -- flag )
\ probes whether current file looks like a block file
/tib 2+ 0 DO isfile@ fgetc #lf = IF ENDLOOP false exit THEN
LOOP true ;
\ *** Block No. 5, Hexblock 5
\ save/restoretib phz 16jan22
$50 constant /stash
create stash[ /stash allot here constant ]stash
variable stash> stash[ stash> !
: savetib ( -- n )
#tib @ >in @ - dup stash> @ + ]stash u>
abort" tib stash overflow" >r
tib >in @ + stash> @ r@ cmove
r@ stash> +! r> ;
: restoretib ( n -- )
dup >r negate stash> +! stash> @ tib r@ cmove
r> #tib ! >in off ;
\ *** Block No. 6, Hexblock 6
\ interpret-via-tib include phz 06feb22
: interpret-via-tib
BEGIN freadline >r .status >in off interpret
r> UNTIL ;
: include ( -- )
pushfile use cr file?
probe-for-fb isfile@ freset IF 1 load close exit THEN
incfile push isfile@ incfile !
incpos push incpos off incpos 2+ dup push off
savetib >r interpret-via-tib close r> restoretib ;
: (stashquit stash[ stash> ! (quit ;
: stashrestore ['] (stashquit IS 'quit ;
' stashrestore IS 'restart
\ *** Block No. 7, Hexblock 7
\ \ phz 25feb22
: \ blk @ IF >in @ negate c/l mod >in +!
ELSE #tib @ >in ! THEN ; immediate
\ : \needs have 0=exit
\ blk @ IF >in @ negate c/l mod >in +!
\ ELSE #tib @ >in ! THEN ;

View File

@ -0,0 +1,5 @@
include extend.fb
include multi.vid
include dos.fb
include log2file.fb