Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • tmiller/SWEN90006-A1-2018
  • cbalasuriya/SWEN90006-A1-2018
  • zhangyuny/SWEN90006-A1-2018
  • zhaor4/SWEN90006-A1-2018
  • nelsonc1/SWEN90006-A1-2018
  • jiamingz3/SWEN90006-A1-2018
  • cvidler/SWEN90006-A1-2018
  • 923841/SWEN90006-A1-2018
  • hzhu5/SWEN90006-A1-2018
  • zhuoyaof/SWEN90006-A1-2018
  • haoyangc/SWEN90006-A1-2018
  • austinl/SWEN90006-A1-2018
  • gxuan/SWEN90006-A1-2018
  • zlang/SWEN90006-A1-2018
  • junhany/SWEN90006-A1-2018
  • shibaoz/SWEN90006-A1-2018
  • arwinders/SWEN90006-A1-2018
  • jiankunc/SWEN90006-A1-2018
  • xujiaz/SWEN90006-A1-2018
  • xiaomingz/SWEN90006-A1-2018
  • xixiangw/SWEN90006-A1-2018
  • yunchengw/SWEN90006-A1-2018
  • abdulk/SWEN90006-A1-2018
  • yangz7/SWEN90006-A1-2018
  • linyuanz/SWEN90006-A1-2018
  • zhaolind/SWEN90006-A1-2018
  • jingjiahuil/SWEN90006-A1-2018
  • hongyic3/SWEN90006-A1-2018
  • zhouw4/SWEN90006-A1-2018
  • emilylm/SWEN90006-A1-2018
  • jingez1/SWEN90006-A1-2018
  • minzhex/SWEN90006-A1-2018
32 results
Select Git revision
  • master
1 result
Show changes
Showing
with 65 additions and 5 deletions
RET R0
\ No newline at end of file
MOV R1 10
JMP 1
RET R1
MOV R1 10
MOV R3 12
MOV R2 1
SUB R4 R3 R1
JMP 3
ADD R2 R1 R2
SUB R2 R1 R2
MUL R10 R2 R3
RET R2
\ No newline at end of file
MOV R1 10
MOV R3 12
MOV R2 1
SUB R4 R3 R1
JMP 655
ADD R2 R1 R2
SUB R2 R1 R2
RET R2
\ No newline at end of file
JZ R1 0
MOV R1 5
MOV R2 2
RET R1
\ No newline at end of file
JZ R1 2
MOV R1 5
MOV R2 2
RET R1
\ No newline at end of file
MOV R1 1
JZ R1 2
MOV R1 5
MOV R2 2
RET R1
\ No newline at end of file
RET R32
\ No newline at end of file
MOV R1 4
MOV R2 2
DIV R-1 R1 R2
RET R0
\ No newline at end of file
MOV R1 1
MOV R2 4
MOV R3 0
DIV R1 R2 R3
RET R1
\ No newline at end of file
MOV R2 4
MOV R3 2
DIV R1 R2 R3
RET R1
\ No newline at end of file
MOV R4 4
MOV R2 2
DIV R32 R4 R2
RET R0
\ No newline at end of file
MOV R2 2
MOV R3 3
SUB R1 R2 R3
RET R1
\ No newline at end of file
MOV R2 2
MOV R3 3
MUL R1 R2 R3
RET R1
\ No newline at end of file
......@@ -216,7 +216,7 @@ public class Machine
}
int rd = parseReg(toks[1]);
int rs1 = parseReg(toks[2]);
int rs2 = parseReg(toks[3]);
int rs2 = parseReg(toks[1]);
do_sub(rd,rs1,rs2);
} else if (toks[0].equals(INSTRUCTION_MULT)){
if (toks.length != 4){
......
......@@ -86,7 +86,7 @@ public class Machine
}else if(regs[src] + offs < 0){
/* no op */
}else{
regs[dest] = memory[regs[src] + offs];
regs[dest] = memory[regs[src] + offs + 1];
}
}
......
......@@ -93,7 +93,7 @@ public class Machine
private void do_store(int a, int offs, int b) {
if (regs[a] + offs > MAX_ADDR){
/* no op */
}else if(regs[a] + offs < 0){
}else if(regs[a] + offs < 1){
/* no op */
}else{
memory[regs[a] + offs] = regs[b];
......
......@@ -170,7 +170,7 @@ public class Machine
int pc = 0;
final int progLength = instructions.size();
while(true){
if (pc < 0 || pc >= progLength){
if (pc < 0 || pc > progLength){
/* will cause NoReturnValueException to be thrown
* but that is not a bug and and indeed is what the
* VM is supposed to do if the pc becomes negative,
......
......@@ -266,7 +266,7 @@ public class Machine
throw new InvalidInstructionException();
}
int offs = parseOffset(toks[1]);
pc = pc + offs;
pc = pc + offs+1;
count++;
continue; /* avoid default increment of pc below */
} else if (toks[0].equals(INSTRUCTION_JZ)){
......
File added