mirror of
https://github.com/pevans/erc-c.git
synced 2025-03-03 08:29:14 +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
|
* Below are some functions that are defined in mos6502.addr.c
|
||||||
*/
|
*/
|
||||||
extern int mos6502_addr_mode(vm_8bit);
|
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
|
* 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
|
// First, we need to know how to resolve our effective address and
|
||||||
// how to execute anything.
|
// 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);
|
handler = mos6502_get_instruction_handler(opcode);
|
||||||
|
|
||||||
// The operand is the effective operand, the value that the
|
// 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.
|
* cpu) that an instruction will use.
|
||||||
*/
|
*/
|
||||||
mos6502_address_resolver
|
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 ACC: return mos6502_resolve_acc;
|
||||||
case ABS: return mos6502_resolve_abs;
|
case ABS: return mos6502_resolve_abs;
|
||||||
case ABX: return mos6502_resolve_abx;
|
case ABX: return mos6502_resolve_abx;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
static char s_inst[4],
|
static char s_inst[4],
|
||||||
s_oper[10],
|
s_oper[10],
|
||||||
|
s_value[3],
|
||||||
s_label[13],
|
s_label[13],
|
||||||
s_state[51],
|
s_state[51],
|
||||||
s_bytes[12];
|
s_bytes[12];
|
||||||
@ -94,38 +95,53 @@ mos6502_dis_operand(mos6502 *cpu,
|
|||||||
{
|
{
|
||||||
int rel_address;
|
int rel_address;
|
||||||
int ind_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) {
|
switch (addr_mode) {
|
||||||
case ACC:
|
case ACC:
|
||||||
break;
|
break;
|
||||||
case ABS:
|
case ABS:
|
||||||
snprintf(str, len, "$%04X", value);
|
snprintf(str, len, "$%04X", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case ABX:
|
case ABX:
|
||||||
snprintf(str, len, "$%04X,X", value);
|
snprintf(str, len, "$%04X,X", value);
|
||||||
|
eff_value = resolv(cpu);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case ABY:
|
case ABY:
|
||||||
snprintf(str, len, "$%04X,Y", value);
|
snprintf(str, len, "$%04X,Y", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case IMM:
|
case IMM:
|
||||||
snprintf(str, len, "#$%02X", value);
|
snprintf(str, len, "#$%02X", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case IMP:
|
case IMP:
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02X", 0);
|
||||||
break;
|
break;
|
||||||
case IND:
|
case IND:
|
||||||
ind_address = mos6502_get(cpu, value + 1) << 8;
|
ind_address = mos6502_get(cpu, value + 1) << 8;
|
||||||
ind_address |= mos6502_get(cpu, value);
|
ind_address |= mos6502_get(cpu, value);
|
||||||
if (jump_table[ind_address]) {
|
if (jump_table[ind_address]) {
|
||||||
mos6502_dis_label(str, len, ind_address);
|
mos6502_dis_label(str, len, ind_address);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02X", 0);
|
||||||
} else {
|
} else {
|
||||||
snprintf(str, len, "($%04X)", value);
|
snprintf(str, len, "($%04X)", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX:
|
case IDX:
|
||||||
snprintf(str, len, "($%02X,X)", value);
|
snprintf(str, len, "($%02X,X)", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case IDY:
|
case IDY:
|
||||||
snprintf(str, len, "($%02X),Y", value);
|
snprintf(str, len, "($%02X),Y", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case REL:
|
case REL:
|
||||||
rel_address = address + value;
|
rel_address = address + value;
|
||||||
@ -134,17 +150,21 @@ mos6502_dis_operand(mos6502 *cpu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mos6502_dis_label(str, len, rel_address);
|
mos6502_dis_label(str, len, rel_address);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case ZPG:
|
case ZPG:
|
||||||
// We add a couple of spaces here to help our output
|
// We add a couple of spaces here to help our output
|
||||||
// comments line up.
|
// comments line up.
|
||||||
snprintf(str, len, "$%02X", value);
|
snprintf(str, len, "$%02X", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case ZPX:
|
case ZPX:
|
||||||
snprintf(str, len, "$%02X,X", value);
|
snprintf(str, len, "$%02X,X", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
break;
|
||||||
case ZPY:
|
case ZPY:
|
||||||
snprintf(str, len, "$%02X,Y", value);
|
snprintf(str, len, "$%02X,Y", value);
|
||||||
|
snprintf(s_value, sizeof(s_value), "%02x", eff_value);
|
||||||
break;
|
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,
|
// what the PC was at the point of this opcode sequence; two,
|
||||||
// the opcode;
|
// the opcode;
|
||||||
snprintf(s_state, sizeof(s_state) - 1,
|
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,
|
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);
|
cpu->A, cpu->X, cpu->Y, cpu->P, cpu->S);
|
||||||
|
|
||||||
// And three, the operand, if any. Remembering that the operand
|
// And three, the operand, if any. Remembering that the operand
|
||||||
|
Loading…
x
Reference in New Issue
Block a user