summaryrefslogtreecommitdiff
path: root/src/wb.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/wb.cc')
-rw-r--r--src/wb.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/wb.cc b/src/wb.cc
index 08d512b..cd24c6a 100644
--- a/src/wb.cc
+++ b/src/wb.cc
@@ -19,13 +19,12 @@
#include "instrDTO.h"
#include "response.h"
#include "stage.h"
-#include <array>
#include <algorithm>
+#include <array>
void WB::advance_helper()
{
- if (this->curr_instr->mnemonic != NOP &&
- this->curr_instr->type != INV) {
+ if (this->curr_instr->mnemonic != NOP) {
if (this->curr_instr->checked_out > 0)
this->write_handler();
else if (this->should_jump())
@@ -46,30 +45,34 @@ void WB::write_handler()
// POP performs a second register write
reg = this->checked_out.front();
this->checked_out.pop_front();
- this->store_register(reg, this->curr_instr->operands.integer.slot_three);
+ this->store_register(
+ reg, this->curr_instr->operands.integer.slot_three);
}
this->checked_out.pop_front();
reg = this->curr_instr->checked_out;
this->store_register(reg, this->curr_instr->operands.integer.slot_one);
-
}
void WB::jump_handler()
{
if (this->curr_instr->operands.integer.slot_one > 0) {
if (this->curr_instr->mnemonic == JAL)
- this->gprs[1] = this->curr_instr->slot_B + 1;;
+ this->gprs[1] = this->curr_instr->slot_B + 1;
+ ;
this->pc = this->curr_instr->operands.integer.slot_one;
this->checked_out = {};
this->next->squash();
}
}
+// TODO clean this up...
bool WB::should_jump()
{
- Type t;
+ vector<Mnemonic> Js = {JMP, JRL, JAL, BEQ, BGT, BUF, BOF, PUSH, POP, RET};
- t = this->curr_instr->type;
- return t == J;
+ if (find(Js.begin(), Js.end(), this->curr_instr->mnemonic) != Js.end())
+ return true;
+ else
+ return false;
}