From 395b8ed9daa18b9a5f2cc0e6e840f21da71feb3b Mon Sep 17 00:00:00 2001 From: William Baker Date: Mon, 20 Nov 2023 11:36:45 -0500 Subject: [PATCH] fix compiler exp --- CHANGELOG.md | 4 ++++ src/compiler.cpp | 2 +- tests/compiler/exp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 120000 tests/compiler/exp diff --git a/CHANGELOG.md b/CHANGELOG.md index b06c828..5d876c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. See [Keep a ## Unreleased +### Fixed + +- The EXP opcode now behaves consistently between the interpreter and the C compiler. + ### Added - You can now customize the colors of the threads in the online debugger. diff --git a/src/compiler.cpp b/src/compiler.cpp index 1f337d2..a2b1aad 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -143,7 +143,7 @@ void compiler::get_c_code(const instruction& i, std::ostream& os, bool assume_as cerr << "Nondeterministic instructions are not yet supported for compiled programs." << endl; exit(EXIT_FAILURE); case op::EXP: - os << "lws_push(stack, 1 << lws_pop(stack));"; + os << "lws_push(stack, 1 << (lws_pop(stack) + 8) >> 8);"; return; case op::SWP: os << "{" diff --git a/tests/compiler/exp b/tests/compiler/exp new file mode 120000 index 0000000..95d177c --- /dev/null +++ b/tests/compiler/exp @@ -0,0 +1 @@ +../cli/exp \ No newline at end of file