summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/cp1610/cp1610.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/cp1610/cp1610.cpp')
-rw-r--r--src/devices/cpu/cp1610/cp1610.cpp157
1 files changed, 77 insertions, 80 deletions
diff --git a/src/devices/cpu/cp1610/cp1610.cpp b/src/devices/cpu/cp1610/cp1610.cpp
index f9b77df991e..4746fc18cd2 100644
--- a/src/devices/cpu/cp1610/cp1610.cpp
+++ b/src/devices/cpu/cp1610/cp1610.cpp
@@ -15,7 +15,6 @@
#include "emu.h"
#include "cp1610.h"
-#include "debugger.h"
#include "1610dasm.h"
DEFINE_DEVICE_TYPE(CP1610, cp1610_cpu_device, "cp1610", "GI CP1610")
@@ -105,8 +104,8 @@ void cp1610_cpu_device::cp1610_hlt()
***************************************************/
void cp1610_cpu_device::cp1610_eis()
{
- m_mask_interrupts = 1;
- m_intr_enabled = 1;
+ m_mask_interrupts = true;
+ m_intr_enabled = true;
m_icount -= 4;
}
@@ -116,8 +115,8 @@ void cp1610_cpu_device::cp1610_eis()
***************************************************/
void cp1610_cpu_device::cp1610_dis()
{
- m_mask_interrupts = 1;
- m_intr_enabled = 0;
+ m_mask_interrupts = true;
+ m_intr_enabled = false;
m_icount -= 4;
}
@@ -128,7 +127,7 @@ void cp1610_cpu_device::cp1610_dis()
void cp1610_cpu_device::cp1610_tci()
{
/* TBD */
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
m_icount -= 4;
}
@@ -138,7 +137,7 @@ void cp1610_cpu_device::cp1610_tci()
***************************************************/
void cp1610_cpu_device::cp1610_clrc()
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
m_flags &= ~C;
m_icount -= 4;
}
@@ -149,7 +148,7 @@ void cp1610_cpu_device::cp1610_clrc()
***************************************************/
void cp1610_cpu_device::cp1610_setc()
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
m_flags |= C;
m_icount -= 6;
}
@@ -196,11 +195,11 @@ void cp1610_cpu_device::cp1610_comr(int n)
***************************************************/
void cp1610_cpu_device::cp1610_negr(int n)
{
- uint32_t temp;
+ uint16_t temp;
CLR_SZOC;
temp = (m_r[n] ^ 0xffff) + 1;
SET_COV(0,temp,1);
- m_r[n] = temp&0xffff;
+ m_r[n] = temp;
SET_SZ(m_r[n]);
m_icount -= 6;
}
@@ -267,7 +266,7 @@ void cp1610_cpu_device::cp1610_rswd(int n)
void cp1610_cpu_device::cp1610_swap(int r)
{
uint8_t temp;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
temp = m_r[r] >> 8;
m_r[r] = (m_r[r] << 8) | temp;
@@ -287,7 +286,7 @@ void cp1610_cpu_device::cp1610_dswap(int r)
{
/* This instruction was not officially supported by GI */
uint16_t temp;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
temp = m_r[r] & 0xff;
m_r[r] = (temp << 8) | temp;
@@ -305,7 +304,7 @@ void cp1610_cpu_device::cp1610_dswap(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sll_1(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] <<= 1;
SET_SZ(m_r[r]);
@@ -318,7 +317,7 @@ void cp1610_cpu_device::cp1610_sll_1(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sll_2(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] <<= 2;
SET_SZ(m_r[r]);
@@ -332,7 +331,7 @@ void cp1610_cpu_device::cp1610_sll_2(int r)
void cp1610_cpu_device::cp1610_rlc_1(int r)
{
uint16_t offset = 0;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
if (m_flags & C)
offset = 1;
CLR_SZC;
@@ -350,7 +349,7 @@ void cp1610_cpu_device::cp1610_rlc_1(int r)
void cp1610_cpu_device::cp1610_rlc_2(int r)
{
uint16_t offset = 0;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
switch(m_flags & (C | OV))
{
case 0:
@@ -384,7 +383,7 @@ void cp1610_cpu_device::cp1610_rlc_2(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sllc_1(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZC;
if (m_r[r] & 0x8000)
m_flags |= C;
@@ -399,7 +398,7 @@ void cp1610_cpu_device::cp1610_sllc_1(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sllc_2(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZOC;
if (m_r[r] & 0x8000)
m_flags |= C;
@@ -416,7 +415,7 @@ void cp1610_cpu_device::cp1610_sllc_2(int r)
***************************************************/
void cp1610_cpu_device::cp1610_slr_1(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] >>= 1;
SET_SZ(m_r[r]);
@@ -433,7 +432,7 @@ void cp1610_cpu_device::cp1610_slr_1(int r)
***************************************************/
void cp1610_cpu_device::cp1610_slr_2(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] >>= 2;
SET_SZ(m_r[r]);
@@ -450,7 +449,7 @@ void cp1610_cpu_device::cp1610_slr_2(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sar_1(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] = (uint16_t)(((int16_t)(m_r[r])) >> 1);
SET_SZ(m_r[r]);
@@ -467,7 +466,7 @@ void cp1610_cpu_device::cp1610_sar_1(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sar_2(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZ;
m_r[r] = (uint16_t)(((int16_t)(m_r[r])) >> 2);
SET_SZ(m_r[r]);
@@ -485,7 +484,7 @@ void cp1610_cpu_device::cp1610_sar_2(int r)
void cp1610_cpu_device::cp1610_rrc_1(int r)
{
uint16_t offset = 0;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
if (m_flags & C)
offset = 0x8000;
CLR_SZC;
@@ -508,7 +507,7 @@ void cp1610_cpu_device::cp1610_rrc_1(int r)
void cp1610_cpu_device::cp1610_rrc_2(int r)
{
uint16_t offset = 0;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
if (m_flags & C)
offset |= 0x4000;
if (m_flags & OV)
@@ -534,7 +533,7 @@ void cp1610_cpu_device::cp1610_rrc_2(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sarc_1(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZC;
if (m_r[r] & 1)
m_flags |= C;
@@ -553,7 +552,7 @@ void cp1610_cpu_device::cp1610_sarc_1(int r)
***************************************************/
void cp1610_cpu_device::cp1610_sarc_2(int r)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
CLR_SZOC;
if (m_r[r] & 1)
m_flags |= C;
@@ -1011,7 +1010,7 @@ void cp1610_cpu_device::cp1610_besc(int dir)
void cp1610_cpu_device::cp1610_mvo(int s)
{
uint16_t addr;
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
addr = cp1610_readop(m_r[7]);
m_r[7]++;
cp1610_writemem16(addr,m_r[s]);
@@ -1024,7 +1023,7 @@ void cp1610_cpu_device::cp1610_mvo(int s)
***************************************************/
void cp1610_cpu_device::cp1610_mvoat(int s, int m)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
cp1610_writemem16(m_r[m],m_r[s]);
m_icount -= 9;
}
@@ -1035,7 +1034,7 @@ void cp1610_cpu_device::cp1610_mvoat(int s, int m)
***************************************************/
void cp1610_cpu_device::cp1610_mvoat_i(int s, int m)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
cp1610_writemem16(m_r[m],m_r[s]);
m_r[m]++;
m_icount -= 9;
@@ -1047,7 +1046,7 @@ void cp1610_cpu_device::cp1610_mvoat_i(int s, int m)
***************************************************/
void cp1610_cpu_device::cp1610_mvoi(int s)
{
- m_mask_interrupts = 1;
+ m_mask_interrupts = true;
cp1610_writemem16(m_r[7],m_r[s]);
m_r[7]++;
m_icount -= 9;
@@ -1643,13 +1642,12 @@ void cp1610_cpu_device::cp1610_sdbd_addi(int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_subat(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
CLR_SZOC;
temp = cp1610_readmem16(m_r[r]) & 0xff;
temp |= (cp1610_readmem16(m_r[r]) << 8);
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
m_r[d] += temp;
SET_SZ(m_r[d]);
m_icount -= 14;
@@ -1661,7 +1659,7 @@ void cp1610_cpu_device::cp1610_sdbd_subat(int r, int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_subat_i(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
CLR_SZOC;
temp = cp1610_readmem16(m_r[r]) & 0xff;
m_r[r]++;
@@ -1669,7 +1667,6 @@ void cp1610_cpu_device::cp1610_sdbd_subat_i(int r, int d)
m_r[r]++;
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
m_r[d] += temp;
SET_SZ(m_r[d]);
m_icount -= 14;
@@ -1681,7 +1678,7 @@ void cp1610_cpu_device::cp1610_sdbd_subat_i(int r, int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_subat_d(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
CLR_SZOC;
m_r[r]--;
temp = cp1610_readmem16(m_r[r]) & 0xff;
@@ -1689,7 +1686,6 @@ void cp1610_cpu_device::cp1610_sdbd_subat_d(int r, int d)
temp |= (cp1610_readmem16(m_r[r]) << 8);
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
m_r[d] += temp;
SET_SZ(m_r[d]);
m_icount -= 17;
@@ -1702,7 +1698,7 @@ void cp1610_cpu_device::cp1610_sdbd_subat_d(int r, int d)
void cp1610_cpu_device::cp1610_sdbd_subi(int d)
{
uint16_t addr;
- uint32_t temp;
+ uint16_t temp;
CLR_SZOC;
addr = cp1610_readop(m_r[7]) & 0xff;
m_r[7]++;
@@ -1711,7 +1707,6 @@ void cp1610_cpu_device::cp1610_sdbd_subi(int d)
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
m_r[d] += temp;
SET_SZ(m_r[d]);
m_icount -= 14;
@@ -1723,14 +1718,13 @@ void cp1610_cpu_device::cp1610_sdbd_subi(int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_cmpat(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
uint16_t temp2;
CLR_SZOC;
temp = cp1610_readmem16(m_r[r]) & 0xff;
temp |= (cp1610_readmem16(m_r[r]) << 8);
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
temp2 = m_r[d] + temp;
SET_SZ(temp2);
m_icount -= 14;
@@ -1742,7 +1736,7 @@ void cp1610_cpu_device::cp1610_sdbd_cmpat(int r, int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_cmpat_i(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
uint16_t temp2;
CLR_SZOC;
temp = cp1610_readmem16(m_r[r]) & 0xff;
@@ -1751,7 +1745,6 @@ void cp1610_cpu_device::cp1610_sdbd_cmpat_i(int r, int d)
m_r[r]++;
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
temp2 = m_r[d] + temp;
SET_SZ(temp2);
m_icount -= 14;
@@ -1763,7 +1756,7 @@ void cp1610_cpu_device::cp1610_sdbd_cmpat_i(int r, int d)
***************************************************/
void cp1610_cpu_device::cp1610_sdbd_cmpat_d(int r, int d)
{
- uint32_t temp;
+ uint16_t temp;
uint16_t temp2;
CLR_SZOC;
m_r[r]--;
@@ -1772,7 +1765,6 @@ void cp1610_cpu_device::cp1610_sdbd_cmpat_d(int r, int d)
temp |= (cp1610_readmem16(m_r[r]) << 8);
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
temp2 = m_r[d] + temp;
SET_SZ(temp2);
m_icount -= 17;
@@ -1785,7 +1777,7 @@ void cp1610_cpu_device::cp1610_sdbd_cmpat_d(int r, int d)
void cp1610_cpu_device::cp1610_sdbd_cmpi(int d)
{
uint16_t addr;
- uint32_t temp;
+ uint16_t temp;
uint16_t temp2;
CLR_SZOC;
addr = cp1610_readop(m_r[7]) & 0xff;
@@ -1795,7 +1787,6 @@ void cp1610_cpu_device::cp1610_sdbd_cmpi(int d)
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(m_r[d],temp,1);
- temp &= 0xffff;
temp2 = m_r[d] + temp;
SET_SZ(temp2);
m_icount -= 14;
@@ -1951,7 +1942,7 @@ void cp1610_cpu_device::cp1610_jsre(int r, uint16_t addr)
{
m_r[r] = m_r[7];
m_r[7] = addr;
- m_intr_enabled = 1;
+ m_intr_enabled = true;
}
/***************************************************
@@ -1962,7 +1953,7 @@ void cp1610_cpu_device::cp1610_jsrd(int r, uint16_t addr)
{
m_r[r] = m_r[7];
m_r[7] = addr;
- m_intr_enabled = 0;
+ m_intr_enabled = false;
}
/***************************************************
@@ -1981,7 +1972,7 @@ void cp1610_cpu_device::cp1610_j(uint16_t addr)
void cp1610_cpu_device::cp1610_je(uint16_t addr)
{
m_r[7] = addr;
- m_intr_enabled = 1;
+ m_intr_enabled = true;
}
/***************************************************
@@ -1991,7 +1982,7 @@ void cp1610_cpu_device::cp1610_je(uint16_t addr)
void cp1610_cpu_device::cp1610_jd(uint16_t addr)
{
m_r[7] = addr;
- m_intr_enabled = 0;
+ m_intr_enabled = false;
}
void cp1610_cpu_device::cp1610_do_sdbd()
@@ -2001,7 +1992,7 @@ void cp1610_cpu_device::cp1610_do_sdbd()
/* Even though SDBD is uninterruptable, we don't need to set the mask bit,
* because we already treat the SDBD prefixed instructions as uninterruptable
*/
- //m_mask_interrupts = 1;
+ //m_mask_interrupts = true;
sdbdtype = cp1610_readop(m_r[7]);
dest = sdbdtype & 0x07;
@@ -2120,11 +2111,17 @@ void cp1610_cpu_device::execute_run()
{
uint16_t opcode;
+ if (m_reset_pending)
+ {
+ m_reset_pending = false;
+ m_r[7] = m_read_iab();
+ }
+
do
{
debugger_instruction_hook(m_r[7]);
- m_mask_interrupts = 0;
+ m_mask_interrupts = false;
opcode = cp1610_readop(m_r[7]);
m_r[7]++;
@@ -3295,30 +3292,34 @@ void cp1610_cpu_device::execute_run()
case 0x3ff: /* 1 111 111 111 */ cp1610_xori(7); break;
}
- if (m_mask_interrupts == 0)
+ if (!m_mask_interrupts)
{
- if (m_intr_pending == 1)
+ if (m_reset_pending)
+ {
+ m_reset_pending = false;
+ m_r[7] = m_read_iab();
+ }
+ else if (m_intr_pending)
{
/* PSHR R7 */
+ standard_irq_callback(CP1610_INT_INTR, m_r[7]);
+ m_write_intak(m_r[6]);
cp1610_writemem16(m_r[6],m_r[7]);
m_r[6]++;
m_icount -= 9;
- m_intr_pending = 0;
- m_r[7] = standard_irq_callback(CP1610_INT_INTR);
+ m_intr_pending = false;
+ m_r[7] = m_read_iab();
}
- if ((m_intrm_pending == 1) && (m_intr_enabled))
+ else if (m_intrm_pending && m_intr_enabled)
{
/* PSHR R7 */
+ standard_irq_callback(CP1610_INT_INTRM, m_r[7]);
+ m_write_intak(m_r[6]);
cp1610_writemem16(m_r[6],m_r[7]);
m_r[6]++;
m_icount -= 9;
- m_intrm_pending = 0;
- m_r[7] = standard_irq_callback(CP1610_INT_INTRM);
- }
- if (m_reset_pending == 1)
- {
- m_reset_pending = 0;
- m_r[7] = standard_irq_callback(CP1610_RESET);
+ m_intrm_pending = false;
+ m_r[7] = m_read_iab();
}
}
@@ -3328,21 +3329,18 @@ void cp1610_cpu_device::execute_run()
void cp1610_cpu_device::device_start()
{
- m_read_bext.resolve_safe(0);
- m_intr_enabled = 0;
- m_reset_pending = 0;
- m_intr_pending = 0;
- m_intrm_pending = 0;
+ m_intr_enabled = false;
+ m_reset_pending = false;
+ m_intr_pending = false;
+ m_intrm_pending = false;
m_flags = 0;
- memset(m_r, 0x00, sizeof(m_r));
+ std::fill(std::begin(m_r), std::end(m_r), 0x0000);
m_program = &space(AS_PROGRAM);
save_item(NAME(m_r));
save_item(NAME(m_flags));
save_item(NAME(m_intr_enabled));
- save_item(NAME(m_intr_vector));
- save_item(NAME(m_reset_state));
save_item(NAME(m_intr_state));
save_item(NAME(m_intrm_state));
save_item(NAME(m_reset_pending));
@@ -3369,7 +3367,7 @@ void cp1610_cpu_device::device_start()
void cp1610_cpu_device::device_reset()
{
/* This is how we set the reset vector */
- pulse_input_line(CP1610_RESET, attotime::zero);
+ m_reset_pending = true;
}
void cp1610_cpu_device::execute_set_input(int irqline, int state)
@@ -3380,14 +3378,9 @@ void cp1610_cpu_device::execute_set_input(int irqline, int state)
m_intrm_pending = (state == ASSERT_LINE);
m_intrm_state = state;
break;
- case CP1610_RESET:
- if (state == ASSERT_LINE)
- m_reset_pending = 1;
- m_reset_state = state;
- break;
case CP1610_INT_INTR:
if (state == ASSERT_LINE)
- m_intr_pending = 1;
+ m_intr_pending = true;
m_intr_state = state;
break;
}
@@ -3397,7 +3390,11 @@ void cp1610_cpu_device::execute_set_input(int irqline, int state)
cp1610_cpu_device::cp1610_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, CP1610, tag, owner, clock)
, m_program_config("program", ENDIANNESS_BIG, 16, 16, -1)
- , m_read_bext(*this)
+ , m_intr_state(0)
+ , m_intrm_state(0)
+ , m_read_bext(*this, 0)
+ , m_read_iab(*this, 0)
+ , m_write_intak(*this)
{
}