summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmakefile2
-rwxr-xr-xqdme.c13
-rw-r--r--qdme.obin11584 -> 0 bytes
3 files changed, 7 insertions, 8 deletions
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
--- a/qdme.o
+++ /dev/null
Binary files differ