Skip to content

Commit

Permalink
#42: refactored cmpgf cmplf
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Nov 1, 2023
1 parent 1b9dbb5 commit e613516
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ChaiVM/interpreter/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,18 @@ void Executor::if_acmpne(Instruction ins) {
void Executor::cmpgf(Instruction ins) {
double acc_f64 = std::bit_cast<double>(regFile_.acc());
double r1_f64 = std::bit_cast<double>(regFile_[ins.r1]);
regFile_.acc() = (acc_f64 < r1_f64 || acc_f64 != acc_f64 || r1_f64 != r1_f64
? static_cast<chsize_t>(-1)
: static_cast<chsize_t>(acc_f64 != r1_f64));
regFile_.acc() = (acc_f64 >= r1_f64)
? static_cast<size_t>(acc_f64 != r1_f64)
: static_cast<size_t>(-1);
advancePc();
DO_NEXT_INS()
}
void Executor::cmplf(Instruction ins) {
double acc_f64 = std::bit_cast<double>(regFile_.acc());
double r1_f64 = std::bit_cast<double>(regFile_[ins.r1]);
regFile_.acc() = (acc_f64 > r1_f64 || acc_f64 != acc_f64 || r1_f64 != r1_f64
? -1
: static_cast<chsize_t>(acc_f64 != r1_f64));
regFile_.acc() = regFile_.acc() = (acc_f64 <= r1_f64)
? static_cast<size_t>(acc_f64 != r1_f64)
: static_cast<size_t>(-1);
advancePc();
DO_NEXT_INS()
}
Expand Down

0 comments on commit e613516

Please sign in to comment.