summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar mamehaze <mamehaze@users.noreply.github.com>2014-12-27 13:39:22 +0000
committerGravatarGravatar mamehaze <mamehaze@users.noreply.github.com>2014-12-27 13:39:22 +0000
commit6ae1429c9230b07282e3a0cb62efd53f522c3b88 (patch) (github)
tree7c99b123d4c41ac360ee33d2ff92b55fd97ff3a5
parent03baaf7e99f162a7b2d1d19a58b685c00d1c9fef (diff)
downloadmame-6ae1429c9230b07282e3a0cb62efd53f522c3b88.tar.bz2
mame-6ae1429c9230b07282e3a0cb62efd53f522c3b88.zip
arcompact - it's actually executing code in cartridge space now (nw)
-rw-r--r--src/emu/cpu/arcompact/arcompact.c8
-rw-r--r--src/emu/cpu/arcompact/arcompact.h31
-rw-r--r--src/emu/cpu/arcompact/arcompact_execute.c132
-rw-r--r--src/emu/cpu/arcompact/arcompact_make.py181
-rw-r--r--src/mess/drivers/leapster.c1
5 files changed, 193 insertions, 160 deletions
diff --git a/src/emu/cpu/arcompact/arcompact.c b/src/emu/cpu/arcompact/arcompact.c
index 735a9ecd893..4f229f7a291 100644
--- a/src/emu/cpu/arcompact/arcompact.c
+++ b/src/emu/cpu/arcompact/arcompact.c
@@ -24,9 +24,14 @@
const device_type ARCA5 = &device_creator<arcompact_device>;
+static ADDRESS_MAP_START( arcompact_auxreg_map, AS_IO, 32, arcompact_device )
+ADDRESS_MAP_END
+
+
arcompact_device::arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: cpu_device(mconfig, ARCA5, "ARCtangent-A5", tag, owner, clock, "arca5", __FILE__)
, m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) // some docs describe these as 'middle endian'?!
+ , m_io_config( "io", ENDIANNESS_LITTLE, 32, 34, 0, ADDRESS_MAP_NAME( arcompact_auxreg_map ) ) // IO space is 32 bits of dwords, so 34-bits
{
}
@@ -59,6 +64,7 @@ void arcompact_device::device_start()
m_debugger_temp = 0;
m_program = &space(AS_PROGRAM);
+ m_io = &space(AS_IO);
state_add( 0, "PC", m_debugger_temp).callimport().callexport().formatstr("%08X");
@@ -156,7 +162,9 @@ void arcompact_device::device_reset()
}
+
/*****************************************************************************/
+
void arcompact_device::execute_set_input(int irqline, int state)
{
diff --git a/src/emu/cpu/arcompact/arcompact.h b/src/emu/cpu/arcompact/arcompact.h
index 974df138c97..4bf491daf00 100644
--- a/src/emu/cpu/arcompact/arcompact.h
+++ b/src/emu/cpu/arcompact/arcompact.h
@@ -77,7 +77,7 @@ protected:
virtual void execute_set_input(int inputnum, int state);
// device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; }
+ virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : NULL ); }
// device_state_interface overrides
virtual void state_import(const device_state_entry &entry);
@@ -160,18 +160,18 @@ protected:
ARCOMPACT_RETTYPE arcompact_handle04_0b(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_0c(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_0d(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_0e(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_0e(OPS_32);
// ARCOMPACT_RETTYPE arcompact_handle04_0f(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_10(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_11(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_12(OPS_32);
// ARCOMPACT_RETTYPE arcompact_handle04_13(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_14(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_14(OPS_32);
// ARCOMPACT_RETTYPE arcompact_handle04_15(OPS_32);
// ARCOMPACT_RETTYPE arcompact_handle04_16(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_17(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_18(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_19(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_17(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_18(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_19(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_1a(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_1b(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_1c(OPS_32);
@@ -183,7 +183,7 @@ protected:
ARCOMPACT_RETTYPE arcompact_handle04_28(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_29(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_2a(OPS_32);
- ARCOMPACT_RETTYPE arcompact_handle04_2b(OPS_32);
+// ARCOMPACT_RETTYPE arcompact_handle04_2b(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_2f_00(OPS_32);
ARCOMPACT_RETTYPE arcompact_handle04_2f_01(OPS_32);
// ARCOMPACT_RETTYPE arcompact_handle04_2f_02(OPS_32);
@@ -773,11 +773,17 @@ protected:
ARCOMPACT_HANDLER04_TYPE_PM(04_06);
ARCOMPACT_HANDLER04_TYPE_PM(04_07);
ARCOMPACT_HANDLER04_TYPE_PM(04_0a);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_0e);
ARCOMPACT_HANDLER04_TYPE_PM(04_0f);
ARCOMPACT_HANDLER04_TYPE_PM(04_13);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_14);
ARCOMPACT_HANDLER04_TYPE_PM(04_15);
ARCOMPACT_HANDLER04_TYPE_PM(04_16);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_17);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_18);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_19);
ARCOMPACT_HANDLER04_TYPE_PM(04_20);
+ ARCOMPACT_HANDLER04_TYPE_PM(04_2b);
ARCOMPACT_HANDLER04_TYPE_PM(04_2f_02);
ARCOMPACT_HANDLER04_TYPE_PM(04_2f_07);
@@ -788,11 +794,14 @@ protected:
private:
- address_space_config m_program_config;
+ const address_space_config m_program_config;
+ const address_space_config m_io_config;
UINT32 m_pc;
address_space *m_program;
+ address_space *m_io;
+
int m_icount;
UINT32 m_debugger_temp;
@@ -806,6 +815,10 @@ private:
inline UINT8 READ8(UINT32 address) { return m_program->read_byte(address << 0); }
inline void WRITE8(UINT32 address, UINT8 data){ m_program->write_byte(address << 0, data); }
+ inline UINT64 READAUX(UINT64 address) { return m_io->read_dword(address *4); }
+ inline void WRITEAUX(UINT64 address, UINT32 data) { m_io->write_dword(address *4, data); }
+
+
int check_condition(UINT8 condition);
UINT32 m_regs[0x40];
@@ -853,7 +866,7 @@ private:
#define CONDITION_EQ (STATUS32_CHECK_Z)
#define CONDITION_CS (STATUS32_CHECK_C)
#define CONDITION_LT ((STATUS32_CHECK_N && !STATUS32_CHECK_V) || (!STATUS32_CHECK_N && STATUS32_CHECK_V))
-
+#define CONDITION_MI (STATUS32_CHECK_N)
extern const device_type ARCA5;
diff --git a/src/emu/cpu/arcompact/arcompact_execute.c b/src/emu/cpu/arcompact/arcompact_execute.c
index da8d90f53ee..e5623089737 100644
--- a/src/emu/cpu/arcompact/arcompact_execute.c
+++ b/src/emu/cpu/arcompact/arcompact_execute.c
@@ -148,7 +148,7 @@ int arcompact_device::check_condition(UINT8 condition)
case 0x01: return CONDITION_EQ;
case 0x02: return !CONDITION_EQ; // NE
case 0x03: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
- case 0x04: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
+ case 0x04: return CONDITION_MI; // MI (N)
case 0x05: return CONDITION_CS; // CS (Carry Set / Lower than)
case 0x06: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
case 0x07: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
@@ -1501,7 +1501,19 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle01_01_01_03(OPS_32)
return m_pc + (size>>0);
}
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle01_01_01_04(OPS_32) { return arcompact_01_01_01_helper(PARAMS, "BRLO"); }
+ARCOMPACT_RETTYPE arcompact_device::arcompact_handle01_01_01_04(OPS_32) // register - immediate BRLO
+{
+ BR_REGIMM_SETUP
+
+ // BRLO (unsigned operation)
+ if (b < c)
+ {
+ BR_TAKEJUMP
+ }
+
+ return m_pc + (size>>0);
+
+}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle01_01_01_05(OPS_32) // register - immediate BRHS
{
@@ -1840,10 +1852,6 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0d(OPS_32)
return arcompact_handle04_helper(PARAMS, opcodes_04[0x0d], /*"RCMP"*/ 1,0);
}
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0e(OPS_32)
-{
- return arcompact_handle04_helper(PARAMS, opcodes_04[0x0e], /*"RSUB"*/ 0,0);
-}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_10(OPS_32)
@@ -1863,28 +1871,8 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_12(OPS_32)
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_14(OPS_32)
-{
- return arcompact_handle04_helper(PARAMS, opcodes_04[0x14], /*"ADD1"*/ 0,0);
-}
-
-
-
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_17(OPS_32)
-{
- return arcompact_handle04_helper(PARAMS, opcodes_04[0x17], /*"SUB1"*/ 0,0);
-}
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_18(OPS_32)
-{
- return arcompact_handle04_helper(PARAMS, opcodes_04[0x18], /*"SUB2"*/ 0,0);
-}
-
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_19(OPS_32)
-{
- return arcompact_handle04_helper(PARAMS, opcodes_04[0x19], /*"SUB3"*/ 0,0);
-}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_1a(OPS_32)
{
@@ -1913,6 +1901,7 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_20_p00(OPS_32)
int got_limm = 0;
COMMON32_GET_creg
+ COMMON32_GET_F
if (creg == LIMM_REG)
{
@@ -1934,7 +1923,32 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_20_p00(OPS_32)
// J.F [ilink1] 0010 0RRR 0010 0000 1RRR 0111 01RR RRRR (creg = ILINK1, FLAG must be set)
// J.F [ilink2] 0010 0RRR 0010 0000 1RRR 0111 10RR RRRR (creg = ILINE2, FLAG must be set)
- arcompact_log("unimplemented J %08x", op);
+ if (F)
+ {
+ if ((creg == REG_ILINK1) || (creg == REG_ILINK2))
+ {
+ arcompact_log("1 unimplemented J.F %08x", op);
+ }
+ else
+ {
+ // should not use .F unless jumping to ILINK1/2
+ arcompact_fatal ("illegal 1 unimplemented J.F (F should not be set) %08x", op);
+ }
+
+ }
+ else
+ {
+ if ((creg == REG_ILINK1) || (creg == REG_ILINK2))
+ {
+ // should only jumping to ILINK1/2 if .F is set
+ arcompact_fatal("illegal 1 unimplemented J (F not set) %08x", op);
+ }
+ else
+ {
+
+ return m_regs[creg];
+ }
+ }
}
return m_pc + (size>>0);
@@ -1945,7 +1959,7 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_20_p01(OPS_32)
// opcode iiii i--- ppII IIII F--- uuuu uu-- ----
// J u6 0010 0RRR 0110 0000 0RRR uuuu uuRR RRRR
int size = 4;
- arcompact_log("unimplemented J %08x", op);
+ arcompact_log("2 unimplemented J %08x", op);
return m_pc + (size>>0);
}
@@ -1954,7 +1968,7 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_20_p10(OPS_32)
// opcode iiii i--- ppII IIII F--- ssss ssSS SSSS
// J s12 0010 0RRR 1010 0000 0RRR ssss ssSS SSSS
int size = 4;
- arcompact_log("unimplemented J %08x", op);
+ arcompact_log("3 unimplemented J %08x", op);
return m_pc + (size>>0);
}
@@ -2148,56 +2162,6 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2a(OPS_32) // Load FROM
return m_pc + (size>>0);
}
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2b(OPS_32) // Store TO Auxiliary register FROM register
-{
- int size = 4;
-// UINT32 limm = 0;
- int got_limm = 0;
-
- COMMON32_GET_p;
- COMMON32_GET_breg;
-
- if (breg == LIMM_REG)
- {
- //GET_LIMM_32;
- size = 8;
- got_limm = 1;
-
- }
- else
- {
- }
-
- if (p == 0)
- {
-
- COMMON32_GET_creg
-
- if (creg == LIMM_REG)
- {
- if (!got_limm)
- {
- //GET_LIMM_32;
- size = 8;
- }
- }
- else
- {
- }
- }
- else if (p == 1)
- {
- }
- else if (p == 2)
- {
- }
- else if (p == 3)
- {
- }
-
- arcompact_log("unimplemented SR %08x", op);
- return m_pc + (size>>0);
-}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_29(OPS_32)
{
@@ -2672,7 +2636,7 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_06(OPS_16) { return a
// Zero parameters (ZOP)
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_07_00(OPS_16) { arcompact_log("NOP_S"); return m_pc + (2 >> 0);}
+ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_07_00(OPS_16) { /*arcompact_log("NOP_S");*/ return m_pc + (2 >> 0);}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_07_01(OPS_16) { arcompact_log("UNIMP_S"); return m_pc + (2 >> 0);} // Unimplemented Instruction, same as illegal, but recommended to fill blank space
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_07_04(OPS_16) { arcompact_log("JEQ_S [blink]"); return m_pc + (2 >> 0);}
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_00_07_05(OPS_16) { arcompact_log("JNE_S [blink]"); return m_pc + (2 >> 0);}
@@ -2719,12 +2683,10 @@ ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_0e(OPS_16) { return arco
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_11(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ABS_S",0); }
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_12(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "NOT_S",0); }
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_13(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "NEG_S",0); }
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_14(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ADD1_S",0); }
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_15(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ADD2_S",0); }
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_16(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ADD3_S",0); }
+
+
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_18(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASL_S",0); }
-ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_19(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "LSR_S",0); }
+
ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1a(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASR_S",0); }
diff --git a/src/emu/cpu/arcompact/arcompact_make.py b/src/emu/cpu/arcompact/arcompact_make.py
index ca80ae7f408..9268a6c55e0 100644
--- a/src/emu/cpu/arcompact/arcompact_make.py
+++ b/src/emu/cpu/arcompact/arcompact_make.py
@@ -17,6 +17,30 @@ def EmitGroup04_Handle_NZC_LSR1_Flags(f, funcname, opname):
print >>f, " if (c == 0x00000001) { STATUS32_SET_C; }"
print >>f, " else { STATUS32_CLEAR_C; }"
+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, " }"
def EmitGroup04_no_Flags(f, funcname, opname):
@@ -42,6 +66,53 @@ def EmitGroup04_Flaghandler(f,funcname, opname, flagcondition, flaghandler):
flaghandler(f, funcname, opname)
print >>f, " }"
+def EmitGroup04_u5fragment(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler):
+ print >>f, " int size = 4;"
+
+ if breg_is_dst_only == 0:
+ print >>f, " UINT32 limm = 0;"
+
+ print >>f, "/* int got_limm = 0; */"
+ print >>f, " "
+ print >>f, " COMMON32_GET_breg;"
+
+ if flagcondition == -1:
+ print >>f, " COMMON32_GET_F;"
+
+ print >>f, " COMMON32_GET_u6;"
+
+ if ignore_a == 0:
+ print >>f, " COMMON32_GET_areg;"
+ elif ignore_a == 1:
+ print >>f, " //COMMON32_GET_areg; // areg is reserved / not used"
+ elif ignore_a == 2:
+ print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select"
+ elif ignore_a == 3:
+ print >>f, " //COMMON32_GET_areg; // areg bits already used as condition code select"
+ 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?) */"
+
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)
@@ -56,15 +127,15 @@ def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, b
if flagcondition == -1:
print >>f, " COMMON32_GET_F;"
-
+
print >>f, " COMMON32_GET_creg;"
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, " //COMMON32_GET_areg; // areg is reserved / not used"
elif ignore_a == 2:
- print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select"
+ print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select"
print >>f, " "
@@ -111,50 +182,7 @@ def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, b
# the mode 0x01 handler
print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p01(OPS_32)" % (funcname)
print >>f, "{"
- print >>f, " int size = 4;"
-
- if breg_is_dst_only == 0:
- print >>f, " UINT32 limm = 0;"
-
- print >>f, "/* int got_limm = 0; */"
- print >>f, " "
- print >>f, " COMMON32_GET_breg;"
-
- if flagcondition == -1:
- print >>f, " COMMON32_GET_F;"
-
- print >>f, " COMMON32_GET_u6;"
-
- if ignore_a == 0:
- print >>f, " COMMON32_GET_areg;"
- elif ignore_a == 1:
- print >>f, " //COMMON32_GET_areg; // areg is reserved / not used"
- elif ignore_a == 2:
- print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select"
-
- 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?) */"
+ 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, " "
@@ -244,8 +272,15 @@ def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, b
print >>f, "}"
else:
print >>f, "{"
- print >>f, " int size = 4;"
- print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m1 (%s)\\n\");" % (funcname, opname)
+ 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, " "
+ EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
print >>f, " return m_pc + (size >> 0);"
print >>f, "}"
print >>f, ""
@@ -297,25 +332,32 @@ except Exception, err:
sys.exit(1)
-EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_Handle_NZCV_ADD_Flags )
-EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c;", "if (areg != LIMM_REG) { m_regs[areg] = result; }", "if (breg != LIMM_REG) { m_regs[breg] = result; }", 0,0, -1, EmitGroup04_Handle_NZ_Flags )
-EmitGroup04(f, "04_05", "OR", "UINT32 result = b | c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c;", "if (areg != LIMM_REG) { m_regs[areg] = result; }", "if (breg != LIMM_REG) { m_regs[breg] = result; }", 0,0, -1, EmitGroup04_Handle_NZ_Flags )
+EmitGroup04(f, "04_05", "OR", "UINT32 result = b | c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c;", "m_regs[breg] = result;", "m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags ) # special case, result always goes to breg
+EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c;", "m_regs[breg] = result;", "m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags ) # special case, result always goes to breg
+EmitGroup04(f, "04_0e", "RSUB", "UINT32 result = c - b;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f));", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_13", "BMSK", "UINT32 result = b & ((1<<(c+1))-1);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_13", "BMSK", "UINT32 result = b & ((1<<(c+1))-1);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+
+EmitGroup04(f, "04_14", "ADD1", "UINT32 result = b + (c << 1);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_17", "SUB1", "UINT32 result = b - (c << 1);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_18", "SUB2", "UINT32 result = b - (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_19", "SUB3", "UINT32 result = b - (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
+EmitGroup04(f, "04_2b", "SR", "WRITEAUX(c,b);", "", "", 1,0, -1, EmitGroup04_unsupported_Flags ) # this can't be conditional (todo)
-EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
-EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
@@ -327,13 +369,20 @@ EmitGroup04(f, "04_2f_07", "EXTB", "UINT32 result = c & 0x000000ff;", "m_regs[b
EmitGroup04(f, "04_2f_08", "EXTW", "UINT32 result = c & 0x0000ffff;", "m_regs[breg] = result;","", 2,1, -1, EmitGroup04_unsupported_Flags ) # ^
# xxx_S b <- b,c format opcodes (or in some cases xxx_S b,c)
-EmitGroup0f(f, "0f_02", "SUB_S", "UINT32 result = m_regs[breg] - m_regs[creg];", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_04", "AND_S", "UINT32 result = m_regs[breg] & m_regs[creg];", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_05", "OR_S", "UINT32 result = m_regs[breg] | m_regs[creg];", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_07", "XOR_S", "UINT32 result = m_regs[breg] ^ m_regs[creg];", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_0f", "EXTB_S","UINT32 result = m_regs[creg] & 0x000000ff;", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_10", "EXTW_S","UINT32 result = m_regs[creg] & 0x0000ffff;", "m_regs[breg] = result;" )
-EmitGroup0f(f, "0f_1b", "ASL1_S","UINT32 result = m_regs[creg] << 1;", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_02", "SUB_S", "UINT32 result = m_regs[breg] - m_regs[creg];", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_04", "AND_S", "UINT32 result = m_regs[breg] & m_regs[creg];", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_05", "OR_S", "UINT32 result = m_regs[breg] | m_regs[creg];", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_07", "XOR_S", "UINT32 result = m_regs[breg] ^ m_regs[creg];", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_0f", "EXTB_S","UINT32 result = m_regs[creg] & 0x000000ff;", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_10", "EXTW_S","UINT32 result = m_regs[creg] & 0x0000ffff;", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_13", "NEG_S"," UINT32 result = 0 - m_regs[creg];", "m_regs[breg] = result;" )
+
+EmitGroup0f(f, "0f_14", "ADD1_S"," UINT32 result = m_regs[breg] + (m_regs[creg] <<1);", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_15", "ADD2_S"," UINT32 result = m_regs[breg] + (m_regs[creg] <<2);", "m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_16", "ADD3_S"," UINT32 result = m_regs[breg] + (m_regs[creg] <<3);", "m_regs[breg] = result;" )
+
+EmitGroup0f(f, "0f_19", "LSR_S", "UINT32 result = m_regs[breg] >> (m_regs[creg]&0x1f);","m_regs[breg] = result;" )
+EmitGroup0f(f, "0f_1b", "ASL1_S","UINT32 result = m_regs[creg] << 1;", "m_regs[breg] = result;" )
# xxx_S b, b, u5 format opcodes
diff --git a/src/mess/drivers/leapster.c b/src/mess/drivers/leapster.c
index 57f951bd16b..5d25830036c 100644
--- a/src/mess/drivers/leapster.c
+++ b/src/mess/drivers/leapster.c
@@ -284,6 +284,7 @@ static ADDRESS_MAP_START( leapster_map, AS_PROGRAM, 32, leapster_state )
AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_MIRROR(0x40000000) // pointers in the bios region seem to be to the 40xxxxxx region, either we mirror there or something (real bios?) is acutally missing
AM_RANGE(0x0180D800, 0x0180D803) AM_READ(leapster_random_r)
AM_RANGE(0x03000000, 0x030007ff) AM_RAM // puts stack here, writes a pointer @ 0x03000000 on startup
+ AM_RANGE(0x3c000000, 0x3c1fffff) AM_RAM // really ram, or has our code execution gone wrong?
// AM_RANGE(0x80000000, 0x807fffff) AM_ROMBANK("cartrom") // game ROM pointers are all to the 80xxxxxx region, so I assume it maps here - installed if a cart is present
ADDRESS_MAP_END