summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-10-01 19:16:54 -0700
committerMichael Pavone <pavone@retrodev.com>2018-10-01 19:16:54 -0700
commit701c5fddc2d25d8d370995ac7fec6762b6aeaed4 (patch)
tree226e1803fd7d23542f23fffbb4980bbecac8151b
parent69f2e0fe14e4af99ddc56b6d7caee38e2150b33c (diff)
Clean up warnings from -1 case
-rwxr-xr-xcpu_dsl.py7
-rw-r--r--svp.cpu4
2 files changed, 6 insertions, 5 deletions
diff --git a/cpu_dsl.py b/cpu_dsl.py
index e81f756..6c9d80d 100755
--- a/cpu_dsl.py
+++ b/cpu_dsl.py
@@ -489,8 +489,9 @@ class Switch(ChildBlock):
def addOp(self, op):
if op.op == 'case':
- self.cases[int(op.params[0])] = self.current_case = []
- self.case_locals[int(op.params[0])] = self.current_locals = {}
+ val = int(op.params[0], 16) if op.params[0].startswith('0x') else int(op.params[0])
+ self.cases[val] = self.current_case = []
+ self.case_locals[val] = self.current_locals = {}
elif op.op == 'default':
self.default = self.current_case = []
self.default_locals = self.current_locals = {}
@@ -543,7 +544,7 @@ class Switch(ChildBlock):
for case in self.cases:
self.current_locals = self.case_locals[case]
self.regValues = dict(self.parent.regValues)
- output.append('\n\tcase {0}: '.format(case) + '{')
+ output.append('\n\tcase {0}U: '.format(case) + '{')
for local in self.case_locals[case]:
output.append('\n\tuint{0}_t {1};'.format(self.case_locals[case][local], local))
for op in self.cases[case]:
diff --git a/svp.cpu b/svp.cpu
index 07e04f6..d6c7fb7 100644
--- a/svp.cpu
+++ b/svp.cpu
@@ -36,9 +36,9 @@ svp_pop
svp_push
arg src 16
- add -1 stackidx stackidx
+ sub 1 stackidx stackidx
switch stackidx
- case -1
+ case 0xFF
mov 5 stackidx
end
mov src stack.stackidx