aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2019-01-04 21:32:35 -0600
committerAustin Adams <git@austinjadams.com>2019-01-04 21:32:35 -0600
commitf62fafdc1635d08f9446dee3ed21b4fb29c68aef (patch)
tree6d6ee95cd865553473beebeaa9422d969d0a1885
parent98c6c866a3c6e19ba46c08930adcfa1673c3d62e (diff)
downloadnovice-f62fafdc1635d08f9446dee3ed21b4fb29c68aef.tar.gz
novice-f62fafdc1635d08f9446dee3ed21b4fb29c68aef.tar.xz
Begin work on machine code generator
-rw-r--r--novice/assembler/codegen/base.ts10
-rw-r--r--novice/assembler/codegen/codegen.ts13
-rw-r--r--novice/assembler/codegen/index.ts4
-rw-r--r--novice/assembler/parsers/index.ts4
4 files changed, 29 insertions, 2 deletions
diff --git a/novice/assembler/codegen/base.ts b/novice/assembler/codegen/base.ts
new file mode 100644
index 0000000..c67e60c
--- /dev/null
+++ b/novice/assembler/codegen/base.ts
@@ -0,0 +1,10 @@
+import { ParsedAssembly, Section } from '../parsers';
+import { MachineCodeGenerator, MachineCodeSection } from './codegen';
+
+class BaseMachineCodeGenerator implements MachineCodeGenerator {
+ public gen(asm: ParsedAssembly): MachineCodeSection[] {
+ return [];
+ }
+}
+
+export { BaseMachineCodeGenerator };
diff --git a/novice/assembler/codegen/codegen.ts b/novice/assembler/codegen/codegen.ts
new file mode 100644
index 0000000..cf34315
--- /dev/null
+++ b/novice/assembler/codegen/codegen.ts
@@ -0,0 +1,13 @@
+import { ParsedAssembly } from '../parsers';
+
+interface MachineCodeSection {
+ startAddr: number;
+ length: number;
+ words: number[];
+}
+
+interface MachineCodeGenerator {
+ gen(asm: ParsedAssembly): MachineCodeSection[];
+}
+
+export { MachineCodeSection, MachineCodeGenerator };
diff --git a/novice/assembler/codegen/index.ts b/novice/assembler/codegen/index.ts
new file mode 100644
index 0000000..991066f
--- /dev/null
+++ b/novice/assembler/codegen/index.ts
@@ -0,0 +1,4 @@
+import { BaseMachineCodeGenerator } from './base';
+import { MachineCodeGenerator, MachineCodeSection } from './codegen';
+
+export { MachineCodeSection, MachineCodeGenerator, BaseMachineCodeGenerator };
diff --git a/novice/assembler/parsers/index.ts b/novice/assembler/parsers/index.ts
index 2c563a0..d21a455 100644
--- a/novice/assembler/parsers/index.ts
+++ b/novice/assembler/parsers/index.ts
@@ -1,8 +1,8 @@
import ComplxParser from './complx';
-import { ParsedAssembly, Parser } from './parser';
+import { ParsedAssembly, Parser, Section } from './parser';
const parsers: {[s: string]: new() => Parser} = {
complx: ComplxParser,
};
-export { ParsedAssembly, Parser, parsers };
+export { ParsedAssembly, Section, Parser, parsers };