Commit e0dbfd1e authored by parvizz's avatar parvizz

Little fix

parent dd90a83f
......@@ -12,195 +12,92 @@ prog = [Branch regSprID(Rel 2),
--End Thread Loop
Jump (Ind regA),
Load (ImmValue 0) regA,--Boolean; Line 7
Push regA,
Pop regA,-- Writing global variable; line 9
WriteInstr regA (DirAddr 7),
Load (ImmValue 0) regA,--Boolean; Line 11
Push regA,
Pop regA,-- Writing global variable; line 13
WriteInstr regA (DirAddr 6),
Load (ImmValue 2) regA,--integer; Line 15
Push regA,
Pop regA,-- Writing global variable; line 17
WriteInstr regA (DirAddr 5),
Load (ImmValue 22) regC,
WriteInstr regC (DirAddr 1),--Call Thread 1 to start execution from line22
Jump (Rel 79),
Load (ImmValue 1) regA,--Boolean; Line 22
Push regA,
Pop regA,-- assigning global variable ; Line 24
WriteInstr regA (DirAddr 7),
Load (ImmValue 1) regA,--integer; Line 26
Push regA,
Pop regA,-- assigning global variable ; Line 28
WriteInstr regA (DirAddr 5),
ReadInstr (DirAddr 6),-- Load from shared memory; Line 30
Receive regA,
Load (ImmValue $ ord 'c') regA,--Char; Line 7
Push regA,
Load (ImmValue 1) regA,--Boolean; Line 33
Pop regB,-- new variable; line 9
Store regB (DirAddr 0),
Load (ImmValue 0) regA,--integer; Line 11
Push regA,
ReadInstr (DirAddr 5),-- Load from shared memory; Line 35
Receive regA,
Pop regB,-- new variable; line 13
Store regB (DirAddr 1),
Load (ImmValue $ ord 'd') regA,--Char; Line 15
Push regA,
Load (ImmValue 1) regA,--integer; Line 38
Pop regB,-- new variable; line 17
Store regB (DirAddr 2),
Load (ImmValue 1) regA,--Boolean; Line 19
Push regA,
Pop regB,--operator: Line 40
Pop regA,
Load (ImmValue 0) regA,--Boolean; Line 21
Push regA,
Pop regA,--operator; Line 23
Load (ImmValue (0)) regB,
Compute Equal regA regB regA,
Push regA,
Pop regA,--operator; Line 27
Load (ImmValue (0)) regB,
Compute Equal regA regB regA,
Push regA,
Pop regA,--operator; Line 31
Load (ImmValue (0)) regB,
Compute Equal regA regB regA,
Push regA,
Pop regB,--operator: Line 44
Pop regB,--operator: Line 35
Pop regA,
Compute And regA regB regA,
Push regA,
Pop regB,--operator: Line 48
Pop regA,
Compute Equal regA regB regA,
Load (DirAddr 1) regA,--Variable; Line 39
Push regA,
Load (ImmValue 0) regE,
Compute Equal regA regE regC, -- whileCheck; Line 55
Branch regC (Rel 2),
Jump (Rel (-25)), -- Jump back for while loop
Load (ImmValue (ord 'C')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'r')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 't')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'c')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'a')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'l')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord ' ')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'S')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'e')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'c')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 't')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'o')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'n')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord ' ')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord '0')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord '\n')) regA,
WriteInstr regA charIO,
Load (ImmValue 0) regA,--Boolean; Line 94
Push regA,
Pop regA,-- assigning global variable ; Line 96
WriteInstr regA (DirAddr 7),
WriteInstr reg0 (DirAddr 1), -- Write to shared memory that this thread is done
Jump (Abs 2), -- Thread 1 jumps back to the threadLoop
Load (ImmValue 103) regC,
WriteInstr regC (DirAddr 2),--Call Thread 2 to start execution from line103
Jump (Rel 79),
Load (ImmValue 1) regA,--Boolean; Line 103
Push regA,
Pop regA,-- assigning global variable ; Line 105
WriteInstr regA (DirAddr 6),
Load (ImmValue 0) regA,--integer; Line 107
Push regA,
Pop regA,-- assigning global variable ; Line 109
WriteInstr regA (DirAddr 5),
ReadInstr (DirAddr 7),-- Load from shared memory; Line 111
Receive regA,
Load (ImmValue 1) regA,--integer; Line 41
Push regA,
Pop regB,--operator: Line 43
Pop regA,
Compute Lt regA regB regA,
Push regA,
Load (ImmValue 1) regA,--Boolean; Line 114
Load (DirAddr 1) regA,--Variable; Line 47
Push regA,
ReadInstr (DirAddr 5),-- Load from shared memory; Line 116
Receive regA,
Load (ImmValue 0) regA,--integer; Line 49
Push regA,
Load (ImmValue 0) regA,--integer; Line 119
Pop regB,--operator: Line 51
Pop regA,
Compute GtE regA regB regA,
Push regA,
Pop regB,--operator: Line 121
Pop regB,--operator: Line 55
Pop regA,
Compute Equal regA regB regA,
Compute And regA regB regA,
Push regA,
Pop regB,--operator: Line 125
Pop regB,--operator: Line 59
Pop regA,
Compute And regA regB regA,
Push regA,
Pop regB,--operator: Line 129
Pop regB,-- new variable; line 63
Store regB (DirAddr 3),
Load (ImmValue $ ord 'e') regA,--Char; Line 65
Push regA,
Pop regB,-- new variable; line 67
Store regB (DirAddr 4),
Load (DirAddr 2) regA,--Variable; Line 69
Push regA,
Load (ImmValue $ ord 'd') regA,--Char; Line 71
Push regA,
Pop regB,--operator: Line 73
Pop regA,
Compute Equal regA regB regA,
Push regA,
Load (ImmValue 0) regE,
Compute Equal regA regE regC,--if statement
Branch regC (Rel 6),
Load (ImmValue 1) regA,--integer; Line 77
Push regA,
Pop regA, --print
WriteInstr regA numberIO,
Jump (Rel 7), -- If body, jump after body of if-statement
Load (ImmValue 1) regA,--Boolean; Line 81
Push regA,
Load (ImmValue 0) regE,
Compute Equal regA regE regC, -- whileCheck; Line 136
Compute Equal regA regE regC, -- whileCheck; Line 86
Branch regC (Rel 2),
Jump (Rel (-25)), -- Jump back for while loop
Load (ImmValue (ord 'C')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'r')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 't')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'c')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'a')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'l')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord ' ')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'S')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'e')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'c')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 't')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'i')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'o')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord 'n')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord ' ')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord '1')) regA,
WriteInstr regA charIO,
Load (ImmValue (ord '\n')) regA,
WriteInstr regA charIO,
Load (ImmValue 0) regA,--Boolean; Line 175
Push regA,
Pop regA,-- assigning global variable ; Line 177
WriteInstr regA (DirAddr 6),
WriteInstr reg0 (DirAddr 2), -- Write to shared memory that this thread is done
Jump (Abs 2), -- Thread 2 jumps back to the threadLoop
Load (ImmValue 1) regC,
ReadInstr (IndAddr regC), -- Waiting for thread 1, (f1)
Receive regA,
Compute NEq regA reg0 regB,
Branch regB (Rel(-3)),
Load (ImmValue 2) regC,
ReadInstr (IndAddr regC), -- Waiting for thread 2, (f2)
Receive regA,
Compute NEq regA reg0 regB,
Branch regB (Rel(-3)),
Load (ImmValue 194) regC, -- Terminate all threads
WriteInstr regC (DirAddr 1),
WriteInstr regC (DirAddr 2),
EndProg -- Line 194
Jump (Rel (-5)), -- Jump back for while loop
EndProg -- Line 87
]
main :: IO ()
main = do run [prog, prog, prog]
main = do run [prog]
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="antlr-runtime-4.9.2" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -232,7 +232,7 @@ public class SemanticsTesting {
"f3.join();\n" +
"printInt(money);\n" +
"\n");
assertEquals(" Thread 0 says 300", ret);
assertEquals(" Sprockell 0 says 300", ret);
execute("global int money = 200;\n" +
"fork f1 {\n" +
" money = money + 100;\n" +
......@@ -256,7 +256,6 @@ public class SemanticsTesting {
"f2.join();\n" +
"f3.join();\n" +
"printInt(money);\n");
System.out.println(ret);
assertNotEquals(" Thread 0 says 300", ret);//This may or may not be the case.
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment