From 0b88b4596e6265863e75e7aabcca52734e147fae Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 24 Feb 2023 19:09:53 -0500 Subject: compact implementation; runs on msp430 --- state.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'state.cpp') diff --git a/state.cpp b/state.cpp index c371101..1510352 100644 --- a/state.cpp +++ b/state.cpp @@ -31,19 +31,26 @@ void State::compiling(bool yes) dict.write(Dictionary::Compiling, yes); } -void State::execute(Addr addr) +State::Error State::execute(Addr addr) { - if (addr < CoreWords::WordCount) { - CoreWords::run(addr, *this); - } else { - pushr(0); - ip = addr - sizeof(Cell); + auto stat = setjmp(jmpbuf); + if (!stat) { + if (addr < CoreWords::WordCount) { + CoreWords::run(addr, *this); + } else { + pushr(0); + ip = addr - sizeof(Cell); - do { - ip += sizeof(Cell); - CoreWords::run(dict.read(ip), *this); - } while (ip); + do { + ip += sizeof(Cell); + CoreWords::run(dict.read(ip), *this); + } while (ip); + } + } else { + return static_cast(stat); } + + return State::Error::none; } std::size_t State::size() const noexcept -- cgit v1.2.3