Previous 199869 Revisions Next

r36276 Thursday 5th March, 2015 at 23:40:54 UTC by hap
added branch opcodes
[src/emu/cpu/hmcs40]hmcs40.c hmcs40.h hmcs40op.inc

trunk/src/emu/cpu/hmcs40/hmcs40.c
r244787r244788
140140   // zerofill
141141   memset(m_stack, 0, sizeof(m_stack));
142142   m_op = 0;
143   m_prev_op = 0;
143144   m_arg = 0;
144145   m_pc = 0;
146   m_page = 0;
145147   m_a = 0;
146148   m_b = 0;
147149   m_x = 0;
r244787r244788
154156   // register for savestates
155157   save_item(NAME(m_stack));
156158   save_item(NAME(m_op));
159   save_item(NAME(m_prev_op));
157160   save_item(NAME(m_arg));
158161   save_item(NAME(m_pc));
162   save_item(NAME(m_page));
159163   save_item(NAME(m_a));
160164   save_item(NAME(m_b));
161165   save_item(NAME(m_x));
r244787r244788
216220inline void hmcs40_cpu_device::fetch_arg()
217221{
218222   // P is the only 2-byte opcode
219   if (m_op == 0x3ff)
223   if ((m_op & 0x3f8) == 0x368)
220224   {
221225      m_icount--;
222226      m_arg = m_program->read_word(m_pc << 1);
r244787r244788
230234   {
231235      m_icount--;
232236     
237      // LPU is handled 1 cycle later
238      if ((m_prev_op & 0x3e0) == 0x340)
239         m_pc = ((m_page << 6) | (m_pc & 0x3f)) & m_prgmask;
240
241      // remember previous opcode
242      m_prev_op = m_op;
243     
244      // fetch next opcode
233245      debugger_instruction_hook(this, m_pc << 1);
234246      m_op = m_program->read_word(m_pc << 1);
235247      increment_pc();
trunk/src/emu/cpu/hmcs40/hmcs40.h
r244787r244788
7272   int m_stack_levels; // number of callstack levels
7373   UINT16 m_stack[4];  // max 4
7474   UINT16 m_op;
75   UINT16 m_prev_op;
7576   UINT16 m_arg;
7677   int m_icount;
7778   
7879   UINT16 m_pc;        // Program Counter
80   UINT8 m_page;       // LPU prepared page
7981   UINT8 m_a;          // 4-bit Accumulator
8082   UINT8 m_b;          // 4-bit B register
8183   UINT8 m_x;          // 1/3/4-bit X register
trunk/src/emu/cpu/hmcs40/hmcs40op.inc
r244787r244788
431431void hmcs40_cpu_device::op_br()
432432{
433433   // BR a: Branch on Status 1
434   op_illegal();
434   if (m_s)
435      m_pc = (m_pc & ~0x3f) | (m_op & 0x3f);
436   else
437      m_s = 1;
435438}
436439
437440void hmcs40_cpu_device::op_cal()
438441{
439442   // CAL a: Subroutine Jump on Status 1
440   op_illegal();
443   if (m_s)
444   {
445      push_stack();
446      m_pc = m_op & 0x3f; // short calls default to page 0
447   }
448   else
449      m_s = 1;
441450}
442451
443452void hmcs40_cpu_device::op_lpu()
444453{
445454   // LPU u: Load Program Counter Upper on Status 1
446   op_illegal();
455   if (m_s)
456      m_page = m_op & 0x1f;
457   else
458      m_op = 0;
447459}
448460
449461void hmcs40_cpu_device::op_tbr()
450462{
451463   // TBR p: Table Branch
452   op_illegal();
464   m_pc = (m_a | m_b << 4 | m_c << 8 | ((m_op & 7) << 9)) & m_prgmask;
453465}
454466
455467void hmcs40_cpu_device::op_rtn()
456468{
457469   // RTN: Return from Subroutine
458   op_illegal();
470   pop_stack();
459471}
460472
461473


Previous 199869 Revisions Next


© 1997-2024 The MAME Team