2023-09-13 03:27:46 +00:00
|
|
|
JMP 9 @>
|
|
|
|
|
|
|
|
L: RETFAR
|
|
|
|
target cell + w>t
|
|
|
|
target cell + w>t
|
|
|
|
MOV SI @[ -2 @+ BP]
|
|
|
|
PUSH @[ -4 @+ BP]
|
|
|
|
PUSH @[ -6 @+ BP]
|
|
|
|
SUB BP 6 #
|
|
|
|
RETF
|
|
|
|
|
|
|
|
L: DOFAR
|
|
|
|
POP @[ 0 @+ BP]
|
|
|
|
POP @[ 2 @+ BP]
|
|
|
|
MOV @[ 4 @+ BP] SI
|
|
|
|
ADD BP 6 #
|
|
|
|
PUSH CS
|
|
|
|
POP DS
|
|
|
|
MOV SI L@ RETFAR #
|
|
|
|
POP BX
|
|
|
|
JMP @[ BX]
|
|
|
|
|
|
|
|
array tdict DICTSIZE allot
|
|
|
|
|
|
|
|
array &FARCALL L@ DOFAR , comseg ,
|
2023-09-15 20:10:24 +00:00
|
|
|
:init comseg &FARCALL cell + ! ; ( comseg can change! )
|
|
|
|
|
2023-09-13 03:27:46 +00:00
|
|
|
asm-here
|
|
|
|
array $DOFAR
|
|
|
|
INC BX INC BX
|
|
|
|
PUSH @[ BX]
|
|
|
|
CALL FAR &FARCALL @+
|
|
|
|
PUSH CS
|
|
|
|
POP DS
|
|
|
|
( NEXT isn't defined yet ;_; )
|
|
|
|
LODSW
|
|
|
|
MOV BX AX
|
|
|
|
JMP @[ BX]
|
|
|
|
asm-com
|
|
|
|
|
|
|
|
: te word tdict dict-lookup interpretword ; immediate
|
2023-09-15 20:10:24 +00:00
|
|
|
: tlookup ( -- tcp ) word tdict dict-lookup not if dup err then cell + @ ;
|
2023-09-13 03:27:46 +00:00
|
|
|
: t' tlookup interpretnumber ; immediate
|
|
|
|
: t& tlookup cell + interpretnumber ; immediate
|
|
|
|
: t, tlookup state if lit ' w>t , else w>t then ; immediate
|
|
|
|
: '>t tlookup w>t ;
|
|
|
|
|
2023-09-15 20:10:24 +00:00
|
|
|
: tdict| ' tdict ' dictionary redefine ;
|
|
|
|
: |tdict ' primary-dict ' dictionary redefine ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: DEF asm-com ' dictionary definition ( preserve the current dictionary )
|
|
|
|
tdict| new-word latest wordname lastlabel ! |tdict $DOFAR , target ,
|
|
|
|
' dictionary redefine ;
|
2023-09-15 20:10:24 +00:00
|
|
|
: :asm asm-here new-word here cell + , ;
|
|
|
|
|
|
|
|
s" coredefs.jrt" loadfile
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
( now we have LIT_ and can hook the full compiler )
|
|
|
|
: pri-targ-lookup
|
2023-09-13 03:27:46 +00:00
|
|
|
primary-dict dict-lookup dup if return then drop tdict dict-lookup ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: targ-pri-lookup
|
|
|
|
( only allow lookup from primary dict if not compiling - this allows
|
|
|
|
using assembly words without duplicating them in the target dictionary )
|
|
|
|
tdict dict-lookup dup state or if return then
|
|
|
|
drop primary-dict dict-lookup ;
|
|
|
|
|
|
|
|
: { tdict| asm-com
|
|
|
|
' targ-pri-lookup ' lookup redefine
|
2023-09-13 03:27:46 +00:00
|
|
|
:| cell + @ w>t |; ' compileword redefine
|
|
|
|
:| t, LIT_ w>t |; ' compilenum redefine ;
|
2023-09-15 20:10:24 +00:00
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: } |tdict asm-here
|
|
|
|
' pri-targ-lookup ' lookup redefine
|
2023-09-13 03:27:46 +00:00
|
|
|
' , ' compileword redefine
|
|
|
|
' lit ' compilenum redefine ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: >{ dictionary tdict = { ;
|
|
|
|
: }< if { else } then ;
|
|
|
|
|
|
|
|
( we mark all target words with no associated code in the target segment
|
|
|
|
as immediate, as it is impossible to compile a reference to them. )
|
|
|
|
: :timm >{ new-word immediate } $DOCOLON , ] }< ;
|
|
|
|
:timm [ ['] [ ; :timm ] ] ; :timm } } ;
|
|
|
|
:timm ; t, return ['] [ ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
|
|
|
:timm ( ['] ( ;
|
|
|
|
|
|
|
|
:timm if t, BZ_ patchpt ;
|
|
|
|
:timm else t, GOTO_ patchpt swap patch!t ;
|
|
|
|
:timm then patch!t ;
|
|
|
|
|
|
|
|
:timm begin target ;
|
|
|
|
:timm while t, BZ_ patchpt ;
|
|
|
|
:timm repeat t, GOTO_ swap w>t patch!t ;
|
|
|
|
:timm again t, GOTO_ w>t ;
|
|
|
|
:timm until t, BZ_ w>t ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
:timm s" t, INLINEDATA_ patchpt
|
|
|
|
begin key dup [ key " lit ] != while >t repeat drop 0 >t patch!t ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
:timm :| t, INLINEDATA_ patchpt t& $DOCOLON w>t ;
|
2023-09-13 03:27:46 +00:00
|
|
|
:timm |; t, return patch!t ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: :t DEF t& $DOCOLON w>t ] { ;
|
|
|
|
:timm : :t ;
|
|
|
|
:timm ' ['] t' ;
|
|
|
|
:timm :noname target t& $DOCOLON w>t ] ;
|
|
|
|
:timm const CONST ;
|
|
|
|
:timm var, VAR, ;
|
|
|
|
:timm var 0 VAR, ;
|
|
|
|
:timm array ARRAY ;
|
|
|
|
:timm allot ALLOT ;
|
|
|
|
:timm :asm :ASM ;
|
|
|
|
:timm , w>t ; :timm b, >t ;
|
|
|
|
:timm lit compilenum ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: CREATE DEF t& $DOCREATE w>t 0 w>t ;
|
|
|
|
: FINISHCREATE { latest } codepointer cell + @ cell + !t ;
|
|
|
|
: DOES> target lit ' FINISHCREATE , ' return , { ; immediate
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
: import >{ >r word loadfile <r }< ;
|
|
|
|
|
|
|
|
import logic.jrt
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-15 20:10:12 +00:00
|
|
|
var comfilename
|
|
|
|
|
|
|
|
: readcom ( filename ) open 0x100 target!
|
|
|
|
begin dup fgetc dup EOF != while >t repeat drop close ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
:init comfilename @ readcom { ;
|
2023-09-15 20:10:12 +00:00
|
|
|
|
|
|
|
: writeenv ( comfile wrapper -- )
|
|
|
|
swap comfilename !
|
|
|
|
dup type cr writeself
|
|
|
|
comfilename @ dup type cr writecom ;
|
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
DEFERRED main terminate
|
|
|
|
|
|
|
|
dbg" boot"
|
|
|
|
|
|
|
|
9 <: ( actual entry point )
|
|
|
|
MOV SI t& main #
|
|
|
|
PUSH CS
|
|
|
|
POP AX
|
|
|
|
ADD AX 4096 #
|
|
|
|
MOV SS AX
|
|
|
|
MOV SP 0x100 #
|
|
|
|
MOV BP 0x00 #
|
|
|
|
NEXT
|
|
|
|
|
2023-09-15 20:10:12 +00:00
|
|
|
here s", zipstub.seg" s" zipoff.com" writeenv
|
2023-09-17 02:45:42 +00:00
|
|
|
|