1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-10 21:30:04 +00:00

Clean up PLASMA interface and fix fileio when calling execmod

This commit is contained in:
David Schmenk 2023-12-28 16:43:53 -08:00
parent 5d6b9b1f7e
commit 3cb1d97a6c
2 changed files with 22 additions and 30 deletions

View File

@ -191,7 +191,7 @@ end
def a2open(path) def a2open(path)
byte i, params[6] byte i, params[6]
for i = 0 to MAX_IOBUFS-1 for i = MAX_IOBUFS-1 downto 0
if iobuf_addr[i] and not iobuf_ref[i] if iobuf_addr[i] and not iobuf_ref[i]
params.0 = 3 params.0 = 3
params:1 = path params:1 = path
@ -221,7 +221,7 @@ end
def a2close(refnum) def a2close(refnum)
byte i, params[2] byte i, params[2]
for i = 0 to MAX_IOBUFS-1 for i = MAX_IOBUFS-1 downto 0
if refnum == iobuf_ref[i] if refnum == iobuf_ref[i]
iobuf_ref[i] = 0 iobuf_ref[i] = 0
params.0 = 1 params.0 = 1

View File

@ -1,5 +1,6 @@
include "inc/cmdsys.plh" include "inc/cmdsys.plh"
include "inc/args.plh" include "inc/args.plh"
include "inc/fileio.plh"
include "inc/longjmp.plh" include "inc/longjmp.plh"
// //
// FORTH dictionary layout // FORTH dictionary layout
@ -40,7 +41,7 @@ predef _do_#0, _doloop_#0, _doplusloop_(a)#0, _plusloop_#0, _loop_#0, _leave_#0,
predef _buildcreate_#0, _builds_#0, _dodoes_#0, _filldoes_#0, _does_#0 predef _buildcreate_#0, _builds_#0, _dodoes_#0, _filldoes_#0, _does_#0
predef pfillw(a)#0, pfillb(a)#0, _colon_#0, _semi_#0 predef pfillw(a)#0, pfillb(a)#0, _colon_#0, _semi_#0
predef _tors_(a)#0, _fromrs_#1, _toprs_#1, _execute_(a)#0, _lookup_#1 predef _tors_(a)#0, _fromrs_#1, _toprs_#1, _execute_(a)#0, _lookup_#1
predef _cmove_(a,b,c)#0, _move_(a,b,c)#0, _fill_(a,b,c)#0, _plasma_#0 predef _cmove_(a,b,c)#0, _move_(a,b,c)#0, _fill_(a,b,c)#0, _plasma_(a)#0
predef _var_(a)#0, _const_(a)#0, _lit_#1, _slit_#1, _tick_#1, _forget_#0 predef _var_(a)#0, _const_(a)#0, _lit_#1, _slit_#1, _tick_#1, _forget_#0
predef _terminal_#1, _prat_(a)#0, _str_#0, _prstr_#0, _src_#0 predef _terminal_#1, _prat_(a)#0, _str_#0, _prstr_#0, _src_#0
predef _vlist_#0, _tron_#0, _troff_#0, _itc_#0, _pbc_#0 predef _vlist_#0, _tron_#0, _troff_#0, _itc_#0, _pbc_#0
@ -533,12 +534,12 @@ def keyin#0
inptr++ inptr++
end end
def filein#0 def filein#0
inbuf = cmdsys:sysread(inref, @inbuf + 1, INBUF_SIZE) inbuf = fileio:read(inref, @inbuf + 1, INBUF_SIZE)
if inbuf if inbuf
inbuf[inbuf + 1] = 0 // NULL terminate inbuf[inbuf + 1] = 0 // NULL terminate
inptr = @inbuf + 1 inptr = @inbuf + 1
else else
cmdsys:sysclose(inref) // EOF - switch back to keyboard input fileio:close(inref) // EOF - switch back to keyboard input
inref = 0 inref = 0
infunc = @keyin infunc = @keyin
keyin keyin
@ -699,6 +700,7 @@ end
// //
def execword(dentry)#0 def execword(dentry)#0
if ^$C000 & $80
if ^$C000 == $83 // CTRL-C if ^$C000 == $83 // CTRL-C
^$C010 // Clear KB strobe ^$C010 // Clear KB strobe
brkhandle(dentry) brkhandle(dentry)
@ -707,6 +709,7 @@ def execword(dentry)#0
^$C010 // Clear KB strobe ^$C010 // Clear KB strobe
state = state ^ trace_flag state = state ^ trace_flag
fin fin
fin
if state & trace_flag if state & trace_flag
showtrace(dentry) showtrace(dentry)
fin fin
@ -755,7 +758,7 @@ def warmstart#0
fin fin
state = 0 state = 0
if inref if inref
cmdsys:sysclose(inref) fileio:close(inref)
inref = 0 inref = 0
fin fin
end end
@ -1035,18 +1038,10 @@ def _lookup_#1
^symname = symlen ^symname = symlen
return cmdsys:lookupsym(stodci(symname, @dci)) return cmdsys:lookupsym(stodci(symname, @dci))
end end
def _plasma_#0 def _plasma_(a)#0
word addr
char dci[31]
_create_ _create_
addr = cmdsys:lookupsym(stodci(vlist, @dci))
if not addr
puts("PLASMA symbol "); puts(vlist); puts(" not found\n")
_abort_
fin
^(_ffa_(vlist)) = 0 // Always compiled ^(_ffa_(vlist)) = 0 // Always compiled
*(_cfa_(vlist)) = addr // Symbol address *(_cfa_(vlist)) = a // Code address
state = state & ~comp_flag state = state & ~comp_flag
end end
def _var_(a)#0 def _var_(a)#0
@ -1375,13 +1370,9 @@ def _src_#0
filename, len = delimit('"') filename, len = delimit('"')
filename-- filename--
^filename = len ^filename = len
inref = cmdsys:sysopen(filename) inref = fileio:open(filename)
if inref if inref
params.0 = 3 fileio:newline(inref, $7F, $0D)
params.1 = inref // refnum
params.2 = $7F // mask
params.3 = $0D // nlchar
syscall($C9, @params)
infunc = @filein infunc = @filein
inptr = @inbuf inptr = @inbuf
inbuf = 0 inbuf = 0
@ -1531,6 +1522,7 @@ if cmdsys:sysver < $0201
puts("PLASMA >= 2.01 required\n") puts("PLASMA >= 2.01 required\n")
return return
fin fin
fileio:iobufalloc(2) // Allocate buffer away from system buffer
startheap = heapmark startheap = heapmark
_estkl = ^(@syscall + 1) // Hack to fill in parameter stack locations _estkl = ^(@syscall + 1) // Hack to fill in parameter stack locations
_estkh = ^(@syscall + 3) _estkh = ^(@syscall + 3)