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
|
|
|
|
|
2023-10-02 01:54:58 +00:00
|
|
|
: tdict-lookup word tdict dict-lookup ;
|
2023-10-16 01:05:54 +00:00
|
|
|
: T] tdict-lookup not if err return then state if , then ; immediate
|
2023-10-02 01:54:58 +00:00
|
|
|
: te tdict-lookup interpretword ; immediate
|
|
|
|
: tlookup ( -- tcp ) tdict-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-18 02:24:14 +00:00
|
|
|
: with-dict ( cp dictcp )
|
|
|
|
' dictionary definition >r
|
|
|
|
' dictionary redefine
|
|
|
|
execute
|
|
|
|
<r ' dictionary redefine ;
|
|
|
|
|
|
|
|
: DEF asm-com
|
|
|
|
:| new-word latest wordname lastlabel ! |; ' tdict with-dict
|
|
|
|
$DOFAR , target , ;
|
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 ;
|
|
|
|
|
2023-09-18 02:24:14 +00:00
|
|
|
: { ' primary-dict ' dictionary redefine
|
2023-09-17 02:45:42 +00:00
|
|
|
' pri-targ-lookup ' lookup redefine
|
2023-09-13 03:27:46 +00:00
|
|
|
' , ' compileword redefine
|
|
|
|
' lit ' compilenum redefine ;
|
|
|
|
|
2023-09-18 02:24:14 +00:00
|
|
|
: } asm-com
|
|
|
|
' tdict ' dictionary redefine
|
|
|
|
' targ-pri-lookup ' lookup redefine
|
|
|
|
:| cell + @ w>t |; ' compileword redefine
|
|
|
|
:| t, LIT_ w>t |; ' compilenum redefine ;
|
2023-09-17 02:45:42 +00:00
|
|
|
|
|
|
|
( 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. )
|
2023-09-18 02:24:14 +00:00
|
|
|
: :timm } new-word immediate { $DOCOLON , ] ;
|
|
|
|
:timm [ ['] [ ; :timm ] ] ;
|
2023-09-17 02:45:42 +00:00
|
|
|
: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-18 02:24:14 +00:00
|
|
|
: t", begin key dup [ key " lit ] != while >t repeat drop 0 >t ;
|
2023-10-15 02:22:50 +00:00
|
|
|
: t" t, INLINEDATA_ patchpt t", patch!t ;
|
|
|
|
:timm s" state if t" else target t", then ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-11-05 03:39:30 +00:00
|
|
|
: gencolon t& $DOCOLON w>t ;
|
|
|
|
: startcolon gencolon ] ;
|
2023-10-04 00:59:18 +00:00
|
|
|
: t:| t, INLINEDATA_ patchpt startcolon ;
|
|
|
|
: t|; t, return patch!t ;
|
|
|
|
:timm :| t:| ;
|
|
|
|
:timm |; t|; ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-10-02 01:54:58 +00:00
|
|
|
:noname DEF startcolon ;
|
2023-09-18 02:24:14 +00:00
|
|
|
:timm : [ dup , ] ; :timm :t [ , ] ;
|
2023-09-17 02:45:42 +00:00
|
|
|
:timm ' ['] t' ;
|
2023-10-02 01:54:58 +00:00
|
|
|
:timm :noname target startcolon ;
|
2023-09-17 02:45:42 +00:00
|
|
|
:timm const CONST ;
|
|
|
|
:timm var, VAR, ;
|
|
|
|
:timm var 0 VAR, ;
|
2023-09-24 02:44:30 +00:00
|
|
|
:timm bvar, ARRAY >t ;
|
2023-09-17 02:45:42 +00:00
|
|
|
:timm array ARRAY ;
|
|
|
|
:timm allot ALLOT ;
|
|
|
|
:timm :asm :ASM ;
|
|
|
|
:timm , w>t ; :timm b, >t ;
|
|
|
|
:timm lit compilenum ;
|
2023-09-18 02:24:14 +00:00
|
|
|
:timm deferred DEFERRED ;
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-10-02 01:54:58 +00:00
|
|
|
: :chain ( cpdeferred -- )
|
|
|
|
cell + dup @t target <rot !t startcolon w>t ;
|
|
|
|
|
2023-09-18 02:24:14 +00:00
|
|
|
dbg" CREATE"
|
2023-09-17 02:45:42 +00:00
|
|
|
: CREATE DEF t& $DOCREATE w>t 0 w>t ;
|
2023-11-05 04:30:34 +00:00
|
|
|
: entry>tcp codepointer cell + @ ;
|
|
|
|
: FINISHCREATE ' latest ' tdict with-dict entry>tcp cell + !t ;
|
2023-09-18 02:24:14 +00:00
|
|
|
: DOES} target lit ' FINISHCREATE , ' return , } ; immediate
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-18 02:24:14 +00:00
|
|
|
( s" blah.jrt" loadfile doesn't work in target mode because s" writes
|
|
|
|
to the target segment. You'd have to write { s" blah.jrt" } loadfile
|
|
|
|
which kind of stinks. We provide a simple, clean alternative. )
|
2023-09-17 02:45:42 +00:00
|
|
|
|
2023-09-18 02:24:14 +00:00
|
|
|
: import word loadfile ;
|
|
|
|
|
|
|
|
} import logic.jrt
|
|
|
|
|
|
|
|
2 const cell
|
|
|
|
: cells 2* ;
|
|
|
|
: redefine ( cp cpdeferred -- ) cell + ! ; {
|
2023-09-13 03:27:46 +00:00
|
|
|
|
2023-09-15 20:10:12 +00:00
|
|
|
var comfilename
|
|
|
|
|
2023-10-16 01:05:54 +00:00
|
|
|
: readcom ( filename ) open >r
|
|
|
|
0x100 0xffff over r@ comseg farfread
|
|
|
|
fcount @ + target! <r close ;
|
2023-09-15 20:10:12 +00:00
|
|
|
|
2023-10-02 01:54:58 +00:00
|
|
|
DEFERRED init noop
|
|
|
|
DEFERRED main noop
|
|
|
|
DEFERRED cleanup noop
|
|
|
|
|
2023-10-16 01:05:54 +00:00
|
|
|
T] cleanup ' cleanup redefine
|
2023-10-02 01:54:58 +00:00
|
|
|
|
|
|
|
:init
|
|
|
|
( we write a fake all-null PSP so openself can fail gracefully )
|
|
|
|
0 target! 0xff ALLOT
|
|
|
|
comfilename @ readcom }
|
2023-10-16 01:05:54 +00:00
|
|
|
T] init ;
|
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
|
|
|
dbg" boot"
|
|
|
|
|
2023-10-15 02:22:50 +00:00
|
|
|
} : exit cleanup terminate ; : start init main exit ; {
|
2023-09-18 02:24:14 +00:00
|
|
|
|
2023-09-17 02:45:42 +00:00
|
|
|
9 <: ( actual entry point )
|
2023-09-18 02:24:14 +00:00
|
|
|
MOV SI t& start #
|
2023-09-17 02:45:42 +00:00
|
|
|
PUSH CS
|
|
|
|
POP AX
|
|
|
|
ADD AX 4096 #
|
|
|
|
MOV SS AX
|
|
|
|
MOV SP 0x100 #
|
|
|
|
MOV BP 0x00 #
|
|
|
|
NEXT
|
|
|
|
|
2023-10-16 01:33:10 +00:00
|
|
|
here s", zipstub.min" s" zipmin.com" writeenv
|
|
|
|
|
2023-09-29 02:07:10 +00:00
|
|
|
} import common.jrt {
|
|
|
|
|
2023-10-16 01:05:54 +00:00
|
|
|
T] init execute
|
2023-10-02 01:54:58 +00:00
|
|
|
|
2023-09-15 20:10:12 +00:00
|
|
|
here s", zipstub.seg" s" zipoff.com" writeenv
|
2023-09-17 02:45:42 +00:00
|
|
|
|