summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-10-04 19:12:56 -0700
committerMichael Pavone <pavone@retrodev.com>2018-10-04 19:12:56 -0700
commit1dab348088655d41be46a1fa33f0e28c0695f86e (patch)
tree56a6bc25f57245591aba72e81086573cc23a00e1
parent701c5fddc2d25d8d370995ac7fec6762b6aeaed4 (diff)
Add the ability for a CPU definition to reference arbitrary C includes and use it to add a placeholder definition of svp_read_16
-rwxr-xr-xcpu_dsl.py3
-rw-r--r--svp.cpu1
-rw-r--r--svp_util.c5
3 files changed, 9 insertions, 0 deletions
diff --git a/cpu_dsl.py b/cpu_dsl.py
index 6c9d80d..33ae62c 100755
--- a/cpu_dsl.py
+++ b/cpu_dsl.py
@@ -893,6 +893,7 @@ class Program:
self.extra_tables = info.get('extra_tables', [])
self.context_type = self.prefix + 'context'
self.body = info.get('body', [None])[0]
+ self.includes = info.get('include', [])
self.flags = flags
self.lastDst = None
self.scopes = []
@@ -930,6 +931,8 @@ class Program:
def build(self, otype):
body = []
pieces = []
+ for include in self.includes:
+ body.append('#include "{0}"\n'.format(include))
for table in self.instructions:
opmap = [None] * (1 << self.opsize)
bodymap = {}
diff --git a/svp.cpu b/svp.cpu
index d6c7fb7..cb12210 100644
--- a/svp.cpu
+++ b/svp.cpu
@@ -3,6 +3,7 @@ info
opcode_size 16
body svp_run_op
header svp.h
+ include svp_util.c
regs
internal 16 scratch1 x y scratch2 st pad pc
diff --git a/svp_util.c b/svp_util.c
new file mode 100644
index 0000000..362646f
--- /dev/null
+++ b/svp_util.c
@@ -0,0 +1,5 @@
+
+void svp_read_16(svp_context *context)
+{
+ context->internal[0] = 0;
+}