diff options
Diffstat (limited to 'src/devices/cpu/h8/h8make.py')
-rw-r--r-- | src/devices/cpu/h8/h8make.py | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/src/devices/cpu/h8/h8make.py b/src/devices/cpu/h8/h8make.py index 99883e92c2a..728dadc5953 100644 --- a/src/devices/cpu/h8/h8make.py +++ b/src/devices/cpu/h8/h8make.py @@ -18,6 +18,8 @@ def name_to_type(name): return 2 if name == "s26": return 3 + if name == "g": + return 4 sys.stderr.write("Unknown chip type name %s\n" % name) sys.exit(1) @@ -29,7 +31,9 @@ def type_to_device(dtype, mode): return "h8h_device" if dtype == 2: return "h8s2000_device" - return "h8s2600_device" + if dtype == 3: + return "h8s2600_device" + return "gt913_device" else: if dtype == 0: return "h8_disassembler" @@ -37,7 +41,9 @@ def type_to_device(dtype, mode): return "h8h_disassembler" if dtype == 2: return "h8s2000_disassembler" - return "h8s2600_disassembler" + if dtype == 3: + return "h8s2600_disassembler" + return "gt913_disassembler" def hexsplit(str): res = [] @@ -46,7 +52,7 @@ def hexsplit(str): return res def has_memory(ins): - for s in ["read", "write", "sp_push", "sp_pop", "sp32_push", "sp32_pop", "fetch(", "prefetch_start(", "prefetch(", "prefetch_noirq("]: + for s in ["read", "write"]: if s in ins: return True return False @@ -62,11 +68,18 @@ def save_full_one(f, t, name, source): substate = 1 for line in source: if has_memory(line): - print("\tif(icount <= bcount) { inst_substate = %d; return; }" % substate, file=f) print(line, file=f) - substate += 1 + print("\tif(m_icount <= m_bcount) {", file=f) + print("\t\tif(access_to_be_redone()) {", file=f) + print("\t\t\tm_icount++;", file=f) + print("\t\t\tm_inst_substate = %d;" % substate, file=f) + print("\t\t} else", file=f) + print("\t\t\tm_inst_substate = %d;" % (substate+1), file=f) + print("\t\treturn;", file=f) + print("\t}", file=f) + substate += 2 elif has_eat(line): - print("\tif(icount) { icount = bcount; } inst_substate = %d; return;" % substate, file=f) + print("\tif(m_icount) { m_icount = m_bcount; } m_inst_substate = %d; return;" % substate, file=f) substate += 1 else: print(line, file=f) @@ -76,24 +89,34 @@ def save_full_one(f, t, name, source): def save_partial_one(f, t, name, source): print("void %s::%s_partial()" % (t, name), file=f) print("{", file=f) - print("switch(inst_substate) {", file=f) + print("switch(m_inst_substate) {", file=f) print("case 0:", file=f) substate = 1 for line in source: if has_memory(line): - print("\tif(icount <= bcount) { inst_substate = %d; return; }" % substate, file=f) + print("\t[[fallthrough]];", file=f) print("case %d:;" % substate, file=f) print(line, file=f) - substate += 1 + print("\tif(m_icount <= m_bcount) {", file=f) + print("\t\tif(access_to_be_redone()) {", file=f) + print("\t\t\tm_icount++;", file=f) + print("\t\t\tm_inst_substate = %d;" % substate, file=f) + print("\t\t} else", file=f) + print("\t\t\tm_inst_substate = %d;" % (substate+1), file=f) + print("\t\treturn;", file=f) + print("\t}", file=f) + print("\t[[fallthrough]];", file=f) + print("case %d:;" % (substate+1), file=f) + substate += 2 elif has_eat(line): - print("\tif(icount) { icount = bcount; } inst_substate = %d; return;" % substate, file=f) + print("\tif(m_icount) { m_icount = m_bcount; } m_inst_substate = %d; return;" % substate, file=f) print("case %d:;" % substate, file=f) substate += 1 else: print(line, file=f) print("\tbreak;", file=f) print("}", file=f) - print("\tinst_substate = 0;", file=f) + print("\tm_inst_substate = 0;", file=f) print("}", file=f) print("", file=f) @@ -138,7 +161,7 @@ class Opcode: if dtype == 0 and (am1 == "r16h" or am2 == "r16h"): self.mask[len(self.mask) - 1] |= 0x80 extra_words = 0 - if (am1 == "abs16" or am2 == "abs16" or am1 == "abs16e" or am1 == "abs24e") and self.skip == 0: + if (am1 == "abs16" or am2 == "abs16" or am1 == "abs16e" or am1 == "abs22e" or am1 == "abs24e") and self.skip == 0: extra_words += 1 if (am1 == "abs32" or am2 == "abs32") and self.skip == 0: extra_words += 2 @@ -149,7 +172,8 @@ class Opcode: self.extra_words = extra_words base_offset = len(self.val)/2 + self.skip for i in range(0, extra_words): - self.source.append("\tfetch(%d);\n" % (i+base_offset)) + self.source.append("\tm_IR[%d] = read16i(m_PC);" % (i+base_offset)) + self.source.append("\tm_PC += 2;") def description(self): return "%s %s %s" % (self.name, self.am1, self.am2) @@ -194,6 +218,8 @@ class Opcode: flags = "%d | STEP_OVER" % size elif self.name == "rts" or self.name == "rte": flags = "%d | STEP_OUT" % size + elif self.am1 == "rel8" and self.name != "bt" and self.name != "bf": + flags = "%d | STEP_COND" % size else: flags = "%d" % size @@ -260,8 +286,9 @@ class DispatchStep: end = start + self.skip s = [] for i in range(start, end+1): - s.append("\tIR[%d] = fetch();" % i) - s.append("\tinst_state = 0x%x0000 | IR[%d];" % (self.id, end)) + s.append("\tm_IR[%d] = read16i(m_PC);" % i) + s.append("\tm_PC += 2;") + s.append("\tm_inst_state = 0x%x0000 | m_IR[%d];" % (self.id, end)) return s @@ -384,11 +411,11 @@ class OpcodeList: def save_exec(self, f, t, dtype, v): print("void %s::do_exec_%s()" % (t, v), file=f) print("{", file=f) - print("\tswitch(inst_state >> 16) {", file=f) + print("\tswitch(m_inst_state >> 16) {", file=f) for i in range(0, len(self.dispatch_info)+2): if i == 1: print("\tcase 0x01: {", file=f) - print("\t\tswitch(inst_state & 0xffff) {", file=f) + print("\t\tswitch(m_inst_state & 0xffff) {", file=f) for sta in self.states_info: if sta.enabled: print("\t\tcase 0x%02x: state_%s_%s(); break;" % (sta.val & 0xffff, sta.name, v), file=f) @@ -399,7 +426,7 @@ class OpcodeList: if i == 0 or self.dispatch_info[i-2].enabled: print("\tcase 0x%02x: {" % i, file=f) h = self.get(i) - print("\t\tswitch((inst_state >> 8) & 0x%02x) {" % h.mask, file=f) + print("\t\tswitch((m_inst_state >> 8) & 0x%02x) {" % h.mask, file=f) for val, h2 in sorted(h.d.items()): if h2.enabled: fmask = h2.premask | (h.mask ^ 0xff) @@ -419,7 +446,7 @@ class OpcodeList: print("\t\t\t%s_%s();" % (n.function_name(), v), file=f) print("\t\t\tbreak;", file=f) else: - print("\t\t\tswitch(inst_state & 0x%02x) {" % h2.mask, file=f) + print("\t\t\tswitch(m_inst_state & 0x%02x) {" % h2.mask, file=f) if i == 0: mpos = 1 else: @@ -473,7 +500,7 @@ def main(argv): if mode == 's': opcodes.build_dispatch() opcodes.save_opcodes(f, dname) - if dtype == 0: + if dtype == 0 or dtype == 4: opcodes.save_dispatch(f, dname) opcodes.save_exec(f, dname, dtype, "full") opcodes.save_exec(f, dname, dtype, "partial") |