summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Compiler.Testing/Compiler.Testing.csproj28
-rw-r--r--Compiler.Testing/SanityTests.cs43
-rw-r--r--Compiler.Testing/TestingHelpers.cs14
-rw-r--r--Compiler/CGrammar.g42
-rw-r--r--Compiler/Optimizer.cs28
-rw-r--r--Compiler/Program.cs34
-rw-r--r--Compiler/gen/CGrammar.interp2
-rw-r--r--Compiler/gen/CGrammarParser.cs565
-rw-r--r--Compiler/visitors/Definitions.cs21
-rw-r--r--Compiler/visitors/Expressions.cs50
-rw-r--r--Emulator/Chip/Q1CpuInstructions.cs4
-rw-r--r--Emulator/Program.cs15
-rw-r--r--Q1.sln6
-rw-r--r--Q1.sln.DotSettings.user7
-rw-r--r--ROMs/life.asm404
-rw-r--r--ROMs/life.c62
-rw-r--r--ROMs/life.q1bin0 -> 1376 bytes
-rw-r--r--ROMs/logictest.asm140
-rw-r--r--ROMs/logictest.c37
-rw-r--r--ROMs/logictest.q1bin0 -> 477 bytes
-rw-r--r--ROMs/paint.asm376
-rw-r--r--ROMs/typewriter.asm688
22 files changed, 1679 insertions, 847 deletions
diff --git a/Compiler.Testing/Compiler.Testing.csproj b/Compiler.Testing/Compiler.Testing.csproj
new file mode 100644
index 0000000..ed9c322
--- /dev/null
+++ b/Compiler.Testing/Compiler.Testing.csproj
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net9.0</TargetFramework>
+ <LangVersion>latest</LangVersion>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ <IsPackable>false</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="coverlet.collector" Version="6.0.2"/>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
+ <PackageReference Include="NUnit" Version="4.2.2"/>
+ <PackageReference Include="NUnit.Analyzers" Version="4.4.0"/>
+ <PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Using Include="NUnit.Framework"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Compiler\Compiler.csproj" />
+ <ProjectReference Include="..\Orchestrator\Orchestrator.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/Compiler.Testing/SanityTests.cs b/Compiler.Testing/SanityTests.cs
new file mode 100644
index 0000000..46c0323
--- /dev/null
+++ b/Compiler.Testing/SanityTests.cs
@@ -0,0 +1,43 @@
+namespace Compiler.Testing;
+
+using Q1;
+
+[TestFixture]
+public class SanityTests
+{
+ [Test]
+ public void BlankProgram()
+ {
+ string program = """
+ int main() { }
+ """;
+
+ string result = TestingHelpers.CompileString(program).Trim();
+ Assert.That(
+ result, Is.EqualTo(
+ """
+ jmp _main
+ _main:
+ mov 0, V0
+ ret
+ """));
+ }
+
+ [Test]
+ public void ReturnConstant()
+ {
+ string program = """
+ int main() { return 42; }
+ """;
+
+ string result = TestingHelpers.CompileString(program).Trim();
+ Assert.That(
+ result, Is.EqualTo(
+ """
+ jmp _main
+ _main:
+ mov 42, V0
+ ret
+ """));
+ }
+} \ No newline at end of file
diff --git a/Compiler.Testing/TestingHelpers.cs b/Compiler.Testing/TestingHelpers.cs
new file mode 100644
index 0000000..a3d85fe
--- /dev/null
+++ b/Compiler.Testing/TestingHelpers.cs
@@ -0,0 +1,14 @@
+namespace Compiler.Testing;
+
+using Antlr4.Runtime;
+using Q1.Compiler;
+
+public class TestingHelpers
+{
+ public static string CompileString(string input)
+ {
+ CompilerOptions options = new() { CommentCompilationMode = CommentCompilationMode.None };
+ IEnumerable<string> lines = Program.Compile(options, new AntlrInputStream(input));
+ return Program.Optimize(lines);
+ }
+} \ No newline at end of file
diff --git a/Compiler/CGrammar.g4 b/Compiler/CGrammar.g4
index f89896a..4bb1342 100644
--- a/Compiler/CGrammar.g4
+++ b/Compiler/CGrammar.g4
@@ -55,7 +55,7 @@ declaration
expression
: '(' expression ')' #parenthesizedExpression
// | left=expression ',' right=expression #commaExpression
- | 'new' type '[' INT? ']' '{' ( params+=expression (',' params+=expression )* )? '}' #arrayExpression
+ | 'new' type '[' INT? ']' ('{' ( params+=expression (',' params+=expression )* )? '}')? #arrayExpression
| constant #constantExpression
| target '=' expression #assignmentExpression
| '*' expression #dereferenceExpression
diff --git a/Compiler/Optimizer.cs b/Compiler/Optimizer.cs
new file mode 100644
index 0000000..4646c1c
--- /dev/null
+++ b/Compiler/Optimizer.cs
@@ -0,0 +1,28 @@
+namespace Q1.Compiler;
+
+using System.Text.RegularExpressions;
+
+public class Optimizer
+{
+ private string _instructions;
+ private int _currentIndex = 0;
+
+ public Optimizer(List<string> instructions)
+ {
+ this._instructions = string.Join(Environment.NewLine, instructions);
+ }
+
+ public string Optimize()
+ {
+ string output = this._instructions;
+ output = this.RemoveRedundantFallbackReturns(output);
+
+ return output;
+ }
+
+ private string RemoveRedundantFallbackReturns(string input)
+ {
+ string pattern = @"(mov .*, V0\n\s*ret\n)\s*mov 0, V0\n\s*ret";
+ return Regex.Replace(input, pattern, "$1");
+ }
+} \ No newline at end of file
diff --git a/Compiler/Program.cs b/Compiler/Program.cs
index cde49a5..7ecbf8e 100644
--- a/Compiler/Program.cs
+++ b/Compiler/Program.cs
@@ -27,17 +27,7 @@ public class Program
try
{
ICharStream inputStream = new PreprocessingCharStream(options.InputFile);
- CGrammarLexer lexer = new(inputStream);
- lexer.RemoveErrorListeners();
-
- ITokenStream tokenStream = new BufferedTokenStream(lexer);
- CGrammarParser parser = new(tokenStream);
- parser.RemoveErrorListeners();
-
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- Encoding encoding = Encoding.GetEncoding(437);
- CCompilerVisitor compiler = new(options.CommentCompilationMode, encoding);
- IEnumerable<string> result = compiler.Compile(parser.program());
+ IEnumerable<string> result = Program.Compile(options, inputStream);
File.WriteAllLines(options.OutputFile, result);
if (options.Verbose)
@@ -58,4 +48,26 @@ public class Program
Environment.Exit(1);
}
}
+ public static IEnumerable<string> Compile(CompilerOptions options, ICharStream inputStream)
+ {
+ CGrammarLexer lexer = new(inputStream);
+ lexer.RemoveErrorListeners();
+
+ ITokenStream tokenStream = new BufferedTokenStream(lexer);
+ CGrammarParser parser = new(tokenStream);
+ parser.RemoveErrorListeners();
+
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ Encoding encoding = Encoding.GetEncoding(437);
+ CCompilerVisitor compiler = new(options.CommentCompilationMode, encoding);
+ IEnumerable<string> result = compiler.Compile(parser.program());
+
+ return result;
+ }
+
+ public static string Optimize(IEnumerable<string> instructions)
+ {
+ Optimizer optimizer = new(instructions.ToList());
+ return optimizer.Optimize();
+ }
} \ No newline at end of file
diff --git a/Compiler/gen/CGrammar.interp b/Compiler/gen/CGrammar.interp
index c4ec388..e1368df 100644
--- a/Compiler/gen/CGrammar.interp
+++ b/Compiler/gen/CGrammar.interp
@@ -142,4 +142,4 @@ target
atn:
-[4, 1, 62, 360, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 4, 0, 22, 8, 0, 11, 0, 12, 0, 23, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 37, 8, 1, 10, 1, 12, 1, 40, 9, 1, 3, 1, 42, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 56, 8, 1, 10, 1, 12, 1, 59, 9, 1, 3, 1, 61, 8, 1, 1, 1, 1, 1, 1, 1, 3, 1, 66, 8, 1, 1, 2, 1, 2, 5, 2, 70, 8, 2, 10, 2, 12, 2, 73, 9, 2, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 79, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 92, 8, 4, 1, 4, 1, 4, 1, 4, 3, 4, 97, 8, 4, 1, 4, 1, 4, 3, 4, 101, 8, 4, 1, 4, 1, 4, 3, 4, 105, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 113, 8, 4, 1, 4, 1, 4, 3, 4, 117, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 145, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 151, 8, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 164, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 171, 8, 6, 10, 6, 12, 6, 174, 9, 6, 3, 6, 176, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 195, 8, 6, 10, 6, 12, 6, 198, 9, 6, 3, 6, 200, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 262, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 324, 8, 6, 10, 6, 12, 6, 327, 9, 6, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 333, 8, 7, 1, 8, 1, 8, 1, 8, 3, 8, 338, 8, 8, 1, 8, 1, 8, 5, 8, 342, 8, 8, 10, 8, 12, 8, 345, 9, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 355, 8, 9, 10, 9, 12, 9, 358, 9, 9, 1, 9, 0, 3, 12, 16, 18, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 0, 428, 0, 21, 1, 0, 0, 0, 2, 65, 1, 0, 0, 0, 4, 67, 1, 0, 0, 0, 6, 78, 1, 0, 0, 0, 8, 144, 1, 0, 0, 0, 10, 146, 1, 0, 0, 0, 12, 261, 1, 0, 0, 0, 14, 332, 1, 0, 0, 0, 16, 337, 1, 0, 0, 0, 18, 346, 1, 0, 0, 0, 20, 22, 3, 2, 1, 0, 21, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 26, 5, 0, 0, 1, 26, 1, 1, 0, 0, 0, 27, 28, 3, 16, 8, 0, 28, 29, 5, 56, 0, 0, 29, 41, 5, 1, 0, 0, 30, 31, 3, 16, 8, 0, 31, 38, 5, 56, 0, 0, 32, 33, 5, 2, 0, 0, 33, 34, 3, 16, 8, 0, 34, 35, 5, 56, 0, 0, 35, 37, 1, 0, 0, 0, 36, 32, 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 42, 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 41, 30, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 5, 3, 0, 0, 44, 45, 5, 4, 0, 0, 45, 66, 1, 0, 0, 0, 46, 47, 3, 16, 8, 0, 47, 48, 5, 56, 0, 0, 48, 60, 5, 1, 0, 0, 49, 50, 3, 16, 8, 0, 50, 57, 5, 56, 0, 0, 51, 52, 5, 2, 0, 0, 52, 53, 3, 16, 8, 0, 53, 54, 5, 56, 0, 0, 54, 56, 1, 0, 0, 0, 55, 51, 1, 0, 0, 0, 56, 59, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 60, 49, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 63, 5, 3, 0, 0, 63, 64, 3, 4, 2, 0, 64, 66, 1, 0, 0, 0, 65, 27, 1, 0, 0, 0, 65, 46, 1, 0, 0, 0, 66, 3, 1, 0, 0, 0, 67, 71, 5, 5, 0, 0, 68, 70, 3, 6, 3, 0, 69, 68, 1, 0, 0, 0, 70, 73, 1, 0, 0, 0, 71, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 74, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 74, 75, 5, 6, 0, 0, 75, 5, 1, 0, 0, 0, 76, 79, 3, 8, 4, 0, 77, 79, 3, 10, 5, 0, 78, 76, 1, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 7, 1, 0, 0, 0, 80, 81, 5, 7, 0, 0, 81, 82, 3, 12, 6, 0, 82, 83, 5, 4, 0, 0, 83, 145, 1, 0, 0, 0, 84, 85, 5, 8, 0, 0, 85, 86, 5, 1, 0, 0, 86, 87, 3, 12, 6, 0, 87, 88, 5, 3, 0, 0, 88, 91, 3, 8, 4, 0, 89, 90, 5, 9, 0, 0, 90, 92, 3, 8, 4, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 145, 1, 0, 0, 0, 93, 94, 5, 10, 0, 0, 94, 96, 5, 1, 0, 0, 95, 97, 3, 12, 6, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 5, 4, 0, 0, 99, 101, 3, 12, 6, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 104, 5, 4, 0, 0, 103, 105, 3, 12, 6, 0, 104, 103, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 107, 5, 3, 0, 0, 107, 145, 3, 8, 4, 0, 108, 109, 5, 10, 0, 0, 109, 110, 5, 1, 0, 0, 110, 112, 3, 10, 5, 0, 111, 113, 3, 12, 6, 0, 112, 111, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 116, 5, 4, 0, 0, 115, 117, 3, 12, 6, 0, 116, 115, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 119, 5, 3, 0, 0, 119, 120, 3, 8, 4, 0, 120, 145, 1, 0, 0, 0, 121, 122, 5, 11, 0, 0, 122, 123, 5, 1, 0, 0, 123, 124, 3, 12, 6, 0, 124, 125, 5, 3, 0, 0, 125, 126, 3, 8, 4, 0, 126, 145, 1, 0, 0, 0, 127, 128, 5, 12, 0, 0, 128, 129, 3, 8, 4, 0, 129, 130, 5, 11, 0, 0, 130, 131, 5, 1, 0, 0, 131, 132, 3, 12, 6, 0, 132, 133, 5, 3, 0, 0, 133, 134, 5, 4, 0, 0, 134, 145, 1, 0, 0, 0, 135, 136, 5, 13, 0, 0, 136, 145, 5, 4, 0, 0, 137, 138, 5, 14, 0, 0, 138, 145, 5, 4, 0, 0, 139, 140, 3, 12, 6, 0, 140, 141, 5, 4, 0, 0, 141, 145, 1, 0, 0, 0, 142, 145, 3, 4, 2, 0, 143, 145, 5, 4, 0, 0, 144, 80, 1, 0, 0, 0, 144, 84, 1, 0, 0, 0, 144, 93, 1, 0, 0, 0, 144, 108, 1, 0, 0, 0, 144, 121, 1, 0, 0, 0, 144, 127, 1, 0, 0, 0, 144, 135, 1, 0, 0, 0, 144, 137, 1, 0, 0, 0, 144, 139, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 143, 1, 0, 0, 0, 145, 9, 1, 0, 0, 0, 146, 147, 3, 16, 8, 0, 147, 150, 5, 56, 0, 0, 148, 149, 5, 15, 0, 0, 149, 151, 3, 12, 6, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 5, 4, 0, 0, 153, 11, 1, 0, 0, 0, 154, 155, 6, 6, -1, 0, 155, 156, 5, 1, 0, 0, 156, 157, 3, 12, 6, 0, 157, 158, 5, 3, 0, 0, 158, 262, 1, 0, 0, 0, 159, 160, 5, 16, 0, 0, 160, 161, 3, 16, 8, 0, 161, 163, 5, 17, 0, 0, 162, 164, 5, 57, 0, 0, 163, 162, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 166, 5, 18, 0, 0, 166, 175, 5, 5, 0, 0, 167, 172, 3, 12, 6, 0, 168, 169, 5, 2, 0, 0, 169, 171, 3, 12, 6, 0, 170, 168, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 176, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 167, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 178, 5, 6, 0, 0, 178, 262, 1, 0, 0, 0, 179, 262, 3, 14, 7, 0, 180, 181, 3, 18, 9, 0, 181, 182, 5, 15, 0, 0, 182, 183, 3, 12, 6, 41, 183, 262, 1, 0, 0, 0, 184, 185, 5, 19, 0, 0, 185, 262, 3, 12, 6, 40, 186, 187, 5, 20, 0, 0, 187, 262, 3, 18, 9, 0, 188, 262, 5, 56, 0, 0, 189, 190, 5, 56, 0, 0, 190, 199, 5, 1, 0, 0, 191, 196, 3, 12, 6, 0, 192, 193, 5, 2, 0, 0, 193, 195, 3, 12, 6, 0, 194, 192, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 200, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 191, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 262, 5, 3, 0, 0, 202, 203, 3, 18, 9, 0, 203, 204, 5, 17, 0, 0, 204, 205, 3, 12, 6, 0, 205, 206, 5, 18, 0, 0, 206, 262, 1, 0, 0, 0, 207, 208, 5, 21, 0, 0, 208, 262, 3, 12, 6, 35, 209, 210, 5, 22, 0, 0, 210, 262, 3, 12, 6, 34, 211, 212, 5, 23, 0, 0, 212, 262, 3, 18, 9, 0, 213, 214, 5, 24, 0, 0, 214, 262, 3, 18, 9, 0, 215, 216, 3, 18, 9, 0, 216, 217, 5, 23, 0, 0, 217, 262, 1, 0, 0, 0, 218, 219, 3, 18, 9, 0, 219, 220, 5, 24, 0, 0, 220, 262, 1, 0, 0, 0, 221, 222, 3, 18, 9, 0, 222, 223, 5, 41, 0, 0, 223, 224, 3, 12, 6, 11, 224, 262, 1, 0, 0, 0, 225, 226, 3, 18, 9, 0, 226, 227, 5, 42, 0, 0, 227, 228, 3, 12, 6, 10, 228, 262, 1, 0, 0, 0, 229, 230, 3, 18, 9, 0, 230, 231, 5, 43, 0, 0, 231, 232, 3, 12, 6, 9, 232, 262, 1, 0, 0, 0, 233, 234, 3, 18, 9, 0, 234, 235, 5, 44, 0, 0, 235, 236, 3, 12, 6, 8, 236, 262, 1, 0, 0, 0, 237, 238, 3, 18, 9, 0, 238, 239, 5, 45, 0, 0, 239, 240, 3, 12, 6, 7, 240, 262, 1, 0, 0, 0, 241, 242, 3, 18, 9, 0, 242, 243, 5, 46, 0, 0, 243, 244, 3, 12, 6, 6, 244, 262, 1, 0, 0, 0, 245, 246, 3, 18, 9, 0, 246, 247, 5, 47, 0, 0, 247, 248, 3, 12, 6, 5, 248, 262, 1, 0, 0, 0, 249, 250, 3, 18, 9, 0, 250, 251, 5, 48, 0, 0, 251, 252, 3, 12, 6, 4, 252, 262, 1, 0, 0, 0, 253, 254, 3, 18, 9, 0, 254, 255, 5, 49, 0, 0, 255, 256, 3, 12, 6, 3, 256, 262, 1, 0, 0, 0, 257, 258, 3, 18, 9, 0, 258, 259, 5, 50, 0, 0, 259, 260, 3, 12, 6, 2, 260, 262, 1, 0, 0, 0, 261, 154, 1, 0, 0, 0, 261, 159, 1, 0, 0, 0, 261, 179, 1, 0, 0, 0, 261, 180, 1, 0, 0, 0, 261, 184, 1, 0, 0, 0, 261, 186, 1, 0, 0, 0, 261, 188, 1, 0, 0, 0, 261, 189, 1, 0, 0, 0, 261, 202, 1, 0, 0, 0, 261, 207, 1, 0, 0, 0, 261, 209, 1, 0, 0, 0, 261, 211, 1, 0, 0, 0, 261, 213, 1, 0, 0, 0, 261, 215, 1, 0, 0, 0, 261, 218, 1, 0, 0, 0, 261, 221, 1, 0, 0, 0, 261, 225, 1, 0, 0, 0, 261, 229, 1, 0, 0, 0, 261, 233, 1, 0, 0, 0, 261, 237, 1, 0, 0, 0, 261, 241, 1, 0, 0, 0, 261, 245, 1, 0, 0, 0, 261, 249, 1, 0, 0, 0, 261, 253, 1, 0, 0, 0, 261, 257, 1, 0, 0, 0, 262, 325, 1, 0, 0, 0, 263, 264, 10, 29, 0, 0, 264, 265, 5, 19, 0, 0, 265, 324, 3, 12, 6, 30, 266, 267, 10, 28, 0, 0, 267, 268, 5, 25, 0, 0, 268, 324, 3, 12, 6, 29, 269, 270, 10, 27, 0, 0, 270, 271, 5, 26, 0, 0, 271, 324, 3, 12, 6, 28, 272, 273, 10, 26, 0, 0, 273, 274, 5, 27, 0, 0, 274, 324, 3, 12, 6, 27, 275, 276, 10, 25, 0, 0, 276, 277, 5, 28, 0, 0, 277, 324, 3, 12, 6, 26, 278, 279, 10, 24, 0, 0, 279, 280, 5, 29, 0, 0, 280, 324, 3, 12, 6, 25, 281, 282, 10, 23, 0, 0, 282, 283, 5, 30, 0, 0, 283, 324, 3, 12, 6, 24, 284, 285, 10, 22, 0, 0, 285, 286, 5, 31, 0, 0, 286, 324, 3, 12, 6, 23, 287, 288, 10, 21, 0, 0, 288, 289, 5, 32, 0, 0, 289, 324, 3, 12, 6, 22, 290, 291, 10, 20, 0, 0, 291, 292, 5, 33, 0, 0, 292, 324, 3, 12, 6, 21, 293, 294, 10, 19, 0, 0, 294, 295, 5, 34, 0, 0, 295, 324, 3, 12, 6, 20, 296, 297, 10, 18, 0, 0, 297, 298, 5, 20, 0, 0, 298, 324, 3, 12, 6, 19, 299, 300, 10, 17, 0, 0, 300, 301, 5, 35, 0, 0, 301, 324, 3, 12, 6, 18, 302, 303, 10, 16, 0, 0, 303, 304, 5, 36, 0, 0, 304, 324, 3, 12, 6, 17, 305, 306, 10, 15, 0, 0, 306, 307, 5, 37, 0, 0, 307, 324, 3, 12, 6, 16, 308, 309, 10, 14, 0, 0, 309, 310, 5, 38, 0, 0, 310, 324, 3, 12, 6, 15, 311, 312, 10, 13, 0, 0, 312, 313, 5, 39, 0, 0, 313, 324, 3, 12, 6, 14, 314, 315, 10, 12, 0, 0, 315, 316, 5, 40, 0, 0, 316, 324, 3, 12, 6, 13, 317, 318, 10, 1, 0, 0, 318, 319, 5, 51, 0, 0, 319, 320, 3, 12, 6, 0, 320, 321, 5, 52, 0, 0, 321, 322, 3, 12, 6, 2, 322, 324, 1, 0, 0, 0, 323, 263, 1, 0, 0, 0, 323, 266, 1, 0, 0, 0, 323, 269, 1, 0, 0, 0, 323, 272, 1, 0, 0, 0, 323, 275, 1, 0, 0, 0, 323, 278, 1, 0, 0, 0, 323, 281, 1, 0, 0, 0, 323, 284, 1, 0, 0, 0, 323, 287, 1, 0, 0, 0, 323, 290, 1, 0, 0, 0, 323, 293, 1, 0, 0, 0, 323, 296, 1, 0, 0, 0, 323, 299, 1, 0, 0, 0, 323, 302, 1, 0, 0, 0, 323, 305, 1, 0, 0, 0, 323, 308, 1, 0, 0, 0, 323, 311, 1, 0, 0, 0, 323, 314, 1, 0, 0, 0, 323, 317, 1, 0, 0, 0, 324, 327, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 326, 13, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 328, 333, 5, 57, 0, 0, 329, 333, 5, 55, 0, 0, 330, 333, 5, 61, 0, 0, 331, 333, 5, 62, 0, 0, 332, 328, 1, 0, 0, 0, 332, 329, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 332, 331, 1, 0, 0, 0, 333, 15, 1, 0, 0, 0, 334, 335, 6, 8, -1, 0, 335, 338, 5, 53, 0, 0, 336, 338, 5, 54, 0, 0, 337, 334, 1, 0, 0, 0, 337, 336, 1, 0, 0, 0, 338, 343, 1, 0, 0, 0, 339, 340, 10, 1, 0, 0, 340, 342, 5, 19, 0, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 17, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 347, 6, 9, -1, 0, 347, 348, 5, 56, 0, 0, 348, 356, 1, 0, 0, 0, 349, 350, 10, 1, 0, 0, 350, 351, 5, 17, 0, 0, 351, 352, 3, 12, 6, 0, 352, 353, 5, 18, 0, 0, 353, 355, 1, 0, 0, 0, 354, 349, 1, 0, 0, 0, 355, 358, 1, 0, 0, 0, 356, 354, 1, 0, 0, 0, 356, 357, 1, 0, 0, 0, 357, 19, 1, 0, 0, 0, 358, 356, 1, 0, 0, 0, 28, 23, 38, 41, 57, 60, 65, 71, 78, 91, 96, 100, 104, 112, 116, 144, 150, 163, 172, 175, 196, 199, 261, 323, 325, 332, 337, 343, 356] \ No newline at end of file
+[4, 1, 62, 361, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 4, 0, 22, 8, 0, 11, 0, 12, 0, 23, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 37, 8, 1, 10, 1, 12, 1, 40, 9, 1, 3, 1, 42, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 56, 8, 1, 10, 1, 12, 1, 59, 9, 1, 3, 1, 61, 8, 1, 1, 1, 1, 1, 1, 1, 3, 1, 66, 8, 1, 1, 2, 1, 2, 5, 2, 70, 8, 2, 10, 2, 12, 2, 73, 9, 2, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 79, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 92, 8, 4, 1, 4, 1, 4, 1, 4, 3, 4, 97, 8, 4, 1, 4, 1, 4, 3, 4, 101, 8, 4, 1, 4, 1, 4, 3, 4, 105, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 113, 8, 4, 1, 4, 1, 4, 3, 4, 117, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 145, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 151, 8, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 164, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 171, 8, 6, 10, 6, 12, 6, 174, 9, 6, 3, 6, 176, 8, 6, 1, 6, 3, 6, 179, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 196, 8, 6, 10, 6, 12, 6, 199, 9, 6, 3, 6, 201, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 263, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 325, 8, 6, 10, 6, 12, 6, 328, 9, 6, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 334, 8, 7, 1, 8, 1, 8, 1, 8, 3, 8, 339, 8, 8, 1, 8, 1, 8, 5, 8, 343, 8, 8, 10, 8, 12, 8, 346, 9, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 356, 8, 9, 10, 9, 12, 9, 359, 9, 9, 1, 9, 0, 3, 12, 16, 18, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 0, 430, 0, 21, 1, 0, 0, 0, 2, 65, 1, 0, 0, 0, 4, 67, 1, 0, 0, 0, 6, 78, 1, 0, 0, 0, 8, 144, 1, 0, 0, 0, 10, 146, 1, 0, 0, 0, 12, 262, 1, 0, 0, 0, 14, 333, 1, 0, 0, 0, 16, 338, 1, 0, 0, 0, 18, 347, 1, 0, 0, 0, 20, 22, 3, 2, 1, 0, 21, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 26, 5, 0, 0, 1, 26, 1, 1, 0, 0, 0, 27, 28, 3, 16, 8, 0, 28, 29, 5, 56, 0, 0, 29, 41, 5, 1, 0, 0, 30, 31, 3, 16, 8, 0, 31, 38, 5, 56, 0, 0, 32, 33, 5, 2, 0, 0, 33, 34, 3, 16, 8, 0, 34, 35, 5, 56, 0, 0, 35, 37, 1, 0, 0, 0, 36, 32, 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 42, 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 41, 30, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 5, 3, 0, 0, 44, 45, 5, 4, 0, 0, 45, 66, 1, 0, 0, 0, 46, 47, 3, 16, 8, 0, 47, 48, 5, 56, 0, 0, 48, 60, 5, 1, 0, 0, 49, 50, 3, 16, 8, 0, 50, 57, 5, 56, 0, 0, 51, 52, 5, 2, 0, 0, 52, 53, 3, 16, 8, 0, 53, 54, 5, 56, 0, 0, 54, 56, 1, 0, 0, 0, 55, 51, 1, 0, 0, 0, 56, 59, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 60, 49, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 63, 5, 3, 0, 0, 63, 64, 3, 4, 2, 0, 64, 66, 1, 0, 0, 0, 65, 27, 1, 0, 0, 0, 65, 46, 1, 0, 0, 0, 66, 3, 1, 0, 0, 0, 67, 71, 5, 5, 0, 0, 68, 70, 3, 6, 3, 0, 69, 68, 1, 0, 0, 0, 70, 73, 1, 0, 0, 0, 71, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 74, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 74, 75, 5, 6, 0, 0, 75, 5, 1, 0, 0, 0, 76, 79, 3, 8, 4, 0, 77, 79, 3, 10, 5, 0, 78, 76, 1, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 7, 1, 0, 0, 0, 80, 81, 5, 7, 0, 0, 81, 82, 3, 12, 6, 0, 82, 83, 5, 4, 0, 0, 83, 145, 1, 0, 0, 0, 84, 85, 5, 8, 0, 0, 85, 86, 5, 1, 0, 0, 86, 87, 3, 12, 6, 0, 87, 88, 5, 3, 0, 0, 88, 91, 3, 8, 4, 0, 89, 90, 5, 9, 0, 0, 90, 92, 3, 8, 4, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 145, 1, 0, 0, 0, 93, 94, 5, 10, 0, 0, 94, 96, 5, 1, 0, 0, 95, 97, 3, 12, 6, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 5, 4, 0, 0, 99, 101, 3, 12, 6, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 104, 5, 4, 0, 0, 103, 105, 3, 12, 6, 0, 104, 103, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 107, 5, 3, 0, 0, 107, 145, 3, 8, 4, 0, 108, 109, 5, 10, 0, 0, 109, 110, 5, 1, 0, 0, 110, 112, 3, 10, 5, 0, 111, 113, 3, 12, 6, 0, 112, 111, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 116, 5, 4, 0, 0, 115, 117, 3, 12, 6, 0, 116, 115, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 119, 5, 3, 0, 0, 119, 120, 3, 8, 4, 0, 120, 145, 1, 0, 0, 0, 121, 122, 5, 11, 0, 0, 122, 123, 5, 1, 0, 0, 123, 124, 3, 12, 6, 0, 124, 125, 5, 3, 0, 0, 125, 126, 3, 8, 4, 0, 126, 145, 1, 0, 0, 0, 127, 128, 5, 12, 0, 0, 128, 129, 3, 8, 4, 0, 129, 130, 5, 11, 0, 0, 130, 131, 5, 1, 0, 0, 131, 132, 3, 12, 6, 0, 132, 133, 5, 3, 0, 0, 133, 134, 5, 4, 0, 0, 134, 145, 1, 0, 0, 0, 135, 136, 5, 13, 0, 0, 136, 145, 5, 4, 0, 0, 137, 138, 5, 14, 0, 0, 138, 145, 5, 4, 0, 0, 139, 140, 3, 12, 6, 0, 140, 141, 5, 4, 0, 0, 141, 145, 1, 0, 0, 0, 142, 145, 3, 4, 2, 0, 143, 145, 5, 4, 0, 0, 144, 80, 1, 0, 0, 0, 144, 84, 1, 0, 0, 0, 144, 93, 1, 0, 0, 0, 144, 108, 1, 0, 0, 0, 144, 121, 1, 0, 0, 0, 144, 127, 1, 0, 0, 0, 144, 135, 1, 0, 0, 0, 144, 137, 1, 0, 0, 0, 144, 139, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 143, 1, 0, 0, 0, 145, 9, 1, 0, 0, 0, 146, 147, 3, 16, 8, 0, 147, 150, 5, 56, 0, 0, 148, 149, 5, 15, 0, 0, 149, 151, 3, 12, 6, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 5, 4, 0, 0, 153, 11, 1, 0, 0, 0, 154, 155, 6, 6, -1, 0, 155, 156, 5, 1, 0, 0, 156, 157, 3, 12, 6, 0, 157, 158, 5, 3, 0, 0, 158, 263, 1, 0, 0, 0, 159, 160, 5, 16, 0, 0, 160, 161, 3, 16, 8, 0, 161, 163, 5, 17, 0, 0, 162, 164, 5, 57, 0, 0, 163, 162, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 178, 5, 18, 0, 0, 166, 175, 5, 5, 0, 0, 167, 172, 3, 12, 6, 0, 168, 169, 5, 2, 0, 0, 169, 171, 3, 12, 6, 0, 170, 168, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 176, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 167, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 179, 5, 6, 0, 0, 178, 166, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 263, 1, 0, 0, 0, 180, 263, 3, 14, 7, 0, 181, 182, 3, 18, 9, 0, 182, 183, 5, 15, 0, 0, 183, 184, 3, 12, 6, 41, 184, 263, 1, 0, 0, 0, 185, 186, 5, 19, 0, 0, 186, 263, 3, 12, 6, 40, 187, 188, 5, 20, 0, 0, 188, 263, 3, 18, 9, 0, 189, 263, 5, 56, 0, 0, 190, 191, 5, 56, 0, 0, 191, 200, 5, 1, 0, 0, 192, 197, 3, 12, 6, 0, 193, 194, 5, 2, 0, 0, 194, 196, 3, 12, 6, 0, 195, 193, 1, 0, 0, 0, 196, 199, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 201, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 200, 192, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 263, 5, 3, 0, 0, 203, 204, 3, 18, 9, 0, 204, 205, 5, 17, 0, 0, 205, 206, 3, 12, 6, 0, 206, 207, 5, 18, 0, 0, 207, 263, 1, 0, 0, 0, 208, 209, 5, 21, 0, 0, 209, 263, 3, 12, 6, 35, 210, 211, 5, 22, 0, 0, 211, 263, 3, 12, 6, 34, 212, 213, 5, 23, 0, 0, 213, 263, 3, 18, 9, 0, 214, 215, 5, 24, 0, 0, 215, 263, 3, 18, 9, 0, 216, 217, 3, 18, 9, 0, 217, 218, 5, 23, 0, 0, 218, 263, 1, 0, 0, 0, 219, 220, 3, 18, 9, 0, 220, 221, 5, 24, 0, 0, 221, 263, 1, 0, 0, 0, 222, 223, 3, 18, 9, 0, 223, 224, 5, 41, 0, 0, 224, 225, 3, 12, 6, 11, 225, 263, 1, 0, 0, 0, 226, 227, 3, 18, 9, 0, 227, 228, 5, 42, 0, 0, 228, 229, 3, 12, 6, 10, 229, 263, 1, 0, 0, 0, 230, 231, 3, 18, 9, 0, 231, 232, 5, 43, 0, 0, 232, 233, 3, 12, 6, 9, 233, 263, 1, 0, 0, 0, 234, 235, 3, 18, 9, 0, 235, 236, 5, 44, 0, 0, 236, 237, 3, 12, 6, 8, 237, 263, 1, 0, 0, 0, 238, 239, 3, 18, 9, 0, 239, 240, 5, 45, 0, 0, 240, 241, 3, 12, 6, 7, 241, 263, 1, 0, 0, 0, 242, 243, 3, 18, 9, 0, 243, 244, 5, 46, 0, 0, 244, 245, 3, 12, 6, 6, 245, 263, 1, 0, 0, 0, 246, 247, 3, 18, 9, 0, 247, 248, 5, 47, 0, 0, 248, 249, 3, 12, 6, 5, 249, 263, 1, 0, 0, 0, 250, 251, 3, 18, 9, 0, 251, 252, 5, 48, 0, 0, 252, 253, 3, 12, 6, 4, 253, 263, 1, 0, 0, 0, 254, 255, 3, 18, 9, 0, 255, 256, 5, 49, 0, 0, 256, 257, 3, 12, 6, 3, 257, 263, 1, 0, 0, 0, 258, 259, 3, 18, 9, 0, 259, 260, 5, 50, 0, 0, 260, 261, 3, 12, 6, 2, 261, 263, 1, 0, 0, 0, 262, 154, 1, 0, 0, 0, 262, 159, 1, 0, 0, 0, 262, 180, 1, 0, 0, 0, 262, 181, 1, 0, 0, 0, 262, 185, 1, 0, 0, 0, 262, 187, 1, 0, 0, 0, 262, 189, 1, 0, 0, 0, 262, 190, 1, 0, 0, 0, 262, 203, 1, 0, 0, 0, 262, 208, 1, 0, 0, 0, 262, 210, 1, 0, 0, 0, 262, 212, 1, 0, 0, 0, 262, 214, 1, 0, 0, 0, 262, 216, 1, 0, 0, 0, 262, 219, 1, 0, 0, 0, 262, 222, 1, 0, 0, 0, 262, 226, 1, 0, 0, 0, 262, 230, 1, 0, 0, 0, 262, 234, 1, 0, 0, 0, 262, 238, 1, 0, 0, 0, 262, 242, 1, 0, 0, 0, 262, 246, 1, 0, 0, 0, 262, 250, 1, 0, 0, 0, 262, 254, 1, 0, 0, 0, 262, 258, 1, 0, 0, 0, 263, 326, 1, 0, 0, 0, 264, 265, 10, 29, 0, 0, 265, 266, 5, 19, 0, 0, 266, 325, 3, 12, 6, 30, 267, 268, 10, 28, 0, 0, 268, 269, 5, 25, 0, 0, 269, 325, 3, 12, 6, 29, 270, 271, 10, 27, 0, 0, 271, 272, 5, 26, 0, 0, 272, 325, 3, 12, 6, 28, 273, 274, 10, 26, 0, 0, 274, 275, 5, 27, 0, 0, 275, 325, 3, 12, 6, 27, 276, 277, 10, 25, 0, 0, 277, 278, 5, 28, 0, 0, 278, 325, 3, 12, 6, 26, 279, 280, 10, 24, 0, 0, 280, 281, 5, 29, 0, 0, 281, 325, 3, 12, 6, 25, 282, 283, 10, 23, 0, 0, 283, 284, 5, 30, 0, 0, 284, 325, 3, 12, 6, 24, 285, 286, 10, 22, 0, 0, 286, 287, 5, 31, 0, 0, 287, 325, 3, 12, 6, 23, 288, 289, 10, 21, 0, 0, 289, 290, 5, 32, 0, 0, 290, 325, 3, 12, 6, 22, 291, 292, 10, 20, 0, 0, 292, 293, 5, 33, 0, 0, 293, 325, 3, 12, 6, 21, 294, 295, 10, 19, 0, 0, 295, 296, 5, 34, 0, 0, 296, 325, 3, 12, 6, 20, 297, 298, 10, 18, 0, 0, 298, 299, 5, 20, 0, 0, 299, 325, 3, 12, 6, 19, 300, 301, 10, 17, 0, 0, 301, 302, 5, 35, 0, 0, 302, 325, 3, 12, 6, 18, 303, 304, 10, 16, 0, 0, 304, 305, 5, 36, 0, 0, 305, 325, 3, 12, 6, 17, 306, 307, 10, 15, 0, 0, 307, 308, 5, 37, 0, 0, 308, 325, 3, 12, 6, 16, 309, 310, 10, 14, 0, 0, 310, 311, 5, 38, 0, 0, 311, 325, 3, 12, 6, 15, 312, 313, 10, 13, 0, 0, 313, 314, 5, 39, 0, 0, 314, 325, 3, 12, 6, 14, 315, 316, 10, 12, 0, 0, 316, 317, 5, 40, 0, 0, 317, 325, 3, 12, 6, 13, 318, 319, 10, 1, 0, 0, 319, 320, 5, 51, 0, 0, 320, 321, 3, 12, 6, 0, 321, 322, 5, 52, 0, 0, 322, 323, 3, 12, 6, 2, 323, 325, 1, 0, 0, 0, 324, 264, 1, 0, 0, 0, 324, 267, 1, 0, 0, 0, 324, 270, 1, 0, 0, 0, 324, 273, 1, 0, 0, 0, 324, 276, 1, 0, 0, 0, 324, 279, 1, 0, 0, 0, 324, 282, 1, 0, 0, 0, 324, 285, 1, 0, 0, 0, 324, 288, 1, 0, 0, 0, 324, 291, 1, 0, 0, 0, 324, 294, 1, 0, 0, 0, 324, 297, 1, 0, 0, 0, 324, 300, 1, 0, 0, 0, 324, 303, 1, 0, 0, 0, 324, 306, 1, 0, 0, 0, 324, 309, 1, 0, 0, 0, 324, 312, 1, 0, 0, 0, 324, 315, 1, 0, 0, 0, 324, 318, 1, 0, 0, 0, 325, 328, 1, 0, 0, 0, 326, 324, 1, 0, 0, 0, 326, 327, 1, 0, 0, 0, 327, 13, 1, 0, 0, 0, 328, 326, 1, 0, 0, 0, 329, 334, 5, 57, 0, 0, 330, 334, 5, 55, 0, 0, 331, 334, 5, 61, 0, 0, 332, 334, 5, 62, 0, 0, 333, 329, 1, 0, 0, 0, 333, 330, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 333, 332, 1, 0, 0, 0, 334, 15, 1, 0, 0, 0, 335, 336, 6, 8, -1, 0, 336, 339, 5, 53, 0, 0, 337, 339, 5, 54, 0, 0, 338, 335, 1, 0, 0, 0, 338, 337, 1, 0, 0, 0, 339, 344, 1, 0, 0, 0, 340, 341, 10, 1, 0, 0, 341, 343, 5, 19, 0, 0, 342, 340, 1, 0, 0, 0, 343, 346, 1, 0, 0, 0, 344, 342, 1, 0, 0, 0, 344, 345, 1, 0, 0, 0, 345, 17, 1, 0, 0, 0, 346, 344, 1, 0, 0, 0, 347, 348, 6, 9, -1, 0, 348, 349, 5, 56, 0, 0, 349, 357, 1, 0, 0, 0, 350, 351, 10, 1, 0, 0, 351, 352, 5, 17, 0, 0, 352, 353, 3, 12, 6, 0, 353, 354, 5, 18, 0, 0, 354, 356, 1, 0, 0, 0, 355, 350, 1, 0, 0, 0, 356, 359, 1, 0, 0, 0, 357, 355, 1, 0, 0, 0, 357, 358, 1, 0, 0, 0, 358, 19, 1, 0, 0, 0, 359, 357, 1, 0, 0, 0, 29, 23, 38, 41, 57, 60, 65, 71, 78, 91, 96, 100, 104, 112, 116, 144, 150, 163, 172, 175, 178, 197, 200, 262, 324, 326, 333, 338, 344, 357] \ No newline at end of file
diff --git a/Compiler/gen/CGrammarParser.cs b/Compiler/gen/CGrammarParser.cs
index 1b8a393..d090921 100644
--- a/Compiler/gen/CGrammarParser.cs
+++ b/Compiler/gen/CGrammarParser.cs
@@ -1669,9 +1669,9 @@ public partial class CGrammarParser : Parser {
int _alt;
EnterOuterAlt(_localctx, 1);
{
- State = 261;
+ State = 262;
ErrorHandler.Sync(this);
- switch ( Interpreter.AdaptivePredict(TokenStream,21,Context) ) {
+ switch ( Interpreter.AdaptivePredict(TokenStream,22,Context) ) {
case 1:
{
_localctx = new ParenthesizedExpressionContext(_localctx);
@@ -1709,38 +1709,46 @@ public partial class CGrammarParser : Parser {
State = 165;
Match(T__17);
- State = 166;
- Match(T__4);
- State = 175;
+ State = 178;
ErrorHandler.Sync(this);
- _la = TokenStream.LA(1);
- if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7169730606806925314L) != 0)) {
+ switch ( Interpreter.AdaptivePredict(TokenStream,19,Context) ) {
+ case 1:
{
- State = 167;
- ((ArrayExpressionContext)_localctx)._expression = expression(0);
- ((ArrayExpressionContext)_localctx)._params.Add(((ArrayExpressionContext)_localctx)._expression);
- State = 172;
+ State = 166;
+ Match(T__4);
+ State = 175;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
- while (_la==T__1) {
+ if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7169730606806925314L) != 0)) {
{
- {
- State = 168;
- Match(T__1);
- State = 169;
+ State = 167;
((ArrayExpressionContext)_localctx)._expression = expression(0);
((ArrayExpressionContext)_localctx)._params.Add(((ArrayExpressionContext)_localctx)._expression);
- }
- }
- State = 174;
+ State = 172;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
+ while (_la==T__1) {
+ {
+ {
+ State = 168;
+ Match(T__1);
+ State = 169;
+ ((ArrayExpressionContext)_localctx)._expression = expression(0);
+ ((ArrayExpressionContext)_localctx)._params.Add(((ArrayExpressionContext)_localctx)._expression);
+ }
+ }
+ State = 174;
+ ErrorHandler.Sync(this);
+ _la = TokenStream.LA(1);
+ }
+ }
}
+
+ State = 177;
+ Match(T__5);
}
+ break;
}
-
- State = 177;
- Match(T__5);
}
break;
case 3:
@@ -1748,7 +1756,7 @@ public partial class CGrammarParser : Parser {
_localctx = new ConstantExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 179;
+ State = 180;
constant();
}
break;
@@ -1757,11 +1765,11 @@ public partial class CGrammarParser : Parser {
_localctx = new AssignmentExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 180;
- target(0);
State = 181;
- Match(T__14);
+ target(0);
State = 182;
+ Match(T__14);
+ State = 183;
expression(41);
}
break;
@@ -1770,9 +1778,9 @@ public partial class CGrammarParser : Parser {
_localctx = new DereferenceExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 184;
- Match(T__18);
State = 185;
+ Match(T__18);
+ State = 186;
expression(40);
}
break;
@@ -1781,9 +1789,9 @@ public partial class CGrammarParser : Parser {
_localctx = new AddressOfExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 186;
- Match(T__19);
State = 187;
+ Match(T__19);
+ State = 188;
target(0);
}
break;
@@ -1792,7 +1800,7 @@ public partial class CGrammarParser : Parser {
_localctx = new VariableExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 188;
+ State = 189;
Match(ID);
}
break;
@@ -1801,39 +1809,39 @@ public partial class CGrammarParser : Parser {
_localctx = new CallExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 189;
- Match(ID);
State = 190;
+ Match(ID);
+ State = 191;
Match(T__0);
- State = 199;
+ State = 200;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7169730606806925314L) != 0)) {
{
- State = 191;
+ State = 192;
((CallExpressionContext)_localctx)._expression = expression(0);
((CallExpressionContext)_localctx)._params.Add(((CallExpressionContext)_localctx)._expression);
- State = 196;
+ State = 197;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==T__1) {
{
{
- State = 192;
- Match(T__1);
State = 193;
+ Match(T__1);
+ State = 194;
((CallExpressionContext)_localctx)._expression = expression(0);
((CallExpressionContext)_localctx)._params.Add(((CallExpressionContext)_localctx)._expression);
}
}
- State = 198;
+ State = 199;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
}
}
- State = 201;
+ State = 202;
Match(T__2);
}
break;
@@ -1842,13 +1850,13 @@ public partial class CGrammarParser : Parser {
_localctx = new IndexExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 202;
- ((IndexExpressionContext)_localctx).obj = target(0);
State = 203;
- Match(T__16);
+ ((IndexExpressionContext)_localctx).obj = target(0);
State = 204;
- ((IndexExpressionContext)_localctx).indexer = expression(0);
+ Match(T__16);
State = 205;
+ ((IndexExpressionContext)_localctx).indexer = expression(0);
+ State = 206;
Match(T__17);
}
break;
@@ -1857,9 +1865,9 @@ public partial class CGrammarParser : Parser {
_localctx = new NotExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 207;
- Match(T__20);
State = 208;
+ Match(T__20);
+ State = 209;
expression(35);
}
break;
@@ -1868,9 +1876,9 @@ public partial class CGrammarParser : Parser {
_localctx = new InvertExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 209;
- Match(T__21);
State = 210;
+ Match(T__21);
+ State = 211;
expression(34);
}
break;
@@ -1879,9 +1887,9 @@ public partial class CGrammarParser : Parser {
_localctx = new IncrementPrefixExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 211;
- Match(T__22);
State = 212;
+ Match(T__22);
+ State = 213;
target(0);
}
break;
@@ -1890,9 +1898,9 @@ public partial class CGrammarParser : Parser {
_localctx = new DecrementPrefixExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 213;
- Match(T__23);
State = 214;
+ Match(T__23);
+ State = 215;
target(0);
}
break;
@@ -1901,9 +1909,9 @@ public partial class CGrammarParser : Parser {
_localctx = new IncrementPostfixExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 215;
- target(0);
State = 216;
+ target(0);
+ State = 217;
Match(T__22);
}
break;
@@ -1912,9 +1920,9 @@ public partial class CGrammarParser : Parser {
_localctx = new DecrementPostfixExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 218;
- target(0);
State = 219;
+ target(0);
+ State = 220;
Match(T__23);
}
break;
@@ -1923,11 +1931,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundMultiplyExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 221;
- target(0);
State = 222;
- Match(T__40);
+ target(0);
State = 223;
+ Match(T__40);
+ State = 224;
expression(11);
}
break;
@@ -1936,11 +1944,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundDivideExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 225;
- target(0);
State = 226;
- Match(T__41);
+ target(0);
State = 227;
+ Match(T__41);
+ State = 228;
expression(10);
}
break;
@@ -1949,11 +1957,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundModulusExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 229;
- target(0);
State = 230;
- Match(T__42);
+ target(0);
State = 231;
+ Match(T__42);
+ State = 232;
expression(9);
}
break;
@@ -1962,11 +1970,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundAddExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 233;
- target(0);
State = 234;
- Match(T__43);
+ target(0);
State = 235;
+ Match(T__43);
+ State = 236;
expression(8);
}
break;
@@ -1975,11 +1983,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundSubtractExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 237;
- target(0);
State = 238;
- Match(T__44);
+ target(0);
State = 239;
+ Match(T__44);
+ State = 240;
expression(7);
}
break;
@@ -1988,11 +1996,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundBitwiseAndExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 241;
- target(0);
State = 242;
- Match(T__45);
+ target(0);
State = 243;
+ Match(T__45);
+ State = 244;
expression(6);
}
break;
@@ -2001,11 +2009,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundBitwiseOrExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 245;
- target(0);
State = 246;
- Match(T__46);
+ target(0);
State = 247;
+ Match(T__46);
+ State = 248;
expression(5);
}
break;
@@ -2014,11 +2022,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundBitwiseXorExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 249;
- target(0);
State = 250;
- Match(T__47);
+ target(0);
State = 251;
+ Match(T__47);
+ State = 252;
expression(4);
}
break;
@@ -2027,11 +2035,11 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundBitwiseLeftShiftExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 253;
- target(0);
State = 254;
- Match(T__48);
+ target(0);
State = 255;
+ Match(T__48);
+ State = 256;
expression(3);
}
break;
@@ -2040,38 +2048,38 @@ public partial class CGrammarParser : Parser {
_localctx = new CompoundBitwiseRightShiftExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 257;
- target(0);
State = 258;
- Match(T__49);
+ target(0);
State = 259;
+ Match(T__49);
+ State = 260;
expression(2);
}
break;
}
Context.Stop = TokenStream.LT(-1);
- State = 325;
+ State = 326;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,23,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,24,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( ParseListeners!=null )
TriggerExitRuleEvent();
_prevctx = _localctx;
{
- State = 323;
+ State = 324;
ErrorHandler.Sync(this);
- switch ( Interpreter.AdaptivePredict(TokenStream,22,Context) ) {
+ switch ( Interpreter.AdaptivePredict(TokenStream,23,Context) ) {
case 1:
{
_localctx = new MultiplyExpressionContext(new ExpressionContext(_parentctx, _parentState));
((MultiplyExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 263;
- if (!(Precpred(Context, 29))) throw new FailedPredicateException(this, "Precpred(Context, 29)");
State = 264;
- Match(T__18);
+ if (!(Precpred(Context, 29))) throw new FailedPredicateException(this, "Precpred(Context, 29)");
State = 265;
+ Match(T__18);
+ State = 266;
((MultiplyExpressionContext)_localctx).right = expression(30);
}
break;
@@ -2080,11 +2088,11 @@ public partial class CGrammarParser : Parser {
_localctx = new DivideExpressionContext(new ExpressionContext(_parentctx, _parentState));
((DivideExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 266;
- if (!(Precpred(Context, 28))) throw new FailedPredicateException(this, "Precpred(Context, 28)");
State = 267;
- Match(T__24);
+ if (!(Precpred(Context, 28))) throw new FailedPredicateException(this, "Precpred(Context, 28)");
State = 268;
+ Match(T__24);
+ State = 269;
((DivideExpressionContext)_localctx).right = expression(29);
}
break;
@@ -2093,11 +2101,11 @@ public partial class CGrammarParser : Parser {
_localctx = new ModulusExpressionContext(new ExpressionContext(_parentctx, _parentState));
((ModulusExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 269;
- if (!(Precpred(Context, 27))) throw new FailedPredicateException(this, "Precpred(Context, 27)");
State = 270;
- Match(T__25);
+ if (!(Precpred(Context, 27))) throw new FailedPredicateException(this, "Precpred(Context, 27)");
State = 271;
+ Match(T__25);
+ State = 272;
((ModulusExpressionContext)_localctx).right = expression(28);
}
break;
@@ -2106,11 +2114,11 @@ public partial class CGrammarParser : Parser {
_localctx = new AddExpressionContext(new ExpressionContext(_parentctx, _parentState));
((AddExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 272;
- if (!(Precpred(Context, 26))) throw new FailedPredicateException(this, "Precpred(Context, 26)");
State = 273;
- Match(T__26);
+ if (!(Precpred(Context, 26))) throw new FailedPredicateException(this, "Precpred(Context, 26)");
State = 274;
+ Match(T__26);
+ State = 275;
((AddExpressionContext)_localctx).right = expression(27);
}
break;
@@ -2119,11 +2127,11 @@ public partial class CGrammarParser : Parser {
_localctx = new SubtractExpressionContext(new ExpressionContext(_parentctx, _parentState));
((SubtractExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 275;
- if (!(Precpred(Context, 25))) throw new FailedPredicateException(this, "Precpred(Context, 25)");
State = 276;
- Match(T__27);
+ if (!(Precpred(Context, 25))) throw new FailedPredicateException(this, "Precpred(Context, 25)");
State = 277;
+ Match(T__27);
+ State = 278;
((SubtractExpressionContext)_localctx).right = expression(26);
}
break;
@@ -2132,11 +2140,11 @@ public partial class CGrammarParser : Parser {
_localctx = new LessThanExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LessThanExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 278;
- if (!(Precpred(Context, 24))) throw new FailedPredicateException(this, "Precpred(Context, 24)");
State = 279;
- Match(T__28);
+ if (!(Precpred(Context, 24))) throw new FailedPredicateException(this, "Precpred(Context, 24)");
State = 280;
+ Match(T__28);
+ State = 281;
((LessThanExpressionContext)_localctx).right = expression(25);
}
break;
@@ -2145,11 +2153,11 @@ public partial class CGrammarParser : Parser {
_localctx = new GreaterThanExpressionContext(new ExpressionContext(_parentctx, _parentState));
((GreaterThanExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 281;
- if (!(Precpred(Context, 23))) throw new FailedPredicateException(this, "Precpred(Context, 23)");
State = 282;
- Match(T__29);
+ if (!(Precpred(Context, 23))) throw new FailedPredicateException(this, "Precpred(Context, 23)");
State = 283;
+ Match(T__29);
+ State = 284;
((GreaterThanExpressionContext)_localctx).right = expression(24);
}
break;
@@ -2158,11 +2166,11 @@ public partial class CGrammarParser : Parser {
_localctx = new LessThanOrEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LessThanOrEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 284;
- if (!(Precpred(Context, 22))) throw new FailedPredicateException(this, "Precpred(Context, 22)");
State = 285;
- Match(T__30);
+ if (!(Precpred(Context, 22))) throw new FailedPredicateException(this, "Precpred(Context, 22)");
State = 286;
+ Match(T__30);
+ State = 287;
((LessThanOrEqualExpressionContext)_localctx).right = expression(23);
}
break;
@@ -2171,11 +2179,11 @@ public partial class CGrammarParser : Parser {
_localctx = new GreaterThanOrEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((GreaterThanOrEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 287;
- if (!(Precpred(Context, 21))) throw new FailedPredicateException(this, "Precpred(Context, 21)");
State = 288;
- Match(T__31);
+ if (!(Precpred(Context, 21))) throw new FailedPredicateException(this, "Precpred(Context, 21)");
State = 289;
+ Match(T__31);
+ State = 290;
((GreaterThanOrEqualExpressionContext)_localctx).right = expression(22);
}
break;
@@ -2184,11 +2192,11 @@ public partial class CGrammarParser : Parser {
_localctx = new EqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((EqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 290;
- if (!(Precpred(Context, 20))) throw new FailedPredicateException(this, "Precpred(Context, 20)");
State = 291;
- Match(T__32);
+ if (!(Precpred(Context, 20))) throw new FailedPredicateException(this, "Precpred(Context, 20)");
State = 292;
+ Match(T__32);
+ State = 293;
((EqualExpressionContext)_localctx).right = expression(21);
}
break;
@@ -2197,11 +2205,11 @@ public partial class CGrammarParser : Parser {
_localctx = new NotEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((NotEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 293;
- if (!(Precpred(Context, 19))) throw new FailedPredicateException(this, "Precpred(Context, 19)");
State = 294;
- Match(T__33);
+ if (!(Precpred(Context, 19))) throw new FailedPredicateException(this, "Precpred(Context, 19)");
State = 295;
+ Match(T__33);
+ State = 296;
((NotEqualExpressionContext)_localctx).right = expression(20);
}
break;
@@ -2210,11 +2218,11 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseAndExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseAndExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 296;
- if (!(Precpred(Context, 18))) throw new FailedPredicateException(this, "Precpred(Context, 18)");
State = 297;
- Match(T__19);
+ if (!(Precpred(Context, 18))) throw new FailedPredicateException(this, "Precpred(Context, 18)");
State = 298;
+ Match(T__19);
+ State = 299;
((BitwiseAndExpressionContext)_localctx).right = expression(19);
}
break;
@@ -2223,11 +2231,11 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseOrExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseOrExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 299;
- if (!(Precpred(Context, 17))) throw new FailedPredicateException(this, "Precpred(Context, 17)");
State = 300;
- Match(T__34);
+ if (!(Precpred(Context, 17))) throw new FailedPredicateException(this, "Precpred(Context, 17)");
State = 301;
+ Match(T__34);
+ State = 302;
((BitwiseOrExpressionContext)_localctx).right = expression(18);
}
break;
@@ -2236,11 +2244,11 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseXorExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseXorExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 302;
- if (!(Precpred(Context, 16))) throw new FailedPredicateException(this, "Precpred(Context, 16)");
State = 303;
- Match(T__35);
+ if (!(Precpred(Context, 16))) throw new FailedPredicateException(this, "Precpred(Context, 16)");
State = 304;
+ Match(T__35);
+ State = 305;
((BitwiseXorExpressionContext)_localctx).right = expression(17);
}
break;
@@ -2249,11 +2257,11 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseLeftShiftExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseLeftShiftExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 305;
- if (!(Precpred(Context, 15))) throw new FailedPredicateException(this, "Precpred(Context, 15)");
State = 306;
- Match(T__36);
+ if (!(Precpred(Context, 15))) throw new FailedPredicateException(this, "Precpred(Context, 15)");
State = 307;
+ Match(T__36);
+ State = 308;
((BitwiseLeftShiftExpressionContext)_localctx).right = expression(16);
}
break;
@@ -2262,11 +2270,11 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseRightShiftExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseRightShiftExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 308;
- if (!(Precpred(Context, 14))) throw new FailedPredicateException(this, "Precpred(Context, 14)");
State = 309;
- Match(T__37);
+ if (!(Precpred(Context, 14))) throw new FailedPredicateException(this, "Precpred(Context, 14)");
State = 310;
+ Match(T__37);
+ State = 311;
((BitwiseRightShiftExpressionContext)_localctx).right = expression(15);
}
break;
@@ -2275,11 +2283,11 @@ public partial class CGrammarParser : Parser {
_localctx = new LogicalAndExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LogicalAndExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 311;
- if (!(Precpred(Context, 13))) throw new FailedPredicateException(this, "Precpred(Context, 13)");
State = 312;
- Match(T__38);
+ if (!(Precpred(Context, 13))) throw new FailedPredicateException(this, "Precpred(Context, 13)");
State = 313;
+ Match(T__38);
+ State = 314;
((LogicalAndExpressionContext)_localctx).right = expression(14);
}
break;
@@ -2288,11 +2296,11 @@ public partial class CGrammarParser : Parser {
_localctx = new LogicalOrExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LogicalOrExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 314;
- if (!(Precpred(Context, 12))) throw new FailedPredicateException(this, "Precpred(Context, 12)");
State = 315;
- Match(T__39);
+ if (!(Precpred(Context, 12))) throw new FailedPredicateException(this, "Precpred(Context, 12)");
State = 316;
+ Match(T__39);
+ State = 317;
((LogicalOrExpressionContext)_localctx).right = expression(13);
}
break;
@@ -2301,24 +2309,24 @@ public partial class CGrammarParser : Parser {
_localctx = new TernaryExpressionContext(new ExpressionContext(_parentctx, _parentState));
((TernaryExpressionContext)_localctx).cond = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 317;
- if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
State = 318;
- Match(T__50);
+ if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
State = 319;
- ((TernaryExpressionContext)_localctx).then = expression(0);
+ Match(T__50);
State = 320;
- Match(T__51);
+ ((TernaryExpressionContext)_localctx).then = expression(0);
State = 321;
+ Match(T__51);
+ State = 322;
((TernaryExpressionContext)_localctx).@else = expression(2);
}
break;
}
}
}
- State = 327;
+ State = 328;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,23,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,24,Context);
}
}
}
@@ -2391,14 +2399,14 @@ public partial class CGrammarParser : Parser {
ConstantContext _localctx = new ConstantContext(Context, State);
EnterRule(_localctx, 14, RULE_constant);
try {
- State = 332;
+ State = 333;
ErrorHandler.Sync(this);
switch (TokenStream.LA(1)) {
case INT:
_localctx = new IntConstantContext(_localctx);
EnterOuterAlt(_localctx, 1);
{
- State = 328;
+ State = 329;
Match(INT);
}
break;
@@ -2406,7 +2414,7 @@ public partial class CGrammarParser : Parser {
_localctx = new HexConstantContext(_localctx);
EnterOuterAlt(_localctx, 2);
{
- State = 329;
+ State = 330;
Match(HEX);
}
break;
@@ -2414,7 +2422,7 @@ public partial class CGrammarParser : Parser {
_localctx = new CharConstantContext(_localctx);
EnterOuterAlt(_localctx, 3);
{
- State = 330;
+ State = 331;
Match(LETTER);
}
break;
@@ -2422,7 +2430,7 @@ public partial class CGrammarParser : Parser {
_localctx = new StringConstantContext(_localctx);
EnterOuterAlt(_localctx, 4);
{
- State = 331;
+ State = 332;
Match(STRING);
}
break;
@@ -2474,18 +2482,18 @@ public partial class CGrammarParser : Parser {
int _alt;
EnterOuterAlt(_localctx, 1);
{
- State = 337;
+ State = 338;
ErrorHandler.Sync(this);
switch (TokenStream.LA(1)) {
case T__52:
{
- State = 335;
+ State = 336;
Match(T__52);
}
break;
case T__53:
{
- State = 336;
+ State = 337;
Match(T__53);
}
break;
@@ -2493,9 +2501,9 @@ public partial class CGrammarParser : Parser {
throw new NoViableAltException(this);
}
Context.Stop = TokenStream.LT(-1);
- State = 343;
+ State = 344;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,26,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,27,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( ParseListeners!=null )
@@ -2505,16 +2513,16 @@ public partial class CGrammarParser : Parser {
{
_localctx = new TypeContext(_parentctx, _parentState);
PushNewRecursionContext(_localctx, _startState, RULE_type);
- State = 339;
- if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
State = 340;
+ if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
+ State = 341;
Match(T__18);
}
}
}
- State = 345;
+ State = 346;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,26,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,27,Context);
}
}
}
@@ -2590,13 +2598,13 @@ public partial class CGrammarParser : Parser {
Context = _localctx;
_prevctx = _localctx;
- State = 347;
+ State = 348;
Match(ID);
}
Context.Stop = TokenStream.LT(-1);
- State = 356;
+ State = 357;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,27,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,28,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( ParseListeners!=null )
@@ -2607,20 +2615,20 @@ public partial class CGrammarParser : Parser {
_localctx = new IndexerTargetContext(new TargetContext(_parentctx, _parentState));
((IndexerTargetContext)_localctx).obj = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_target);
- State = 349;
- if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
State = 350;
- Match(T__16);
+ if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
State = 351;
- ((IndexerTargetContext)_localctx).indexer = expression(0);
+ Match(T__16);
State = 352;
+ ((IndexerTargetContext)_localctx).indexer = expression(0);
+ State = 353;
Match(T__17);
}
}
}
- State = 358;
+ State = 359;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,27,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,28,Context);
}
}
}
@@ -2681,7 +2689,7 @@ public partial class CGrammarParser : Parser {
}
private static int[] _serializedATN = {
- 4,1,62,360,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,
+ 4,1,62,361,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,
7,7,2,8,7,8,2,9,7,9,1,0,4,0,22,8,0,11,0,12,0,23,1,0,1,0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,5,1,37,8,1,10,1,12,1,40,9,1,3,1,42,8,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,56,8,1,10,1,12,1,59,9,1,3,1,
@@ -2692,117 +2700,118 @@ public partial class CGrammarParser : Parser {
4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,
1,4,1,4,1,4,1,4,1,4,3,4,145,8,4,1,5,1,5,1,5,1,5,3,5,151,8,5,1,5,1,5,1,
6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,164,8,6,1,6,1,6,1,6,1,6,1,6,5,6,
- 171,8,6,10,6,12,6,174,9,6,3,6,176,8,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
- 1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,5,6,195,8,6,10,6,12,6,198,9,6,3,6,
- 200,8,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,
+ 171,8,6,10,6,12,6,174,9,6,3,6,176,8,6,1,6,3,6,179,8,6,1,6,1,6,1,6,1,6,
+ 1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,5,6,196,8,6,10,6,12,6,199,
+ 9,6,3,6,201,8,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,
6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,
- 6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,262,8,6,1,6,1,6,1,6,1,6,1,6,
+ 6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,263,8,6,1,6,1,6,1,6,
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,
6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,
- 6,1,6,1,6,5,6,324,8,6,10,6,12,6,327,9,6,1,7,1,7,1,7,1,7,3,7,333,8,7,1,
- 8,1,8,1,8,3,8,338,8,8,1,8,1,8,5,8,342,8,8,10,8,12,8,345,9,8,1,9,1,9,1,
- 9,1,9,1,9,1,9,1,9,1,9,5,9,355,8,9,10,9,12,9,358,9,9,1,9,0,3,12,16,18,10,
- 0,2,4,6,8,10,12,14,16,18,0,0,428,0,21,1,0,0,0,2,65,1,0,0,0,4,67,1,0,0,
- 0,6,78,1,0,0,0,8,144,1,0,0,0,10,146,1,0,0,0,12,261,1,0,0,0,14,332,1,0,
- 0,0,16,337,1,0,0,0,18,346,1,0,0,0,20,22,3,2,1,0,21,20,1,0,0,0,22,23,1,
- 0,0,0,23,21,1,0,0,0,23,24,1,0,0,0,24,25,1,0,0,0,25,26,5,0,0,1,26,1,1,0,
- 0,0,27,28,3,16,8,0,28,29,5,56,0,0,29,41,5,1,0,0,30,31,3,16,8,0,31,38,5,
- 56,0,0,32,33,5,2,0,0,33,34,3,16,8,0,34,35,5,56,0,0,35,37,1,0,0,0,36,32,
- 1,0,0,0,37,40,1,0,0,0,38,36,1,0,0,0,38,39,1,0,0,0,39,42,1,0,0,0,40,38,
- 1,0,0,0,41,30,1,0,0,0,41,42,1,0,0,0,42,43,1,0,0,0,43,44,5,3,0,0,44,45,
- 5,4,0,0,45,66,1,0,0,0,46,47,3,16,8,0,47,48,5,56,0,0,48,60,5,1,0,0,49,50,
- 3,16,8,0,50,57,5,56,0,0,51,52,5,2,0,0,52,53,3,16,8,0,53,54,5,56,0,0,54,
- 56,1,0,0,0,55,51,1,0,0,0,56,59,1,0,0,0,57,55,1,0,0,0,57,58,1,0,0,0,58,
- 61,1,0,0,0,59,57,1,0,0,0,60,49,1,0,0,0,60,61,1,0,0,0,61,62,1,0,0,0,62,
- 63,5,3,0,0,63,64,3,4,2,0,64,66,1,0,0,0,65,27,1,0,0,0,65,46,1,0,0,0,66,
- 3,1,0,0,0,67,71,5,5,0,0,68,70,3,6,3,0,69,68,1,0,0,0,70,73,1,0,0,0,71,69,
- 1,0,0,0,71,72,1,0,0,0,72,74,1,0,0,0,73,71,1,0,0,0,74,75,5,6,0,0,75,5,1,
- 0,0,0,76,79,3,8,4,0,77,79,3,10,5,0,78,76,1,0,0,0,78,77,1,0,0,0,79,7,1,
- 0,0,0,80,81,5,7,0,0,81,82,3,12,6,0,82,83,5,4,0,0,83,145,1,0,0,0,84,85,
- 5,8,0,0,85,86,5,1,0,0,86,87,3,12,6,0,87,88,5,3,0,0,88,91,3,8,4,0,89,90,
- 5,9,0,0,90,92,3,8,4,0,91,89,1,0,0,0,91,92,1,0,0,0,92,145,1,0,0,0,93,94,
- 5,10,0,0,94,96,5,1,0,0,95,97,3,12,6,0,96,95,1,0,0,0,96,97,1,0,0,0,97,98,
- 1,0,0,0,98,100,5,4,0,0,99,101,3,12,6,0,100,99,1,0,0,0,100,101,1,0,0,0,
- 101,102,1,0,0,0,102,104,5,4,0,0,103,105,3,12,6,0,104,103,1,0,0,0,104,105,
- 1,0,0,0,105,106,1,0,0,0,106,107,5,3,0,0,107,145,3,8,4,0,108,109,5,10,0,
- 0,109,110,5,1,0,0,110,112,3,10,5,0,111,113,3,12,6,0,112,111,1,0,0,0,112,
- 113,1,0,0,0,113,114,1,0,0,0,114,116,5,4,0,0,115,117,3,12,6,0,116,115,1,
- 0,0,0,116,117,1,0,0,0,117,118,1,0,0,0,118,119,5,3,0,0,119,120,3,8,4,0,
- 120,145,1,0,0,0,121,122,5,11,0,0,122,123,5,1,0,0,123,124,3,12,6,0,124,
- 125,5,3,0,0,125,126,3,8,4,0,126,145,1,0,0,0,127,128,5,12,0,0,128,129,3,
- 8,4,0,129,130,5,11,0,0,130,131,5,1,0,0,131,132,3,12,6,0,132,133,5,3,0,
- 0,133,134,5,4,0,0,134,145,1,0,0,0,135,136,5,13,0,0,136,145,5,4,0,0,137,
- 138,5,14,0,0,138,145,5,4,0,0,139,140,3,12,6,0,140,141,5,4,0,0,141,145,
- 1,0,0,0,142,145,3,4,2,0,143,145,5,4,0,0,144,80,1,0,0,0,144,84,1,0,0,0,
- 144,93,1,0,0,0,144,108,1,0,0,0,144,121,1,0,0,0,144,127,1,0,0,0,144,135,
- 1,0,0,0,144,137,1,0,0,0,144,139,1,0,0,0,144,142,1,0,0,0,144,143,1,0,0,
- 0,145,9,1,0,0,0,146,147,3,16,8,0,147,150,5,56,0,0,148,149,5,15,0,0,149,
- 151,3,12,6,0,150,148,1,0,0,0,150,151,1,0,0,0,151,152,1,0,0,0,152,153,5,
- 4,0,0,153,11,1,0,0,0,154,155,6,6,-1,0,155,156,5,1,0,0,156,157,3,12,6,0,
- 157,158,5,3,0,0,158,262,1,0,0,0,159,160,5,16,0,0,160,161,3,16,8,0,161,
+ 6,1,6,1,6,1,6,1,6,5,6,325,8,6,10,6,12,6,328,9,6,1,7,1,7,1,7,1,7,3,7,334,
+ 8,7,1,8,1,8,1,8,3,8,339,8,8,1,8,1,8,5,8,343,8,8,10,8,12,8,346,9,8,1,9,
+ 1,9,1,9,1,9,1,9,1,9,1,9,1,9,5,9,356,8,9,10,9,12,9,359,9,9,1,9,0,3,12,16,
+ 18,10,0,2,4,6,8,10,12,14,16,18,0,0,430,0,21,1,0,0,0,2,65,1,0,0,0,4,67,
+ 1,0,0,0,6,78,1,0,0,0,8,144,1,0,0,0,10,146,1,0,0,0,12,262,1,0,0,0,14,333,
+ 1,0,0,0,16,338,1,0,0,0,18,347,1,0,0,0,20,22,3,2,1,0,21,20,1,0,0,0,22,23,
+ 1,0,0,0,23,21,1,0,0,0,23,24,1,0,0,0,24,25,1,0,0,0,25,26,5,0,0,1,26,1,1,
+ 0,0,0,27,28,3,16,8,0,28,29,5,56,0,0,29,41,5,1,0,0,30,31,3,16,8,0,31,38,
+ 5,56,0,0,32,33,5,2,0,0,33,34,3,16,8,0,34,35,5,56,0,0,35,37,1,0,0,0,36,
+ 32,1,0,0,0,37,40,1,0,0,0,38,36,1,0,0,0,38,39,1,0,0,0,39,42,1,0,0,0,40,
+ 38,1,0,0,0,41,30,1,0,0,0,41,42,1,0,0,0,42,43,1,0,0,0,43,44,5,3,0,0,44,
+ 45,5,4,0,0,45,66,1,0,0,0,46,47,3,16,8,0,47,48,5,56,0,0,48,60,5,1,0,0,49,
+ 50,3,16,8,0,50,57,5,56,0,0,51,52,5,2,0,0,52,53,3,16,8,0,53,54,5,56,0,0,
+ 54,56,1,0,0,0,55,51,1,0,0,0,56,59,1,0,0,0,57,55,1,0,0,0,57,58,1,0,0,0,
+ 58,61,1,0,0,0,59,57,1,0,0,0,60,49,1,0,0,0,60,61,1,0,0,0,61,62,1,0,0,0,
+ 62,63,5,3,0,0,63,64,3,4,2,0,64,66,1,0,0,0,65,27,1,0,0,0,65,46,1,0,0,0,
+ 66,3,1,0,0,0,67,71,5,5,0,0,68,70,3,6,3,0,69,68,1,0,0,0,70,73,1,0,0,0,71,
+ 69,1,0,0,0,71,72,1,0,0,0,72,74,1,0,0,0,73,71,1,0,0,0,74,75,5,6,0,0,75,
+ 5,1,0,0,0,76,79,3,8,4,0,77,79,3,10,5,0,78,76,1,0,0,0,78,77,1,0,0,0,79,
+ 7,1,0,0,0,80,81,5,7,0,0,81,82,3,12,6,0,82,83,5,4,0,0,83,145,1,0,0,0,84,
+ 85,5,8,0,0,85,86,5,1,0,0,86,87,3,12,6,0,87,88,5,3,0,0,88,91,3,8,4,0,89,
+ 90,5,9,0,0,90,92,3,8,4,0,91,89,1,0,0,0,91,92,1,0,0,0,92,145,1,0,0,0,93,
+ 94,5,10,0,0,94,96,5,1,0,0,95,97,3,12,6,0,96,95,1,0,0,0,96,97,1,0,0,0,97,
+ 98,1,0,0,0,98,100,5,4,0,0,99,101,3,12,6,0,100,99,1,0,0,0,100,101,1,0,0,
+ 0,101,102,1,0,0,0,102,104,5,4,0,0,103,105,3,12,6,0,104,103,1,0,0,0,104,
+ 105,1,0,0,0,105,106,1,0,0,0,106,107,5,3,0,0,107,145,3,8,4,0,108,109,5,
+ 10,0,0,109,110,5,1,0,0,110,112,3,10,5,0,111,113,3,12,6,0,112,111,1,0,0,
+ 0,112,113,1,0,0,0,113,114,1,0,0,0,114,116,5,4,0,0,115,117,3,12,6,0,116,
+ 115,1,0,0,0,116,117,1,0,0,0,117,118,1,0,0,0,118,119,5,3,0,0,119,120,3,
+ 8,4,0,120,145,1,0,0,0,121,122,5,11,0,0,122,123,5,1,0,0,123,124,3,12,6,
+ 0,124,125,5,3,0,0,125,126,3,8,4,0,126,145,1,0,0,0,127,128,5,12,0,0,128,
+ 129,3,8,4,0,129,130,5,11,0,0,130,131,5,1,0,0,131,132,3,12,6,0,132,133,
+ 5,3,0,0,133,134,5,4,0,0,134,145,1,0,0,0,135,136,5,13,0,0,136,145,5,4,0,
+ 0,137,138,5,14,0,0,138,145,5,4,0,0,139,140,3,12,6,0,140,141,5,4,0,0,141,
+ 145,1,0,0,0,142,145,3,4,2,0,143,145,5,4,0,0,144,80,1,0,0,0,144,84,1,0,
+ 0,0,144,93,1,0,0,0,144,108,1,0,0,0,144,121,1,0,0,0,144,127,1,0,0,0,144,
+ 135,1,0,0,0,144,137,1,0,0,0,144,139,1,0,0,0,144,142,1,0,0,0,144,143,1,
+ 0,0,0,145,9,1,0,0,0,146,147,3,16,8,0,147,150,5,56,0,0,148,149,5,15,0,0,
+ 149,151,3,12,6,0,150,148,1,0,0,0,150,151,1,0,0,0,151,152,1,0,0,0,152,153,
+ 5,4,0,0,153,11,1,0,0,0,154,155,6,6,-1,0,155,156,5,1,0,0,156,157,3,12,6,
+ 0,157,158,5,3,0,0,158,263,1,0,0,0,159,160,5,16,0,0,160,161,3,16,8,0,161,
163,5,17,0,0,162,164,5,57,0,0,163,162,1,0,0,0,163,164,1,0,0,0,164,165,
- 1,0,0,0,165,166,5,18,0,0,166,175,5,5,0,0,167,172,3,12,6,0,168,169,5,2,
+ 1,0,0,0,165,178,5,18,0,0,166,175,5,5,0,0,167,172,3,12,6,0,168,169,5,2,
0,0,169,171,3,12,6,0,170,168,1,0,0,0,171,174,1,0,0,0,172,170,1,0,0,0,172,
173,1,0,0,0,173,176,1,0,0,0,174,172,1,0,0,0,175,167,1,0,0,0,175,176,1,
- 0,0,0,176,177,1,0,0,0,177,178,5,6,0,0,178,262,1,0,0,0,179,262,3,14,7,0,
- 180,181,3,18,9,0,181,182,5,15,0,0,182,183,3,12,6,41,183,262,1,0,0,0,184,
- 185,5,19,0,0,185,262,3,12,6,40,186,187,5,20,0,0,187,262,3,18,9,0,188,262,
- 5,56,0,0,189,190,5,56,0,0,190,199,5,1,0,0,191,196,3,12,6,0,192,193,5,2,
- 0,0,193,195,3,12,6,0,194,192,1,0,0,0,195,198,1,0,0,0,196,194,1,0,0,0,196,
- 197,1,0,0,0,197,200,1,0,0,0,198,196,1,0,0,0,199,191,1,0,0,0,199,200,1,
- 0,0,0,200,201,1,0,0,0,201,262,5,3,0,0,202,203,3,18,9,0,203,204,5,17,0,
- 0,204,205,3,12,6,0,205,206,5,18,0,0,206,262,1,0,0,0,207,208,5,21,0,0,208,
- 262,3,12,6,35,209,210,5,22,0,0,210,262,3,12,6,34,211,212,5,23,0,0,212,
- 262,3,18,9,0,213,214,5,24,0,0,214,262,3,18,9,0,215,216,3,18,9,0,216,217,
- 5,23,0,0,217,262,1,0,0,0,218,219,3,18,9,0,219,220,5,24,0,0,220,262,1,0,
- 0,0,221,222,3,18,9,0,222,223,5,41,0,0,223,224,3,12,6,11,224,262,1,0,0,
- 0,225,226,3,18,9,0,226,227,5,42,0,0,227,228,3,12,6,10,228,262,1,0,0,0,
- 229,230,3,18,9,0,230,231,5,43,0,0,231,232,3,12,6,9,232,262,1,0,0,0,233,
- 234,3,18,9,0,234,235,5,44,0,0,235,236,3,12,6,8,236,262,1,0,0,0,237,238,
- 3,18,9,0,238,239,5,45,0,0,239,240,3,12,6,7,240,262,1,0,0,0,241,242,3,18,
- 9,0,242,243,5,46,0,0,243,244,3,12,6,6,244,262,1,0,0,0,245,246,3,18,9,0,
- 246,247,5,47,0,0,247,248,3,12,6,5,248,262,1,0,0,0,249,250,3,18,9,0,250,
- 251,5,48,0,0,251,252,3,12,6,4,252,262,1,0,0,0,253,254,3,18,9,0,254,255,
- 5,49,0,0,255,256,3,12,6,3,256,262,1,0,0,0,257,258,3,18,9,0,258,259,5,50,
- 0,0,259,260,3,12,6,2,260,262,1,0,0,0,261,154,1,0,0,0,261,159,1,0,0,0,261,
- 179,1,0,0,0,261,180,1,0,0,0,261,184,1,0,0,0,261,186,1,0,0,0,261,188,1,
- 0,0,0,261,189,1,0,0,0,261,202,1,0,0,0,261,207,1,0,0,0,261,209,1,0,0,0,
- 261,211,1,0,0,0,261,213,1,0,0,0,261,215,1,0,0,0,261,218,1,0,0,0,261,221,
- 1,0,0,0,261,225,1,0,0,0,261,229,1,0,0,0,261,233,1,0,0,0,261,237,1,0,0,
- 0,261,241,1,0,0,0,261,245,1,0,0,0,261,249,1,0,0,0,261,253,1,0,0,0,261,
- 257,1,0,0,0,262,325,1,0,0,0,263,264,10,29,0,0,264,265,5,19,0,0,265,324,
- 3,12,6,30,266,267,10,28,0,0,267,268,5,25,0,0,268,324,3,12,6,29,269,270,
- 10,27,0,0,270,271,5,26,0,0,271,324,3,12,6,28,272,273,10,26,0,0,273,274,
- 5,27,0,0,274,324,3,12,6,27,275,276,10,25,0,0,276,277,5,28,0,0,277,324,
- 3,12,6,26,278,279,10,24,0,0,279,280,5,29,0,0,280,324,3,12,6,25,281,282,
- 10,23,0,0,282,283,5,30,0,0,283,324,3,12,6,24,284,285,10,22,0,0,285,286,
- 5,31,0,0,286,324,3,12,6,23,287,288,10,21,0,0,288,289,5,32,0,0,289,324,
- 3,12,6,22,290,291,10,20,0,0,291,292,5,33,0,0,292,324,3,12,6,21,293,294,
- 10,19,0,0,294,295,5,34,0,0,295,324,3,12,6,20,296,297,10,18,0,0,297,298,
- 5,20,0,0,298,324,3,12,6,19,299,300,10,17,0,0,300,301,5,35,0,0,301,324,
- 3,12,6,18,302,303,10,16,0,0,303,304,5,36,0,0,304,324,3,12,6,17,305,306,
- 10,15,0,0,306,307,5,37,0,0,307,324,3,12,6,16,308,309,10,14,0,0,309,310,
- 5,38,0,0,310,324,3,12,6,15,311,312,10,13,0,0,312,313,5,39,0,0,313,324,
- 3,12,6,14,314,315,10,12,0,0,315,316,5,40,0,0,316,324,3,12,6,13,317,318,
- 10,1,0,0,318,319,5,51,0,0,319,320,3,12,6,0,320,321,5,52,0,0,321,322,3,
- 12,6,2,322,324,1,0,0,0,323,263,1,0,0,0,323,266,1,0,0,0,323,269,1,0,0,0,
- 323,272,1,0,0,0,323,275,1,0,0,0,323,278,1,0,0,0,323,281,1,0,0,0,323,284,
- 1,0,0,0,323,287,1,0,0,0,323,290,1,0,0,0,323,293,1,0,0,0,323,296,1,0,0,
- 0,323,299,1,0,0,0,323,302,1,0,0,0,323,305,1,0,0,0,323,308,1,0,0,0,323,
- 311,1,0,0,0,323,314,1,0,0,0,323,317,1,0,0,0,324,327,1,0,0,0,325,323,1,
- 0,0,0,325,326,1,0,0,0,326,13,1,0,0,0,327,325,1,0,0,0,328,333,5,57,0,0,
- 329,333,5,55,0,0,330,333,5,61,0,0,331,333,5,62,0,0,332,328,1,0,0,0,332,
- 329,1,0,0,0,332,330,1,0,0,0,332,331,1,0,0,0,333,15,1,0,0,0,334,335,6,8,
- -1,0,335,338,5,53,0,0,336,338,5,54,0,0,337,334,1,0,0,0,337,336,1,0,0,0,
- 338,343,1,0,0,0,339,340,10,1,0,0,340,342,5,19,0,0,341,339,1,0,0,0,342,
- 345,1,0,0,0,343,341,1,0,0,0,343,344,1,0,0,0,344,17,1,0,0,0,345,343,1,0,
- 0,0,346,347,6,9,-1,0,347,348,5,56,0,0,348,356,1,0,0,0,349,350,10,1,0,0,
- 350,351,5,17,0,0,351,352,3,12,6,0,352,353,5,18,0,0,353,355,1,0,0,0,354,
- 349,1,0,0,0,355,358,1,0,0,0,356,354,1,0,0,0,356,357,1,0,0,0,357,19,1,0,
- 0,0,358,356,1,0,0,0,28,23,38,41,57,60,65,71,78,91,96,100,104,112,116,144,
- 150,163,172,175,196,199,261,323,325,332,337,343,356
+ 0,0,0,176,177,1,0,0,0,177,179,5,6,0,0,178,166,1,0,0,0,178,179,1,0,0,0,
+ 179,263,1,0,0,0,180,263,3,14,7,0,181,182,3,18,9,0,182,183,5,15,0,0,183,
+ 184,3,12,6,41,184,263,1,0,0,0,185,186,5,19,0,0,186,263,3,12,6,40,187,188,
+ 5,20,0,0,188,263,3,18,9,0,189,263,5,56,0,0,190,191,5,56,0,0,191,200,5,
+ 1,0,0,192,197,3,12,6,0,193,194,5,2,0,0,194,196,3,12,6,0,195,193,1,0,0,
+ 0,196,199,1,0,0,0,197,195,1,0,0,0,197,198,1,0,0,0,198,201,1,0,0,0,199,
+ 197,1,0,0,0,200,192,1,0,0,0,200,201,1,0,0,0,201,202,1,0,0,0,202,263,5,
+ 3,0,0,203,204,3,18,9,0,204,205,5,17,0,0,205,206,3,12,6,0,206,207,5,18,
+ 0,0,207,263,1,0,0,0,208,209,5,21,0,0,209,263,3,12,6,35,210,211,5,22,0,
+ 0,211,263,3,12,6,34,212,213,5,23,0,0,213,263,3,18,9,0,214,215,5,24,0,0,
+ 215,263,3,18,9,0,216,217,3,18,9,0,217,218,5,23,0,0,218,263,1,0,0,0,219,
+ 220,3,18,9,0,220,221,5,24,0,0,221,263,1,0,0,0,222,223,3,18,9,0,223,224,
+ 5,41,0,0,224,225,3,12,6,11,225,263,1,0,0,0,226,227,3,18,9,0,227,228,5,
+ 42,0,0,228,229,3,12,6,10,229,263,1,0,0,0,230,231,3,18,9,0,231,232,5,43,
+ 0,0,232,233,3,12,6,9,233,263,1,0,0,0,234,235,3,18,9,0,235,236,5,44,0,0,
+ 236,237,3,12,6,8,237,263,1,0,0,0,238,239,3,18,9,0,239,240,5,45,0,0,240,
+ 241,3,12,6,7,241,263,1,0,0,0,242,243,3,18,9,0,243,244,5,46,0,0,244,245,
+ 3,12,6,6,245,263,1,0,0,0,246,247,3,18,9,0,247,248,5,47,0,0,248,249,3,12,
+ 6,5,249,263,1,0,0,0,250,251,3,18,9,0,251,252,5,48,0,0,252,253,3,12,6,4,
+ 253,263,1,0,0,0,254,255,3,18,9,0,255,256,5,49,0,0,256,257,3,12,6,3,257,
+ 263,1,0,0,0,258,259,3,18,9,0,259,260,5,50,0,0,260,261,3,12,6,2,261,263,
+ 1,0,0,0,262,154,1,0,0,0,262,159,1,0,0,0,262,180,1,0,0,0,262,181,1,0,0,
+ 0,262,185,1,0,0,0,262,187,1,0,0,0,262,189,1,0,0,0,262,190,1,0,0,0,262,
+ 203,1,0,0,0,262,208,1,0,0,0,262,210,1,0,0,0,262,212,1,0,0,0,262,214,1,
+ 0,0,0,262,216,1,0,0,0,262,219,1,0,0,0,262,222,1,0,0,0,262,226,1,0,0,0,
+ 262,230,1,0,0,0,262,234,1,0,0,0,262,238,1,0,0,0,262,242,1,0,0,0,262,246,
+ 1,0,0,0,262,250,1,0,0,0,262,254,1,0,0,0,262,258,1,0,0,0,263,326,1,0,0,
+ 0,264,265,10,29,0,0,265,266,5,19,0,0,266,325,3,12,6,30,267,268,10,28,0,
+ 0,268,269,5,25,0,0,269,325,3,12,6,29,270,271,10,27,0,0,271,272,5,26,0,
+ 0,272,325,3,12,6,28,273,274,10,26,0,0,274,275,5,27,0,0,275,325,3,12,6,
+ 27,276,277,10,25,0,0,277,278,5,28,0,0,278,325,3,12,6,26,279,280,10,24,
+ 0,0,280,281,5,29,0,0,281,325,3,12,6,25,282,283,10,23,0,0,283,284,5,30,
+ 0,0,284,325,3,12,6,24,285,286,10,22,0,0,286,287,5,31,0,0,287,325,3,12,
+ 6,23,288,289,10,21,0,0,289,290,5,32,0,0,290,325,3,12,6,22,291,292,10,20,
+ 0,0,292,293,5,33,0,0,293,325,3,12,6,21,294,295,10,19,0,0,295,296,5,34,
+ 0,0,296,325,3,12,6,20,297,298,10,18,0,0,298,299,5,20,0,0,299,325,3,12,
+ 6,19,300,301,10,17,0,0,301,302,5,35,0,0,302,325,3,12,6,18,303,304,10,16,
+ 0,0,304,305,5,36,0,0,305,325,3,12,6,17,306,307,10,15,0,0,307,308,5,37,
+ 0,0,308,325,3,12,6,16,309,310,10,14,0,0,310,311,5,38,0,0,311,325,3,12,
+ 6,15,312,313,10,13,0,0,313,314,5,39,0,0,314,325,3,12,6,14,315,316,10,12,
+ 0,0,316,317,5,40,0,0,317,325,3,12,6,13,318,319,10,1,0,0,319,320,5,51,0,
+ 0,320,321,3,12,6,0,321,322,5,52,0,0,322,323,3,12,6,2,323,325,1,0,0,0,324,
+ 264,1,0,0,0,324,267,1,0,0,0,324,270,1,0,0,0,324,273,1,0,0,0,324,276,1,
+ 0,0,0,324,279,1,0,0,0,324,282,1,0,0,0,324,285,1,0,0,0,324,288,1,0,0,0,
+ 324,291,1,0,0,0,324,294,1,0,0,0,324,297,1,0,0,0,324,300,1,0,0,0,324,303,
+ 1,0,0,0,324,306,1,0,0,0,324,309,1,0,0,0,324,312,1,0,0,0,324,315,1,0,0,
+ 0,324,318,1,0,0,0,325,328,1,0,0,0,326,324,1,0,0,0,326,327,1,0,0,0,327,
+ 13,1,0,0,0,328,326,1,0,0,0,329,334,5,57,0,0,330,334,5,55,0,0,331,334,5,
+ 61,0,0,332,334,5,62,0,0,333,329,1,0,0,0,333,330,1,0,0,0,333,331,1,0,0,
+ 0,333,332,1,0,0,0,334,15,1,0,0,0,335,336,6,8,-1,0,336,339,5,53,0,0,337,
+ 339,5,54,0,0,338,335,1,0,0,0,338,337,1,0,0,0,339,344,1,0,0,0,340,341,10,
+ 1,0,0,341,343,5,19,0,0,342,340,1,0,0,0,343,346,1,0,0,0,344,342,1,0,0,0,
+ 344,345,1,0,0,0,345,17,1,0,0,0,346,344,1,0,0,0,347,348,6,9,-1,0,348,349,
+ 5,56,0,0,349,357,1,0,0,0,350,351,10,1,0,0,351,352,5,17,0,0,352,353,3,12,
+ 6,0,353,354,5,18,0,0,354,356,1,0,0,0,355,350,1,0,0,0,356,359,1,0,0,0,357,
+ 355,1,0,0,0,357,358,1,0,0,0,358,19,1,0,0,0,359,357,1,0,0,0,29,23,38,41,
+ 57,60,65,71,78,91,96,100,104,112,116,144,150,163,172,175,178,197,200,262,
+ 324,326,333,338,344,357
};
public static readonly ATN _ATN =
diff --git a/Compiler/visitors/Definitions.cs b/Compiler/visitors/Definitions.cs
index e4cf797..c27405e 100644
--- a/Compiler/visitors/Definitions.cs
+++ b/Compiler/visitors/Definitions.cs
@@ -5,7 +5,7 @@ public partial class CCompilerVisitor
private List<(CGrammarParser.FunctionDefinitionContext context,
FunctionReference function, FunctionOverload overload,
List<string> paramNames, List<CType> paramTypes)> _functionBodies = new();
-
+
private VariableReference FindVariable(string varName)
{
foreach (Dictionary<string, VariableReference> variables in this._variableStack)
@@ -42,7 +42,7 @@ public partial class CCompilerVisitor
throw new CompilerException($"Function '{name}' has not been defined or prototyped.");
}
-
+
public override string? VisitFunctionPrototype(CGrammarParser.FunctionPrototypeContext context)
{
string functionName = context.name.Text;
@@ -52,13 +52,15 @@ public partial class CCompilerVisitor
List<string> parameterNames = context._params.Select(x => x.Text).ToList();
FunctionReference function = this.CreateOrGetFunctionReference(functionName, type);
- FunctionOverload overload = function.CreateOverloadWithoutBody(parameterNames, parameterTypes);
+ FunctionOverload overload =
+ function.CreateOverloadWithoutBody(parameterNames, parameterTypes);
function.Overloads.Add(overload);
return null;
}
- public override string? VisitFunctionDefinition(CGrammarParser.FunctionDefinitionContext context)
+ public override string? VisitFunctionDefinition(
+ CGrammarParser.FunctionDefinitionContext context)
{
string functionName = context.name.Text;
CType type = this.VisitCType(context.rtype);
@@ -73,7 +75,12 @@ public partial class CCompilerVisitor
return null;
}
- private void VisitFunctionBody(CGrammarParser.FunctionDefinitionContext context, FunctionReference function, FunctionOverload overload, List<string> paramNames, List<CType> paramTypes)
+ private void VisitFunctionBody(
+ CGrammarParser.FunctionDefinitionContext context,
+ FunctionReference function,
+ FunctionOverload overload,
+ List<string> paramNames,
+ List<CType> paramTypes)
{
this.Branch(function.GetBranchName(overload), function.GetBranchFriendlyName(overload));
@@ -96,9 +103,11 @@ public partial class CCompilerVisitor
this.Instruction("mov 0, V0", "fallback return 0");
this.Instruction("ret");
+
this.Blank();
}
- public override string? VisitVariableDeclaration(CGrammarParser.VariableDeclarationContext context)
+ public override string? VisitVariableDeclaration(
+ CGrammarParser.VariableDeclarationContext context)
{
CType type = this.VisitCType(context.type());
int addr = this.Alloc(CType.Int.Size);
diff --git a/Compiler/visitors/Expressions.cs b/Compiler/visitors/Expressions.cs
index e67688d..1cc4291 100644
--- a/Compiler/visitors/Expressions.cs
+++ b/Compiler/visitors/Expressions.cs
@@ -10,7 +10,7 @@ public partial class CCompilerVisitor
return expressionString;
}
-
+
public override string VisitCallExpression(CGrammarParser.CallExpressionContext context)
{
string functionName = context.ID().GetText();
@@ -25,15 +25,20 @@ public partial class CCompilerVisitor
{
CGrammarParser.ExpressionContext argument = argumentsReversed[i];
string result = this.VisitExpression(argument);
+
+ int indexReverse = argumentsReversed.Length - i - 1;
- this.Instruction($"push {result}", $"arg {overload.ParameterTypes[i]} {overload.ParameterNames[i]}");
+ this.Instruction(
+ $"push {result}", $"arg {overload.ParameterTypes[indexReverse]} {overload.ParameterNames[indexReverse]}");
}
- this.Instruction($"call {function.GetBranchName(overload)}", function.GetBranchFriendlyName(overload));
+ this.Instruction(
+ $"call {function.GetBranchName(overload)}", function.GetBranchFriendlyName(overload));
return "V0";
}
- public override string VisitParenthesizedExpression(CGrammarParser.ParenthesizedExpressionContext context)
+ public override string VisitParenthesizedExpression(
+ CGrammarParser.ParenthesizedExpressionContext context)
{
return this.VisitExpression(context.expression());
}
@@ -44,7 +49,8 @@ public partial class CCompilerVisitor
return $"[${reference.Address:X4}]";
}
- public override string VisitAssignmentExpression(CGrammarParser.AssignmentExpressionContext context)
+ public override string VisitAssignmentExpression(
+ CGrammarParser.AssignmentExpressionContext context)
{
Target target = this.VisitTarget(context.target());
string value = this.VisitExpression(context.expression());
@@ -78,13 +84,15 @@ public partial class CCompilerVisitor
return "V0";
}
- public override string VisitAddressOfExpression(CGrammarParser.AddressOfExpressionContext context)
+ public override string VisitAddressOfExpression(
+ CGrammarParser.AddressOfExpressionContext context)
{
Target target = this.VisitTarget(context.target());
return target.Address;
}
- public override string VisitDereferenceExpression(CGrammarParser.DereferenceExpressionContext context)
+ public override string VisitDereferenceExpression(
+ CGrammarParser.DereferenceExpressionContext context)
{
string value = this.VisitExpression(context.expression());
@@ -97,16 +105,16 @@ public partial class CCompilerVisitor
Target obj = this.VisitTarget(context.obj);
if (obj.Type is not CTypePtr ptr)
throw new CompilerException("Indexer target was not a pointer!");
-
+
this.Instruction($"push {obj.Value}", "store index obj");
string indexer = this.VisitExpression(context.indexer);
- this.Instruction($"mov {indexer}, V1", "store indexer");
- this.Instruction($"pop V0", "restore index obj");
+ this.Instruction($"mov {indexer}, V1", "store indexer");
+ this.Instruction($"pop V0", "restore index obj");
this.Instruction($"mul V1, {ptr.Sub.Size}", $"multiply indexer by {ptr.Sub.Size}");
- this.Instruction($"add AX, V0", "add indexer and index obj");
- this.Instruction($"mov AX, V0", "move to general purpose register");
+ this.Instruction($"add AX, V0", "add indexer and index obj");
+ this.Instruction($"mov AX, V0", "move to general purpose register");
return "[V0]";
}
@@ -115,13 +123,17 @@ public partial class CCompilerVisitor
CType type = this.VisitCType(context.type());
int? arrPtr = null;
- if (context._params.Count == 0)
+ int length = context.INT() != null
+ ? int.Parse(context.INT().GetText())
+ : context._params.Count;
+
+ if (length == 0)
throw new CompilerException("Cannot create empty array");
-
+
foreach (CGrammarParser.ExpressionContext? param in context._params)
{
int itemPtr = Alloc(type.Size);
-
+
if (arrPtr == null)
arrPtr = itemPtr;
@@ -129,6 +141,14 @@ public partial class CCompilerVisitor
this.DynamicMove(type, value, $"[${itemPtr:X4}]");
}
+ int remainingSize = (length - context._params.Count) * type.Size;
+ if (remainingSize < 0)
+ throw new CompilerException("Array length larger than specified length");
+ int blockPtr = Alloc(remainingSize);
+
+ if (arrPtr == null)
+ arrPtr = blockPtr;
+
return $"${arrPtr:X4}";
}
} \ No newline at end of file
diff --git a/Emulator/Chip/Q1CpuInstructions.cs b/Emulator/Chip/Q1CpuInstructions.cs
index 72d78e5..0041b25 100644
--- a/Emulator/Chip/Q1CpuInstructions.cs
+++ b/Emulator/Chip/Q1CpuInstructions.cs
@@ -125,14 +125,14 @@ public partial class Q1Cpu
private void Instruction_SHL(u8 m1, u8 m2)
{
u16 v1 = this.Address(m1).read();
- u16 v2 = this.Address(m1).read();
+ u16 v2 = this.Address(m2).read();
u16 shifted = (u16) (v1 << v2);
this.DX = shifted;
}
private void Instruction_SHR(u8 m1, u8 m2)
{
u16 v1 = this.Address(m1).read();
- u16 v2 = this.Address(m1).read();
+ u16 v2 = this.Address(m2).read();
u16 shifted = (u16) (v1 >> v2);
this.DX = shifted;
}
diff --git a/Emulator/Program.cs b/Emulator/Program.cs
index 65bf068..f6fa932 100644
--- a/Emulator/Program.cs
+++ b/Emulator/Program.cs
@@ -64,6 +64,7 @@ public class Program
cpu.Clock();
}
Console.WriteLine($"Exit code: 0x{cpu.V[0]:X4}");
+ MemoryDump(memory, Q1Layout.FreeMemoryStart, (u16) (Q1Layout.Memory.start + Q1Layout.Memory.size - 1));
});
t.IsBackground = true;
t.Start();
@@ -80,4 +81,18 @@ public class Program
Console.WriteLine("Display surface closed. Waiting for CPU thread to finish...");
t.Join();
}
+
+ private static void MemoryDump(RamDevice memory, u16 start, u16 end)
+ {
+ for (u16 addr = start; addr <= end; addr += 16)
+ {
+ Console.Write($"0x{addr:X4}: ");
+ for (u16 offset = 0; offset < 16; offset++)
+ {
+ if (addr + offset > end) break;
+ Console.Write($"{memory.Read((u16) (addr + offset)):X2} ");
+ }
+ Console.WriteLine();
+ }
+ }
} \ No newline at end of file
diff --git a/Q1.sln b/Q1.sln
index dda6839..6dae249 100644
--- a/Q1.sln
+++ b/Q1.sln
@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchestrator", "Orchestrato
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegionVisualiser", "RegionVisualiser\RegionVisualiser.csproj", "{43523E07-07BD-456A-BD53-C1515ED8148E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compiler.Testing", "Compiler.Testing\Compiler.Testing.csproj", "{2BE81C5F-2117-412D-9FAF-8AA31C2E7000}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -36,5 +38,9 @@ Global
{43523E07-07BD-456A-BD53-C1515ED8148E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43523E07-07BD-456A-BD53-C1515ED8148E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43523E07-07BD-456A-BD53-C1515ED8148E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2BE81C5F-2117-412D-9FAF-8AA31C2E7000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2BE81C5F-2117-412D-9FAF-8AA31C2E7000}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2BE81C5F-2117-412D-9FAF-8AA31C2E7000}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2BE81C5F-2117-412D-9FAF-8AA31C2E7000}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/Q1.sln.DotSettings.user b/Q1.sln.DotSettings.user
index 982881d..8231c84 100644
--- a/Q1.sln.DotSettings.user
+++ b/Q1.sln.DotSettings.user
@@ -9,4 +9,9 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AITokenSource_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F09190d4d899c4e68827ef2ee0d8f96282ee00_003Feb_003Fbfeed1b2_003FITokenSource_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AITokenStream_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F09190d4d899c4e68827ef2ee0d8f96282ee00_003F70_003Ffcaa3e03_003FITokenStream_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ALexer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F09190d4d899c4e68827ef2ee0d8f96282ee00_003F1e_003F6f12b962_003FLexer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
- <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AParserRuleContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F09190d4d899c4e68827ef2ee0d8f96282ee00_003Fa2_003F4aba81d4_003FParserRuleContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary> \ No newline at end of file
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AParserRuleContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F09190d4d899c4e68827ef2ee0d8f96282ee00_003Fa2_003F4aba81d4_003FParserRuleContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+ <s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">/Users/melodidey/Library/Caches/JetBrains/Rider2025.1/resharper-host/temp/Rider/vAny/CoverageData/_Q1.-1839411224/Snapshot/snapshot.utdcvr</s:String>
+
+ <s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=d790e387_002D9540_002D4a7c_002Dafa3_002D7d34149507b2/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
+ &lt;Solution /&gt;
+&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary> \ No newline at end of file
diff --git a/ROMs/life.asm b/ROMs/life.asm
new file mode 100644
index 0000000..d5250a0
--- /dev/null
+++ b/ROMs/life.asm
@@ -0,0 +1,404 @@
+ jmp _main
+_hid_getKeyState_int_scanCode:; int hid_getKeyState(int scanCode)
+ pop V0 ; preserve function return address
+ pop [$71FF] ; param int scanCode
+ push V0 ; restore function return address
+ mov $6033, [$7201] ; int sk_table = $6033
+ push [$71FF] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$7203] ; int index = AX
+ push [$71FF] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$7205] ; int bit = AX
+ push [$7201] ; store index obj
+ push [$7203] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ mov AX, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7207] ; int val = [V0]
+ push [$7207] ; left operand
+ push 1 ; left operand
+ mov [$7205], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
+ not
+ mov LX, V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_hid_getPressedKey: ; int hid_getPressedKey()
+ mov 0, [$7209] ; int sk = 0
+_body_1:
+ push [$7209] ; left operand
+ mov 256, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_2 ; if for condition fails, jump to end
+ push [$7209] ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
+ cmp V0, 0 ; logical and
+ not
+ bz
+ jmp _clause_3
+ mov 0, V0 ; first operand failed, store 0 and skip second
+ jmp _end_4
+_clause_3:
+ push [$7209] ; left operand
+ mov 160, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
+ not
+ cmp LX, 0 ; compare result from second operand to 0
+ not
+ mov LX, V0 ; store second operand result
+_end_4:
+ not V0
+ bz ; check if condition
+ jmp _end_5 ; if succeeds, continue, else jump to end
+ mov [$7209], V0 ; return value
+ ret
+_end_5:
+ push [$7209] ; i++
+ inc [$7209]
+ pop V0
+ jmp _body_1
+_end_2:
+ mov 0, V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_hid_waitForPressedKey: ; int hid_waitForPressedKey()
+_body_6:
+ not 1
+ bz
+ jmp _end_7 ; if while condition fails, jump to end
+ call _hid_getPressedKey ; int hid_getPressedKey()
+ mov V0, [$720B] ; int sk = V0
+ push [$720B] ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
+ not
+ not LX
+ bz ; check if condition
+ jmp _end_8 ; if succeeds, continue, else jump to end
+ mov [$720B], V0 ; return value
+ ret
+_end_8:
+ jmp _body_6
+_end_7:
+ mov 0, V0 ; fallback return 0
+ ret
+
+_hid_getMouseIndex: ; int hid_getMouseIndex()
+ mov $602F, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_hid_getMouseState: ; int hid_getMouseState()
+ push $602F ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_screen_setPixel_int_x__int_y__int_c:; int screen_setPixel(int x, int y, int c)
+ pop V0 ; preserve function return address
+ pop [$720D] ; param int x
+ pop [$720F] ; param int y
+ pop [$7211] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7213] ; int screenStart = $402F
+ push [$720F] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$720D], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$7215] ; int i = AX
+ push [$7213] ; store index obj
+ mov [$7215], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7211], [V0] ; [V0] = [$7211]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_screen_setPixel_int_i__int_c:; int screen_setPixel(int i, int c)
+ pop V0 ; preserve function return address
+ pop [$7217] ; param int i
+ pop [$7219] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$721B] ; int screenStart = $402F
+ push [$721B] ; store index obj
+ mov [$7217], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7219], [V0] ; [V0] = [$7219]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_screen_clear_int_c: ; int screen_clear(int c)
+ pop V0 ; preserve function return address
+ pop [$721D] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$721F] ; int screenStart = $402F
+ mov 0, [$7221] ; int i = 0
+_body_9:
+ push [$7221] ; left operand
+ push 128 ; left operand
+ mov 64, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_10 ; if for condition fails, jump to end
+ push [$721F] ; store index obj
+ mov [$7221], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$721D], [V0] ; [V0] = [$721D]
+ push [$7221] ; i++
+ inc [$7221]
+ pop V0
+ jmp _body_9
+_end_10:
+ mov 0, V0 ; fallback return 0
+ ret
+
+_getState_char*_grid__int_index:; char getState(char* grid, int index)
+ pop V0 ; preserve function return address
+ pop [$7223] ; param char* grid
+ pop [$7225] ; param int index
+ push V0 ; restore function return address
+ push [$7225] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$7227] ; int byteIndex = AX
+ push [$7225] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$7229] ; int bitIndex = AX
+ push [$7223] ; store index obj
+ mov [$7227], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$722B] ; int byte = [V0]
+ push [$722B] ; left operand
+ mov [$7229], V1 ; right operand
+ pop V0 ; get left operand back
+ shr V0, V1 ; compute right shift
+ push DX ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
+ not
+ mov LX, V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_setState_char*_grid__int_index__int_state:; int setState(char* grid, int index, int state)
+ pop V0 ; preserve function return address
+ pop [$722D] ; param char* grid
+ pop [$722F] ; param int index
+ pop [$7231] ; param int state
+ push V0 ; restore function return address
+ push [$722F] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$7233] ; int byteIndex = AX
+ push [$722F] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$7235] ; int bitIndex = AX
+ push [$722D] ; store index obj
+ mov [$7233], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7237] ; int byte = [V0]
+ bz [$7231] ; check if condition
+ jmp _then_12
+ ; if failed
+ push [$7237] ; left operand
+ push 1 ; left operand
+ mov [$7235], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ inv DX
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7237] ; store back into left param
+ jmp _end_11
+_then_12: ; if succeeded
+ push [$7237] ; left operand
+ push 1 ; left operand
+ mov [$7235], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ or V0, V1 ; compute or
+ push DX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7237] ; store back into left param
+_end_11:
+ push [$722D] ; store index obj
+ mov [$7233], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7237], [V0] ; [V0] = [$7237]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_drawGrid_char*_grid: ; int drawGrid(char* grid)
+ pop V0 ; preserve function return address
+ pop [$7239] ; param char* grid
+ push V0 ; restore function return address
+ push 8 ; arg int c
+ call _screen_clear_int_c ; int screen_clear(int c)
+ mov 0, [$723B] ; int y = 0
+_body_13:
+ push [$723B] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_14 ; if for condition fails, jump to end
+ mov 0, [$723D] ; int x = 0
+_body_15:
+ push [$723D] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_16 ; if for condition fails, jump to end
+ push [$723B] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$723D], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$723F] ; int index = AX
+ push [$723F] ; arg int index
+ push [$7239] ; arg char* grid
+ call _getState_char*_grid__int_index; char getState(char* grid, int index)
+ not V0
+ bz ; check if condition
+ jmp _end_17 ; if succeeds, continue, else jump to end
+ push 7 ; arg int c
+ push [$723B] ; arg int y
+ push [$723D] ; arg int x
+ call _screen_setPixel_int_x__int_y__int_c; int screen_setPixel(int x, int y, int c)
+_end_17:
+ push [$723D] ; i++
+ inc [$723D]
+ pop V0
+ jmp _body_15
+_end_16:
+ push [$723B] ; i++
+ inc [$723B]
+ pop V0
+ jmp _body_13
+_end_14:
+ mov 0, V0 ; fallback return 0
+ ret
+
+_main: ; int main()
+ mov $7243, [$7241] ; int grid = $7243
+ ; clear memory
+ mov 0, [$724B] ; int i = 0
+_body_18:
+ push [$724B] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_19 ; if for condition fails, jump to end
+ push [$7241] ; store index obj
+ mov [$724B], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb 0, [V0] ; [V0] = 0
+ push [$724B] ; i++
+ inc [$724B]
+ pop V0
+ jmp _body_18
+_end_19:
+ ; turn on pixel at (0,0)
+ push 1 ; arg int state
+ push 0 ; arg int index
+ push [$7241] ; arg char* grid
+ call _setState_char*_grid__int_index__int_state; int setState(char* grid, int index, int state)
+ push [$7241] ; arg char* grid
+ call _drawGrid_char*_grid ; int drawGrid(char* grid)
+_body_20:
+ not 1
+ bz
+ jmp _end_21 ; if while condition fails, jump to end
+ jmp _body_20
+_end_21:
+ mov 0, V0 ; fallback return 0
+ ret
+
diff --git a/ROMs/life.c b/ROMs/life.c
new file mode 100644
index 0000000..f35f9d0
--- /dev/null
+++ b/ROMs/life.c
@@ -0,0 +1,62 @@
+#include "std.c"
+#include "hid.c"
+#include "screen.c"
+
+#define GRID_SIZE 64
+#define GRID_BYTES 8
+#define GRID_WIDTH 8
+#define GRID_HEIGHT 8
+
+char getState(char* grid, int index)
+{
+ int byteIndex = index / 8;
+ int bitIndex = index % 8;
+ int byte = grid[byteIndex];
+
+ return ((byte >> bitIndex) & 1) != 0;
+}
+
+int setState(char* grid, int index, int state)
+{
+ int byteIndex = index / 8;
+ int bitIndex = index % 8;
+ int byte = grid[byteIndex];
+
+ if (state)
+ byte |= (1 << bitIndex);
+ else
+ byte &= ~(1 << bitIndex);
+
+ grid[byteIndex] = byte;
+}
+
+int drawGrid(char* grid)
+{
+ screen_clear(COLOR_BLACK);
+
+ for (int y = 0; y < GRID_HEIGHT; y++)
+ {
+ for (int x = 0; x < GRID_WIDTH; x++)
+ {
+ int index = (y * GRID_WIDTH) + x;
+ if (getState(grid, index))
+ screen_setPixel(x, y, COLOR_WHITE);
+ }
+ }
+}
+
+int main()
+{
+ char* grid = new char[GRID_BYTES];
+
+ // clear memory
+ for (int i = 0; i < GRID_BYTES; i++)
+ grid[i] = 0;
+
+ // turn on pixel at (0,0)
+ setState(grid, 0, 1);
+
+ drawGrid(grid);
+
+ while (1) { }
+} \ No newline at end of file
diff --git a/ROMs/life.q1 b/ROMs/life.q1
new file mode 100644
index 0000000..47e3f95
--- /dev/null
+++ b/ROMs/life.q1
Binary files differ
diff --git a/ROMs/logictest.asm b/ROMs/logictest.asm
new file mode 100644
index 0000000..6a2aac1
--- /dev/null
+++ b/ROMs/logictest.asm
@@ -0,0 +1,140 @@
+ jmp _main
+_screen_setPixel_int_x__int_y__int_c:; int screen_setPixel(int x, int y, int c)
+ pop V0 ; preserve function return address
+ pop [$71FF] ; param int x
+ pop [$7201] ; param int y
+ pop [$7203] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7205] ; int screenStart = $402F
+ push [$7201] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$71FF], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$7207] ; int i = AX
+ push [$7205] ; store index obj
+ mov [$7207], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7203], [V0] ; [V0] = [$7203]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_screen_setPixel_int_i__int_c:; int screen_setPixel(int i, int c)
+ pop V0 ; preserve function return address
+ pop [$7209] ; param int i
+ pop [$720B] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$720D] ; int screenStart = $402F
+ push [$720D] ; store index obj
+ mov [$7209], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720B], [V0] ; [V0] = [$720B]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_screen_clear_int_c: ; int screen_clear(int c)
+ pop V0 ; preserve function return address
+ pop [$720F] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7211] ; int screenStart = $402F
+ mov 0, [$7213] ; int i = 0
+_body_1:
+ push [$7213] ; left operand
+ push 128 ; left operand
+ mov 64, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_2 ; if for condition fails, jump to end
+ push [$7211] ; store index obj
+ mov [$7213], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720F], [V0] ; [V0] = [$720F]
+ push [$7213] ; i++
+ inc [$7213]
+ pop V0
+ jmp _body_1
+_end_2:
+ mov 0, V0 ; fallback return 0
+ ret
+
+_main: ; int main()
+ ; Test values
+ mov 0, [$7215] ; int a = 0
+ ; 170
+ mov 0, [$7217] ; int b = 0
+ ; 204
+ mov 0, [$7219] ; int c = 0
+ ; AND
+ movb [$7215], [$7219] ; [$7219] = [$7215]
+ push [$7219] ; left operand
+ mov [$7217], V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ ; expect 0b10001000 = 136
+ mov $7100, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; OR
+ movb [$7215], [$7219] ; [$7219] = [$7215]
+ push [$7219] ; left operand
+ mov [$7217], V1 ; right operand
+ pop V0 ; get left operand back
+ or V0, V1 ; compute or
+ ; expect 0b11101110 = 238
+ mov $7101, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; XOR
+ movb [$7215], [$7219] ; [$7219] = [$7215]
+ push [$7219] ; left operand
+ mov [$7217], V1 ; right operand
+ pop V0 ; get left operand back
+ xor V0, V1 ; compute exclusive or
+ ; expect 0b01100110 = 102
+ mov $7102, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; NOT
+ inv [$7215]
+ movb DX, [$7219] ; [$7219] = DX
+ ; expect 0b01010101 = 85
+ mov $7103, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; SHL
+ movb [$7215], [$7219] ; [$7219] = [$7215]
+ push [$7219] ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ ; expect 0b10101000 = 168
+ mov $7104, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; SHR
+ movb [$7215], [$7219] ; [$7219] = [$7215]
+ push [$7219] ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ shr V0, V1 ; compute right shift
+ ; expect 0b00101010 = 42
+ mov $7105, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; move pointer into register for dereference
+ ; Program ends cleanly
+ mov 0, V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
diff --git a/ROMs/logictest.c b/ROMs/logictest.c
new file mode 100644
index 0000000..f2ef6d9
--- /dev/null
+++ b/ROMs/logictest.c
@@ -0,0 +1,37 @@
+#include "std.c"
+#include "screen.c"
+
+int main()
+{
+ // Test values
+ char a = 0b10101010; // 170
+ char b = 0b11001100; // 204
+ char c;
+
+ // AND
+ c = a & b; // expect 0b10001000 = 136
+ *((char*)0x7100) = c;
+
+ // OR
+ c = a | b; // expect 0b11101110 = 238
+ *((char*)0x7101) = c;
+
+ // XOR
+ c = a ^ b; // expect 0b01100110 = 102
+ *((char*)0x7102) = c;
+
+ // NOT
+ c = ~a; // expect 0b01010101 = 85
+ *((char*)0x7103) = c;
+
+ // SHL
+ c = a << 2; // expect 0b10101000 = 168
+ *((char*)0x7104) = c;
+
+ // SHR
+ c = a >> 2; // expect 0b00101010 = 42
+ *((char*)0x7105) = c;
+
+ // Program ends cleanly
+ return 0;
+} \ No newline at end of file
diff --git a/ROMs/logictest.q1 b/ROMs/logictest.q1
new file mode 100644
index 0000000..f68eb77
--- /dev/null
+++ b/ROMs/logictest.q1
Binary files differ
diff --git a/ROMs/paint.asm b/ROMs/paint.asm
index c5bfe14..9a853a4 100644
--- a/ROMs/paint.asm
+++ b/ROMs/paint.asm
@@ -1,264 +1,264 @@
jmp _main
-_hid_getKeyState_int_scanCode:
- pop V0
- pop [$71FF]
- push V0
- mov $6033, [$7201]
- push [$71FF]
- mov 8, V1
- pop V0
- div V0, V1
- mov AX, [$7203]
- push [$71FF]
- mov 8, V1
- pop V0
- mod V0, V1
- mov AX, [$7205]
- push [$7201]
- push [$7203]
- mov 1, V1
- pop V0
- sub V0, V1
- mov AX, V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- mov [V0], [$7207]
- push [$7207]
- push 1
- mov [$7205], V1
- pop V0
- shl V0, V1
- mov DX, V1
- pop V0
- and V0, V1
- push DX
- mov 0, V1
- pop V0
- cmp V0, V1
+_hid_getKeyState_int_scanCode:; int hid_getKeyState(int scanCode)
+ pop V0 ; preserve function return address
+ pop [$71FF] ; param int scanCode
+ push V0 ; restore function return address
+ mov $6033, [$7201] ; int sk_table = $6033
+ push [$71FF] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$7203] ; int index = AX
+ push [$71FF] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$7205] ; int bit = AX
+ push [$7201] ; store index obj
+ push [$7203] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ mov AX, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7207] ; int val = [V0]
+ push [$7207] ; left operand
+ push 1 ; left operand
+ mov [$7205], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
- mov LX, V0
+ mov LX, V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getPressedKey:
- mov 0, [$7209]
+_hid_getPressedKey: ; int hid_getPressedKey()
+ mov 0, [$7209] ; int sk = 0
_body_1:
- push [$7209]
- mov 256, V1
- pop V0
- lt V0, V1
+ push [$7209] ; left operand
+ mov 256, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_2
- push [$7209]
- call _hid_getKeyState_int_scanCode
- cmp V0, 0
+ jmp _end_2 ; if for condition fails, jump to end
+ push [$7209] ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
+ cmp V0, 0 ; logical and
not
bz
jmp _clause_3
- mov 0, V0
+ mov 0, V0 ; first operand failed, store 0 and skip second
jmp _end_4
_clause_3:
- push [$7209]
- mov 160, V1
- pop V0
- cmp V0, V1
+ push [$7209] ; left operand
+ mov 160, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
- cmp LX, 0
+ cmp LX, 0 ; compare result from second operand to 0
not
- mov LX, V0
+ mov LX, V0 ; store second operand result
_end_4:
not V0
- bz
- jmp _end_5
- mov [$7209], V0
+ bz ; check if condition
+ jmp _end_5 ; if succeeds, continue, else jump to end
+ mov [$7209], V0 ; return value
ret
_end_5:
- push [$7209]
+ push [$7209] ; i++
inc [$7209]
pop V0
jmp _body_1
_end_2:
- mov 0, V0
+ mov 0, V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_waitForPressedKey:
+_hid_waitForPressedKey: ; int hid_waitForPressedKey()
_body_6:
not 1
bz
- jmp _end_7
- call _hid_getPressedKey
- mov V0, [$720B]
- push [$720B]
- mov 0, V1
- pop V0
- cmp V0, V1
+ jmp _end_7 ; if while condition fails, jump to end
+ call _hid_getPressedKey ; int hid_getPressedKey()
+ mov V0, [$720B] ; int sk = V0
+ push [$720B] ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
not LX
- bz
- jmp _end_8
- mov [$720B], V0
+ bz ; check if condition
+ jmp _end_8 ; if succeeds, continue, else jump to end
+ mov [$720B], V0 ; return value
ret
_end_8:
jmp _body_6
_end_7:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getMouseIndex:
- mov $602F, V0
- mov [V0], V0
+_hid_getMouseIndex: ; int hid_getMouseIndex()
+ mov $602F, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getMouseState:
- push $602F
- mov 2, V1
- pop V0
- add V0, V1
- mov AX, V0
- mov [V0], V0
+_hid_getMouseState: ; int hid_getMouseState()
+ push $602F ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_screen_setPixel_int_x__int_y__int_c:
- pop V0
- pop [$720D]
- pop [$720F]
- pop [$7211]
- push V0
- mov $402F, [$7213]
- push [$720F]
- mov 128, V1
- pop V0
- mul V0, V1
- push AX
- mov [$720D], V1
- pop V0
- add V0, V1
- mov AX, [$7215]
- push [$7213]
- mov [$7215], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$7211], [V0]
- mov 0, V0
+_screen_setPixel_int_x__int_y__int_c:; int screen_setPixel(int x, int y, int c)
+ pop V0 ; preserve function return address
+ pop [$720D] ; param int x
+ pop [$720F] ; param int y
+ pop [$7211] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7213] ; int screenStart = $402F
+ push [$720F] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$720D], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$7215] ; int i = AX
+ push [$7213] ; store index obj
+ mov [$7215], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7211], [V0] ; [V0] = [$7211]
+ mov 0, V0 ; fallback return 0
ret
-_screen_setPixel_int_i__int_c:
- pop V0
- pop [$7217]
- pop [$7219]
- push V0
- mov $402F, [$721B]
- push [$721B]
- mov [$7217], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$7219], [V0]
- mov 0, V0
+_screen_setPixel_int_i__int_c:; int screen_setPixel(int i, int c)
+ pop V0 ; preserve function return address
+ pop [$7217] ; param int i
+ pop [$7219] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$721B] ; int screenStart = $402F
+ push [$721B] ; store index obj
+ mov [$7217], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7219], [V0] ; [V0] = [$7219]
+ mov 0, V0 ; fallback return 0
ret
-_screen_clear_int_c:
- pop V0
- pop [$721D]
- push V0
- mov $402F, [$721F]
- mov 0, [$7221]
+_screen_clear_int_c: ; int screen_clear(int c)
+ pop V0 ; preserve function return address
+ pop [$721D] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$721F] ; int screenStart = $402F
+ mov 0, [$7221] ; int i = 0
_body_9:
- push [$7221]
- push 128
- mov 64, V1
- pop V0
- mul V0, V1
- mov AX, V1
- pop V0
- lt V0, V1
+ push [$7221] ; left operand
+ push 128 ; left operand
+ mov 64, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_10
- push [$721F]
- mov [$7221], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$721D], [V0]
- push [$7221]
+ jmp _end_10 ; if for condition fails, jump to end
+ push [$721F] ; store index obj
+ mov [$7221], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$721D], [V0] ; [V0] = [$721D]
+ push [$7221] ; i++
inc [$7221]
pop V0
jmp _body_9
_end_10:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_main:
- mov 0, [$7223]
+_main: ; int main()
+ mov 0, [$7223] ; int color = 0
_body_11:
not 1
bz
- jmp _end_12
- call _hid_getMouseIndex
- mov V0, [$7225]
- call _hid_getMouseState
- mov V0, [$7227]
- push [$7227]
- mov 1, V1
- pop V0
- and V0, V1
+ jmp _end_12 ; if while condition fails, jump to end
+ call _hid_getMouseIndex ; int hid_getMouseIndex()
+ mov V0, [$7225] ; int mouseIndex = V0
+ call _hid_getMouseState ; int hid_getMouseState()
+ mov V0, [$7227] ; int mouseState = V0
+ push [$7227] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
not DX
- bz
- jmp _end_13
- push [$7223]
- mov 3, V1
- pop V0
- mod V0, V1
- push AX
- mov 1, V1
- pop V0
- add V0, V1
- push AX
- push [$7225]
- call _screen_setPixel_int_i__int_c
+ bz ; check if condition
+ jmp _end_13 ; if succeeds, continue, else jump to end
+ push [$7223] ; left operand
+ mov 3, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ push AX ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; arg int i
+ push [$7225] ; arg int c
+ call _screen_setPixel_int_i__int_c; int screen_setPixel(int i, int c)
_end_13:
- push 67
- call _hid_getKeyState_int_scanCode
+ push 67 ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
not V0
- bz
- jmp _end_14
- push 8
- call _screen_clear_int_c
+ bz ; check if condition
+ jmp _end_14 ; if succeeds, continue, else jump to end
+ push 8 ; arg int c
+ call _screen_clear_int_c ; int screen_clear(int c)
_end_14:
- push 65
- call _hid_getKeyState_int_scanCode
+ push 65 ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
not V0
- bz
- jmp _end_15
- push [$7223]
+ bz ; check if condition
+ jmp _end_15 ; if succeeds, continue, else jump to end
+ push [$7223] ; i++
inc [$7223]
pop V0
_body_16:
- push 65
- call _hid_getKeyState_int_scanCode
+ push 65 ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
not V0
bz
- jmp _end_17
+ jmp _end_17 ; if while condition fails, jump to end
jmp _body_16
_end_17:
_end_15:
jmp _body_11
_end_12:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
diff --git a/ROMs/typewriter.asm b/ROMs/typewriter.asm
index a2369c3..a9379d9 100644
--- a/ROMs/typewriter.asm
+++ b/ROMs/typewriter.asm
@@ -1,461 +1,461 @@
jmp _main
.include "font.bin"
-_screen_setPixel_int_x__int_y__int_c:
- pop V0
- pop [$71FF]
- pop [$7201]
- pop [$7203]
- push V0
- mov $402F, [$7205]
- push [$7201]
- mov 128, V1
- pop V0
- mul V0, V1
- push AX
- mov [$71FF], V1
- pop V0
- add V0, V1
- mov AX, [$7207]
- push [$7205]
- mov [$7207], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$7203], [V0]
- mov 0, V0
+_screen_setPixel_int_x__int_y__int_c:; int screen_setPixel(int x, int y, int c)
+ pop V0 ; preserve function return address
+ pop [$71FF] ; param int x
+ pop [$7201] ; param int y
+ pop [$7203] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7205] ; int screenStart = $402F
+ push [$7201] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$71FF], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$7207] ; int i = AX
+ push [$7205] ; store index obj
+ mov [$7207], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7203], [V0] ; [V0] = [$7203]
+ mov 0, V0 ; fallback return 0
ret
-_screen_setPixel_int_i__int_c:
- pop V0
- pop [$7209]
- pop [$720B]
- push V0
- mov $402F, [$720D]
- push [$720D]
- mov [$7209], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$720B], [V0]
- mov 0, V0
+_screen_setPixel_int_i__int_c:; int screen_setPixel(int i, int c)
+ pop V0 ; preserve function return address
+ pop [$7209] ; param int i
+ pop [$720B] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$720D] ; int screenStart = $402F
+ push [$720D] ; store index obj
+ mov [$7209], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720B], [V0] ; [V0] = [$720B]
+ mov 0, V0 ; fallback return 0
ret
-_screen_clear_int_c:
- pop V0
- pop [$720F]
- push V0
- mov $402F, [$7211]
- mov 0, [$7213]
+_screen_clear_int_c: ; int screen_clear(int c)
+ pop V0 ; preserve function return address
+ pop [$720F] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7211] ; int screenStart = $402F
+ mov 0, [$7213] ; int i = 0
_body_1:
- push [$7213]
- push 128
- mov 64, V1
- pop V0
- mul V0, V1
- mov AX, V1
- pop V0
- lt V0, V1
+ push [$7213] ; left operand
+ push 128 ; left operand
+ mov 64, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_2
- push [$7211]
- mov [$7213], V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- movb [$720F], [V0]
- push [$7213]
+ jmp _end_2 ; if for condition fails, jump to end
+ push [$7211] ; store index obj
+ mov [$7213], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720F], [V0] ; [V0] = [$720F]
+ push [$7213] ; i++
inc [$7213]
pop V0
jmp _body_1
_end_2:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getKeyState_int_scanCode:
- pop V0
- pop [$7215]
- push V0
- mov $6033, [$7217]
- push [$7215]
- mov 8, V1
- pop V0
- div V0, V1
- mov AX, [$7219]
- push [$7215]
- mov 8, V1
- pop V0
- mod V0, V1
- mov AX, [$721B]
- push [$7217]
- push [$7219]
- mov 1, V1
- pop V0
- sub V0, V1
- mov AX, V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- mov [V0], [$721D]
- push [$721D]
- push 1
- mov [$721B], V1
- pop V0
- shl V0, V1
- mov DX, V1
- pop V0
- and V0, V1
- push DX
- mov 0, V1
- pop V0
- cmp V0, V1
+_hid_getKeyState_int_scanCode:; int hid_getKeyState(int scanCode)
+ pop V0 ; preserve function return address
+ pop [$7215] ; param int scanCode
+ push V0 ; restore function return address
+ mov $6033, [$7217] ; int sk_table = $6033
+ push [$7215] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$7219] ; int index = AX
+ push [$7215] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$721B] ; int bit = AX
+ push [$7217] ; store index obj
+ push [$7219] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ mov AX, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$721D] ; int val = [V0]
+ push [$721D] ; left operand
+ push 1 ; left operand
+ mov [$721B], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
- mov LX, V0
+ mov LX, V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getPressedKey:
- mov 0, [$721F]
+_hid_getPressedKey: ; int hid_getPressedKey()
+ mov 0, [$721F] ; int sk = 0
_body_3:
- push [$721F]
- mov 256, V1
- pop V0
- lt V0, V1
+ push [$721F] ; left operand
+ mov 256, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_4
- push [$721F]
- call _hid_getKeyState_int_scanCode
- cmp V0, 0
+ jmp _end_4 ; if for condition fails, jump to end
+ push [$721F] ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
+ cmp V0, 0 ; logical and
not
bz
jmp _clause_5
- mov 0, V0
+ mov 0, V0 ; first operand failed, store 0 and skip second
jmp _end_6
_clause_5:
- push [$721F]
- mov 160, V1
- pop V0
- cmp V0, V1
+ push [$721F] ; left operand
+ mov 160, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
- cmp LX, 0
+ cmp LX, 0 ; compare result from second operand to 0
not
- mov LX, V0
+ mov LX, V0 ; store second operand result
_end_6:
not V0
- bz
- jmp _end_7
- mov [$721F], V0
+ bz ; check if condition
+ jmp _end_7 ; if succeeds, continue, else jump to end
+ mov [$721F], V0 ; return value
ret
_end_7:
- push [$721F]
+ push [$721F] ; i++
inc [$721F]
pop V0
jmp _body_3
_end_4:
- mov 0, V0
+ mov 0, V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_waitForPressedKey:
+_hid_waitForPressedKey: ; int hid_waitForPressedKey()
_body_8:
not 1
bz
- jmp _end_9
- call _hid_getPressedKey
- mov V0, [$7221]
- push [$7221]
- mov 0, V1
- pop V0
- cmp V0, V1
+ jmp _end_9 ; if while condition fails, jump to end
+ call _hid_getPressedKey ; int hid_getPressedKey()
+ mov V0, [$7221] ; int sk = V0
+ push [$7221] ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
not
not LX
- bz
- jmp _end_10
- mov [$7221], V0
+ bz ; check if condition
+ jmp _end_10 ; if succeeds, continue, else jump to end
+ mov [$7221], V0 ; return value
ret
_end_10:
jmp _body_8
_end_9:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getMouseIndex:
- mov $602F, V0
- mov [V0], V0
+_hid_getMouseIndex: ; int hid_getMouseIndex()
+ mov $602F, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_hid_getMouseState:
- push $602F
- mov 2, V1
- pop V0
- add V0, V1
- mov AX, V0
- mov [V0], V0
+_hid_getMouseState: ; int hid_getMouseState()
+ push $602F ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, V0 ; move pointer into register for dereference
+ mov [V0], V0 ; return value
ret
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_drawChar_int_ch__int_x__int_y__int_color:
- pop V0
- pop [$7223]
- pop [$7225]
- pop [$7227]
- pop [$7229]
- push V0
+_drawChar_int_ch__int_x__int_y__int_color:; int drawChar(int ch, int x, int y, int color)
+ pop V0 ; preserve function return address
+ pop [$7223] ; param int ch
+ pop [$7225] ; param int x
+ pop [$7227] ; param int y
+ pop [$7229] ; param int color
+ push V0 ; restore function return address
; adjust for jmp instruction
- push $1FFF
- mov 2, V1
- pop V0
- add V0, V1
- mov AX, [$722B]
- push [$7223]
- mov 8, V1
- pop V0
- mul V0, V1
- mov AX, [$722D]
- mov 0, [$722F]
+ push $1FFF ; left operand
+ mov 2, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$722B] ; int fontStart = AX
+ push [$7223] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, [$722D] ; int charStart = AX
+ mov 0, [$722F] ; int yOff = 0
_body_11:
- push [$722F]
- mov 8, V1
- pop V0
- lt V0, V1
+ push [$722F] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_12
- push [$722B]
- push [$722D]
- mov [$722F], V1
- pop V0
- add V0, V1
- mov AX, V1
- pop V0
- mul V1, 1
- add AX, V0
- mov AX, V0
- mov [V0], [$7231]
- mov 0, [$7233]
+ jmp _end_12 ; if for condition fails, jump to end
+ push [$722B] ; store index obj
+ push [$722D] ; left operand
+ mov [$722F], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7231] ; int row = [V0]
+ mov 0, [$7233] ; int xOff = 0
_body_13:
- push [$7233]
- mov 8, V1
- pop V0
- lt V0, V1
+ push [$7233] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_14
- push [$7231]
- push 7
- mov [$7233], V1
- pop V0
- sub V0, V1
- mov AX, V1
- pop V0
- shr V0, V1
- push DX
- mov 1, V1
- pop V0
- and V0, V1
- mov DX, [$7235]
- bz [$7235]
+ jmp _end_14 ; if for condition fails, jump to end
+ push [$7231] ; left operand
+ push 7 ; left operand
+ mov [$7233], V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ shr V0, V1 ; compute right shift
+ push DX ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ mov DX, [$7235] ; int bit = DX
+ bz [$7235] ; check ternary condition
jmp _then_15
- mov [$7229], V0
+ mov [$7229], V0 ; store ternary fail result
jmp _end_16
_then_15:
- mov 8, V0
+ mov 8, V0 ; store ternary success result
_end_16:
- mov V0, [$7237]
- push [$7237]
- push [$7227]
- mov [$722F], V1
- pop V0
- add V0, V1
- push AX
- push [$7225]
- mov [$7233], V1
- pop V0
- add V0, V1
- push AX
- call _screen_setPixel_int_x__int_y__int_c
- push [$7233]
+ mov V0, [$7237] ; int pix = V0
+ push [$7237] ; arg int x
+ push [$7227] ; left operand
+ mov [$722F], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; arg int y
+ push [$7225] ; left operand
+ mov [$7233], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; arg int c
+ call _screen_setPixel_int_x__int_y__int_c; int screen_setPixel(int x, int y, int c)
+ push [$7233] ; i++
inc [$7233]
pop V0
jmp _body_13
_end_14:
- push [$722F]
+ push [$722F] ; i++
inc [$722F]
pop V0
jmp _body_11
_end_12:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_print_int*_text__int_len__int_x__int_y__int_color:
- pop V0
- pop [$7239]
- pop [$723B]
- pop [$723D]
- pop [$723F]
- pop [$7241]
- push V0
- mov 0, [$7243]
+_print_int*_text__int_len__int_x__int_y__int_color:; int print(int* text, int len, int x, int y, int color)
+ pop V0 ; preserve function return address
+ pop [$7239] ; param int* text
+ pop [$723B] ; param int len
+ pop [$723D] ; param int x
+ pop [$723F] ; param int y
+ pop [$7241] ; param int color
+ push V0 ; restore function return address
+ mov 0, [$7243] ; int i = 0
_body_17:
- push [$7243]
- mov [$723B], V1
- pop V0
- lt V0, V1
+ push [$7243] ; left operand
+ mov [$723B], V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
bz
- jmp _end_18
- push [$7239]
- mov [$7243], V1
- pop V0
- mul V1, 2
- add AX, V0
- mov AX, V0
- mov [V0], [$7245]
- push [$7241]
- push [$723F]
- push [$723D]
- push [$7243]
- mov 8, V1
- pop V0
- mul V0, V1
- mov AX, V1
- pop V0
- add V0, V1
- push AX
- push [$7245]
- call _drawChar_int_ch__int_x__int_y__int_color
- push [$7243]
+ jmp _end_18 ; if for condition fails, jump to end
+ push [$7239] ; store index obj
+ mov [$7243], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 2 ; multiply indexer by 2
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7245] ; int ch = [V0]
+ push [$7241] ; arg int ch
+ push [$723F] ; arg int x
+ push [$723D] ; left operand
+ push [$7243] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; arg int y
+ push [$7245] ; arg int color
+ call _drawChar_int_ch__int_x__int_y__int_color; int drawChar(int ch, int x, int y, int color)
+ push [$7243] ; i++
inc [$7243]
pop V0
jmp _body_17
_end_18:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret
-_main:
- mov 0, [$7247]
- mov 0, [$7249]
+_main: ; int main()
+ mov 0, [$7247] ; int x = 0
+ mov 0, [$7249] ; int y = 0
_body_19:
not 1
bz
- jmp _end_20
- push [$7247]
- mov 128, V1
- pop V0
- cmp V0, V1
+ jmp _end_20 ; if while condition fails, jump to end
+ push [$7247] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute equality check
bz
jmp _end_21
gt V0, V1
_end_21:
not LX
- bz
- jmp _end_22
- mov 0, [$7247]
- push [$7249]
- mov 8, V1
- pop V0
- add V0, V1
- push AX
- pop V1
- mov V1, [$7249]
+ bz ; check if condition
+ jmp _end_22 ; if succeeds, continue, else jump to end
+ mov 0, [$7247] ; [$7247] = 0
+ push [$7249] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7249] ; store back into left param
_end_22:
- push [$7249]
- mov 64, V1
- pop V0
- cmp V0, V1
+ push [$7249] ; left operand
+ mov 64, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute equality check
bz
jmp _end_23
gt V0, V1
_end_23:
not LX
- bz
- jmp _end_24
- mov 0, [$7247]
- mov 0, [$7249]
- push 8
- call _screen_clear_int_c
+ bz ; check if condition
+ jmp _end_24 ; if succeeds, continue, else jump to end
+ mov 0, [$7247] ; [$7247] = 0
+ mov 0, [$7249] ; [$7249] = 0
+ push 8 ; arg int c
+ call _screen_clear_int_c ; int screen_clear(int c)
_end_24:
- call _hid_waitForPressedKey
- mov V0, [$724B]
+ call _hid_waitForPressedKey; int hid_waitForPressedKey()
+ mov V0, [$724B] ; int sk = V0
_body_25:
- push [$724B]
- call _hid_getKeyState_int_scanCode
+ push [$724B] ; arg int scanCode
+ call _hid_getKeyState_int_scanCode; int hid_getKeyState(int scanCode)
not V0
bz
- jmp _end_26
+ jmp _end_26 ; if while condition fails, jump to end
jmp _body_25
_end_26:
- push [$724B]
- mov 13, V1
- pop V0
- cmp V0, V1
+ push [$724B] ; left operand
+ mov 13, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute equality check
not LX
- bz
- jmp _end_27
- push [$7249]
- mov 8, V1
- pop V0
- add V0, V1
- push AX
- pop V1
- mov V1, [$7249]
- mov 0, [$7247]
- jmp _body_19
+ bz ; check if condition
+ jmp _end_27 ; if succeeds, continue, else jump to end
+ push [$7249] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7249] ; store back into left param
+ mov 0, [$7247] ; [$7247] = 0
+ jmp _body_19 ; continue
_end_27:
- push [$724B]
- mov 8, V1
- pop V0
- cmp V0, V1
+ push [$724B] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute equality check
not LX
- bz
- jmp _end_28
- push [$7247]
- mov 8, V1
- pop V0
- sub V0, V1
- push AX
- pop V1
- mov V1, [$7247]
- push [$7247]
- mov 0, V1
- pop V0
- lt V0, V1
+ bz ; check if condition
+ jmp _end_28 ; if succeeds, continue, else jump to end
+ push [$7247] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ push AX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7247] ; store back into left param
+ push [$7247] ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
not LX
- bz
- jmp _end_29
- mov 0, [$7247]
+ bz ; check if condition
+ jmp _end_29 ; if succeeds, continue, else jump to end
+ mov 0, [$7247] ; [$7247] = 0
_end_29:
- push 1
- push [$7249]
- push [$7247]
- push 32
- call _drawChar_int_ch__int_x__int_y__int_color
- jmp _body_19
+ push 1 ; arg int ch
+ push [$7249] ; arg int x
+ push [$7247] ; arg int y
+ push 32 ; arg int color
+ call _drawChar_int_ch__int_x__int_y__int_color; int drawChar(int ch, int x, int y, int color)
+ jmp _body_19 ; continue
_end_28:
- push 1
- push [$7249]
- push [$7247]
- push [$724B]
- call _drawChar_int_ch__int_x__int_y__int_color
- push [$7247]
- mov 8, V1
- pop V0
- add V0, V1
- push AX
- pop V1
- mov V1, [$7247]
+ push 1 ; arg int ch
+ push [$7249] ; arg int x
+ push [$7247] ; arg int y
+ push [$724B] ; arg int color
+ call _drawChar_int_ch__int_x__int_y__int_color; int drawChar(int ch, int x, int y, int color)
+ push [$7247] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; computation results
+ pop V1 ; get computation results back
+ mov V1, [$7247] ; store back into left param
jmp _body_19
_end_20:
- mov 0, V0
+ mov 0, V0 ; fallback return 0
ret