Previous 199869 Revisions Next

r21987 Wednesday 20th March, 2013 at 16:14:39 UTC by O. Galibert
m6502: Seriously untested multi-dispatch-table support [O. Galibert]
[docs]m6502.txt
[src/emu/cpu/m6502]m6502.c m6502.h m6502make.py

trunk/src/emu/cpu/m6502/m6502.c
r21986r21987
100100   save_item(NAME(v_state));
101101   save_item(NAME(inst_state));
102102   save_item(NAME(inst_substate));
103   save_item(NAME(inst_state_base));
103104   save_item(NAME(irq_taken));
104105   save_item(NAME(inhibit_interrupts));
105106
r21986r21987
122123   v_state = false;
123124   inst_state = STATE_RESET;
124125   inst_substate = 0;
126   inst_state_base = 0;
125127   sync = false;
126128   end_cycles = 0;
127129   inhibit_interrupts = false;
r21986r21987
131133{
132134   inst_state = STATE_RESET;
133135   inst_substate = 0;
136   inst_state_base = 0;
134137   nmi_state = false;
135138   irq_state = false;
136139   apu_irq_state = false;
r21986r21987
406409   while(icount > 0) {
407410      if(inst_state < 0x100) {
408411         PPC = NPC;
409         inst_state = IR;
412         inst_state = IR | inst_state_base;
410413         if(machine().debug_flags & DEBUG_FLAG_ENABLED)
411414            debugger_instruction_hook(this, NPC);
412415      }
r21986r21987
479482
480483offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options, const disasm_entry *table)
481484{
482   const disasm_entry &e = table[oprom[0]];
485   const disasm_entry &e = table[oprom[0] | inst_state_base];
483486   UINT32 flags = e.flags | DASMFLAG_SUPPORTED;
484487   buffer += sprintf(buffer, "%s", e.opcode);
485488
trunk/src/emu/cpu/m6502/m6502make.py
r21986r21987
77import sys
88import logging
99
10MAX_STATES = 0x101
10MAX_STATES = 0
1111
1212def load_opcodes(fname):
1313    """Load opcodes from .lst file"""
r21986r21987
174174"""
175175
176176DISASM_PROLOG="""\
177const %(device)s::disasm_entry %(device)s::disasm_entries[0x100] = {
177const %(device)s::disasm_entry %(device)s::disasm_entries[0x%(disasm_count)x] = {
178178"""
179179
180180DISASM_EPILOG="""\
r21986r21987
182182"""
183183
184184def save_tables(f, device, states):
185    total_states = len(states)
186
185187    d = { "device": device,
188          "disasm_count": total_states-1
186189          }
187
188    assert len(states) == MAX_STATES
189
190   
191   
190192    emit(f, DO_EXEC_FULL_PROLOG % d)
191193    for n, state in enumerate(states):
192194        if state == ".": continue
193        if n < MAX_STATES - 1:
195        if n < total_states - 1:
194196            emit(f, "\tcase 0x%02x: %s_full(); break;\n" % (n, state))
195197        else:
196198            emit(f, "\tcase %s: %s_full(); break;\n" % ("STATE_RESET", state))
r21986r21987
199201    emit(f, DO_EXEC_PARTIAL_PROLOG % d)
200202    for n, state in enumerate(states):
201203        if state == ".": continue
202        if n < MAX_STATES - 1:
204        if n < total_states - 1:
203205            emit(f, "\tcase 0x%02x: %s_partial(); break;\n" % (n, state))
204206        else:
205207            emit(f, "\tcase %s: %s_partial(); break;\n" % ("STATE_RESET", state))
206208    emit(f, DO_EXEC_PARTIAL_EPILOG % d)
207209
208    emit(f, DISASM_PROLOG % d)
210    emit(f, DISASM_PROLOG % d )
209211    for n, state in enumerate(states):
210212        if state == ".": continue
211        if n == MAX_STATES - 1: break
213        if n == total_states - 1: break
212214        tokens = state.split("_")
213215        opc = tokens[0]
214216        mode = tokens[-1]
r21986r21987
262264
263265    states = load_disp(argv[3])
264266    logging.info("loaded %s states", len(states))
265    assert len(states) == MAX_STATES
266267
268    assert (len(states) & 0xff) == 1
267269    save(argv[4], device_name, opcodes, states)
268270
269271
trunk/src/emu/cpu/m6502/m6502.h
r21986r21987
9797   };
9898
9999   enum {
100      STATE_RESET = 0x100,
100      STATE_RESET = 0xff00,
101101   };
102102
103103   enum {
r21986r21987
182182   UINT8   Y;                      /* Y index register */
183183   UINT8   P;                      /* Processor status */
184184   UINT8   IR;                     /* Prefetched instruction register */
185   int     inst_state_base;        /* Current instruction bank */
185186
186187   memory_interface *mintf;
187188   int inst_state, inst_substate;
trunk/docs/m6502.txt
r21986r21987
252252instruction in the middle.  This is done through a two-level state
253253machine with updates only at the boundaries.  More precisely,
254254inst_state tells you which main state you're in.  It's equal to the
255opcode byte when 0-255, and 256 means reset.  It's always valid and
255opcode byte when 0-255, and 0xff00 means reset.  It's always valid and
256256used by instructions like rmb.  inst_substate indicates at which step
257257we are in an instruction, but it set only when an instruction has been
258258interrupted.  Let's go back to the asl <abs> code:
r21986r21987
458458state goes further than the scheduling slice of the cpu.  That should
459459not usually be the case, so the cost should be minimal.
460460
461  10. Current TODO
461  10. Multi-dispatch variants
462462
463Some variants currently in the process of being supported change
464instruction set depending on an internal flag, either switching to a
46516-bits mode or changing some register accesses to memory accesses.
466This is handled by having multiple dispatch tables for the cpu, the
467d<cpu>.lst not being 257 entries anymore but 256*n+1.  The variable
468inst_state_base must select which instruction table to use at a given
469time.  It must be a multiple of 256, and is in fact simply or-ed to
470the first instruction byte to get the dispatch table index (aka
471inst_state).
472
473  11. Current TODO
474
463475- Implement the bus contention/wait states stuff, but that requires
464476  support on the memory map side first.
465477

Previous 199869 Revisions Next


© 1997-2024 The MAME Team