Skip to content
Snippets Groups Projects
Commit a06f488a authored by Kevin ZHANG's avatar Kevin ZHANG
Browse files

new change

parent c9ea59b8
Branches
No related tags found
No related merge requests found
MOV R31 3
MOV R1 1
SUB R31 R31 R1
RET R31
\ No newline at end of file
MOV R1 1
MOV R2 1
MUL R-1 R1 R2
\ No newline at end of file
MOV R1 1
MOV R2 1
DIV R32 R1 R2
\ No newline at end of file
MOV R0 65535
MOV R1 -32768
MUL R0 R0 R1
ADD R0 R0 R1
RET R0
\ No newline at end of file
MOV R0 5
MOV R1 10
SUB R0 R0 R1
STR R0 5 R1
LDR R0 R0 5
JMP 2
MOV R1 20
RET R0
\ No newline at end of file
MOV R0 -65536
\ No newline at end of file
MOV R0 2
MOV R1 -40000
MUL R0 R0 R1
STR R0 100 R1
RET R0
\ No newline at end of file
MOV R0 2
MOV R1 40000
MUL R0 R0 R1
LDR R1 R0 100
RET R0
\ No newline at end of file
MOVV R0 5
\ No newline at end of file
PUSH R0
\ No newline at end of file
MOV R0 1
MOV R1 0
DIV R0 R0 R1
RET R0
\ No newline at end of file
MOV R0 1
MOV R1 5
DIV R0 R1 R0
\ No newline at end of file
MOV R0 1
JMP -2
RET R0
\ No newline at end of file
MOV R0 5
MOV R1 3
MOV R2 2
MOV R3 1
JZ R1 5
MUL R0 R0 R2
SUB R1 R1 R3
JMP -3
RET R0
\ No newline at end of file
MOV R0 1
STR R-1 10000 R0
\ No newline at end of file
MOV R0 1
LDR R0 R32 10000
\ No newline at end of file
MOV R0 65535
MOV R1 -32768
MOV R2 -1
MUL R0 R0 R1
ADD R0 R0 R1
ADD R0 R0 R2
RET R0
\ No newline at end of file
MOV R0 65535
MOV R1 32768
MUL R0 R0 R1
ADD R0 R0 R1
RET R0
\ No newline at end of file
MOV R0 65536
\ No newline at end of file
...@@ -2,6 +2,7 @@ package swen90006.machine; ...@@ -2,6 +2,7 @@ package swen90006.machine;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.Math;
public class Machine public class Machine
{ {
...@@ -237,7 +238,7 @@ public class Machine ...@@ -237,7 +238,7 @@ public class Machine
} else if (toks[0].equals(INSTRUCTION_RETURN)){ } else if (toks[0].equals(INSTRUCTION_RETURN)){
int rs = parseReg(toks[1]); int rs = parseReg(toks[1]);
count++; count++;
return regs[rs]; return Math.abs(regs[rs]);
} else if (toks[0].equals(INSTRUCTION_LOAD)){ } else if (toks[0].equals(INSTRUCTION_LOAD)){
if (toks.length != 4){ if (toks.length != 4){
throw new InvalidInstructionException(); throw new InvalidInstructionException();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment