X-Git-Url: https://git.kengrimes.com/?p=watForth.git;a=blobdiff_plain;f=forth.forth;h=cb6090f20113adc87f86ec7be54589961374bb54;hp=fb04e4d2061dd5965b7ef0cda264c72bc9008e11;hb=fb7946e17777ee389e3eaf742e6ff87a5d832710;hpb=94d40c7e5521898acd394ca7a3e30cf20065ee5c diff --git a/forth.forth b/forth.forth index fb04e4d..cb6090f 100644 --- a/forth.forth +++ b/forth.forth @@ -34,11 +34,13 @@ word DEFINE-DOES 45 define word QUIT 16384 define word BYE 25 define word WORDS 27 define -word !CHANNEL 35 define +word CHANNEL-IN 35 define +word CHANNEL-OUT 48 define word !HERE 36 define word HERE 28 define word STACKTRACE 46 define +word FETCH 47 define word ; 1 define word JZ: 14 define @@ -83,9 +85,9 @@ word ::> here define ' word , ' 2dup , ' here , ' define-does , ' here , ' define , ' ; , \ write the execution semantics of a word to memory -: MEMORIZE-WORD ' dup , ' JNZ: , here 12 + , ' 2drop , ' ; , +: MEMORIZE-WORD ' dup , ' JNZ: , here 12 + , ' 2drop , ' ; , ' 2dup , ' find , ' dup , ' JZ: , here 16 + , ' , , ' 2drop , ' ; , -' drop , ' lit , ' lit , ' , , ' execute-num , ' , , ' ; , +' drop , ' lit , ' lit , ' , , ' execute-num , ' , , ' ; , \ change interpreter semantics to "memorize-word" : memorizing ' lit , ' mode , ' lit , ' memorize-word , ' ! , ' ; , @@ -94,7 +96,8 @@ word ::> here define \memorizing \: executing lit mode lit execute-word ! ; \: FINISH-" drop string-end ; -\: " string-start \: KLOOP key 34 =? JNZ: finish-" string-put JMP: KLOOP +\: BSLASH-" drop key string-put JMP: \here \8 \+ \, +\: " string-start \: KLOOP key 92 =? JNZ: bslash-" 34 =? JNZ: finish-" string-put JMP: KLOOP \: DO" \:> " " swap lit lit , , lit lit , , ; \: DOIF \:> IF lit JZ: , here dup , ; \: DOELSE \:> ELSE lit JMP: , here dup , swap here ! ; @@ -142,5 +145,6 @@ here define-does then compiling ; beyond this point, all hope is lost ) +\ Print intro string " watForth-32 Interactive CLI: " .s