--- mon/src/mon_6502.cpp 1999/10/04 19:31:09 1.1.1.1 +++ mon/src/mon_6502.cpp 2007/01/21 17:32:05 1.10 @@ -1,17 +1,31 @@ /* * mon_6502.cpp - 6502 disassembler * - * (C) 1997-1999 Christian Bauer + * cxmon (C) 1997-2004 Christian Bauer, Marc Hellwig + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "sysdeps.h" #include "mon.h" -#include "mon_6502.h" +#include "mon_disass.h" // Addressing modes -enum { +enum AddrMode { A_IMPL, A_ACCU, // A A_IMM, // #zz @@ -28,7 +42,7 @@ enum { }; // Mnemonics -enum { +enum Mnemonic { M_ADC, M_AND, M_ASL, M_BCC, M_BCS, M_BEQ, M_BIT, M_BMI, M_BNE, M_BPL, M_BRK, M_BVC, M_BVS, M_CLC, M_CLD, M_CLI, M_CLV, M_CMP, M_CPX, M_CPY, M_DEC, M_DEX, M_DEY, M_EOR, M_INC, M_INX, M_INY, M_JMP, M_JSR, M_LDA, @@ -46,7 +60,7 @@ enum { }; // Mnemonic for each opcode -static const char mnemonic[256] = { +static const Mnemonic mnemonic[256] = { M_BRK , M_ORA , M_IJAM, M_ISLO, M_INOP, M_ORA, M_ASL , M_ISLO, // 00 M_PHP , M_ORA , M_ASL , M_IANC, M_INOP, M_ORA, M_ASL , M_ISLO, M_BPL , M_ORA , M_IJAM, M_ISLO, M_INOP, M_ORA, M_ASL , M_ISLO, // 10 @@ -82,7 +96,7 @@ static const char mnemonic[256] = { }; // Addressing mode for each opcode -static const char adr_mode[256] = { +static const AddrMode adr_mode[256] = { A_IMPL, A_INDX, A_IMPL, A_INDX, A_ZERO , A_ZERO , A_ZERO , A_ZERO, // 00 A_IMPL, A_IMM , A_ACCU, A_IMM , A_ABS , A_ABS , A_ABS , A_ABS, A_REL , A_INDY, A_IMPL, A_INDY, A_ZEROX, A_ZEROX, A_ZEROX, A_ZEROX, // 10 @@ -123,7 +137,7 @@ static const char mnem_2[] = "dnscceimnp static const char mnem_3[] = "cdlcsqtielkcscdivpxycxyrcxypraxyrpaapaplrisccdiaxyxyxasa?cerrpbmpsxaaaxcxasxyoe"; // Instruction length for each addressing mode -static const char adr_length[] = {1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2}; +static const int adr_length[] = {1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2}; /* @@ -132,7 +146,8 @@ static const char adr_length[] = {1, 1, int disass_6502(FILE *f, uint32 adr, uint8 op, uint8 lo, uint8 hi) { - char mode = adr_mode[op], mnem = mnemonic[op]; + AddrMode mode = adr_mode[op]; + Mnemonic mnem = mnemonic[op]; // Display instruction bytes in hex switch (adr_length[mode]) { @@ -172,7 +187,7 @@ int disass_6502(FILE *f, uint32 adr, uin break; case A_REL: - fprintf(f, "$%04lx", (adr + 2) + (int8)lo); + fprintf(f, "$%04x", (adr + 2) + (int8)lo); break; case A_ZERO: