mcs48: remove todo note about EN/DIS I opcode not incrementing the timer, doc is wrong, and add another note

This commit is contained in:
hap 2024-12-05 15:08:27 +01:00
parent 40d5879187
commit c4e1751255

View File

@ -1,6 +1,6 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Dan Boris, Mirko Buffoni, Aaron Giles, Couriersud // copyright-holders:Dan Boris, Mirko Buffoni, Aaron Giles, Couriersud
/*************************************************************************** /*******************************************************************************
Intel MCS-48/UPI-41 Portable Emulator Intel MCS-48/UPI-41 Portable Emulator
@ -10,13 +10,42 @@
TODO: TODO:
- add CMOS devices, 1 new opcode (01 IDL) - add CMOS devices, 1 new opcode (01 IDL)
- add special 8022 opcodes (RAD, SEL AN0, SEL AN1, RETI) - add special 8022 opcodes (RAD, SEL AN0, SEL AN1, RETI)
- according to the user manual, some opcodes(dis/enable timer/interrupt) - IRQ and/or timer increment timing is wrong? See test below. After IRQ,
don't increment the timer, does it affect the prescaler too? A = 0x20 on MAME, A = 0x22 on the real 8048 as tested by bataais.
Most likely, timer input (prescaler overflow or T1 edge) still occurs,
just that m_timer increment is delayed 1 opcode.
- IRQ timing is hacked due to WY-100 needing to take JNI branch before servicing interrupt
**************************************************************************** stop tcnt
mov a,0xff
mov t,a
inc a
en tcnti
strt t
inc a
inc a
inc a
(etc.)
With the following test, on MAME, A = 0xff after 30 NOPs, A = 0 after 31
NOPs. On the real 8048, A = 0xff after 31 NOPs, A = 0 after 32 NOPs.
It can mean that STRT T has a 1 cycle delay, or simply that MOV A,T gets
the timer value pre-increment.
stop tcnt
mov a,0xff
mov t,a
strt t
nop
nop
nop
(etc.)
mov a,t
- IRQ timing is hacked due to WY-100 needing to take JNI branch before
servicing interrupt (see m_irq_polled), probably related to note above?
********************************************************************************
Note that the default internal divisor for this chip is by 3 and Note that the default internal divisor for this chip is by 3 and
then again by 5, or by 15 total. then again by 5, or by 15 total.
@ -41,7 +70,7 @@
8040 256 0 27 (external ROM) 8040 256 0 27 (external ROM)
8050 256 4k 27 (ROM) 8050 256 4k 27 (ROM)
**************************************************************************** ********************************************************************************
UPI-41/42 chips are MCS-48 derived, with some opcode changes: UPI-41/42 chips are MCS-48 derived, with some opcode changes:
@ -78,16 +107,16 @@
8742 128 2k (EPROM) 8742 128 2k (EPROM)
8742AH 256 2k (EPROM) 8742AH 256 2k (EPROM)
***************************************************************************/ *******************************************************************************/
#include "emu.h" #include "emu.h"
#include "mcs48.h" #include "mcs48.h"
#include "mcs48dsm.h" #include "mcs48dsm.h"
/*************************************************************************** /*******************************************************************************
CONSTANTS CONSTANTS
***************************************************************************/ *******************************************************************************/
// timer/counter enable bits // timer/counter enable bits
#define TIMER_ENABLED 0x01 #define TIMER_ENABLED 0x01
@ -121,9 +150,9 @@
#define I8048_FEATURE (MB_FEATURE | EXT_BUS_FEATURE) #define I8048_FEATURE (MB_FEATURE | EXT_BUS_FEATURE)
/*************************************************************************** /*******************************************************************************
MACROS MACROS
***************************************************************************/ *******************************************************************************/
// r0-r7 map to memory via the regptr // r0-r7 map to memory via the regptr
#define R0 m_regptr[0] #define R0 m_regptr[0]
@ -136,9 +165,9 @@
#define R7 m_regptr[7] #define R7 m_regptr[7]
/*************************************************************************** /*******************************************************************************
DEVICE TYPES DEVICE TYPES
***************************************************************************/ *******************************************************************************/
DEFINE_DEVICE_TYPE(I8021, i8021_device, "i8021", "Intel 8021") DEFINE_DEVICE_TYPE(I8021, i8021_device, "i8021", "Intel 8021")
DEFINE_DEVICE_TYPE(I8022, i8022_device, "i8022", "Intel 8022") DEFINE_DEVICE_TYPE(I8022, i8022_device, "i8022", "Intel 8022")
@ -166,9 +195,9 @@ DEFINE_DEVICE_TYPE(UPD7751, upd7751_device, "upd7751", "NEC uPD7751")
DEFINE_DEVICE_TYPE(M58715, m58715_device, "m58715", "Mitsubishi M58715") DEFINE_DEVICE_TYPE(M58715, m58715_device, "m58715", "Mitsubishi M58715")
/*************************************************************************** /*******************************************************************************
CONSTRUCTOR CONSTRUCTOR
***************************************************************************/ *******************************************************************************/
mcs48_cpu_device::mcs48_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int rom_size, int ram_size, u8 feature_mask, const mcs48_cpu_device::mcs48_ophandler *opcode_table) mcs48_cpu_device::mcs48_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int rom_size, int ram_size, u8 feature_mask, const mcs48_cpu_device::mcs48_ophandler *opcode_table)
: cpu_device(mconfig, type, tag, owner, clock) : cpu_device(mconfig, type, tag, owner, clock)
@ -340,9 +369,9 @@ std::unique_ptr<util::disasm_interface> mcs48_cpu_device::create_disassembler()
} }
/*************************************************************************** /*******************************************************************************
ADDRESS MAPS ADDRESS MAPS
***************************************************************************/ *******************************************************************************/
void mcs48_cpu_device::program_map(address_map &map) void mcs48_cpu_device::program_map(address_map &map)
{ {
@ -364,9 +393,9 @@ void mcs48_cpu_device::data_map(address_map &map)
} }
/*************************************************************************** /*******************************************************************************
INLINE FUNCTIONS INLINE FUNCTIONS
***************************************************************************/ *******************************************************************************/
/*------------------------------------------------- /*-------------------------------------------------
opcode_fetch - fetch an opcode byte opcode_fetch - fetch an opcode byte
@ -588,9 +617,9 @@ void mcs48_cpu_device::expander_operation(expander_op operation, u8 port)
/*************************************************************************** /*******************************************************************************
OPCODE HANDLERS OPCODE HANDLERS
***************************************************************************/ *******************************************************************************/
#define OPHANDLER(_name) void mcs48_cpu_device::_name() #define OPHANDLER(_name) void mcs48_cpu_device::_name()
@ -598,7 +627,7 @@ void mcs48_cpu_device::expander_operation(expander_op operation, u8 port)
OPHANDLER( illegal ) OPHANDLER( illegal )
{ {
burn_cycles(1); burn_cycles(1);
logerror("MCS-48 PC:%04X - Illegal opcode = %02x\n", m_prevpc, program_r(m_prevpc)); logerror("Illegal opcode = %02x @ %04X\n", program_r(m_prevpc), m_prevpc);
} }
OPHANDLER( add_a_r0 ) { burn_cycles(1); execute_add(R0); } OPHANDLER( add_a_r0 ) { burn_cycles(1); execute_add(R0); }
@ -873,7 +902,6 @@ OPHANDLER( out_dbb_a )
port_w(2, m_p2 |= P2_OBF); port_w(2, m_p2 |= P2_OBF);
} }
OPHANDLER( ret ) { burn_cycles(2); pull_pc(); } OPHANDLER( ret ) { burn_cycles(2); pull_pc(); }
OPHANDLER( retr ) OPHANDLER( retr )
{ {
@ -937,9 +965,9 @@ OPHANDLER( xrl_a_n ) { burn_cycles(2); m_a ^= argument_fetch(); }
/*************************************************************************** /*******************************************************************************
OPCODE TABLES OPCODE TABLES
***************************************************************************/ *******************************************************************************/
#define OP(_a) &mcs48_cpu_device::_a #define OP(_a) &mcs48_cpu_device::_a
@ -1089,9 +1117,9 @@ const mcs48_cpu_device::mcs48_ophandler mcs48_cpu_device::s_i8022_opcodes[256] =
/*************************************************************************** /*******************************************************************************
INITIALIZATION/RESET INITIALIZATION/RESET
***************************************************************************/ *******************************************************************************/
void mcs48_cpu_device::device_config_complete() void mcs48_cpu_device::device_config_complete()
{ {
@ -1244,9 +1272,9 @@ void mcs48_cpu_device::device_reset()
} }
/*************************************************************************** /*******************************************************************************
EXECUTION EXECUTION
***************************************************************************/ *******************************************************************************/
/*------------------------------------------------- /*-------------------------------------------------
check_irqs - check for and process IRQs check_irqs - check for and process IRQs
@ -1374,9 +1402,9 @@ void mcs48_cpu_device::execute_run()
/*************************************************************************** /*******************************************************************************
DATA ACCESS HELPERS DATA ACCESS HELPERS
***************************************************************************/ *******************************************************************************/
/*------------------------------------------------- /*-------------------------------------------------
upi41_master_r - master CPU data/status upi41_master_r - master CPU data/status
@ -1429,9 +1457,9 @@ void upi41_cpu_device::upi41_master_w(offs_t offset, u8 data)
} }
/*************************************************************************** /*******************************************************************************
GENERAL CONTEXT ACCESS GENERAL CONTEXT ACCESS
***************************************************************************/ *******************************************************************************/
/*------------------------------------------------- /*-------------------------------------------------
mcs48_import_state - import state from the mcs48_import_state - import state from the