From 0d7da86ea5e5187dca2e843549c33f761e35f068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 25 Nov 2017 16:39:10 +0100 Subject: Add crude implementation of MOV* instructions I don't like how it's implemented but I have no other idea atm. --- qtmips_machine/core.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qtmips_machine/core.cpp') diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp index 1008886..20c1b74 100644 --- a/qtmips_machine/core.cpp +++ b/qtmips_machine/core.cpp @@ -126,8 +126,14 @@ struct Core::dtDecode Core::decode(struct dtFetch dt) { struct Core::dtExecute Core::execute(struct dtDecode dt) { // TODO signals + // Handle conditional move (we have to change regwrite signal if conditional is not met) + // TODO can't we do this some cleaner way? + bool regwrite = dt.regwrite; + if (dt.inst.opcode() == 0 && ((dt.inst.funct() == 10 && dt.val_rt != 0) || (dt.inst.funct() == 11 && dt.val_rt == 0))) + regwrite = false; + return { - .regwrite = dt.regwrite, + .regwrite = regwrite, .rwrite = dt.regd ? dt.inst.rd() : dt.inst.rt(), .alu_val = alu_operate(dt.aluop, dt.val_rs, dt.alusrc ? dt.inst.immediate() : dt.val_rt, dt.inst.shamt(), regs), }; -- cgit v1.2.3