added 2 code files; added enl instruction; completed main to do the right thing

This commit is contained in:
Bob Polis
2020-09-07 18:50:09 +02:00
parent b0a3637b1d
commit 344f26b05f
6 changed files with 48 additions and 2 deletions

View File

@ -119,6 +119,7 @@ void interpreter::exec_instruction(const std::string& code, bool& done) {
else if (code == "gge") gge();
else if (code == "fun") fun();
else if (code == "ret") ret();
else if (code == "enl") enl();
else throw syntax_error {code};
}
@ -271,6 +272,14 @@ void interpreter::rot() {
_pc++;
}
void interpreter::enl() {
std::string val {_stack.back()};
_stack.pop_back();
val += '\n';
_stack.push_back(val);
_pc++;
}
// tests & jumps ----------------------------------------------------------
void interpreter::gto() {