]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
key in forth; abort"; draft find
authorClyne Sullivan <clyne@bitgloo.com>
Mon, 27 Feb 2023 13:39:21 +0000 (08:39 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Mon, 27 Feb 2023 13:39:21 +0000 (08:39 -0500)
compat.txt
core.fth
corewords.cpp
corewords.hpp

index a4c6326be944d9622d2d63c46a1a7b74c46e41ba..91e29316e4665c6dcb5ebb05e451272d312a40e1 100644 (file)
@@ -43,7 +43,7 @@ yes 6.1.0580 >R
 yes 6.1.0630 ?DUP
 yes 6.1.0650 @
 yes 6.1.0670 ABORT
-    6.1.0680 ABORT"
+yes 6.1.0680 ABORT"
 yes 6.1.0690 ABS
 yes 6.1.0695 ACCEPT
 yes 6.1.0705 ALIGN
index 147522401257bde84005cb48f73094183cdefad0..178a5d28e1bf27c876dd0d84b428f0e6c2c832a9 100644 (file)
--- a/core.fth
+++ b/core.fth
 : min      2dup <= if drop else nip then ;
 : max      2dup <= if nip else drop then ;
 
+: key      begin _input @ dup 0 <= while drop _in repeat
+           dup 1- _input !
+           _input cell+ 80 chars + swap - c@ ;
 : word     here -1 cells over ! dup cell+ rot begin key 2dup <> while
            2 pick c! swap char+ swap repeat
            2drop over - over +!  ;
 
 : quit     begin _rdepth 1 > while r> drop repeat postpone [ ;
 : abort    begin depth 0 > while drop repeat quit ;
+: abort"   postpone s" ['] rot ,
+           postpone if ['] type , ['] abort ,
+           postpone else ['] 2drop , postpone then ; imm
 
 : recurse  _latword , ; imm
 
index 1ee7928f0504b9d47d8d2a6b943d3f420d4dc5fb..49a757af98f5fa8267b4a113516996a52824946d 100644 (file)
@@ -49,6 +49,21 @@ void tick(State& state)
     else
         state.push(0);
 }
+//    auto addr = state.pop();
+//    auto count = state.dict.read(addr++);
+//    Word word (addr, addr + count);
+//
+//    if (auto j = state.dict.find(word); j > 0) {
+//        state.push(state.dict.getexec(j));
+//        auto imm = state.dict.read(ins) & CoreWords::Immediate;
+//        state.push(imm ? 1 : -1);
+//    } else if (auto i = CoreWords::findi(state, word); i >= 0) {
+//        state.push(((i & ~CoreWords::Immediate) << 1) | 1);
+//        state.push((i & CoreWords::Immediate) ? 1 : -1);
+//    } else {
+//        state.push(addr);
+//        state.push(0);
+//    }
 
 void CoreWords::run(unsigned int index, State& state)
 {
@@ -191,19 +206,8 @@ execute:
     case 30: // _rdepth
         state.push(state.rsize());
         break;
-    case 31: // key
-        cell = state.dict.read(Dictionary::Input);
-        while (cell <= 0) {
-            state.input(state);
-            cell = state.dict.read(Dictionary::Input);
-        }
-
-        state.dict.write(Dictionary::Input, cell - 1);
-
-        state.push(
-            state.dict.readbyte(
-                Dictionary::Input + sizeof(Cell) +
-                Dictionary::InputCells - cell));
+    case 31: // _in
+        state.input(state);
         break;
     }
 
index 56f7703a5dc4297fc2954d642f10c9fb20a1dd79..9546ac1b7bb928390a06c8a759386c039bc8431d 100644 (file)
@@ -45,7 +45,7 @@ private:
         "<\0&\0|\0^\0"
         "<<\0>>\0:\0'\0execute\0"
         "exit\0;\0_jmp0\0_jmp\0"
-        "depth\0_rdepth\0key\0";
+        "depth\0_rdepth\0_in\0";
 };
 
 #endif // ALEEFORTH_COREWORDS_HPP