From f11179089e83d2af89c39a4fb50c34a8ea805462 Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Thu, 31 Dec 2020 20:23:08 +0900 Subject: [PATCH] Add ":" and ";" ! --- core.fs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/core.fs b/core.fs index a0f898d..2138d85 100644 --- a/core.fs +++ b/core.fs @@ -336,4 +336,39 @@ I \ Enter 2nd Stage r C + R \ Drop 1st stage interpreter from call stack + +\ : ( "name" -- R:w ) COLON +\ Read name, create word, push it to return stack, +\ compile 'docol' and enter compile mode. +c : i , + \ save the address of the word to + \ **2nd position** of return stack. + \ Same reasons for TOR and FROMR + ' h , ' @ , ' # , + ' } , ' ~ , ' { , ' { , + ' l , ' @ , ' , , \ fill link + ' W , \ read name ( addr len ) + ' # , ' B , \ fill length ( addr len ) + ' m , \ fill name + ' A , \ align here + ' i , ' , , \ compile docol + \ enter compile mode + ' L , k 1 k 0 - , ' M , ' ! , +' e , l ! + +\ ; immediate ( R:w -- ) SEMICOLON +\ Compile 'exit', add w to dictionary and enter immediate mode. +c ; i , + ' L , ' e , ' , , \ compile exit + + \ pick 2nd element of return stack + ' } , ' } , ' ~ , ' { , + ' l , ' ! , \ update latest + + \ enter immediate mode + ' L , k 0 k 0 - , ' M , ' ! , +' e , l ! +\ Toggle immediate-bit of ';' +l @ C + # { ? k @ k @ + | } $ + Q