Skip to content
Snippets Groups Projects
Commit 2fa219a8 authored by JKCai's avatar JKCai
Browse files

877109 Jiankun Cai

Assignment 1
parent 7e6e7575
No related branches found
No related tags found
No related merge requests found
...@@ -148,7 +148,7 @@ public class Machine ...@@ -148,7 +148,7 @@ public class Machine
private void validate_offset(int offset) private void validate_offset(int offset)
throws InvalidInstructionException throws InvalidInstructionException
{ {
if (offset < -MAX_ADDR || offset > MAX_ADDR) { if (offset < -MAX_ADDR || offset >= MAX_ADDR) {
throw new InvalidInstructionException(); throw new InvalidInstructionException();
} }
} }
...@@ -266,7 +266,7 @@ public class Machine ...@@ -266,7 +266,7 @@ public class Machine
throw new InvalidInstructionException(); throw new InvalidInstructionException();
} }
int offs = parseOffset(toks[1]); int offs = parseOffset(toks[1]);
pc = pc + offs+1; pc = pc + offs;
count++; count++;
continue; /* avoid default increment of pc below */ continue; /* avoid default increment of pc below */
} else if (toks[0].equals(INSTRUCTION_JZ)){ } else if (toks[0].equals(INSTRUCTION_JZ)){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment