Previous 199869 Revisions Next

r36294 Friday 6th March, 2015 at 20:47:36 UTC by hap
fix hmcs40 10-bit-word handling
[src/emu/cpu/hmcs40]hmcs40.c hmcs40.h hmcs40d.c hmcs40op.inc
[src/tools]unidasm.c

trunk/src/emu/cpu/hmcs40/hmcs40.c
r244805r244806
3131// MCU types
3232
3333// HMCS42/C/CL
34//const device_type HD38702 = &device_creator<hd38702_device>; // PMOS, 28 pins, 22 I/O lines, (512+32)x10 ROM, 32x4 RAM
34//const device_type HD38702 = &device_creator<hd38702_device>; // PMOS, 28 pins, 22 I/O lines, (512+32)x10 ROM, 32x4 RAM, no B or SPY register
3535//const device_type HD44700 = &device_creator<hd44700_device>; // CMOS version
3636//const device_type HD44708 = &device_creator<hd44708_device>; // CMOS version, low-power
3737
r244805r244806
6565
6666// internal memory maps
6767static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 16, hmcs40_cpu_device)
68   AM_RANGE(0x0000, 0x07ff) AM_ROM
69   AM_RANGE(0x0800, 0x007f) AM_ROM
68   AM_RANGE(0x0000, 0x03ff) AM_ROM
69   AM_RANGE(0x0400, 0x043f) AM_ROM
7070ADDRESS_MAP_END
7171
7272static ADDRESS_MAP_START(program_2k, AS_PROGRAM, 16, hmcs40_cpu_device)
73   AM_RANGE(0x0000, 0x0fff) AM_ROM
74   AM_RANGE(0x1000, 0x10ff) AM_ROM
73   AM_RANGE(0x0000, 0x07ff) AM_ROM
74   AM_RANGE(0x0800, 0x087f) AM_ROM
7575ADDRESS_MAP_END
7676
7777
r244805r244806
8989
9090// device definitions
9191hmcs43_cpu_device::hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
92   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS43, is_cmos, 3, 12, ADDRESS_MAP_NAME(program_1k), 7, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__)
92   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS43, is_cmos, 3, 10, 11, ADDRESS_MAP_NAME(program_1k), 7, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__)
9393{ }
9494
9595hd38750_device::hd38750_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244805r244806
9898
9999
100100hmcs44_cpu_device::hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
101   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS44, is_cmos, 4, 13, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
101   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS44, is_cmos, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
102102{ }
103103
104104hd38800_device::hd38800_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244805r244806
107107
108108
109109hmcs45_cpu_device::hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
110   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS45, is_cmos, 4, 13, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
110   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS45, is_cmos, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
111111{ }
112112
113113hd38820_device::hd38820_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244805r244806
127127         );
128128         break;
129129
130      case STATE_GENPC:
131         string.printf("%04X", m_pc << 1);
132         break;
133
134130      default: break;
135131   }
136132}
r244805r244806
159155   m_data = &space(AS_DATA);
160156   m_prgmask = (1 << m_prgwidth) - 1;
161157   m_datamask = (1 << m_datawidth) - 1;
158   m_pcmask = (1 << m_pcwidth) - 1;
162159   
163160   UINT8 defval = (m_is_cmos) ? 0xf : 0;
164161   m_read_r0.resolve_safe(defval);
r244805r244806
241238
242239void hmcs40_cpu_device::device_reset()
243240{
244   m_pc = m_prgmask;
241   m_pc = m_pcmask;
245242   m_prev_op = m_op = 0;
246243   
247244   // clear i/o
r244805r244806
282279     
283280      // LPU is handled 1 cycle later
284281      if ((m_prev_op & 0x3e0) == 0x340)
285         m_pc = ((m_page << 6) | (m_pc & 0x3f)) & m_prgmask;
282         m_pc = ((m_page << 6) | (m_pc & 0x3f)) & m_pcmask;
286283
287284      // remember previous state
288285      m_prev_op = m_op;
289286      m_prev_pc = m_pc;
290287     
291288      // fetch next opcode
292      debugger_instruction_hook(this, m_pc << 1);
293      m_op = m_program->read_word(m_pc << 1);
289      debugger_instruction_hook(this, m_pc);
290      m_op = m_program->read_word(m_pc << 1) & 0x3ff;
294291      increment_pc();
295292   }
296293}
trunk/src/emu/cpu/hmcs40/hmcs40.h
r244805r244806
3232{
3333public:
3434   // construction/destruction
35   hmcs40_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int family, bool is_cmos, int stack_levels, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source)
35   hmcs40_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int family, bool is_cmos, int stack_levels, int pcwidth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source)
3636      : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source)
37      , m_program_config("program", ENDIANNESS_LITTLE, 16, prgwidth, 0, program)
37      , m_program_config("program", ENDIANNESS_LITTLE, 16, prgwidth, -1, program)
3838      , m_data_config("data", ENDIANNESS_LITTLE, 8, datawidth, 0, data)
39      , m_prgwidth(prgwidth-1)
39      , m_pcwidth(pcwidth)
40      , m_prgwidth(prgwidth)
4041      , m_datawidth(datawidth)
4142      , m_family(family)
4243      , m_is_cmos(is_cmos)
r244805r244806
9495   address_space *m_program;
9596   address_space *m_data;
9697
98   int m_pcwidth;      // Program Counter bit-width
9799   int m_prgwidth;
98100   int m_datawidth;
101   int m_pcmask;
99102   int m_prgmask;
100103   int m_datamask;
101104   int m_family;       // MCU family (42-47)
trunk/src/emu/cpu/hmcs40/hmcs40d.c
r244805r244806
1313
1414CPU_DISASSEMBLE(hmcs40)
1515{
16   int pos = 2;//0;
16   int pos = 1;//0;
1717//   UINT16 op = (oprom[pos] | oprom[pos + 1] << 8) & 0x3ff;
1818//   pos += 2;
1919//   UINT8 instr = hmcs40_mnemonic[op];
trunk/src/emu/cpu/hmcs40/hmcs40op.inc
r244805r244806
1616
1717void hmcs40_cpu_device::pop_stack()
1818{
19   m_pc = m_stack[0] & m_prgmask;
19   m_pc = m_stack[0] & m_pcmask;
2020   for (int i = 0; i < m_stack_levels-1; i++)
2121      m_stack[i] = m_stack[i+1];
2222}
r244805r244806
594594void hmcs40_cpu_device::op_tbr()
595595{
596596   // TBR p: Table Branch
597   m_pc = (m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9) & m_prgmask;
597   m_pc = (m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9) & m_pcmask;
598598}
599599
600600void hmcs40_cpu_device::op_rtn()
r244805r244806
782782   // P p: Pattern Generation
783783   m_icount--;
784784   UINT16 address = (m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9) | (m_pc & ~0x3f);
785   UINT16 o = m_program->read_word(address << 1);
785   UINT16 o = m_program->read_word((address & m_prgmask) << 1);
786786   
787787   // destination is determined by the 2 highest bits
788788   if (o & 0x100)
trunk/src/tools/unidasm.c
r244805r244806
244244   { "hd6301",     _8bit,  0, CPU_DISASSEMBLE_NAME(hd6301) },
245245   { "hd6309",     _8bit,  0, CPU_DISASSEMBLE_NAME(hd6309) },
246246   { "hd63701",    _8bit,  0, CPU_DISASSEMBLE_NAME(hd63701) },
247   { "hmcs40",     _16le, 0, CPU_DISASSEMBLE_NAME(hmcs40) },
247   { "hmcs40",     _16le, -1, CPU_DISASSEMBLE_NAME(hmcs40) },
248248   { "hyperstone", _16be,  0, CPU_DISASSEMBLE_NAME(hyperstone_generic) },
249249   { "i4004",      _8bit,  0, CPU_DISASSEMBLE_NAME(i4004) },
250250   { "i8008",      _8bit,  0, CPU_DISASSEMBLE_NAME(i8008) },


Previous 199869 Revisions Next


© 1997-2024 The MAME Team