From a9cf25853d9a3479fadb262e467d768fd075544a Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 19 Jan 2018 13:14:02 -0600 Subject: [PATCH] Show the individual flags of the P register --- src/mos6502.dis.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mos6502.dis.c b/src/mos6502.dis.c index be94b03..885c1fd 100644 --- a/src/mos6502.dis.c +++ b/src/mos6502.dis.c @@ -14,7 +14,7 @@ static char s_inst[4], s_oper[10], s_value[3], s_label[13], - s_state[51], + s_state[54], s_bytes[12]; static vm_8bit jump_table[MOS6502_MEMSIZE]; @@ -321,10 +321,18 @@ 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:%2s a:%02x x:%02x y:%02x p:%02x s:%02x", + "pc:%02x%02x cy:%02d val:%2s a:%02x x:%02x y:%02x p:%c%c-%c%c%c%c%c s:%02x", cpu->PC >> 8, cpu->PC & 0xff, mos6502_cycles(cpu, opcode), s_value, - cpu->A, cpu->X, cpu->Y, cpu->P, cpu->S); + cpu->A, cpu->X, cpu->Y, + cpu->P & MOS_NEGATIVE ? 'N' : 'n', + cpu->P & MOS_OVERFLOW ? 'O' : 'o', + cpu->P & MOS_BREAK ? 'B' : 'b', + cpu->P & MOS_DECIMAL ? 'D' : 'd', + cpu->P & MOS_INTERRUPT ? 'I' : 'i', + cpu->P & MOS_ZERO ? 'Z' : 'z', + cpu->P & MOS_CARRY ? 'C' : 'c', + cpu->S); // And three, the operand, if any. Remembering that the operand // should be shown in little-endian order. @@ -339,7 +347,7 @@ mos6502_dis_opcode(mos6502 *cpu, FILE *stream, int address) } } - fprintf(stream, "%s %4s %-9s ; %-51s | %s\n", + fprintf(stream, "%s %4s %-9s ; %-54s | %s\n", s_label, s_inst, s_oper, s_state, s_bytes); if (mos6502_would_jump(inst_code)) {