Previous 199869 Revisions Next

r35058 Monday 16th February, 2015 at 00:32:18 UTC by hap
added interrupt handling
[src/emu/cpu/ucom4]ucom4.c ucom4.h

trunk/src/emu/cpu/ucom4/ucom4.c
r243569r243570
1010  I've also looked at asterick's JavaScript D553 emulator for verification, with permission.
1111
1212  TODO:
13  - add external interrupt
1413  - what happens with uCOM-43 opcodes on an uCOM-44/45 MCU?
1514  - what's the data after the ROM data for? (eg. 2000-2047, official ROM size is 2000)
1615
r243569r243570
153152   m_timer_f = 0;
154153   m_int_f = 0;
155154   m_inte_f = 0;
155   m_int_line = CLEAR_LINE;
156156
157157   // register for savestates
158158   save_item(NAME(m_stack));
r243569r243570
168168   save_item(NAME(m_carry_s_f));
169169   save_item(NAME(m_timer_f));
170170   save_item(NAME(m_int_f));
171   save_item(NAME(m_inte_f));
171   save_item(NAME(m_int_line));
172172
173173   // register state for debugger
174174   state_add(UCOM4_PC, "PC",  m_pc).formatstr("%04X");
r243569r243570
195195   m_skip = false;
196196
197197   m_timer->adjust(attotime::never);
198
198   
199   // clear interrupt
200   m_int_line = CLEAR_LINE;
201   m_int_f = 0;
202   m_inte_f = (m_family == NEC_UCOM43) ? 0 : 1;
203   
199204   // clear i/o
200205   for (int i = NEC_UCOM4_PORTC; i <= NEC_UCOM4_PORTI; i++)
201206      output_w(i, 0xf);
r243569r243570
207212//  execute
208213//-------------------------------------------------
209214
215void ucom4_cpu_device::execute_set_input(int line, int state)
216{
217   switch (line)
218   {
219      case 0:
220         // edge triggered
221         if (m_int_line == CLEAR_LINE && state)
222            m_int_f = 1;
223         m_int_line = state;
224         
225         break;
226     
227      default:
228         break;
229   }
230}
231
210232inline void ucom4_cpu_device::increment_pc()
211233{
212234   // upper bits (field register) don't auto-increment
r243569r243570
233255      // remember previous opcode
234256      m_prev_op = m_op;
235257
258      // handle interrupt - it not accepted during LI($9x) or EI($31), or while skipping
259      if (m_int_f && m_inte_f && (m_prev_op & 0xf0) != 0x90 && m_prev_op != 0x31 && !m_skip)
260      {
261         m_icount--;
262         push_stack();
263         m_pc = 0xf << 2;
264         m_int_f = 0;
265         m_inte_f = (m_family == NEC_UCOM43) ? 0 : 1;
266
267         standard_irq_callback(0);
268      }
269
270      // fetch next opcode
236271      debugger_instruction_hook(this, m_pc);
237272      m_op = m_program->read_byte(m_pc);
238273      m_bitmask = 1 << (m_op & 0x03);
r243569r243570
245280         m_op = 0; // nop
246281      }
247282     
283      // handle opcode
248284      switch (m_op & 0xf0)
249285      {
250286         case 0x80: op_ldz(); break;
trunk/src/emu/cpu/ucom4/ucom4.h
r243569r243570
110110   virtual UINT32 execute_min_cycles() const { return 1; }
111111   virtual UINT32 execute_max_cycles() const { return 2; }
112112   virtual UINT32 execute_input_lines() const { return 1; }
113   virtual void execute_set_input(int line, int state);
113114   virtual void execute_run();
114   
115
115116   // device_memory_interface overrides
116117   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); }
117118
r243569r243570
153154   UINT8 m_timer_f;        // timer out flag
154155   UINT8 m_int_f;          // interrupt flag
155156   UINT8 m_inte_f;         // interrupt enable flag
157   int m_int_line;         // interrupt pin state
156158
157159   // i/o handlers
158160   devcb_read8 m_read_a;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team