assemble.jrt for creating assemble.com which has asm.jrt preloaded rebuild.bat for re-bootstrapping tinyjort from scratch and verifying that minijort and assemble produce the same binary small CGA textmode vocabulary with test program
189 lines
2.3 KiB
Plaintext
Executable file
189 lines
2.3 KiB
Plaintext
Executable file
( REQUIRED: defs.jrt, asm.jrt, target.jrt, DEF, '>t )
|
|
dbg" core"
|
|
|
|
: :ASM DEF target 2 + w>t ;
|
|
|
|
: NEXT
|
|
LODSW
|
|
MOV BX AX
|
|
JMP @[ BX] ;
|
|
|
|
L: $$CONST
|
|
INC BX INC BX
|
|
PUSH @[ BX]
|
|
NEXT
|
|
|
|
: CONST DEF [ L@ $$CONST lit ] w>t w>t ;
|
|
|
|
L@ $$CONST CONST $DOCONST
|
|
0 CONST 0 1 CONST 1
|
|
|
|
L: $$VAR
|
|
INC BX INC BX
|
|
PUSH BX
|
|
NEXT
|
|
|
|
: ARRAY DEF [ L@ $$VAR lit ] w>t ;
|
|
: VAR, ARRAY w>t ;
|
|
|
|
( "codepointer words" that evaluate to a pointer to the assembly -
|
|
useful to define things like $DOCOLON. )
|
|
: :CP ARRAY ;
|
|
L@ $$VAR CONST $DOVAR
|
|
|
|
:CP $DOCOLON
|
|
MOV @[ BP] SI
|
|
INC BP INC BP
|
|
INC BX INC BX
|
|
MOV SI BX
|
|
NEXT
|
|
|
|
:ASM return
|
|
DEC BP DEC BP
|
|
MOV SI @[ BP]
|
|
NEXT
|
|
|
|
:CP $DODEFERRED
|
|
INC BX INC BX
|
|
MOV BX @[ BX]
|
|
JMP @[ BX]
|
|
|
|
:CP $DOCREATE
|
|
MOV @[ BP] SI
|
|
INC BP INC BP
|
|
INC BX INC BX
|
|
MOV SI @[ BX]
|
|
INC BX INC BX PUSH BX
|
|
NEXT
|
|
|
|
:ASM LIT_
|
|
LODSW
|
|
PUSH AX
|
|
NEXT
|
|
|
|
:ASM noop NEXT
|
|
|
|
: DEFERRED DEF [ t& $DODEFERRED lit ] w>t [ ' '>t , ] ;
|
|
|
|
:ASM INLINEDATA_
|
|
LODSW
|
|
PUSH SI
|
|
MOV SI AX
|
|
NEXT
|
|
|
|
|
|
:ASM BZ_
|
|
POP CX
|
|
JCXZ 0 @>
|
|
LODSW
|
|
NEXT
|
|
L: GOTO_IMPL 0 <:
|
|
LODSW
|
|
MOV SI AX
|
|
NEXT
|
|
|
|
DEF GOTO_ L@ GOTO_IMPL w>t
|
|
|
|
:ASM drop
|
|
POP AX
|
|
NEXT
|
|
|
|
:ASM dup
|
|
POP AX
|
|
PUSH AX
|
|
PUSH AX
|
|
NEXT
|
|
|
|
:ASM 2dup
|
|
POP AX
|
|
POP BX
|
|
PUSH BX
|
|
PUSH AX
|
|
PUSH BX
|
|
PUSH AX
|
|
NEXT
|
|
|
|
:ASM 3dup
|
|
POP AX
|
|
POP BX
|
|
POP CX
|
|
PUSH CX
|
|
PUSH BX
|
|
PUSH AX
|
|
PUSH CX
|
|
PUSH BX
|
|
PUSH AX
|
|
NEXT
|
|
|
|
:ASM swap
|
|
POP AX
|
|
POP BX
|
|
PUSH AX
|
|
PUSH BX
|
|
NEXT
|
|
|
|
:ASM over
|
|
( this costs 1 extra byte but should save 20 clock cycles )
|
|
MOV BX SP
|
|
PUSH @[ 2 @+ SS: BX]
|
|
( POP AX
|
|
POP BX
|
|
PUSH BX
|
|
PUSH AX
|
|
PUSH BX )
|
|
NEXT
|
|
|
|
:ASM <rot
|
|
POP AX
|
|
POP BX
|
|
POP CX
|
|
PUSH BX
|
|
PUSH AX
|
|
PUSH CX
|
|
NEXT
|
|
|
|
:ASM >rot
|
|
POP AX
|
|
POP BX
|
|
POP CX
|
|
PUSH AX
|
|
PUSH CX
|
|
PUSH BX
|
|
NEXT
|
|
|
|
:ASM terminate
|
|
MOV AH 0x4c #
|
|
MOV AL 0 # ( todo: pop? )
|
|
INT 0x21 #
|
|
|
|
:ASM execute
|
|
POP BX
|
|
JMP @[ BX]
|
|
|
|
dbg" return stack"
|
|
:ASM >r
|
|
POP @[ BP]
|
|
INC BP INC BP
|
|
NEXT
|
|
|
|
:ASM <r
|
|
DEC BP DEC BP
|
|
PUSH @[ BP]
|
|
NEXT
|
|
|
|
:ASM r@
|
|
PUSH @[ -2 @+ BP]
|
|
NEXT
|
|
|
|
:ASM rdrop
|
|
DEC BP DEC BP
|
|
NEXT
|
|
|
|
:ASM rswap
|
|
MOV AX @[ -2 @+ BP]
|
|
MOV BX @[ -4 @+ BP]
|
|
MOV @[ -2 @+ BP] BX
|
|
MOV @[ -4 @+ BP] AX
|
|
NEXT
|
|
|