|
|
@ -40,16 +40,17 @@ void find(State& state, Word word)
|
|
|
|
void CoreWords::run(Cell ins, State& state)
|
|
|
|
void CoreWords::run(Cell ins, State& state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DoubleCell dcell;
|
|
|
|
DoubleCell dcell;
|
|
|
|
const Addr index = ins;
|
|
|
|
Addr index = ins;
|
|
|
|
auto& ip = state.ip();
|
|
|
|
auto& ip = state.ip();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
execute:
|
|
|
|
if (index >= Dictionary::Begin) {
|
|
|
|
if (index >= Dictionary::Begin) {
|
|
|
|
// must be calling a defined subroutine
|
|
|
|
// must be calling a defined subroutine
|
|
|
|
state.pushr(ip);
|
|
|
|
state.pushr(ip);
|
|
|
|
ip = index;
|
|
|
|
ip = index;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (index >= WordCount) {
|
|
|
|
} else if (index >= WordCount) {
|
|
|
|
state.push(index - WordCount);
|
|
|
|
state.push(static_cast<Cell>(index - WordCount));
|
|
|
|
} else switch (index) {
|
|
|
|
} else switch (index) {
|
|
|
|
case 0: // _lit
|
|
|
|
case 0: // _lit
|
|
|
|
state.push(state.beyondip());
|
|
|
|
state.push(state.beyondip());
|
|
|
@ -148,11 +149,12 @@ void CoreWords::run(Cell ins, State& state)
|
|
|
|
find(state, state.dict.input());
|
|
|
|
find(state, state.dict.input());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 24: // execute
|
|
|
|
case 24: // execute
|
|
|
|
ip = state.pop();
|
|
|
|
index = state.pop();
|
|
|
|
return;
|
|
|
|
goto execute;
|
|
|
|
case 25: // exit
|
|
|
|
case 25: // exit
|
|
|
|
ip = state.popr();
|
|
|
|
ip = state.popr();
|
|
|
|
state.verify(ip != 0, Error::exit);
|
|
|
|
if (ip == 0)
|
|
|
|
|
|
|
|
state.exit();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 26: // semic
|
|
|
|
case 26: // semic
|
|
|
|
state.dict.add(findi("exit"));
|
|
|
|
state.dict.add(findi("exit"));
|
|
|
|