trunk/src/emu/cpu/arcompact/arcompact.c
| r242679 | r242680 | |
| 24 | 24 | |
| 25 | 25 | const device_type ARCA5 = &device_creator<arcompact_device>; |
| 26 | 26 | |
| 27 | |
| 28 | READ32_MEMBER( arcompact_device::arcompact_auxreg002_LPSTART_r) { return m_LP_START&0xfffffffe; } |
| 29 | WRITE32_MEMBER(arcompact_device::arcompact_auxreg002_LPSTART_w) { m_LP_START = data&0xfffffffe; } |
| 30 | READ32_MEMBER( arcompact_device::arcompact_auxreg003_LPEND_r) { return m_LP_END&0xfffffffe; } |
| 31 | WRITE32_MEMBER(arcompact_device::arcompact_auxreg003_LPEND_w) { m_LP_END = data&0xfffffffe; } |
| 32 | |
| 27 | 33 | static ADDRESS_MAP_START( arcompact_auxreg_map, AS_IO, 32, arcompact_device ) |
| 34 | AM_RANGE(0x000000008, 0x00000000b) AM_READWRITE(arcompact_auxreg002_LPSTART_r, arcompact_auxreg002_LPSTART_w) |
| 35 | AM_RANGE(0x00000000c, 0x00000000f) AM_READWRITE(arcompact_auxreg003_LPEND_r, arcompact_auxreg003_LPEND_w) |
| 28 | 36 | ADDRESS_MAP_END |
| 29 | 37 | |
| 38 | //#define AUX_SPACE_ADDRESS_WIDTH 34 // IO space is 32 bits of dwords, so 34-bits |
| 39 | #define AUX_SPACE_ADDRESS_WIDTH 64 // but the MAME core requires us to use power of 2 values for >32 |
| 30 | 40 | |
| 31 | 41 | arcompact_device::arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 32 | 42 | : cpu_device(mconfig, ARCA5, "ARCtangent-A5", tag, owner, clock, "arca5", __FILE__) |
| 33 | 43 | , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) // some docs describe these as 'middle endian'?! |
| 34 | | , 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 |
| 44 | , m_io_config( "io", ENDIANNESS_LITTLE, 32, AUX_SPACE_ADDRESS_WIDTH, 0, ADDRESS_MAP_NAME( arcompact_auxreg_map ) ) |
| 35 | 45 | { |
| 36 | 46 | } |
| 37 | 47 | |
trunk/src/emu/cpu/arcompact/arcompact.h
| r242679 | r242680 | |
| 60 | 60 | public: |
| 61 | 61 | // construction/destruction |
| 62 | 62 | arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 63 | |
| 64 | DECLARE_READ32_MEMBER( arcompact_auxreg002_LPSTART_r); |
| 65 | DECLARE_WRITE32_MEMBER(arcompact_auxreg002_LPSTART_w); |
| 66 | DECLARE_READ32_MEMBER( arcompact_auxreg003_LPEND_r); |
| 67 | DECLARE_WRITE32_MEMBER(arcompact_auxreg003_LPEND_w); |
| 63 | 68 | |
| 64 | 69 | protected: |
| 65 | 70 | // device-level overrides |
| r242679 | r242680 | |
| 174 | 179 | ARCOMPACT_RETTYPE arcompact_handle04_1c(OPS_32); |
| 175 | 180 | ARCOMPACT_RETTYPE arcompact_handle04_1d(OPS_32); |
| 176 | 181 | // ARCOMPACT_RETTYPE arcompact_handle04_20(OPS_32); |
| 177 | | ARCOMPACT_RETTYPE arcompact_handle04_21(OPS_32); |
| 182 | // ARCOMPACT_RETTYPE arcompact_handle04_21(OPS_32); |
| 178 | 183 | ARCOMPACT_RETTYPE arcompact_handle04_22(OPS_32); |
| 179 | 184 | ARCOMPACT_RETTYPE arcompact_handle04_23(OPS_32); |
| 180 | 185 | ARCOMPACT_RETTYPE arcompact_handle04_28(OPS_32); |
| 181 | 186 | ARCOMPACT_RETTYPE arcompact_handle04_29(OPS_32); |
| 182 | | ARCOMPACT_RETTYPE arcompact_handle04_2a(OPS_32); |
| 187 | // ARCOMPACT_RETTYPE arcompact_handle04_2a(OPS_32); |
| 183 | 188 | // ARCOMPACT_RETTYPE arcompact_handle04_2b(OPS_32); |
| 184 | 189 | ARCOMPACT_RETTYPE arcompact_handle04_2f_00(OPS_32); |
| 185 | 190 | ARCOMPACT_RETTYPE arcompact_handle04_2f_01(OPS_32); |
| r242679 | r242680 | |
| 760 | 765 | ARCOMPACT_RETTYPE arcompact_handle19_0x_helper(OPS_16, const char* optext, int shift, int format); |
| 761 | 766 | ARCOMPACT_RETTYPE arcompact_handle1e_0x_helper(OPS_16, const char* optext); |
| 762 | 767 | ARCOMPACT_RETTYPE arcompact_handle1e_03_0x_helper(OPS_16, const char* optext); |
| 768 | |
| 763 | 769 | |
| 770 | UINT32 handle_jump_to_addr(int delay, int link, UINT32 address, UINT32 next_addr); |
| 771 | UINT32 handle_jump_to_register(int delay, int link, UINT32 reg, UINT32 next_addr, int flag); |
| 772 | |
| 764 | 773 | ARCOMPACT_RETTYPE get_insruction(OPS_32); |
| 765 | 774 | |
| 766 | 775 | ARCOMPACT_HANDLER04_TYPE_PM(04_00); |
| r242679 | r242680 | |
| 780 | 789 | ARCOMPACT_HANDLER04_TYPE_PM(04_18); |
| 781 | 790 | ARCOMPACT_HANDLER04_TYPE_PM(04_19); |
| 782 | 791 | ARCOMPACT_HANDLER04_TYPE_PM(04_20); |
| 792 | ARCOMPACT_HANDLER04_TYPE_PM(04_21); |
| 793 | ARCOMPACT_HANDLER04_TYPE_PM(04_2a); |
| 783 | 794 | ARCOMPACT_HANDLER04_TYPE_PM(04_2b); |
| 784 | 795 | |
| 785 | 796 | ARCOMPACT_HANDLER04_TYPE_PM(04_2f_02); |
trunk/src/emu/cpu/arcompact/arcompact_execute.c
| r242679 | r242680 | |
| 1128 | 1128 | |
| 1129 | 1129 | // handlers |
| 1130 | 1130 | |
| 1131 | UINT32 arcompact_device::handle_jump_to_addr(int delay, int link, UINT32 address, UINT32 next_addr) |
| 1132 | { |
| 1133 | if (delay) |
| 1134 | { |
| 1135 | m_delayactive = 1; |
| 1136 | m_delayjump = address; |
| 1137 | if (link) m_delaylinks = 1; |
| 1138 | else m_delaylinks = 0; |
| 1139 | return next_addr; |
| 1140 | } |
| 1141 | else |
| 1142 | { |
| 1143 | if (link) m_regs[REG_BLINK] = next_addr; |
| 1144 | return address; |
| 1145 | } |
| 1131 | 1146 | |
| 1147 | } |
| 1132 | 1148 | |
| 1149 | UINT32 arcompact_device::handle_jump_to_register(int delay, int link, UINT32 reg, UINT32 next_addr, int flag) |
| 1150 | { |
| 1151 | if (reg == LIMM_REG) |
| 1152 | arcompact_fatal("handle_jump_to_register called with LIMM register, call handle_jump_to_addr instead"); |
| 1153 | |
| 1154 | if ((reg == REG_ILINK1) || (reg == REG_ILINK2)) |
| 1155 | { |
| 1156 | if (flag) |
| 1157 | { |
| 1158 | arcompact_fatal("jump to ILINK1/ILINK2 not supported"); |
| 1159 | return next_addr; |
| 1160 | } |
| 1161 | else |
| 1162 | { |
| 1163 | arcompact_fatal("illegal jump to ILINK1/ILINK2 not supported"); // FLAG bit must be set |
| 1164 | return next_addr; |
| 1165 | } |
| 1166 | } |
| 1167 | else |
| 1168 | { |
| 1169 | if (flag) |
| 1170 | { |
| 1171 | arcompact_fatal("illegal jump (flag bit set)"); // FLAG bit must NOT be set |
| 1172 | return next_addr; |
| 1173 | } |
| 1174 | else |
| 1175 | { |
| 1176 | //arcompact_fatal("jump not supported"); |
| 1177 | UINT32 target = m_regs[reg]; |
| 1178 | return handle_jump_to_addr(delay, link, target, next_addr); |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | return 0; |
| 1183 | } |
| 1184 | |
| 1133 | 1185 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle00_00(OPS_32) |
| 1134 | 1186 | { |
| 1135 | 1187 | int size = 4; |
| r242679 | r242680 | |
| 2028 | 2080 | } |
| 2029 | 2081 | |
| 2030 | 2082 | |
| 2083 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21_p00(OPS_32) |
| 2084 | { |
| 2085 | int size = 4; |
| 2086 | UINT32 limm = 0; |
| 2087 | int got_limm = 0; |
| 2031 | 2088 | |
| 2032 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21(OPS_32) |
| 2089 | COMMON32_GET_creg |
| 2090 | COMMON32_GET_F |
| 2091 | |
| 2092 | if (creg == LIMM_REG) |
| 2093 | { |
| 2094 | if (!got_limm) |
| 2095 | { |
| 2096 | GET_LIMM_32; |
| 2097 | size = 8; |
| 2098 | } |
| 2099 | |
| 2100 | handle_jump_to_addr(1,0,limm, m_pc + (size>>0)); |
| 2101 | } |
| 2102 | else |
| 2103 | { |
| 2104 | return handle_jump_to_register(1,0,creg, m_pc + (size>>0), F); // delay, no link |
| 2105 | } |
| 2106 | |
| 2107 | return m_pc + (size>>0); |
| 2108 | } |
| 2109 | |
| 2110 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21_p01(OPS_32) |
| 2033 | 2111 | { |
| 2034 | | return arcompact_handle04_helper(PARAMS, opcodes_04[0x21], /*"J.D"*/ 1,1); |
| 2112 | int size = 4; |
| 2113 | arcompact_log("unimplemented J.D (u6 type) %08x", op); |
| 2114 | return m_pc + (size>>0); |
| 2035 | 2115 | } |
| 2036 | 2116 | |
| 2117 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21_p10(OPS_32) |
| 2118 | { |
| 2119 | int size = 4; |
| 2120 | arcompact_log("unimplemented J.D (s12 type) %08x", op); |
| 2121 | return m_pc + (size>>0); |
| 2122 | } |
| 2123 | |
| 2124 | |
| 2125 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21_p11_m0(OPS_32) // Jcc.D (no link, delay) |
| 2126 | { |
| 2127 | int size = 4; |
| 2128 | UINT32 limm = 0; |
| 2129 | int got_limm = 0; |
| 2130 | |
| 2131 | COMMON32_GET_creg |
| 2132 | COMMON32_GET_CONDITION; |
| 2133 | COMMON32_GET_F |
| 2134 | |
| 2135 | //UINT32 c = 0; |
| 2136 | |
| 2137 | if (creg == LIMM_REG) |
| 2138 | { |
| 2139 | if (!got_limm) |
| 2140 | { |
| 2141 | GET_LIMM_32; |
| 2142 | size = 8; |
| 2143 | } |
| 2144 | |
| 2145 | // c = limm; |
| 2146 | |
| 2147 | } |
| 2148 | else |
| 2149 | { |
| 2150 | // opcode iiii i--- ppII IIII F--- cccc ccmq qqqq |
| 2151 | // Jcc [c] 0010 0RRR 1110 0000 0RRR CCCC CC0Q QQQQ |
| 2152 | // no conditional links to ILINK1, ILINK2? |
| 2153 | |
| 2154 | // c = m_regs[creg]; |
| 2155 | } |
| 2156 | |
| 2157 | if (!check_condition(condition)) |
| 2158 | return m_pc + (size>>0); |
| 2159 | |
| 2160 | if (!F) |
| 2161 | { |
| 2162 | // if F isn't set then the destination can't be ILINK1 or ILINK2 |
| 2163 | |
| 2164 | if ((creg == REG_ILINK1) || (creg == REG_ILINK1)) |
| 2165 | { |
| 2166 | arcompact_log("unimplemented Jcc.D (p11_m0 type, illegal) %08x", op); |
| 2167 | } |
| 2168 | else |
| 2169 | { |
| 2170 | arcompact_log("unimplemented Jcc.D (p11_m0 type, unimplemented) %08x", op); |
| 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | if (F) |
| 2175 | { |
| 2176 | // if F is set then the destination MUST be ILINK1 or ILINK2 |
| 2177 | |
| 2178 | if ((creg == REG_ILINK1) || (creg == REG_ILINK1)) |
| 2179 | { |
| 2180 | arcompact_log("unimplemented Jcc.D.F (p11_m0 type, unimplemented) %08x", op); |
| 2181 | } |
| 2182 | else |
| 2183 | { |
| 2184 | arcompact_log("unimplemented Jcc.D.F (p11_m0 type, illegal) %08x", op); |
| 2185 | } |
| 2186 | } |
| 2187 | |
| 2188 | |
| 2189 | return m_pc + (size>>0); |
| 2190 | } |
| 2191 | |
| 2192 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_21_p11_m1(OPS_32) |
| 2193 | { |
| 2194 | int size = 4; |
| 2195 | arcompact_log("unimplemented arcompact_handle04_21_p11_m1 J.D %08x (u6)", op); |
| 2196 | return m_pc + (size>>0); |
| 2197 | } |
| 2198 | |
| 2199 | |
| 2200 | |
| 2037 | 2201 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_22(OPS_32) |
| 2038 | 2202 | { |
| 2039 | 2203 | return arcompact_handle04_helper(PARAMS, opcodes_04[0x22], /*"JL"*/ 1,1); |
| r242679 | r242680 | |
| 2095 | 2259 | } |
| 2096 | 2260 | |
| 2097 | 2261 | |
| 2098 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2a(OPS_32) // Load FROM Auxiliary register TO register |
| 2099 | | { |
| 2100 | | int size = 4; |
| 2101 | | // UINT32 limm = 0; |
| 2102 | | int got_limm = 0; |
| 2103 | | |
| 2104 | | COMMON32_GET_p; |
| 2105 | | //COMMON32_GET_breg; |
| 2106 | | |
| 2107 | | if (p == 0) |
| 2108 | | { |
| 2109 | | COMMON32_GET_creg |
| 2110 | | |
| 2111 | | if (creg == LIMM_REG) |
| 2112 | | { |
| 2113 | | if (!got_limm) |
| 2114 | | { |
| 2115 | | //GET_LIMM_32; |
| 2116 | | size = 8; |
| 2117 | | } |
| 2118 | | |
| 2119 | | } |
| 2120 | | else |
| 2121 | | { |
| 2122 | | } |
| 2123 | | } |
| 2124 | | else if (p == 1) |
| 2125 | | { |
| 2126 | | } |
| 2127 | | else if (p == 2) |
| 2128 | | { |
| 2129 | | } |
| 2130 | | else if (p == 3) |
| 2131 | | { |
| 2132 | | } |
| 2133 | | |
| 2134 | | arcompact_log("unimplemented LR %08x", op); |
| 2135 | | return m_pc + (size>>0); |
| 2136 | | } |
| 2137 | | |
| 2138 | | |
| 2139 | 2262 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_29(OPS_32) |
| 2140 | 2263 | { |
| 2141 | 2264 | // leapster bios uses formats for FLAG that are not defined, bug I guess work anyway (P modes 0 / 1) |
trunk/src/emu/cpu/arcompact/arcompact_make.py
| r242679 | r242680 | |
| 244 | 244 | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 245 | 245 | print >>f, " return m_pc + (size >> 0);" |
| 246 | 246 | print >>f, "}" |
| 247 | | print >>f, "" |
| 248 | | print >>f, "" |
| 247 | print >>f, "" |
| 248 | print >>f, "" |
| 249 | 249 | # the mode 0x11 m0 handler |
| 250 | 250 | print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m0(OPS_32)" % (funcname) |
| 251 | 251 | if ignore_a == 2: |
| r242679 | r242680 | |
| 283 | 283 | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 284 | 284 | print >>f, " return m_pc + (size >> 0);" |
| 285 | 285 | print >>f, "}" |
| 286 | | print >>f, "" |
| 287 | | print >>f, "" |
| 286 | print >>f, "" |
| 287 | print >>f, "" |
| 288 | 288 | |
| 289 | 289 | |
| 290 | 290 | # xxx_S c, b, u3 format opcodes (note c is destination) |
| r242679 | r242680 | |
| 305 | 305 | print >>f, "" |
| 306 | 306 | print >>f, " return m_pc + (2 >> 0);" |
| 307 | 307 | print >>f, "}" |
| 308 | print >>f, "" |
| 309 | print >>f, "" |
| 308 | 310 | |
| 309 | 311 | |
| 310 | 312 | # xxx_S b <- b,c format opcodes |
| r242679 | r242680 | |
| 324 | 326 | print >>f, "" |
| 325 | 327 | print >>f, " return m_pc + (2 >> 0);" |
| 326 | 328 | print >>f, "}" |
| 329 | print >>f, "" |
| 330 | print >>f, "" |
| 327 | 331 | |
| 328 | 332 | |
| 329 | 333 | # xxx_S b, b, u5 format opcodes |
| r242679 | r242680 | |
| 377 | 381 | EmitGroup04(f, "04_18", "SUB2", "UINT32 result = b - (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 378 | 382 | EmitGroup04(f, "04_19", "SUB3", "UINT32 result = b - (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 379 | 383 | |
| 380 | | EmitGroup04(f, "04_2b", "SR", "WRITEAUX(c,b);", "", "", 1,0, -1, EmitGroup04_unsupported_Flags ) # this can't be conditional (todo) |
| 384 | EmitGroup04(f, "04_2a", "LR", "m_regs[breg] = READAUX(c);", "", "", 1,1, -1, EmitGroup04_no_Flags ) # this can't be conditional (todo) |
| 385 | EmitGroup04(f, "04_2b", "SR", "WRITEAUX(c,b);", "", "", 1,0, -1, EmitGroup04_no_Flags ) # this can't be conditional (todo) |
| 381 | 386 | |
| 382 | 387 | |
| 383 | 388 | |