added SM510 cpu skeleton

This commit is contained in:
hap 2015-06-30 02:10:33 +02:00
parent 12505514ec
commit 7b0b0bbc95
8 changed files with 371 additions and 16 deletions

View File

@ -1545,6 +1545,38 @@ if (CPUS["SATURN"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/emu/cpu/saturn/saturnds.c")
end
--------------------------------------------------
-- Sharp SM510 series
--@src/emu/cpu/sm510/sm510.h,CPUS["SM510"] = true
--------------------------------------------------
if (CPUS["SM510"]~=null) then
files {
MAME_DIR .. "src/emu/cpu/sm510/sm510.c",
MAME_DIR .. "src/emu/cpu/sm510/sm510.h",
}
end
if (CPUS["SM510"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/emu/cpu/sm510/sm510d.c")
end
--------------------------------------------------
-- Sharp SM8500
--@src/emu/cpu/sm8500/sm8500.h,CPUS["SM8500"] = true
--------------------------------------------------
if (CPUS["SM8500"]~=null) then
files {
MAME_DIR .. "src/emu/cpu/sm8500/sm8500.c",
MAME_DIR .. "src/emu/cpu/sm8500/sm8500.h",
}
end
if (CPUS["SM8500"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/emu/cpu/sm8500/sm8500d.c")
end
--------------------------------------------------
-- Signetics 2650
--@src/emu/cpu/s2650/s2650.h,CPUS["S2650"] = true
@ -1577,22 +1609,6 @@ if (CPUS["SC61860"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/emu/cpu/sc61860/scdasm.c")
end
--------------------------------------------------
-- SM8500
--@src/emu/cpu/sm8500/sm8500.h,CPUS["SM8500"] = true
--------------------------------------------------
if (CPUS["SM8500"]~=null) then
files {
MAME_DIR .. "src/emu/cpu/sm8500/sm8500.c",
MAME_DIR .. "src/emu/cpu/sm8500/sm8500.h",
}
end
if (CPUS["SM8500"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/emu/cpu/sm8500/sm8500d.c")
end
--------------------------------------------------
-- Sony/Nintendo SPC700
--@src/emu/cpu/spc700/spc700.h,CPUS["SPC700"] = true

View File

@ -128,6 +128,8 @@ CPUS["ARCOMPACT"] = true
CPUS["HMCS40"] = true
--CPUS["E0C6200"] = true
--CPUS["MELPS4"] = true
--CPUS["HPHYBRID"] = true
--CPUS["SM510"] = true
--------------------------------------------------
-- specify available sound cores

View File

@ -129,6 +129,7 @@ CPUS["HMCS40"] = true
CPUS["E0C6200"] = true
CPUS["MELPS4"] = true
CPUS["HPHYBRID"] = true
CPUS["SM510"] = true
--------------------------------------------------
-- specify available sound cores; some of these are

163
src/emu/cpu/sm510/sm510.c Normal file
View File

@ -0,0 +1,163 @@
// license:BSD-3-Clause
// copyright-holders:hap
/*
Sharp SM510 MCU family cores
References:
- 1990 Sharp Microcomputers Data Book
*/
#include "sm510.h"
#include "debugger.h"
#include "sm510op.inc"
// MCU types
const device_type SM510 = &device_creator<sm510_device>;
// internal memory maps
static ADDRESS_MAP_START(program_2_7k, AS_PROGRAM, 8, sm510_base_device)
AM_RANGE(0x0000, 0x0aff) AM_ROM
ADDRESS_MAP_END
static ADDRESS_MAP_START(data_96_32x4, AS_DATA, 8, sm510_base_device)
AM_RANGE(0x00, 0x5f) AM_RAM
AM_RANGE(0x60, 0x7f) AM_RAM
ADDRESS_MAP_END
// device definitions
sm510_device::sm510_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: sm510_base_device(mconfig, SM510, "SM510", tag, owner, clock, 2 /* stack levels */, 12 /* prg width */, ADDRESS_MAP_NAME(program_2_7k), 7 /* data width */, ADDRESS_MAP_NAME(data_96_32x4), "sm510", __FILE__)
{ }
// disasm
void sm510_base_device::state_string_export(const device_state_entry &entry, std::string &str)
{
#if 0
switch (entry.index())
{
case STATE_GENFLAGS:
strprintf(str, "%c%c",
m_c ? 'C':'c',
m_s ? 'S':'s'
);
break;
default: break;
}
#endif
}
offs_t sm510_base_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
{
extern CPU_DISASSEMBLE(sm510);
return CPU_DISASSEMBLE_NAME(sm510)(this, buffer, pc, oprom, opram, options);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
enum
{
SM510_PC=1, SM510_ACC, SM510_BL, SM510_BM
};
void sm510_base_device::device_start()
{
m_program = &space(AS_PROGRAM);
m_data = &space(AS_DATA);
m_prgmask = (1 << m_prgwidth) - 1;
m_datamask = (1 << m_datawidth) - 1;
// resolve callbacks
//..
// zerofill
memset(m_stack, 0, sizeof(m_stack));
m_op = 0;
m_prev_op = 0;
m_pc = 0;
m_prev_pc = 0;
m_acc = 0;
m_bl = 0;
m_bm = 0;
// register for savestates
save_item(NAME(m_stack));
save_item(NAME(m_op));
save_item(NAME(m_prev_op));
save_item(NAME(m_pc));
save_item(NAME(m_prev_pc));
save_item(NAME(m_acc));
save_item(NAME(m_bl));
save_item(NAME(m_bm));
// register state for debugger
state_add(SM510_PC, "PC", m_pc).formatstr("%04X");
state_add(SM510_ACC, "ACC", m_acc).formatstr("%01X");
state_add(SM510_BL, "BL", m_bl).formatstr("%01X");
state_add(SM510_BM, "BM", m_bm).formatstr("%01X");
state_add(STATE_GENPC, "curpc", m_pc).formatstr("%04X").noshow();
state_add(STATE_GENFLAGS, "GENFLAGS", m_pc).formatstr("%2s").noshow();
m_icountptr = &m_icount;
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void sm510_base_device::device_reset()
{
}
//-------------------------------------------------
// execute
//-------------------------------------------------
inline void sm510_base_device::increment_pc()
{
}
void sm510_base_device::execute_run()
{
while (m_icount > 0)
{
// remember previous state
m_prev_op = m_op;
m_prev_pc = m_pc;
// fetch next opcode
debugger_instruction_hook(this, m_pc);
m_icount--;
m_op = m_program->read_byte(m_pc);
//m_param = fetch_opcode_param();
increment_pc();
// handle opcode
}
}

108
src/emu/cpu/sm510/sm510.h Normal file
View File

@ -0,0 +1,108 @@
// license:BSD-3-Clause
// copyright-holders:hap
/*
Sharp SM510 MCU family cores
*/
#ifndef _SM510_H_
#define _SM510_H_
#include "emu.h"
// I/O ports setup
// pinout reference
/*
*/
class sm510_base_device : public cpu_device
{
public:
// construction/destruction
sm510_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int stack_levels, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source)
: cpu_device(mconfig, type, name, tag, owner, clock, shortname, source)
, m_program_config("program", ENDIANNESS_LITTLE, 8, prgwidth, 0, program)
, m_data_config("data", ENDIANNESS_LITTLE, 8, datawidth, 0, data)
, m_prgwidth(prgwidth)
, m_datawidth(datawidth)
, m_stack_levels(stack_levels)
{ }
// static configuration helpers
//..
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
// device_execute_interface overrides
virtual UINT32 execute_min_cycles() const { return 1; }
virtual UINT32 execute_max_cycles() const { return 2; }
virtual UINT32 execute_input_lines() const { return 1; }
//virtual void execute_set_input(int line, int state);
virtual void execute_run();
// 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 : ((spacenum == AS_DATA) ? &m_data_config : NULL); }
// device_disasm_interface overrides
virtual UINT32 disasm_min_opcode_bytes() const { return 1; }
virtual UINT32 disasm_max_opcode_bytes() const { return 2; }
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
void state_string_export(const device_state_entry &entry, std::string &str);
address_space_config m_program_config;
address_space_config m_data_config;
address_space *m_program;
address_space *m_data;
int m_prgwidth;
int m_datawidth;
int m_prgmask;
int m_datamask;
UINT16 m_prev_pc;
UINT16 m_pc;
UINT8 m_prev_op;
UINT8 m_op;
UINT8 m_param;
int m_stack_levels;
UINT16 m_stack[2];
int m_icount;
UINT8 m_acc;
UINT8 m_bl;
UINT8 m_bm;
// i/o handlers
//..
// misc internal helpers
void increment_pc();
UINT8 ram_r();
void ram_w(UINT8 data);
void pop_stack();
void push_stack();
// opcode handlers
void op_illegal();
};
class sm510_device : public sm510_base_device
{
public:
sm510_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
extern const device_type SM510;
#endif /* _SM510_H_ */

View File

@ -0,0 +1,22 @@
// license:BSD-3-Clause
// copyright-holders:hap
/*
Sharp SM510 MCU family disassembler
*/
#include "emu.h"
#include "debugger.h"
#include "sm510.h"
CPU_DISASSEMBLE(sm510)
{
//int pos = 0;
//UINT8 op = oprom[pos++];
return 1 | DASMFLAG_SUPPORTED;
}

View File

@ -0,0 +1,41 @@
// license:BSD-3-Clause
// copyright-holders:hap
// SM510 opcode handlers
// internal helpers
inline UINT8 sm510_base_device::ram_r()
{
UINT8 address = (m_bm << 4 | m_bl) & m_datamask;
return m_data->read_byte(address) & 0xf;
}
inline void sm510_base_device::ram_w(UINT8 data)
{
UINT8 address = (m_bm << 4 | m_bl) & m_datamask;
m_data->write_byte(address, data & 0xf);
}
void sm510_base_device::pop_stack()
{
m_pc = m_stack[0] & m_prgmask;
for (int i = 0; i < m_stack_levels-1; i++)
m_stack[i] = m_stack[i+1];
}
void sm510_base_device::push_stack()
{
for (int i = m_stack_levels-1; i >= 1; i--)
m_stack[i] = m_stack[i-1];
m_stack[0] = m_pc;
}
// instruction set
void sm510_base_device::op_illegal()
{
logerror("%s unknown opcode $%03X at $%04X\n", tag(), m_op, m_prev_pc);
}

View File

@ -158,6 +158,7 @@ CPU_DISASSEMBLE( sh2 );
CPU_DISASSEMBLE( sh4 );
CPU_DISASSEMBLE( sh4be );
CPU_DISASSEMBLE( sharc );
CPU_DISASSEMBLE( sm510 );
CPU_DISASSEMBLE( sm8500 );
CPU_DISASSEMBLE( spc700 );
CPU_DISASSEMBLE( ssem );
@ -309,6 +310,7 @@ static const dasm_table_entry dasm_table[] =
{ "sh4", _16le, 0, CPU_DISASSEMBLE_NAME(sh4) },
{ "sh4be", _16be, 0, CPU_DISASSEMBLE_NAME(sh4be) },
{ "sharc", _48le, -2, CPU_DISASSEMBLE_NAME(sharc) },
{ "sm510", _8bit, 0, CPU_DISASSEMBLE_NAME(sm510) },
{ "sm8500", _8bit, 0, CPU_DISASSEMBLE_NAME(sm8500) },
{ "spc700", _8bit, 0, CPU_DISASSEMBLE_NAME(spc700) },
{ "ssem", _32le, 0, CPU_DISASSEMBLE_NAME(ssem) },