From 9a025aeaeb4104d6a66baaa575c669231d5d76bc Mon Sep 17 00:00:00 2001 From: bd-912 Date: Tue, 7 May 2024 18:37:10 -0600 Subject: Fix indexing for MemRead/MemWrite in Condense, almost all tests pass --- condense/CondenseVisitor.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'condense/CondenseVisitor.java') diff --git a/condense/CondenseVisitor.java b/condense/CondenseVisitor.java index fd337d9..5713ded 100644 --- a/condense/CondenseVisitor.java +++ b/condense/CondenseVisitor.java @@ -180,9 +180,9 @@ public class CondenseVisitor extends VInstr.Visitor{ else if (op.equals("MulS")) ret += " mul"; else if (op.equals("Eq")) - ret += "NULL"; // fixme + ret += " and"; else if (op.equals("Lt")) - ; + ret += " slt"; else if (op.equals("LtS")) ret += " slt"; else if (op.equals("PrintIntS")) { @@ -223,12 +223,18 @@ public class CondenseVisitor extends VInstr.Visitor{ n.sourcePos.toString())); /////////////////////////////////////////////////////////////// String source = n.source.toString(); + if (this.isNumeric(source)) { + this.addMIPS(String.format(" li $t9 %s", + source)); + source = "$t9"; + } String dest; if (n.dest instanceof VMemRef.Stack) dest = this.curr.get(((VMemRef.Stack) n.dest)); else - dest = String.format("0(%s)", + dest = String.format("%d(%s)", + ((VMemRef.Global) n.dest).byteOffset, ((VMemRef.Global) n.dest).base.toString()); if (source.contains(":")) { this.addMIPS(String.format(" la $t9 %s", @@ -252,11 +258,15 @@ public class CondenseVisitor extends VInstr.Visitor{ String dest = n.dest.toString(); String source; - if (n.source instanceof VMemRef.Stack) + if (n.source instanceof VMemRef.Stack) { + MinimalLogger.info("Loading from stack..."); source = this.curr.get(((VMemRef.Stack) n.source)); - else - source = String.format("0(%s)", + } else { + MinimalLogger.info("Loading a const..."); + source = String.format("%d(%s)", + ((VMemRef.Global) n.source).byteOffset, ((VMemRef.Global) n.source).base.toString()); + } this.addMIPS(String.format(" lw %s %s", dest, source)); -- cgit v1.2.3