mirror of
https://github.com/pevans/erc-c.git
synced 2025-02-25 14:29:13 +00:00
Show the dereferenced value for a given address
This commit is contained in:
parent
2c319399d2
commit
6b160c6ca2
@ -149,7 +149,7 @@ extern void mos6502_set_status(mos6502 *, vm_8bit);
|
||||
* Below are some functions that are defined in mos6502.addr.c
|
||||
*/
|
||||
extern int mos6502_addr_mode(vm_8bit);
|
||||
extern mos6502_address_resolver mos6502_get_address_resolver(vm_8bit);
|
||||
extern mos6502_address_resolver mos6502_get_address_resolver(int);
|
||||
|
||||
/*
|
||||
* All of our address modes
|
||||
|
@ -352,7 +352,7 @@ mos6502_execute(mos6502 *cpu)
|
||||
|
||||
// First, we need to know how to resolve our effective address and
|
||||
// how to execute anything.
|
||||
resolver = mos6502_get_address_resolver(opcode);
|
||||
resolver = mos6502_get_address_resolver(mos6502_addr_mode(opcode));
|
||||
handler = mos6502_get_instruction_handler(opcode);
|
||||
|
||||
// The operand is the effective operand, the value that the
|
||||
@ -454,9 +454,9 @@ mos6502_would_jump(int inst_code)
|
||||
* cpu) that an instruction will use.
|
||||
*/
|
||||
mos6502_address_resolver
|
||||
mos6502_get_address_resolver(vm_8bit opcode)
|
||||
mos6502_get_address_resolver(int addr_mode)
|
||||
{
|
||||
switch (mos6502_addr_mode(opcode)) {
|
||||
switch (addr_mode) {
|
||||
case ACC: return mos6502_resolve_acc;
|
||||
case ABS: return mos6502_resolve_abs;
|
||||
case ABX: return mos6502_resolve_abx;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
static char s_inst[4],
|
||||
s_oper[10],
|
||||
s_value[3],
|
||||
s_label[13],
|
||||
s_state[51],
|
||||
s_bytes[12];
|
||||
@ -94,38 +95,53 @@ mos6502_dis_operand(mos6502 *cpu,
|
||||
{
|
||||
int rel_address;
|
||||
int ind_address;
|
||||
vm_8bit eff_value;
|
||||
mos6502_address_resolver resolv;
|
||||
|
||||
resolv = mos6502_get_address_resolver(addr_mode);
|
||||
eff_value = resolv(cpu);
|
||||
|
||||
switch (addr_mode) {
|
||||
case ACC:
|
||||
break;
|
||||
case ABS:
|
||||
snprintf(str, len, "$%04X", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case ABX:
|
||||
snprintf(str, len, "$%04X,X", value);
|
||||
eff_value = resolv(cpu);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case ABY:
|
||||
snprintf(str, len, "$%04X,Y", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case IMM:
|
||||
snprintf(str, len, "#$%02X", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case IMP:
|
||||
snprintf(s_value, sizeof(s_value), "%02X", 0);
|
||||
break;
|
||||
case IND:
|
||||
ind_address = mos6502_get(cpu, value + 1) << 8;
|
||||
ind_address |= mos6502_get(cpu, value);
|
||||
if (jump_table[ind_address]) {
|
||||
mos6502_dis_label(str, len, ind_address);
|
||||
snprintf(s_value, sizeof(s_value), "%02X", 0);
|
||||
} else {
|
||||
snprintf(str, len, "($%04X)", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
}
|
||||
break;
|
||||
case IDX:
|
||||
snprintf(str, len, "($%02X,X)", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case IDY:
|
||||
snprintf(str, len, "($%02X),Y", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case REL:
|
||||
rel_address = address + value;
|
||||
@ -134,17 +150,21 @@ mos6502_dis_operand(mos6502 *cpu,
|
||||
}
|
||||
|
||||
mos6502_dis_label(str, len, rel_address);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case ZPG:
|
||||
// We add a couple of spaces here to help our output
|
||||
// comments line up.
|
||||
snprintf(str, len, "$%02X", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case ZPX:
|
||||
snprintf(str, len, "$%02X,X", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
case ZPY:
|
||||
snprintf(str, len, "$%02X,Y", value);
|
||||
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -301,9 +321,9 @@ mos6502_dis_opcode(mos6502 *cpu, FILE *stream, int address)
|
||||
// what the PC was at the point of this opcode sequence; two,
|
||||
// the opcode;
|
||||
snprintf(s_state, sizeof(s_state) - 1,
|
||||
"pc:%02x%02x cy:%02d val:%04x a:%02x x:%02x y:%02x p:%02x s:%02x",
|
||||
"pc:%02x%02x cy:%02d val:%2s a:%02x x:%02x y:%02x p:%02x s:%02x",
|
||||
cpu->PC >> 8, cpu->PC & 0xff,
|
||||
mos6502_cycles(cpu, opcode), operand,
|
||||
mos6502_cycles(cpu, opcode), s_value,
|
||||
cpu->A, cpu->X, cpu->Y, cpu->P, cpu->S);
|
||||
|
||||
// And three, the operand, if any. Remembering that the operand
|
||||
|
Loading…
x
Reference in New Issue
Block a user