llvm
Clyne 2 years ago
parent 400e277b0c
commit f186ff2a22

@ -20,7 +20,6 @@ Running Alee without `core.fth` or `core-ext.fth` passed as arguments will leave
* Pictured numeric output conversion (e.g. `<# #>`) * Pictured numeric output conversion (e.g. `<# #>`)
* Words for unsigned integers: `U. U< UM* UM/MOD` * Words for unsigned integers: `U. U< UM* UM/MOD`
* `>NUMBER` * `>NUMBER`
* `FIND`
**Missing** core extensions: **Missing** core extensions:
``` ```

@ -78,7 +78,7 @@ yes 6.1.1360 EVALUATE
yes 6.1.1370 EXECUTE yes 6.1.1370 EXECUTE
yes 6.1.1380 EXIT yes 6.1.1380 EXIT
yes 6.1.1540 FILL yes 6.1.1540 FILL
6.1.1550 FIND yes 6.1.1550 FIND
yes 6.1.1561 FM/MOD yes 6.1.1561 FM/MOD
yes 6.1.1650 HERE yes 6.1.1650 HERE
6.1.1670 HOLD 6.1.1670 HOLD

@ -647,8 +647,8 @@ T{ : GT2 ['] GT1 ; IMMEDIATE -> }T
T{ GT2 EXECUTE -> 123 }T T{ GT2 EXECUTE -> 123 }T
HERE 3 C, CHAR G C, CHAR T C, CHAR 1 C, CONSTANT GT1STRING HERE 3 C, CHAR G C, CHAR T C, CHAR 1 C, CONSTANT GT1STRING
HERE 3 C, CHAR G C, CHAR T C, CHAR 2 C, CONSTANT GT2STRING HERE 3 C, CHAR G C, CHAR T C, CHAR 2 C, CONSTANT GT2STRING
\ T{ GT1STRING FIND -> ' GT1 -1 }T T{ GT1STRING FIND -> ' GT1 -1 }T
\ T{ GT2STRING FIND -> ' GT2 1 }T T{ GT2STRING FIND -> ' GT2 1 }T
\ ( HOW TO SEARCH FOR NON-EXISTENT WORD? ) \ ( HOW TO SEARCH FOR NON-EXISTENT WORD? )
T{ : GT3 GT2 LITERAL ; -> }T T{ : GT3 GT2 LITERAL ; -> }T
T{ GT3 -> ' GT1 }T T{ GT3 -> ' GT1 }T

@ -39,9 +39,8 @@ void newdef(State& state, Word word)
dict.addDefinition(word); dict.addDefinition(word);
state.push(addr); state.push(addr);
}; };
void tick(State& state) void find(State& state, Word word)
{ {
auto word = getword(state);
if (auto j = state.dict.find(word); j > 0) { if (auto j = state.dict.find(word); j > 0) {
state.push(state.dict.getexec(j)); state.push(state.dict.getexec(j));
auto imm = state.dict.read(j) & Dictionary::Immediate; auto imm = state.dict.read(j) & Dictionary::Immediate;
@ -165,7 +164,7 @@ execute:
state.compiling(true); state.compiling(true);
break; break;
case 23: // tick case 23: // tick
tick(state); find(state, getword(state));
break; break;
case 24: // execute case 24: // execute
index = state.pop(); index = state.pop();
@ -213,6 +212,16 @@ execute:
state.load(st); state.load(st);
} }
break; break;
case 33: // find
{
const Addr caddr = state.pop();
const Word word {
static_cast<Addr>(caddr + 1),
static_cast<Addr>(caddr + 1 + state.dict.readbyte(caddr))
};
find(state, word);
}
break;
default: default:
state.push(index - WordCount); state.push(index - WordCount);
break; break;

@ -31,7 +31,7 @@ void user_sys(State&);
class CoreWords class CoreWords
{ {
public: public:
constexpr static std::size_t WordCount = 33; constexpr static std::size_t WordCount = 34;
constexpr static int Semicolon = 26; constexpr static int Semicolon = 26;
/** /**
@ -53,7 +53,7 @@ public:
"<\0&\0|\0^\0" "<\0&\0|\0^\0"
"<<\0>>\0:\0_'\0execute\0" "<<\0>>\0:\0_'\0execute\0"
"exit\0;\0_jmp0\0_jmp\0" "exit\0;\0_jmp0\0_jmp\0"
"depth\0_rdepth\0_in\0_ev\0"; "depth\0_rdepth\0_in\0_ev\0find\0";
}; };
#endif // ALEEFORTH_COREWORDS_HPP #endif // ALEEFORTH_COREWORDS_HPP

Loading…
Cancel
Save