summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/scmp/scmp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/scmp/scmp.cpp')
-rw-r--r--src/devices/cpu/scmp/scmp.cpp88
1 files changed, 38 insertions, 50 deletions
diff --git a/src/devices/cpu/scmp/scmp.cpp b/src/devices/cpu/scmp/scmp.cpp
index bb19aef3536..efd89f31469 100644
--- a/src/devices/cpu/scmp/scmp.cpp
+++ b/src/devices/cpu/scmp/scmp.cpp
@@ -2,9 +2,10 @@
// copyright-holders:Miodrag Milanovic
/*****************************************************************************
*
- * scmp.c
+ * scmp.cpp
*
- * National Semiconductor SC/MP CPU Disassembly
+ * National Semiconductor SC/MP CPU emulation
+ * (SC/MP = Simple-to-use, Cost-effective MicroProcessor)
*
*****************************************************************************/
@@ -12,13 +13,11 @@
#include "scmp.h"
#include "scmpdasm.h"
-#include "debugger.h"
-
//#define VERBOSE 1
#include "logmacro.h"
-DEFINE_DEVICE_TYPE(SCMP, scmp_device, "ins8050", "National Semiconductor INS 8050 SC/MP")
+DEFINE_DEVICE_TYPE(SCMP, scmp_device, "ins8050", "National Semiconductor ISP-8A/500D SC/MP")
DEFINE_DEVICE_TYPE(INS8060, ins8060_device, "ins8060", "National Semiconductor INS 8060 SC/MP II")
@@ -30,13 +29,13 @@ scmp_device::scmp_device(const machine_config &mconfig, const char *tag, device_
scmp_device::scmp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, type, tag, owner, clock)
- , m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0)
- , m_AC(0), m_ER(0), m_SR(0), m_program(nullptr), m_cache(nullptr), m_icount(0)
+ , m_program_config("program", ENDIANNESS_BIG, 8, 16, 0)
+ , m_AC(0), m_ER(0), m_SR(0)
, m_flag_out_func(*this)
, m_sout_func(*this)
- , m_sin_func(*this)
- , m_sensea_func(*this)
- , m_senseb_func(*this)
+ , m_sin_func(*this, 0)
+ , m_sensea_func(*this, 0)
+ , m_senseb_func(*this, 0)
, m_halt_func(*this)
{
}
@@ -70,24 +69,24 @@ uint8_t scmp_device::ROP()
{
uint16_t pc = m_PC.w.l;
m_PC.w.l = ADD12(m_PC.w.l,1);
- return m_cache->read_byte( pc);
+ return m_cache.read_byte( pc);
}
uint8_t scmp_device::ARG()
{
uint16_t pc = m_PC.w.l;
m_PC.w.l = ADD12(m_PC.w.l,1);
- return m_cache->read_byte(pc);
+ return m_cache.read_byte(pc);
}
uint8_t scmp_device::RM(uint32_t a)
{
- return m_program->read_byte(a);
+ return m_program.read_byte(a);
}
void scmp_device::WM(uint32_t a, uint8_t v)
{
- m_program->write_byte(a, v);
+ m_program.write_byte(a, v);
}
void scmp_device::illegal(uint8_t opcode)
@@ -134,15 +133,10 @@ uint16_t scmp_device::GET_ADDR(uint8_t code)
uint16_t ptr = GET_PTR_REG(code & 0x03)->w.l;
uint8_t arg = ARG();
- if (arg == 0x80) {
+ if (arg == 0x80)
offset = m_ER;
- } else {
- if (arg & 0x80) {
- offset = (int8_t)arg;
- } else {
- offset = arg;
- }
- }
+ else
+ offset = (int8_t)arg;
addr = ADD12(ptr,offset);
@@ -276,7 +270,8 @@ void scmp_device::execute_one(int opcode)
// Transfer Instructions
case 0x90 : case 0x91 : case 0x92 : case 0x93 :// JMP
m_icount -= 11;
- m_PC.w.l = ADD12(GET_PTR_REG(ptr)->w.l,(int8_t)ARG());
+ tmp = ARG(); // PC must be updated before the destination address is calculated
+ m_PC.w.l = ADD12(GET_PTR_REG(ptr)->w.l,(int8_t)tmp);
break;
case 0x94 : case 0x95 : case 0x96 : case 0x97 :
// JP
@@ -312,7 +307,7 @@ void scmp_device::execute_one(int opcode)
m_AC = 0xff;
break;
// Others are illegal
- default : m_icount -= 1;
+ default : m_icount -= 5;
illegal (opcode);
break;
}
@@ -444,7 +439,7 @@ void scmp_device::execute_one(int opcode)
m_icount -= 5;
break;
// Others are illegal
- default : m_icount -= 1;
+ default : m_icount -= 5;
illegal (opcode);
break;
}
@@ -455,6 +450,7 @@ void scmp_device::execute_one(int opcode)
/***************************************************************************
COMMON EXECUTION
***************************************************************************/
+
void scmp_device::take_interrupt()
{
uint16_t tmp = ADD12(m_PC.w.l,-1); // We fix PC so at return it goes to current location
@@ -487,31 +483,23 @@ void scmp_device::execute_run()
void scmp_device::device_start()
{
- /* set up the state table */
- {
- state_add(SCMP_PC, "PC", m_PC.w.l);
- state_add(STATE_GENPC, "GENPC", m_PC.w.l).noshow();
- state_add(STATE_GENPCBASE, "CURPC", m_PC.w.l).noshow();
- state_add(STATE_GENFLAGS, "GENFLAGS", m_SR).noshow().formatstr("%8s");
- state_add(SCMP_P1, "P1", m_P1.w.l);
- state_add(SCMP_P2, "P2", m_P2.w.l);
- state_add(SCMP_P3, "P3", m_P3.w.l);
- state_add(SCMP_AC, "AC", m_AC);
- state_add(SCMP_ER, "ER", m_ER);
- state_add(SCMP_SR, "SR", m_SR);
- }
-
- m_program = &space(AS_PROGRAM);
- m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>();
-
- /* resolve callbacks */
- m_flag_out_func.resolve_safe();
- m_sout_func.resolve_safe();
- m_sin_func.resolve_safe(0);
- m_sensea_func.resolve_safe(0);
- m_senseb_func.resolve_safe(0);
- m_halt_func.resolve_safe();
-
+ space(AS_PROGRAM).cache(m_cache);
+ space(AS_PROGRAM).specific(m_program);
+
+ // set up the state table
+ state_add(SCMP_PC, "PC", m_PC.w.l);
+ state_add(STATE_GENPC, "GENPC", m_PC.w.l).noshow();
+ state_add(STATE_GENPCBASE, "CURPC", m_PC.w.l).noshow();
+ state_add(STATE_GENFLAGS, "GENFLAGS", m_SR).noshow().formatstr("%8s");
+
+ state_add(SCMP_P1, "P1", m_P1.w.l);
+ state_add(SCMP_P2, "P2", m_P2.w.l);
+ state_add(SCMP_P3, "P3", m_P3.w.l);
+ state_add(SCMP_AC, "AC", m_AC);
+ state_add(SCMP_ER, "ER", m_ER);
+ state_add(SCMP_SR, "SR", m_SR);
+
+ // register for savestates
save_item(NAME(m_PC));
save_item(NAME(m_P1));
save_item(NAME(m_P2));