|
|
@ -37,21 +37,12 @@ void find(State& state, Word word)
|
|
|
|
state.push(imm);
|
|
|
|
state.push(imm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::run(Cell ins, State& state)
|
|
|
|
bool CoreWords::run(Cell ins, State& state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DoubleCell dcell;
|
|
|
|
DoubleCell dcell;
|
|
|
|
Addr index = ins;
|
|
|
|
|
|
|
|
auto& ip = state.ip();
|
|
|
|
auto& ip = state.ip();
|
|
|
|
|
|
|
|
|
|
|
|
execute:
|
|
|
|
switch (ins) {
|
|
|
|
if (index >= Dictionary::Begin) {
|
|
|
|
|
|
|
|
// must be calling a defined subroutine
|
|
|
|
|
|
|
|
state.pushr(ip);
|
|
|
|
|
|
|
|
ip = index;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (index >= WordCount) {
|
|
|
|
|
|
|
|
state.push(static_cast<Cell>(index - WordCount));
|
|
|
|
|
|
|
|
} else switch (index) {
|
|
|
|
|
|
|
|
case 0: // _lit
|
|
|
|
case 0: // _lit
|
|
|
|
state.push(state.beyondip());
|
|
|
|
state.push(state.beyondip());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -149,8 +140,7 @@ execute:
|
|
|
|
find(state, state.dict.input());
|
|
|
|
find(state, state.dict.input());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 24: // execute
|
|
|
|
case 24: // execute
|
|
|
|
index = state.pop();
|
|
|
|
return true;
|
|
|
|
goto execute;
|
|
|
|
|
|
|
|
case 25: // exit
|
|
|
|
case 25: // exit
|
|
|
|
ip = state.popr();
|
|
|
|
ip = state.popr();
|
|
|
|
if (ip == 0)
|
|
|
|
if (ip == 0)
|
|
|
@ -180,8 +170,8 @@ execute:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[[fallthrough]];
|
|
|
|
[[fallthrough]];
|
|
|
|
case 28: // _jmp
|
|
|
|
case 28: // _jmp
|
|
|
|
ip = state.beyondip();
|
|
|
|
ip = static_cast<Addr>(state.beyondip() - sizeof(Cell));
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 29: // depth
|
|
|
|
case 29: // depth
|
|
|
|
state.push(static_cast<Cell>(state.size()));
|
|
|
|
state.push(static_cast<Cell>(state.size()));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -191,7 +181,7 @@ execute:
|
|
|
|
case 31: // _in
|
|
|
|
case 31: // _in
|
|
|
|
state.input();
|
|
|
|
state.input();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 32: // _ex
|
|
|
|
case 32: // _ev
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const auto st = state.save();
|
|
|
|
const auto st = state.save();
|
|
|
|
ip = 0;
|
|
|
|
ip = 0;
|
|
|
@ -235,7 +225,7 @@ execute:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ip += sizeof(Cell);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cell CoreWords::findi(State& state, Word word)
|
|
|
|
Cell CoreWords::findi(State& state, Word word)
|
|
|
|