diff --git a/classes/swen90006/machine/Machine.class b/classes/swen90006/machine/Machine.class index bc67cdff3d66160515599de443f4aea563326bac..e8ad0e469a8f1238f60c863da1415d3ab8a51b74 100644 Binary files a/classes/swen90006/machine/Machine.class and b/classes/swen90006/machine/Machine.class differ diff --git a/mutants/mutant-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 27c8d4f78c91c09ab2825293be3ef28557af1925..b2fa4d123d8ee9bb24bd533b3f4d4a5181fd2dbc 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/swen90006/machine/Machine.java @@ -82,7 +82,7 @@ public class Machine private void do_load(int dest, int src, int offs) { // Relational Operator Replacement - if (regs[src] + offs => MAX_ADDR){ + if (regs[src] + offs >= MAX_ADDR){ /* no op */ }else if(regs[src] + offs < 0){ /* no op */ diff --git a/src/swen90006/machine/Machine.java b/src/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..1e17b30304003071dff49f4156e7b988adcf9544 100644 --- a/src/swen90006/machine/Machine.java +++ b/src/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,17 +60,17 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { if (regs[src2] == 0){ @@ -152,16 +152,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -180,7 +180,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";");