arcompact (nw)

This commit is contained in:
mamehaze 2014-12-26 15:37:30 +00:00
parent b011d09468
commit 2e56b52086
2 changed files with 137 additions and 178 deletions

View File

@ -1745,111 +1745,6 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_09(OPS_32)
}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p00(OPS_32) // MOV<f> b, c
{
int size = 4;
UINT32 limm = 0;
int got_limm = 0;
COMMON32_GET_breg
COMMON32_GET_creg
COMMON32_GET_F
if (creg == LIMM_REG)
{
// opcode iiii iBBB ppII IIII FBBB CCCC CC-- ----
// MOV b <- limm 0010 0RRR 0000 1010 0RRR 1111 10RR RRRR [LIMM] (creg = LIMM)
// MOV.F b <- limm 0010 0RRR 0000 1010 1RRR 1111 10RR RRRR [LIMM] (creg = LIMM)
if (!got_limm)
{
GET_LIMM_32;
size = 8;
}
m_regs[breg] = limm;
if (F)
{ // currently not supported
arcompact_fatal("unimplemented MOV.F %08x", op);
}
return m_pc + (size>>0);
}
else
{
// opcode iiii iBBB ppII IIII FBBB CCCC CC-- ----
// MOV b <- c 0010 0RRR 0000 1010 0RRR cccc ccRR RRRR
// MOV.F b <- c 0010 0RRR 0000 1010 1RRR cccc ccRR RRRR
m_regs[breg] = m_regs[creg];
if (F)
{ // currently not supported
arcompact_fatal("unimplemented MOV.F %08x", op);
}
return m_pc + (size>>0);
}
return m_pc + (size>>0);
}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p01(OPS_32)
{
// opcode iiii i--- ppII IIII F--- uuuu uu-- ----
// MOV b <- u6 0010 0RRR 0100 1010 0RRR uuuu uuRR RRRR
// MOV.F b <- u6 0010 0RRR 0100 1010 1RRR uuuu uuRR RRRR
int size = 4;
COMMON32_GET_breg
COMMON32_GET_u6
COMMON32_GET_F
m_regs[breg] = u;
if (F)
{ // currently not supported
arcompact_fatal("unimplemented MOV.F b <- u6 %08x", op);
}
return m_pc + (size>>0);
}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p10(OPS_32)
{
int size = 4;
COMMON32_GET_breg;
COMMON32_GET_s12;
COMMON32_GET_F;
m_regs[breg] = S;
if (F)
{ // currently not supported
arcompact_fatal("unimplemented MOV.F b <- s12 %08x", op);
}
return m_pc + (size>>0);}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p11_m0(OPS_32)
{
int size = 4;
arcompact_fatal("arcompact_handle04_0a_p11_m0\n");
return m_pc + (size >> 0);
}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p11_m1(OPS_32)
{
int size = 4;
arcompact_fatal("arcompact_handle04_0a_p11_m1\n");
return m_pc + (size >> 0);
}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0b(OPS_32)
{

View File

@ -3,33 +3,75 @@
import sys
import re
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; }"
def EmitGroup04(f,funcname, opname, opexecute):
def EmitGroup04_no_Flags(f, funcname, opname):
print >>f, " // no flag changes"
def EmitGroup04_unsupported_Flags(f, funcname, opname):
print >>f, " arcompact_fatal(\"arcompact_handle%s (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
def EmitGroup04_Flaghandler(f,funcname, opname, flagcondition, flaghandler):
if flagcondition == -1:
print >>f, " if (F)"
print >>f, " {"
flaghandler(f, funcname, opname)
print >>f, " }"
elif flagcondition == 0:
print >>f, " if (0)"
print >>f, " {"
flaghandler(f, funcname, opname)
print >>f, " }"
elif flagcondition == 1:
print >>f, " if (1)"
print >>f, " {"
flaghandler(f, funcname, opname)
print >>f, " }"
def EmitGroup04(f,funcname, opname, opexecute, 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 >>f, " UINT32 limm = 0;"
print >>f, " int got_limm = 0;"
print >>f, " "
print >>f, " COMMON32_GET_breg;"
print >>f, " COMMON32_GET_F;"
if flagcondition == -1:
print >>f, " COMMON32_GET_F;"
print >>f, " COMMON32_GET_creg;"
print >>f, " COMMON32_GET_areg;"
if ignore_a == 0:
print >>f, " COMMON32_GET_areg;"
elif ignore_a == 1:
print >>f, " //COMMON32_GET_areg; // areg is reserved / not used"
print >>f, " "
print >>f, " UINT32 b, c;"
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 >>f, " UINT32 c;"
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 >>f, " "
print >>f, " if (creg == LIMM_REG)"
print >>f, " {"
@ -48,10 +90,7 @@ def EmitGroup04(f,funcname, opname, opexecute):
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, " "
print >>f, " if (F)"
print >>f, " {"
print >>f, " arcompact_fatal(\"arcompact_handle%s_p00 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
print >>f, " }"
EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
print >>f, " return m_pc + (size >> 0);"
print >>f, "}"
print >>f, ""
@ -60,38 +99,50 @@ def EmitGroup04(f,funcname, opname, opexecute):
print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p01(OPS_32)" % (funcname)
print >>f, "{"
print >>f, " int size = 4;"
print >>f, " UINT32 limm = 0;"
if breg_is_dst_only == 0:
print >>f, " UINT32 limm = 0;"
print >>f, "/* int got_limm = 0; */"
print >>f, " "
print >>f, " COMMON32_GET_breg;"
print >>f, " COMMON32_GET_F;"
if flagcondition == -1:
print >>f, " COMMON32_GET_F;"
print >>f, " COMMON32_GET_u6;"
print >>f, " COMMON32_GET_areg;"
if ignore_a == 0:
print >>f, " COMMON32_GET_areg;"
elif ignore_a == 1:
print >>f, " //COMMON32_GET_areg; // areg is reserved / not used"
print >>f, " "
print >>f, " UINT32 b, c;"
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 >>f, " UINT32 c;"
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 >>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 >>f, " %s" % (opexecute)
print >>f, " "
print >>f, " if (F)"
print >>f, " {"
print >>f, " arcompact_fatal(\"arcompact_handle%s_p01 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
print >>f, " }"
EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
print >>f, " return m_pc + (size >> 0);"
print >>f, "}"
print >>f, ""
@ -100,38 +151,49 @@ def EmitGroup04(f,funcname, opname, opexecute):
print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % (funcname)
print >>f, "{"
print >>f, " int size = 4;"
print >>f, " UINT32 limm = 0;"
if breg_is_dst_only == 0:
print >>f, " UINT32 limm = 0;"
print >>f, "/* int got_limm = 0; */"
print >>f, " "
print >>f, " COMMON32_GET_breg;"
print >>f, " COMMON32_GET_F;"
if flagcondition == -1:
print >>f, " COMMON32_GET_F;"
print >>f, " COMMON32_GET_s12;"
print >>f, " COMMON32_GET_areg;"
if ignore_a == 0:
print >>f, " COMMON32_GET_areg;"
elif ignore_a == 1:
print >>f, " //COMMON32_GET_areg; // areg is reserved / not used"
print >>f, " "
print >>f, " UINT32 b, c;"
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 >>f, " UINT32 c;"
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 >>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, " "
print >>f, " if (F)"
print >>f, " {"
print >>f, " arcompact_fatal(\"arcompact_handle%s_p01 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
print >>f, " }"
EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
print >>f, " return m_pc + (size >> 0);"
print >>f, "}"
print >>f, ""
@ -182,23 +244,25 @@ except Exception, err:
sys.exit(1)
EmitGroup04(f, "04_00", "ADD", "m_regs[areg] = b + c;" )
EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_02", "SUB", "m_regs[areg] = b - c;" )
EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_04", "AND", "m_regs[areg] = b & c;" )
EmitGroup04(f, "04_05", "OR", "m_regs[areg] = b | c;" )
EmitGroup04(f, "04_06", "BIC", "m_regs[areg] = b & (~c);" )
EmitGroup04(f, "04_07", "XOR", "m_regs[areg] = b ^ c;" )
EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_05", "OR", "UINT32 result = b | c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_0f", "BSET", "m_regs[areg] = b | (1 << (c & 0x1f));" )
EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c; m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags )
EmitGroup04(f, "04_15", "ADD2", "m_regs[areg] = b + (c << 2);" )
EmitGroup04(f, "04_16", "ADD3", "m_regs[areg] = b + (c << 3);" )
EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f)); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "05_00", "ASL", "m_regs[areg] = b << (c&0x1f);" )
EmitGroup04(f, "05_01", "LSR", "m_regs[areg] = b >> (c&0x1f);" )
EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "05_01", "LSR", "UINT32 result = b >> (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
# xxx_S b, b, u5 format opcodes
EmitGroup17(f, "17_00", "ASL_S", "m_regs[breg] = m_regs[breg] << (u&0x1f);" )