diff options
Diffstat (limited to 'src/emu/cpu')
-rw-r--r-- | src/emu/cpu/arcompact/arcompact_make.py | 513 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8make.py | 118 | ||||
-rwxr-xr-x | src/emu/cpu/m6502/m6502make.py | 6 | ||||
-rw-r--r-- | src/emu/cpu/mcs96/mcs96make.py | 40 |
4 files changed, 342 insertions, 335 deletions
diff --git a/src/emu/cpu/arcompact/arcompact_make.py b/src/emu/cpu/arcompact/arcompact_make.py index dba815b9f70..080fd72b426 100644 --- a/src/emu/cpu/arcompact/arcompact_make.py +++ b/src/emu/cpu/arcompact/arcompact_make.py @@ -1,351 +1,352 @@ #!/usr/bin/python +from __future__ import print_function import sys def EmitGroup04_Handle_NZ_Flags(f, funcname, opname): - print >>f, " if (result & 0x80000000) { STATUS32_SET_N; }" - print >>f, " else { STATUS32_CLEAR_N; }" - print >>f, " if (result == 0x00000000) { STATUS32_SET_Z; }" - print >>f, " else { STATUS32_CLEAR_Z; }" + print(" if (result & 0x80000000) { STATUS32_SET_N; }", file=f) + print(" else { STATUS32_CLEAR_N; }", file=f) + print(" if (result == 0x00000000) { STATUS32_SET_Z; }", file=f) + print(" else { STATUS32_CLEAR_Z; }", file=f) def EmitGroup04_Handle_NZC_LSR1_Flags(f, funcname, opname): - print >>f, " if (result & 0x80000000) { STATUS32_SET_N; }" - print >>f, " else { STATUS32_CLEAR_N; }" - print >>f, " if (result == 0x00000000) { STATUS32_SET_Z; }" - print >>f, " else { STATUS32_CLEAR_Z; }" - print >>f, " if (c == 0x00000001) { STATUS32_SET_C; }" - print >>f, " else { STATUS32_CLEAR_C; }" + print(" if (result & 0x80000000) { STATUS32_SET_N; }", file=f) + print(" else { STATUS32_CLEAR_N; }", file=f) + print(" if (result == 0x00000000) { STATUS32_SET_Z; }", file=f) + print(" else { STATUS32_CLEAR_Z; }", file=f) + print(" if (c == 0x00000001) { STATUS32_SET_C; }", file=f) + print(" else { STATUS32_CLEAR_C; }", file=f) def EmitGroup04_Handle_NZCV_ADD_Flags(f, funcname, opname): - print >>f, " if (result & 0x80000000) { STATUS32_SET_N; }" - print >>f, " else { STATUS32_CLEAR_N; }" - print >>f, " if (result == 0x00000000) { STATUS32_SET_Z; }" - print >>f, " else { STATUS32_CLEAR_Z; }" - print >>f, " if ((b & 0x80000000) == (c & 0x80000000))" - print >>f, " {" - print >>f, " if ((result & 0x80000000) != (b & 0x80000000))" - print >>f, " {" - print >>f, " STATUS32_SET_V;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " STATUS32_CLEAR_V;" - print >>f, " }" - print >>f, " }" - print >>f, " if (b < c)" - print >>f, " {" - print >>f, " STATUS32_SET_C;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " STATUS32_CLEAR_C;" - print >>f, " }" + print(" if (result & 0x80000000) { STATUS32_SET_N; }", file=f) + print(" else { STATUS32_CLEAR_N; }", file=f) + print(" if (result == 0x00000000) { STATUS32_SET_Z; }", file=f) + print(" else { STATUS32_CLEAR_Z; }", file=f) + print(" if ((b & 0x80000000) == (c & 0x80000000))", file=f) + print(" {", file=f) + print(" if ((result & 0x80000000) != (b & 0x80000000))", file=f) + print(" {", file=f) + print(" STATUS32_SET_V;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" STATUS32_CLEAR_V;", file=f) + print(" }", file=f) + print(" }", file=f) + print(" if (b < c)", file=f) + print(" {", file=f) + print(" STATUS32_SET_C;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" STATUS32_CLEAR_C;", file=f) + print(" }", file=f) def EmitGroup04_no_Flags(f, funcname, opname): - print >>f, " // no flag changes" + print(" // no flag changes", file=f) def EmitGroup04_unsupported_Flags(f, funcname, opname): - print >>f, " arcompact_fatal(\"arcompact_handle%s (%s) (F set)\\n\"); // not yet supported" % (funcname, opname) + print(" arcompact_fatal(\"arcompact_handle%s (%s) (F set)\\n\"); // not yet supported" % (funcname, opname), file=f) def EmitGroup04_Flaghandler(f,funcname, opname, flagcondition, flaghandler): if flagcondition == -1: - print >>f, " if (F)" - print >>f, " {" + print(" if (F)", file=f) + print(" {", file=f) flaghandler(f, funcname, opname) - print >>f, " }" + print(" }", file=f) elif flagcondition == 0: - print >>f, " if (0)" - print >>f, " {" + print(" if (0)", file=f) + print(" {", file=f) flaghandler(f, funcname, opname) - print >>f, " }" + print(" }", file=f) elif flagcondition == 1: - print >>f, " if (1)" - print >>f, " {" + print(" if (1)", file=f) + print(" {", file=f) flaghandler(f, funcname, opname) - print >>f, " }" + print(" }", file=f) def EmitGroup04_u5fragment(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler): - print >>f, " int size = 4;" + print(" int size = 4;", file=f) if breg_is_dst_only == 0: - print >>f, " UINT32 limm = 0;" + print(" UINT32 limm = 0;", file=f) - print >>f, "/* int got_limm = 0; */" - print >>f, " " - print >>f, " COMMON32_GET_breg;" + print("/* int got_limm = 0; */", file=f) + print(" ", file=f) + print(" COMMON32_GET_breg;", file=f) if flagcondition == -1: - print >>f, " COMMON32_GET_F;" + print(" COMMON32_GET_F;", file=f) - print >>f, " COMMON32_GET_u6;" + print(" COMMON32_GET_u6;", file=f) if ignore_a == 0: - print >>f, " COMMON32_GET_areg;" + print(" COMMON32_GET_areg;", file=f) elif ignore_a == 1: - print >>f, " //COMMON32_GET_areg; // areg is reserved / not used" + print(" //COMMON32_GET_areg; // areg is reserved / not used", file=f) elif ignore_a == 2: - print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select" + print(" //COMMON32_GET_areg; // areg bits already used as opcode select", file=f) elif ignore_a == 3: - print >>f, " //COMMON32_GET_areg; // areg bits already used as condition code select" - print >>f, " " + print(" //COMMON32_GET_areg; // areg bits already used as condition code select", file=f) + print(" ", file=f) - print >>f, " UINT32 c;" + print(" UINT32 c;", file=f) if breg_is_dst_only == 0: - print >>f, " UINT32 b;" - print >>f, " " - print >>f, " /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */" - print >>f, " if (breg == LIMM_REG)" - print >>f, " {" - print >>f, " GET_LIMM_32;" - print >>f, " size = 8;" - print >>f, "/* got_limm = 1; */" - print >>f, " b = limm;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " b = m_regs[breg];" - print >>f, " }" + print(" UINT32 b;", file=f) + print(" ", file=f) + print(" /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */", file=f) + print(" if (breg == LIMM_REG)", file=f) + print(" {", file=f) + print(" GET_LIMM_32;", file=f) + print(" size = 8;", file=f) + print("/* got_limm = 1; */", file=f) + print(" b = limm;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" b = m_regs[breg];", file=f) + print(" }", file=f) - print >>f, " " - print >>f, " c = u;" - print >>f, " " - print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" + print(" ", file=f) + print(" c = u;", file=f) + print(" ", file=f) + print(" /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */", file=f) def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler): # the mode 0x00 handler - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p00(OPS_32)" % funcname - print >>f, "{" - print >>f, " int size = 4;" + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p00(OPS_32)" % funcname, file=f) + print("{", file=f) + print(" int size = 4;", file=f) - print >>f, " UINT32 limm = 0;" + print(" UINT32 limm = 0;", file=f) - print >>f, " int got_limm = 0;" - print >>f, " " - print >>f, " COMMON32_GET_breg;" + print(" int got_limm = 0;", file=f) + print(" ", file=f) + print(" COMMON32_GET_breg;", file=f) if flagcondition == -1: - print >>f, " COMMON32_GET_F;" + print(" COMMON32_GET_F;", file=f) - print >>f, " COMMON32_GET_creg;" + print(" COMMON32_GET_creg;", file=f) if ignore_a == 0: - print >>f, " COMMON32_GET_areg;" + print(" COMMON32_GET_areg;", file=f) elif ignore_a == 1: - print >>f, " //COMMON32_GET_areg; // areg is reserved / not used" + print(" //COMMON32_GET_areg; // areg is reserved / not used", file=f) elif ignore_a == 2: - print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select" + print(" //COMMON32_GET_areg; // areg bits already used as opcode select", file=f) - print >>f, " " + print(" ", file=f) - print >>f, " UINT32 c;" + print(" UINT32 c;", file=f) if breg_is_dst_only == 0: - print >>f, " UINT32 b;" - print >>f, " " - print >>f, " if (breg == LIMM_REG)" - print >>f, " {" - print >>f, " GET_LIMM_32;" - print >>f, " size = 8;" - print >>f, " got_limm = 1;" - print >>f, " b = limm;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " b = m_regs[breg];" - print >>f, " }" + print(" UINT32 b;", file=f) + print(" ", file=f) + print(" if (breg == LIMM_REG)", file=f) + print(" {", file=f) + print(" GET_LIMM_32;", file=f) + print(" size = 8;", file=f) + print(" got_limm = 1;", file=f) + print(" b = limm;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" b = m_regs[breg];", file=f) + print(" }", file=f) - print >>f, " " - print >>f, " if (creg == LIMM_REG)" - print >>f, " {" - print >>f, " if (!got_limm)" - print >>f, " {" - print >>f, " GET_LIMM_32;" - print >>f, " size = 8;" - print >>f, " }" - print >>f, " c = limm;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " c = m_regs[creg];" - print >>f, " }" - print >>f, " /* todo: is the limm, limm syntax valid? (it's pointless.) */" - print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite - print >>f, " " + print(" ", file=f) + print(" if (creg == LIMM_REG)", file=f) + print(" {", file=f) + print(" if (!got_limm)", file=f) + print(" {", file=f) + print(" GET_LIMM_32;", file=f) + print(" size = 8;", file=f) + print(" }", file=f) + print(" c = limm;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" c = m_regs[creg];", file=f) + print(" }", file=f) + print(" /* todo: is the limm, limm syntax valid? (it's pointless.) */", file=f) + print(" /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */", file=f) + print(" %s" % opexecute, file=f) + print(" %s" % opwrite, file=f) + print(" ", file=f) EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # the mode 0x01 handler - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p01(OPS_32)" % funcname - print >>f, "{" + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p01(OPS_32)" % funcname, file=f) + print("{", file=f) EmitGroup04_u5fragment(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler) - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite - print >>f, " " + print(" %s" % opexecute, file=f) + print(" %s" % opwrite, file=f) + print(" ", file=f) EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # the mode 0x10 handler - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % funcname + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % funcname, file=f) if ignore_a == 2: - print >>f, "{" - print >>f, " int size = 4;" - print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p10 (ares bits already used as opcode select, can't be used as s12) (%s)\\n\");" % (funcname, opname) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" + print("{", file=f) + print(" int size = 4;", file=f) + print(" arcompact_fatal(\"illegal arcompact_handle%s_p10 (ares bits already used as opcode select, can't be used as s12) (%s)\\n\");" % (funcname, opname), file=f) + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) else: - print >>f, "{" - print >>f, " int size = 4;" + print("{", file=f) + print(" int size = 4;", file=f) if breg_is_dst_only == 0: - print >>f, " UINT32 limm = 0;" + print(" UINT32 limm = 0;", file=f) - print >>f, "/* int got_limm = 0; */" - print >>f, " " - print >>f, " COMMON32_GET_breg;" + print("/* int got_limm = 0; */", file=f) + print(" ", file=f) + print(" COMMON32_GET_breg;", file=f) if flagcondition == -1: - print >>f, " COMMON32_GET_F;" + print(" COMMON32_GET_F;", file=f) - print >>f, " COMMON32_GET_s12;" + print(" COMMON32_GET_s12;", file=f) # areg can't be used here, it's used for s12 bits - print >>f, " " - print >>f, " UINT32 c;" + print(" ", file=f) + print(" UINT32 c;", file=f) if breg_is_dst_only == 0: - print >>f, " UINT32 b;" - print >>f, " " - print >>f, " /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */" - print >>f, " if (breg == LIMM_REG)" - print >>f, " {" - print >>f, " GET_LIMM_32;" - print >>f, " size = 8;" - print >>f, "/* got_limm = 1; */" - print >>f, " b = limm;" - print >>f, " }" - print >>f, " else" - print >>f, " {" - print >>f, " b = m_regs[breg];" - print >>f, " }" + print(" UINT32 b;", file=f) + print(" ", file=f) + print(" /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */", file=f) + print(" if (breg == LIMM_REG)", file=f) + print(" {", file=f) + print(" GET_LIMM_32;", file=f) + print(" size = 8;", file=f) + print("/* got_limm = 1; */", file=f) + print(" b = limm;", file=f) + print(" }", file=f) + print(" else", file=f) + print(" {", file=f) + print(" b = m_regs[breg];", file=f) + print(" }", file=f) - print >>f, " " - print >>f, " c = (UINT32)S;" - print >>f, " " - print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite_alt - print >>f, " " + print(" ", file=f) + print(" c = (UINT32)S;", file=f) + print(" ", file=f) + print(" /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */", file=f) + print(" %s" % opexecute, file=f) + print(" %s" % opwrite_alt, file=f) + print(" ", file=f) EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # the mode 0x11 m0 handler - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m0(OPS_32)" % funcname + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m0(OPS_32)" % funcname, file=f) if ignore_a == 2: - print >>f, "{" - print >>f, " int size = 4;" - print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p11_m0 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" + print("{", file=f) + print(" int size = 4;", file=f) + print(" arcompact_fatal(\"illegal arcompact_handle%s_p11_m0 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname), file=f) + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) else: - print >>f, "{" - print >>f, " int size = 4;" - print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");" % (funcname, opname) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print("{", file=f) + print(" int size = 4;", file=f) + print(" arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");" % (funcname, opname), file=f) + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # the mode 0x11 m1 handler - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m1(OPS_32)" % funcname + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m1(OPS_32)" % funcname, file=f) if ignore_a == 2: - print >>f, "{" - print >>f, " int size = 4;" - print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p11_m1 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" + print("{", file=f) + print(" int size = 4;", file=f) + print(" arcompact_fatal(\"illegal arcompact_handle%s_p11_m1 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname), file=f) + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) else: - print >>f, "{" + print("{", file=f) EmitGroup04_u5fragment(f,funcname, opname, opexecute, opwrite, opwrite_alt, 3, breg_is_dst_only, flagcondition, flaghandler) - print >>f, " COMMON32_GET_CONDITION;" - print >>f, " if (!check_condition(condition))" - print >>f, " return m_pc + (size>>0);" - print >>f, "" - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite_alt - print >>f, " " + print(" COMMON32_GET_CONDITION;", file=f) + print(" if (!check_condition(condition))", file=f) + print(" return m_pc + (size>>0);", file=f) + print("", file=f) + print(" %s" % opexecute, file=f) + print(" %s" % opwrite_alt, file=f) + print(" ", file=f) EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) - print >>f, " return m_pc + (size >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print(" return m_pc + (size >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # xxx_S c, b, u3 format opcodes (note c is destination) def EmitGroup0d(f,funcname, opname, opexecute, opwrite): - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)" % funcname - print >>f, "{" - print >>f, " int u, breg, creg;" - print >>f, "" - print >>f, " COMMON16_GET_u3;" - print >>f, " COMMON16_GET_breg;" - print >>f, " COMMON16_GET_creg;" - print >>f, "" - print >>f, " REG_16BIT_RANGE(breg);" - print >>f, " REG_16BIT_RANGE(creg);" - print >>f, "" - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite - print >>f, "" - print >>f, " return m_pc + (2 >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)" % funcname, file=f) + print("{", file=f) + print(" int u, breg, creg;", file=f) + print("", file=f) + print(" COMMON16_GET_u3;", file=f) + print(" COMMON16_GET_breg;", file=f) + print(" COMMON16_GET_creg;", file=f) + print("", file=f) + print(" REG_16BIT_RANGE(breg);", file=f) + print(" REG_16BIT_RANGE(creg);", file=f) + print("", file=f) + print(" %s" % opexecute, file=f) + print(" %s" % opwrite, file=f) + print("", file=f) + print(" return m_pc + (2 >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # xxx_S b <- b,c format opcodes def EmitGroup0f(f,funcname, opname, opexecute, opwrite): - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)"% funcname - print >>f, "{" - print >>f, " int breg, creg;" - print >>f, "" - print >>f, " COMMON16_GET_breg;" - print >>f, " COMMON16_GET_creg;" - print >>f, "" - print >>f, " REG_16BIT_RANGE(breg);" - print >>f, " REG_16BIT_RANGE(creg);" - print >>f, "" - print >>f, " %s" % opexecute - print >>f, " %s" % opwrite - print >>f, "" - print >>f, " return m_pc + (2 >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)"% funcname, file=f) + print("{", file=f) + print(" int breg, creg;", file=f) + print("", file=f) + print(" COMMON16_GET_breg;", file=f) + print(" COMMON16_GET_creg;", file=f) + print("", file=f) + print(" REG_16BIT_RANGE(breg);", file=f) + print(" REG_16BIT_RANGE(creg);", file=f) + print("", file=f) + print(" %s" % opexecute, file=f) + print(" %s" % opwrite, file=f) + print("", file=f) + print(" return m_pc + (2 >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) # xxx_S b, b, u5 format opcodes def EmitGroup17(f,funcname, opname, opexecute): - print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)" % funcname - print >>f, "{" - print >>f, " int breg, u;" - print >>f, " " - print >>f, " COMMON16_GET_breg;" - print >>f, " COMMON16_GET_u5;" - print >>f, " " - print >>f, " REG_16BIT_RANGE(breg);" - print >>f, " " - print >>f, " %s" % opexecute - print >>f, " " - print >>f, " return m_pc + (2 >> 0);" - print >>f, "}" - print >>f, "" - print >>f, "" + print("ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s(OPS_16)" % funcname, file=f) + print("{", file=f) + print(" int breg, u;", file=f) + print(" ", file=f) + print(" COMMON16_GET_breg;", file=f) + print(" COMMON16_GET_u5;", file=f) + print(" ", file=f) + print(" REG_16BIT_RANGE(breg);", file=f) + print(" ", file=f) + print(" %s" % opexecute, file=f) + print(" ", file=f) + print(" return m_pc + (2 >> 0);", file=f) + print("}", file=f) + print("", file=f) + print("", file=f) diff --git a/src/emu/cpu/h8/h8make.py b/src/emu/cpu/h8/h8make.py index 4cd435df373..929b5d14c4e 100644 --- a/src/emu/cpu/h8/h8make.py +++ b/src/emu/cpu/h8/h8make.py @@ -1,5 +1,7 @@ #!/usr/bin/python +from __future__ import print_function + USAGE = """ Usage: %s h8.lst <type> h8.inc (type = o/h/s20/s26) @@ -45,45 +47,45 @@ def has_eat(ins): return False def save_full_one(f, t, name, source): - print >>f, "void %s::%s_full()" % (t, name) - print >>f, "{" + print("void %s::%s_full()" % (t, name), file=f) + print("{", file=f) substate = 1 for line in source: if has_memory(line): - print >>f, "\tif(icount <= bcount) { inst_substate = %d; return; }" % substate - print >>f, line + print("\tif(icount <= bcount) { inst_substate = %d; return; }" % substate, file=f) + print(line, file=f) substate += 1 elif has_eat(line): - print >>f, "\tif(icount) icount = bcount; inst_substate = %d; return;" % substate + print("\tif(icount) icount = bcount; inst_substate = %d; return;" % substate, file=f) substate += 1 else: - print >>f, line - print >>f, "}" - print >>f + print(line, file=f) + print("}", file=f) + print("", file=f) def save_partial_one(f, t, name, source): - print >>f, "void %s::%s_partial()" % (t, name) - print >>f, "{" - print >>f, "switch(inst_substate) {" - print >>f, "case 0:" + print("void %s::%s_partial()" % (t, name), file=f) + print("{", file=f) + print("switch(inst_substate) {", file=f) + print("case 0:", file=f) substate = 1 for line in source: if has_memory(line): - print >>f, "\tif(icount <= bcount) { inst_substate = %d; return; }" % substate - print >>f, "case %d:;" % substate - print >>f, line + print("\tif(icount <= bcount) { inst_substate = %d; return; }" % substate, file=f) + print("case %d:;" % substate, file=f) + print(line, file=f) substate += 1 elif has_eat(line): - print >>f, "\tif(icount) icount = bcount; inst_substate = %d; return;" % substate - print >>f, "case %d:;" % substate + print("\tif(icount) icount = bcount; inst_substate = %d; return;" % substate, file=f) + print("case %d:;" % substate, file=f) substate += 1 else: - print >>f, line - print >>f, "\tbreak;" - print >>f, "}" - print >>f, "\tinst_substate = 0;" - print >>f, "}" - print >>f + print(line, file=f) + print("\tbreak;", file=f) + print("}", file=f) + print("\tinst_substate = 0;", file=f) + print("}", file=f) + print("", file=f) class Hash: def __init__(self, premask): @@ -185,7 +187,7 @@ class Opcode: else: flags = "%d" % size - print >>f, "\t{ %d, 0x%08x, 0x%08x, 0x%04x, 0x%04x, \"%s\", DASM_%s, DASM_%s, %s }, // %s" % ( slot, val, mask, val2, mask2, self.name, self.am1 if self.am1 != "-" else "none", self.am2 if self.am2 != "-" else "none", flags, "needed" if self.needed else "inherited") + print("\t{ %d, 0x%08x, 0x%08x, 0x%04x, 0x%04x, \"%s\", DASM_%s, DASM_%s, %s }, // %s" % ( slot, val, mask, val2, mask2, self.name, self.am1 if self.am1 != "-" else "none", self.am2 if self.am2 != "-" else "none", flags, "needed" if self.needed else "inherited"), file=f) class Special: def __init__(self, val, name, otype, dtype): @@ -244,7 +246,7 @@ class DispatchStep: return True def source(self): - start = self.pos / 2 + start = self.pos // 2 end = start + self.skip s = [] for i in range(start, end+1): @@ -345,13 +347,13 @@ class OpcodeList: h = self.get(d.id) def save_dasm(self, f, dname): - print >>f, "const %s::disasm_entry %s::disasm_entries[] = {" % (dname, dname) + print("const %s::disasm_entry %s::disasm_entries[] = {" % (dname, dname), file=f) for opc in self.opcode_info: if opc.enabled: opc.save_dasm(f) - print >>f, "\t{ 0, 0, 0, 0, 0, \"illegal\", 0, 0, 2 }," - print >>f, "};" - print >>f + print("\t{ 0, 0, 0, 0, 0, \"illegal\", 0, 0, 2 },", file=f) + print("};", file=f) + print("", file=f) def save_opcodes(self, f, t): for opc in self.opcode_info: @@ -370,24 +372,24 @@ class OpcodeList: save_partial_one(f, t, "dispatch_" + dsp.name, dsp.source()) def save_exec(self, f, t, dtype, v): - print >>f, "void %s::do_exec_%s()" % (t, v) - print >>f, "{" - print >>f, "\tswitch(inst_state >> 16) {" + print("void %s::do_exec_%s()" % (t, v), file=f) + print("{", file=f) + print("\tswitch(inst_state >> 16) {", file=f) for i in range(0, len(self.dispatch_info)+2): if i == 1: - print >>f, "\tcase 0x01: {" - print >>f, "\t\tswitch(inst_state & 0xffff) {" + print("\tcase 0x01: {", file=f) + print("\t\tswitch(inst_state & 0xffff) {", file=f) for sta in self.states_info: if sta.enabled: - print >>f, "\t\tcase 0x%02x: state_%s_%s(); break;" % (sta.val & 0xffff, sta.name, v) - print >>f, "\t\t}" - print >>f, "\t\tbreak;" - print >>f, "\t}" + print("\t\tcase 0x%02x: state_%s_%s(); break;" % (sta.val & 0xffff, sta.name, v), file=f) + print("\t\t}", file=f) + print("\t\tbreak;", file=f) + print("\t}", file=f) else: if i == 0 or self.dispatch_info[i-2].enabled: - print >>f, "\tcase 0x%02x: {" % i + print("\tcase 0x%02x: {" % i, file=f) h = self.get(i) - print >>f, "\t\tswitch((inst_state >> 8) & 0x%02x) {" % h.mask + print("\t\tswitch((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) @@ -398,16 +400,16 @@ class OpcodeList: s += 1 while s & fmask: s += s & fmask - print >>f, "\t\t%s{" % c + print("\t\t%s{" % c, file=f) if h2.mask == 0x00: n = h2.d[0] if n.is_dispatch(): - print >>f, "\t\t\tdispatch_%s_%s();" % (n.name, v) + print("\t\t\tdispatch_%s_%s();" % (n.name, v), file=f) else: - print >>f, "\t\t\t%s_%s();" % (n.function_name(), v) - print >>f, "\t\t\tbreak;" + print("\t\t\t%s_%s();" % (n.function_name(), v), file=f) + print("\t\t\tbreak;", file=f) else: - print >>f, "\t\t\tswitch(inst_state & 0x%02x) {" % h2.mask + print("\t\t\tswitch(inst_state & 0x%02x) {" % h2.mask, file=f) if i == 0: mpos = 1 else: @@ -427,23 +429,23 @@ class OpcodeList: while s & fmask: s += s & fmask if n.is_dispatch(): - print >>f, "\t\t\t%sdispatch_%s_%s(); break;" % (c, n.name, v) + print("\t\t\t%sdispatch_%s_%s(); break;" % (c, n.name, v), file=f) else: - print >>f, "\t\t\t%s%s_%s(); break;" % (c, n.function_name(), v) - print >>f, "\t\t\tdefault: illegal(); break;" - print >>f, "\t\t\t}" - print >>f, "\t\t\tbreak;" - print >>f, "\t\t}" - print >>f, "\t\tdefault: illegal(); break;" - print >>f, "\t\t}" - print >>f, "\t\tbreak;" - print >>f, "\t}" - print >>f, "\t}" - print >>f, "}" + print("\t\t\t%s%s_%s(); break;" % (c, n.function_name(), v), file=f) + print("\t\t\tdefault: illegal(); break;", file=f) + print("\t\t\t}", file=f) + print("\t\t\tbreak;", file=f) + print("\t\t}", file=f) + print("\t\tdefault: illegal(); break;", file=f) + print("\t\t}", file=f) + print("\t\tbreak;", file=f) + print("\t}", file=f) + print("\t}", file=f) + print("}", file=f) def main(argv): if len(argv) != 4: - print USAGE % argv[0] + print(USAGE % argv[0]) return 1 dtype = name_to_type(argv[2]) diff --git a/src/emu/cpu/m6502/m6502make.py b/src/emu/cpu/m6502/m6502make.py index 591d01268ca..4ac62e90ce9 100755 --- a/src/emu/cpu/m6502/m6502make.py +++ b/src/emu/cpu/m6502/m6502make.py @@ -1,5 +1,7 @@ #!/usr/bin/python +from __future__ import print_function + USAGE = """ Usage: %s device_name {opc.lst|-} disp.lst device.inc @@ -52,7 +54,7 @@ def load_disp(fname): def emit(f, text): """write string to file""" - print >>f, text, + print(text, file=f) FULL_PROLOG="""\ void %(device)s::%(opcode)s_full() @@ -252,7 +254,7 @@ def main(argv): if len(argv) != 5: - print USAGE % argv[0] + print(USAGE % argv[0]) return 1 device_name = argv[1] diff --git a/src/emu/cpu/mcs96/mcs96make.py b/src/emu/cpu/mcs96/mcs96make.py index 8381e63dc2f..72d8f36cfa6 100644 --- a/src/emu/cpu/mcs96/mcs96make.py +++ b/src/emu/cpu/mcs96/mcs96make.py @@ -1,5 +1,7 @@ #!/usr/bin/python +from __future__ import print_function + USAGE = """ Usage: %s mcs96ops.lst mcs96.inc @@ -7,12 +9,12 @@ Usage: import sys def save_full_one(f, t, name, source): - print >>f, "void %s_device::%s_full()" % (t, name) - print >>f, "{" + print("void %s_device::%s_full()" % (t, name), file=f) + print("{", file=f) for line in source: - print >>f, line - print >>f, "}" - print >>f + print(line, file=f) + print("}", file=f) + print("", file=f) class Opcode: def __init__(self, rng, name, amode, is_196, ea): @@ -113,7 +115,7 @@ class OpcodeList: self.opcode_per_id[i] = inf def save_dasm(self, f, t): - print >>f, "const %s_device::disasm_entry %s_device::disasm_entries[0x100] = {" % (t, t) + print("const %s_device::disasm_entry %s_device::disasm_entries[0x100] = {" % (t, t), file=f) for i in range(0, 0x100): if i in self.opcode_per_id: opc = self.opcode_per_id[i] @@ -126,11 +128,11 @@ class OpcodeList: flags = "DASMFLAG_STEP_OUT" else: flags = "0" - print >>f, "\t{ \"%s\", %s, DASM_%s, %s }," % (opc.name, alt, opc.amode, flags) + print("\t{ \"%s\", %s, DASM_%s, %s }," % (opc.name, alt, opc.amode, flags), file=f) else: - print >>f, "\t{ \"???\", NULL, DASM_none, 0 }," - print >>f, "};" - print >>f + print("\t{ \"???\", NULL, DASM_none, 0 },", file=f) + print("};", file=f) + print("", file=f) def save_opcodes(self, f, t): pf = "" @@ -146,9 +148,9 @@ class OpcodeList: save_full_one(f, t, "fetch_noirq", self.fetch_noirq.source) def save_exec(self, f, t): - print >>f, "void %s_device::do_exec_full()" % t - print >>f, "{" - print >>f, "\tswitch(inst_state) {" + print("void %s_device::do_exec_full()" % t, file=f) + print("{", file=f) + print("\tswitch(inst_state) {", file=f) for i in range(0x000, 0x200): opc = None if i >= 0x100 and i-0x100+0xfe00 in self.opcode_per_id: @@ -159,15 +161,15 @@ class OpcodeList: nm = opc.name + "_" + opc.amode if opc.is_196: nm += "_196" - print >>f, "\tcase 0x%03x: %s_full(); break;" % (i, nm) - print >>f, "\tcase 0x200: fetch_full(); break;" - print >>f, "\tcase 0x201: fetch_noirq_full(); break;" - print >>f, "\t}" - print >>f, "}" + print("\tcase 0x%03x: %s_full(); break;" % (i, nm), file=f) + print("\tcase 0x200: fetch_full(); break;", file=f) + print("\tcase 0x201: fetch_noirq_full(); break;", file=f) + print("\t}", file=f) + print("}", file=f) def main(argv): if len(argv) != 4: - print USAGE % argv[0] + print(USAGE % argv[0]) return 1 t = argv[1] |