From a8a4d0ceff7ea57a7b11236a634cf6d9a6be75bd Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Mon, 13 May 2024 13:15:26 -0400 Subject: Fixed jal pc storage --- makefile | 2 +- qdme.c | 13 ++++++------- qdme.o | Bin 11584 -> 0 bytes 3 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 qdme.o diff --git a/makefile b/makefile index 843c699..b021616 100755 --- a/makefile +++ b/makefile @@ -16,4 +16,4 @@ mips: $(OBJS) $(CC) $(CFLAGS) -o $@ $^ clean: - rm -rf $(TARGET) + rm -rf $(TARGET) $(OBJS) diff --git a/qdme.c b/qdme.c index 821c487..171bd0f 100755 --- a/qdme.c +++ b/qdme.c @@ -13,7 +13,7 @@ uint32_t regFile[32] = {0}; void InstFetch(inst_t *inst) { uint32_t value = 0; memcpy(&value, memory + pc, WORD_SIZE); - switch ((value & 0xFC000000) >> 24) { + switch ((value & 0xFC000000) >> 26) { case 0: inst->type = RTYPE; inst->r.op = (value & 0xFC000000) >> 26; @@ -166,11 +166,10 @@ void ExecRtype(const inst_t inst) { case 19: // MTLO lo = regFile[r.rs]; break; - case 8: // jr - pc = a; - break; case 9: // jalr - regFile[r.rd] = pc + 4; + regFile[r.rd] = pc; + /* Intentional Fall Through */ + case 8: // jr pc = a; break; case 12: // syscall @@ -190,10 +189,10 @@ void InstExec(const inst_t inst) { ExecRtype(inst); break; case 3: // jal - regFile[RA] = pc + 4; + regFile[RA] = pc; /* intentional fall through */ case 2: // j - pc = (0xF0000000 & pc ) | inst.j.addr; + pc = (0xF0000000 & pc ) | (signed)inst.j.addr; break; case 4: // beq pc = (regFile[inst.i.rs] == regFile[inst.i.rt]) ? pc + 4 + diff --git a/qdme.o b/qdme.o deleted file mode 100644 index fae379c..0000000 Binary files a/qdme.o and /dev/null differ -- cgit v1.2.3