From e6135168e4c857afcb6969d70944a8aafc8f3935 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 1 Nov 2023 12:55:56 +0300 Subject: [PATCH] #42: refactored cmpgf cmplf --- src/ChaiVM/interpreter/executor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ChaiVM/interpreter/executor.cpp b/src/ChaiVM/interpreter/executor.cpp index c4c8f46..3c4fe8c 100644 --- a/src/ChaiVM/interpreter/executor.cpp +++ b/src/ChaiVM/interpreter/executor.cpp @@ -257,18 +257,18 @@ void Executor::if_acmpne(Instruction ins) { void Executor::cmpgf(Instruction ins) { double acc_f64 = std::bit_cast(regFile_.acc()); double r1_f64 = std::bit_cast(regFile_[ins.r1]); - regFile_.acc() = (acc_f64 < r1_f64 || acc_f64 != acc_f64 || r1_f64 != r1_f64 - ? static_cast(-1) - : static_cast(acc_f64 != r1_f64)); + regFile_.acc() = (acc_f64 >= r1_f64) + ? static_cast(acc_f64 != r1_f64) + : static_cast(-1); advancePc(); DO_NEXT_INS() } void Executor::cmplf(Instruction ins) { double acc_f64 = std::bit_cast(regFile_.acc()); double r1_f64 = std::bit_cast(regFile_[ins.r1]); - regFile_.acc() = (acc_f64 > r1_f64 || acc_f64 != acc_f64 || r1_f64 != r1_f64 - ? -1 - : static_cast(acc_f64 != r1_f64)); + regFile_.acc() = regFile_.acc() = (acc_f64 <= r1_f64) + ? static_cast(acc_f64 != r1_f64) + : static_cast(-1); advancePc(); DO_NEXT_INS() }