1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-09-29 11:55:01 +00:00

Move address resolver

This commit is contained in:
Peter Evans 2018-01-07 15:47:57 -06:00
parent 7b2450131e
commit cccf6df354
2 changed files with 30 additions and 29 deletions

View File

@ -37,35 +37,6 @@ static int addr_modes[] = {
REL, IDY, NOA, NOA, NOA, ZPX, ZPX, NOA, IMP, ABY, NOA, NOA, NOA, ABX, ABX, NOA, // Fx
};
/*
* This is a _kind_ of factory method, except we're obviously not
* instantiating an object. Given an address mode, we return the
* resolver function which will give you the right value (for a given
* cpu) that an instruction will use.
*/
mos6502_address_resolver
mos6502_get_address_resolver(vm_8bit opcode)
{
switch (mos6502_addr_mode(opcode)) {
case ACC: return mos6502_resolve_acc;
case ABS: return mos6502_resolve_abs;
case ABX: return mos6502_resolve_abx;
case ABY: return mos6502_resolve_aby;
case IMM: return mos6502_resolve_imm;
case IND: return mos6502_resolve_ind;
case IDX: return mos6502_resolve_idx;
case IDY: return mos6502_resolve_idy;
case REL: return mos6502_resolve_rel;
case ZPG: return mos6502_resolve_zpg;
case ZPX: return mos6502_resolve_zpx;
case ZPY: return mos6502_resolve_zpy;
case IMP: // FALLTHRU
default: break;
}
return NULL;
}
/*
* Just a little macro to help us figure out what the address is for
* for 16-bit values

View File

@ -451,3 +451,33 @@ mos6502_flash_memory(mos6502 *cpu, vm_segment *segment)
{
vm_segment_copy(cpu->memory, segment, 0, 0, cpu->memory->size - 1);
}
/*
* This is a _kind_ of factory method, except we're obviously not
* instantiating an object. Given an address mode, we return the
* resolver function which will give you the right value (for a given
* cpu) that an instruction will use.
*/
mos6502_address_resolver
mos6502_get_address_resolver(vm_8bit opcode)
{
switch (mos6502_addr_mode(opcode)) {
case ACC: return mos6502_resolve_acc;
case ABS: return mos6502_resolve_abs;
case ABX: return mos6502_resolve_abx;
case ABY: return mos6502_resolve_aby;
case IMM: return mos6502_resolve_imm;
case IND: return mos6502_resolve_ind;
case IDX: return mos6502_resolve_idx;
case IDY: return mos6502_resolve_idy;
case REL: return mos6502_resolve_rel;
case ZPG: return mos6502_resolve_zpg;
case ZPX: return mos6502_resolve_zpx;
case ZPY: return mos6502_resolve_zpy;
case IMP: // FALLTHRU
default: break;
}
return NULL;
}