aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/core.cpp
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-01-31 11:45:41 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-01-31 11:45:41 +0100
commitb1f0e4fcc83c7692f4b066fcc026d77a051c1d7d (patch)
tree51a452e656edd61f75b982c35d0656f691f72deb /qtmips_machine/core.cpp
parenteab6cf4fc5720b330ba89c38e9e6119a8a6fabfa (diff)
downloadqtmips-b1f0e4fcc83c7692f4b066fcc026d77a051c1d7d.tar.gz
qtmips-b1f0e4fcc83c7692f4b066fcc026d77a051c1d7d.tar.bz2
qtmips-b1f0e4fcc83c7692f4b066fcc026d77a051c1d7d.zip
Include support for JALR support.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_machine/core.cpp')
-rw-r--r--qtmips_machine/core.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index 6443be1..2ff528d 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -134,6 +134,7 @@ struct Core::dtDecode Core::decode(const struct dtFetch &dt) {
std::uint32_t val_rs = regs->read_gp(dt.inst.rs());
std::uint32_t val_rt = regs->read_gp(dt.inst.rt());
std::uint32_t immediate_val;
+ bool regd31 = dec.flags & DM_PC_TO_R31;
if (dec.flags & DM_ZERO_EXTEND)
immediate_val = dt.inst.immediate();
@@ -153,19 +154,23 @@ struct Core::dtDecode Core::decode(const struct dtFetch &dt) {
emit decode_rs_num_value(dt.inst.rs());
emit decode_rt_num_value(dt.inst.rt());
emit decode_rd_num_value(dt.inst.rd());
- emit decode_regd31_value((bool)(dec.flags & DM_PC_TO_R31));
+ emit decode_regd31_value(regd31);
- if (dec.flags & DM_PC_TO_R31) {
+ if (regd31) {
val_rs = dt.inst_addr + 8;
}
+ if ((dt.inst.opcode() == 0 && dt.inst.funct() == ALU_OP_JALR)) {
+ val_rt = dt.inst_addr + 8;
+ }
+
return {
.inst = dt.inst,
.memread = dec.flags & DM_MEMREAD,
.memwrite = dec.flags & DM_MEMWRITE,
.alusrc = dec.flags & DM_ALUSRC,
.regd = dec.flags & DM_REGD,
- .regd31 = dec.flags & DM_PC_TO_R31,
+ .regd31 = regd31,
.regwrite = dec.flags & DM_REGWRITE,
.aluop = dt.inst.opcode() == 0 ? (enum AluOp)dt.inst.funct() : dec.alu,
.memctl = dec.mem_ctl,