dialer/boot.jor

73 lines
1.7 KiB
Plaintext
Executable File

0 const 0
1 const 1
: 1+ 1 + ;
: 1- 1 - ;
2 const cell
: cells cell * ;
10 const '\n'
13 const '\r'
key const sp
: cr '\n' emit ;
: bl sp emit ;
0x100 const F_IMMEDIATE
: if ' BZ_ , here 0 , ; immediate
: else ' GOTO_ , 0 , here swap ! here cell - ; immediate
: then here swap ! ; immediate
: begin here ; immediate
: while ' BZ_ , here 0 , ; immediate
: repeat ' GOTO_ , swap , here swap ! ; immediate
: again ' GOTO_ , , ; immediate
: until ' BZ_ , , ; immediate
: lit ' LIT_ , , ;
: ( begin key [ key ) lit ] = until ; immediate
: inline| ' INLINEDATA_ , here 0 , ;
: |inline [ ' then , ] ;
' cells @ const $DOCOLON ( get the colon execution token )
: :| inline| $DOCOLON , ; immediate
: |; ' return , |inline ; immediate
: s" state if inline| else here then
begin key dup [ key " lit ] != over 0 != and while b, repeat drop 0 b,
state if |inline else dup here! then ; immediate
: interpretword F_IMMEDIATE & state not or if execute else , then ;
: interpretnumber state if lit then ;
: interpretunknown type s" ?" type cr ;
: expileword lookup dup
if interpretword
else drop number
if interpretnumber
else interpretunknown
then
then ;
: interpreter
begin word dup b@ while expileword repeat drop ;
: loadfp ( fp -- fp )
infile @ >r
infile !
interpreter
infile @
<r infile ! ;
: loadfile ( filename -- ) open loadfp close ;
( image loading )
: noop ;
: defer new-word $DODEFERRED , ' noop , ;
: redefine ( cp cpdeferred ) cell + ! ;
: definition ( cpdeferred ) cell + @ ;
( minijort implementations of words defined in assembly in tinyjort )
: >rot <rot <rot ;
: 2dup over over ;
: 3dup >r 2dup r@ >rot <r ;