Added whitespace for each run-in comma

This commit is contained in:
Tennessee Carmel-Veilleux 2014-07-23 15:07:19 -04:00
parent 984edd2187
commit 676ddb5177

572
dcc6502.c
View File

@ -45,229 +45,229 @@ typedef struct OPcode {
typedef union typedef union
{ {
#ifdef LSB_FIRST #ifdef LSB_FIRST
struct { unsigned char l,h; } B; struct { unsigned char l, h; } B;
#else #else
struct { byte h,l; } B; struct { byte h, l; } B;
#endif #endif
unsigned short W; unsigned short W;
} word; } word;
char name_table[56][4]={ char name_table[56][4]={
"ADC","AND","ASL","BCC","BCS","BEQ","BIT","BMI","BNE","BPL", "ADC", "AND", "ASL", "BCC", "BCS", "BEQ", "BIT", "BMI", "BNE", "BPL",
"BRK","BVC","BVS","CLC","CLD","CLI","CLV","CMP","CPX","CPY", "BRK", "BVC", "BVS", "CLC", "CLD", "CLI", "CLV", "CMP", "CPX", "CPY",
"DEC","DEX","DEY","EOR","INC","INX","INY","JMP","JSR","LDA", "DEC", "DEX", "DEY", "EOR", "INC", "INX", "INY", "JMP", "JSR", "LDA",
"LDX","LDY","LSR","NOP","ORA","PHA","PHP","PLA","PLP","ROL", "LDX", "LDY", "LSR", "NOP", "ORA", "PHA", "PHP", "PLA", "PLP", "ROL",
"ROR","RTI","RTS","SBC","SEC","SED","SEI","STA","STX","STY", "ROR", "RTI", "RTS", "SBC", "SEC", "SED", "SEI", "STA", "STX", "STY",
"TAX","TAY","TSX","TXA","TXS","TYA"}; "TAX", "TAY", "TSX", "TXA", "TXS", "TYA"};
/* Opcode table */ /* Opcode table */
OPcode opcode_table[NUMBER_OPCODES] = { OPcode opcode_table[NUMBER_OPCODES] = {
{0x69,0,IMMED,2,1}, /* ADC */ {0x69, 0, IMMED, 2, 1}, /* ADC */
{0x65,0,ZEROP,3,1}, {0x65, 0, ZEROP, 3, 1},
{0x75,0,ZEPIX,4,1}, {0x75, 0, ZEPIX, 4, 1},
{0x6D,0,ABSOL,4,1}, {0x6D, 0, ABSOL, 4, 1},
{0x7D,0,ABSIX,4,1}, {0x7D, 0, ABSIX, 4, 1},
{0x79,0,ABSIY,4,1}, {0x79, 0, ABSIY, 4, 1},
{0x61,0,INDIN,6,1}, {0x61, 0, INDIN, 6, 1},
{0x71,0,ININD,5,1}, {0x71, 0, ININD, 5, 1},
{0x29,1,IMMED,2,1}, /* AND */ {0x29, 1, IMMED, 2, 1}, /* AND */
{0x25,1,ZEROP,3,1}, {0x25, 1, ZEROP, 3, 1},
{0x35,1,ZEPIX,4,1}, {0x35, 1, ZEPIX, 4, 1},
{0x2D,1,ABSOL,4,1}, {0x2D, 1, ABSOL, 4, 1},
{0x3D,1,ABSIX,4,1}, {0x3D, 1, ABSIX, 4, 1},
{0x39,1,ABSIY,4,1}, {0x39, 1, ABSIY, 4, 1},
{0x21,1,INDIN,6,1}, {0x21, 1, INDIN, 6, 1},
{0x31,1,ININD,5,1}, {0x31, 1, ININD, 5, 1},
{0x0A,2,ACCUM,2,0}, /* ASL */ {0x0A, 2, ACCUM, 2, 0}, /* ASL */
{0x06,2,ZEROP,5,0}, {0x06, 2, ZEROP, 5, 0},
{0x16,2,ZEPIX,6,0}, {0x16, 2, ZEPIX, 6, 0},
{0x0E,2,ABSOL,6,0}, {0x0E, 2, ABSOL, 6, 0},
{0x1E,2,ABSIX,6,0}, {0x1E, 2, ABSIX, 6, 0},
{0x90,3,RELAT,4,1}, /* BCC */ {0x90, 3, RELAT, 4, 1}, /* BCC */
{0xB0,4,RELAT,4,1}, /* BCS */ {0xB0, 4, RELAT, 4, 1}, /* BCS */
{0xF0,5,RELAT,4,1}, /* BEQ */ {0xF0, 5, RELAT, 4, 1}, /* BEQ */
{0x24,6,ZEROP,3,0}, /* BIT */ {0x24, 6, ZEROP, 3, 0}, /* BIT */
{0x2C,6,ABSOL,4,0}, {0x2C, 6, ABSOL, 4, 0},
{0x30,7,RELAT,4,1}, /* BMI */ {0x30, 7, RELAT, 4, 1}, /* BMI */
{0xD0,8,RELAT,4,1}, /* BNE */ {0xD0, 8, RELAT, 4, 1}, /* BNE */
{0x10,9,RELAT,4,1}, /* BPL */ {0x10, 9, RELAT, 4, 1}, /* BPL */
{0x00,10,IMPLI,7,0}, /* BRK */ {0x00, 10, IMPLI, 7, 0}, /* BRK */
{0x50,11,RELAT,4,1}, /* BVC */ {0x50, 11, RELAT, 4, 1}, /* BVC */
{0x70,12,RELAT,4,1}, /* BVS */ {0x70, 12, RELAT, 4, 1}, /* BVS */
{0x18,13,IMPLI,2,0}, /* CLC */ {0x18, 13, IMPLI, 2, 0}, /* CLC */
{0xD8,14,IMPLI,2,0}, /* CLD */ {0xD8, 14, IMPLI, 2, 0}, /* CLD */
{0x58,15,IMPLI,2,0}, /* CLI */ {0x58, 15, IMPLI, 2, 0}, /* CLI */
{0xB8,16,IMPLI,2,0}, /* CLV */ {0xB8, 16, IMPLI, 2, 0}, /* CLV */
{0xC9,17,IMMED,2,0}, /* CMP */ {0xC9, 17, IMMED, 2, 0}, /* CMP */
{0xC5,17,ZEROP,3,0}, {0xC5, 17, ZEROP, 3, 0},
{0xD5,17,ZEPIX,4,0}, {0xD5, 17, ZEPIX, 4, 0},
{0xCD,17,ABSOL,4,0}, {0xCD, 17, ABSOL, 4, 0},
{0xDD,17,ABSIX,4,0}, {0xDD, 17, ABSIX, 4, 0},
{0xD9,17,ABSIY,4,0}, {0xD9, 17, ABSIY, 4, 0},
{0xC1,17,INDIN,6,0}, {0xC1, 17, INDIN, 6, 0},
{0xD1,17,ININD,5,0}, {0xD1, 17, ININD, 5, 0},
{0xE0,18,IMMED,2,0}, /* CPX */ {0xE0, 18, IMMED, 2, 0}, /* CPX */
{0xE4,18,ZEROP,3,0}, {0xE4, 18, ZEROP, 3, 0},
{0xEC,18,ABSOL,4,0}, {0xEC, 18, ABSOL, 4, 0},
{0xC0,19,IMMED,2,0}, /* CPY */ {0xC0, 19, IMMED, 2, 0}, /* CPY */
{0xC4,19,ZEROP,3,0}, {0xC4, 19, ZEROP, 3, 0},
{0xCC,19,ABSOL,4,0}, {0xCC, 19, ABSOL, 4, 0},
{0xC6,20,ZEROP,5,0}, /* DEC */ {0xC6, 20, ZEROP, 5, 0}, /* DEC */
{0xD6,20,ZEPIX,6,0}, {0xD6, 20, ZEPIX, 6, 0},
{0xCE,20,ABSOL,6,0}, {0xCE, 20, ABSOL, 6, 0},
{0xDE,20,ABSIX,6,0}, {0xDE, 20, ABSIX, 6, 0},
{0xCA,21,IMPLI,2,0}, /* DEX */ {0xCA, 21, IMPLI, 2, 0}, /* DEX */
{0x88,22,IMPLI,2,0}, /* DEY */ {0x88, 22, IMPLI, 2, 0}, /* DEY */
{0x49,23,IMMED,2,1}, /* EOR */ {0x49, 23, IMMED, 2, 1}, /* EOR */
{0x45,23,ZEROP,3,1}, {0x45, 23, ZEROP, 3, 1},
{0x55,23,ZEPIX,4,1}, {0x55, 23, ZEPIX, 4, 1},
{0x4D,23,ABSOL,4,1}, {0x4D, 23, ABSOL, 4, 1},
{0x5D,23,ABSIX,4,1}, {0x5D, 23, ABSIX, 4, 1},
{0x59,23,ABSIY,4,1}, {0x59, 23, ABSIY, 4, 1},
{0x41,23,INDIN,6,1}, {0x41, 23, INDIN, 6, 1},
{0x51,23,ININD,5,1}, {0x51, 23, ININD, 5, 1},
{0xE6,24,ZEROP,5,0}, /* INC */ {0xE6, 24, ZEROP, 5, 0}, /* INC */
{0xF6,24,ZEPIX,6,0}, {0xF6, 24, ZEPIX, 6, 0},
{0xEE,24,ABSOL,6,0}, {0xEE, 24, ABSOL, 6, 0},
{0xFE,24,ABSIX,6,0}, {0xFE, 24, ABSIX, 6, 0},
{0xE8,25,IMPLI,2,0}, /* INX */ {0xE8, 25, IMPLI, 2, 0}, /* INX */
{0xC8,26,IMPLI,2,0}, /* INY */ {0xC8, 26, IMPLI, 2, 0}, /* INY */
{0x4C,27,ABSOL,3,0}, /* JMP */ {0x4C, 27, ABSOL, 3, 0}, /* JMP */
{0x6C,27,INDIA,5,0}, {0x6C, 27, INDIA, 5, 0},
{0x20,28,ABSOL,6,0}, /* JSR */ {0x20, 28, ABSOL, 6, 0}, /* JSR */
{0xA9,29,IMMED,2,1}, /* LDA */ {0xA9, 29, IMMED, 2, 1}, /* LDA */
{0xA5,29,ZEROP,3,1}, {0xA5, 29, ZEROP, 3, 1},
{0xB5,29,ZEPIX,4,1}, {0xB5, 29, ZEPIX, 4, 1},
{0xAD,29,ABSOL,4,1}, {0xAD, 29, ABSOL, 4, 1},
{0xBD,29,ABSIX,4,1}, {0xBD, 29, ABSIX, 4, 1},
{0xB9,29,ABSIY,4,1}, {0xB9, 29, ABSIY, 4, 1},
{0xA1,29,INDIN,6,1}, {0xA1, 29, INDIN, 6, 1},
{0xB1,29,ININD,5,1}, {0xB1, 29, ININD, 5, 1},
{0xA2,30,IMMED,2,1}, /* LDX */ {0xA2, 30, IMMED, 2, 1}, /* LDX */
{0xA6,30,ZEROP,3,1}, {0xA6, 30, ZEROP, 3, 1},
{0xB6,30,ZEPIY,4,1}, {0xB6, 30, ZEPIY, 4, 1},
{0xAE,30,ABSOL,4,1}, {0xAE, 30, ABSOL, 4, 1},
{0xBE,30,ABSIY,4,1}, {0xBE, 30, ABSIY, 4, 1},
{0xA0,31,IMMED,2,1}, /* LDY */ {0xA0, 31, IMMED, 2, 1}, /* LDY */
{0xA4,31,ZEROP,3,1}, {0xA4, 31, ZEROP, 3, 1},
{0xB4,31,ZEPIX,4,1}, {0xB4, 31, ZEPIX, 4, 1},
{0xAC,31,ABSOL,4,1}, {0xAC, 31, ABSOL, 4, 1},
{0xBC,31,ABSIX,4,1}, {0xBC, 31, ABSIX, 4, 1},
{0x4A,32,ACCUM,2,0}, /* LSR */ {0x4A, 32, ACCUM, 2, 0}, /* LSR */
{0x46,32,ZEROP,5,0}, {0x46, 32, ZEROP, 5, 0},
{0x56,32,ZEPIX,6,0}, {0x56, 32, ZEPIX, 6, 0},
{0x4E,32,ABSOL,6,0}, {0x4E, 32, ABSOL, 6, 0},
{0x5E,32,ABSIX,6,0}, {0x5E, 32, ABSIX, 6, 0},
{0xEA,33,IMPLI,2,0}, /* NOP */ {0xEA, 33, IMPLI, 2, 0}, /* NOP */
{0x09,34,IMMED,2,0}, /* ORA */ {0x09, 34, IMMED, 2, 0}, /* ORA */
{0x05,34,ZEROP,3,0}, {0x05, 34, ZEROP, 3, 0},
{0x15,34,ZEPIX,4,0}, {0x15, 34, ZEPIX, 4, 0},
{0x0D,34,ABSOL,4,0}, {0x0D, 34, ABSOL, 4, 0},
{0x1D,34,ABSIX,4,0}, {0x1D, 34, ABSIX, 4, 0},
{0x19,34,ABSIY,4,0}, {0x19, 34, ABSIY, 4, 0},
{0x01,34,INDIN,6,0}, {0x01, 34, INDIN, 6, 0},
{0x11,34,ININD,5,0}, {0x11, 34, ININD, 5, 0},
{0x48,35,IMPLI,3,0}, /* PHA */ {0x48, 35, IMPLI, 3, 0}, /* PHA */
{0x08,36,IMPLI,3,0}, /* PHP */ {0x08, 36, IMPLI, 3, 0}, /* PHP */
{0x68,37,IMPLI,4,0}, /* PLA */ {0x68, 37, IMPLI, 4, 0}, /* PLA */
{0x28,38,IMPLI,4,0}, /* PLP */ {0x28, 38, IMPLI, 4, 0}, /* PLP */
{0x2A,39,ACCUM,2,0}, /* ROL */ {0x2A, 39, ACCUM, 2, 0}, /* ROL */
{0x26,39,ZEROP,5,0}, {0x26, 39, ZEROP, 5, 0},
{0x36,39,ZEPIX,6,0}, {0x36, 39, ZEPIX, 6, 0},
{0x2E,39,ABSOL,6,0}, {0x2E, 39, ABSOL, 6, 0},
{0x3E,39,ABSIX,6,0}, {0x3E, 39, ABSIX, 6, 0},
{0x6A,40,ACCUM,2,0}, /* ROR */ {0x6A, 40, ACCUM, 2, 0}, /* ROR */
{0x66,40,ZEROP,5,0}, {0x66, 40, ZEROP, 5, 0},
{0x76,40,ZEPIX,6,0}, {0x76, 40, ZEPIX, 6, 0},
{0x6E,40,ABSOL,6,0}, {0x6E, 40, ABSOL, 6, 0},
{0x7E,40,ABSIX,6,0}, {0x7E, 40, ABSIX, 6, 0},
{0x40,41,IMPLI,6,0}, /* RTI */ {0x40, 41, IMPLI, 6, 0}, /* RTI */
{0x60,42,IMPLI,6,0}, /* RTS */ {0x60, 42, IMPLI, 6, 0}, /* RTS */
{0xE9,43,IMMED,2,1}, /* SBC */ {0xE9, 43, IMMED, 2, 1}, /* SBC */
{0xE5,43,ZEROP,3,1}, {0xE5, 43, ZEROP, 3, 1},
{0xF5,43,ZEPIX,4,1}, {0xF5, 43, ZEPIX, 4, 1},
{0xED,43,ABSOL,4,1}, {0xED, 43, ABSOL, 4, 1},
{0xFD,43,ABSIX,4,1}, {0xFD, 43, ABSIX, 4, 1},
{0xF9,43,ABSIY,4,1}, {0xF9, 43, ABSIY, 4, 1},
{0xE1,43,INDIN,6,1}, {0xE1, 43, INDIN, 6, 1},
{0xF1,43,ININD,5,1}, {0xF1, 43, ININD, 5, 1},
{0x38,44,IMPLI,2,0}, /* SEC */ {0x38, 44, IMPLI, 2, 0}, /* SEC */
{0xF8,45,IMPLI,2,0}, /* SED */ {0xF8, 45, IMPLI, 2, 0}, /* SED */
{0x78,46,IMPLI,2,0}, /* SEI */ {0x78, 46, IMPLI, 2, 0}, /* SEI */
{0x85,47,ZEROP,3,0}, /* STA */ {0x85, 47, ZEROP, 3, 0}, /* STA */
{0x95,47,ZEPIX,4,0}, {0x95, 47, ZEPIX, 4, 0},
{0x8D,47,ABSOL,4,0}, {0x8D, 47, ABSOL, 4, 0},
{0x9D,47,ABSIX,4,0}, {0x9D, 47, ABSIX, 4, 0},
{0x99,47,ABSIY,4,0}, {0x99, 47, ABSIY, 4, 0},
{0x81,47,INDIN,6,0}, {0x81, 47, INDIN, 6, 0},
{0x91,47,ININD,5,0}, {0x91, 47, ININD, 5, 0},
{0x86,48,ZEROP,3,0}, /* STX */ {0x86, 48, ZEROP, 3, 0}, /* STX */
{0x96,48,ZEPIY,4,0}, {0x96, 48, ZEPIY, 4, 0},
{0x8E,48,ABSOL,4,0}, {0x8E, 48, ABSOL, 4, 0},
{0x84,49,ZEROP,3,0}, /* STY */ {0x84, 49, ZEROP, 3, 0}, /* STY */
{0x94,49,ZEPIX,4,0}, {0x94, 49, ZEPIX, 4, 0},
{0x8C,49,ABSOL,4,0}, {0x8C, 49, ABSOL, 4, 0},
{0xAA,50,IMPLI,2,0}, /* TAX */ {0xAA, 50, IMPLI, 2, 0}, /* TAX */
{0xA8,51,IMPLI,2,0}, /* TAY */ {0xA8, 51, IMPLI, 2, 0}, /* TAY */
{0xBA,52,IMPLI,2,0}, /* TSX */ {0xBA, 52, IMPLI, 2, 0}, /* TSX */
{0x8A,53,IMPLI,2,0}, /* TXA */ {0x8A, 53, IMPLI, 2, 0}, /* TXA */
{0x9A,54,IMPLI,2,0}, /* TXS */ {0x9A, 54, IMPLI, 2, 0}, /* TXS */
{0x98,55,IMPLI,2,0} /* TYA */ {0x98, 55, IMPLI, 2, 0} /* TYA */
}; };
unsigned short org; /* Origin of addresses */ unsigned short org; /* Origin of addresses */
@ -284,13 +284,13 @@ char line[512];
being disassembled */ being disassembled */
void emit_header(char *filename, int fsize, unsigned short org) { void emit_header(char *filename, int fsize, unsigned short org) {
fprintf(stdout,"; Source generated by DCC6502 version %s\n",VERSION_INFO); fprintf(stdout, "; Source generated by DCC6502 version %s\n", VERSION_INFO);
fprintf(stdout,"; For more info about DCC6502, e-mail veilleux@ameth.org\n;\n"); fprintf(stdout, "; For more info about DCC6502, e-mail veilleux@ameth.org\n;\n");
fprintf(stdout,"; FILENAME: %s, File Size: %d, ORG: $%04X\n",filename,fsize,org); fprintf(stdout, "; FILENAME: %s, File Size: %d, ORG: $%04X\n", filename, fsize, org);
if (hex_output) fprintf(stdout,"; -> Hex output enabled\n"); if (hex_output) fprintf(stdout, "; -> Hex output enabled\n");
if (cycle_counting) fprintf(stdout,"; -> Cycle counting enabled\n"); if (cycle_counting) fprintf(stdout, "; -> Cycle counting enabled\n");
if (nes_mode) fprintf(stdout,"; -> NES mode enabled\n"); if (nes_mode) fprintf(stdout, "; -> NES mode enabled\n");
fprintf(stdout,";---------------------------------------------------------------------------\n"); fprintf(stdout, ";---------------------------------------------------------------------------\n");
} }
/* This function appends cycle counting to the comment block */ /* This function appends cycle counting to the comment block */
@ -300,50 +300,50 @@ void append_cycle(char *input, unsigned char entry, unsigned short arg, unsigned
cycles = opcode_table[entry].cycles; cycles = opcode_table[entry].cycles;
sprintf(tmpstr," Cycles: %d ",cycles); sprintf(tmpstr, " Cycles: %d ", cycles);
if (opcode_table[entry].cross_page) strcat(tmpstr,"*!* "); if (opcode_table[entry].cross_page) strcat(tmpstr, "*!* ");
strcat(input,tmpstr); strcat(input, tmpstr);
} }
void add_nes_str(char *instr, char *instr2) { void add_nes_str(char *instr, char *instr2) {
strcat(instr," [NES] "); strcat(instr, " [NES] ");
strcat(instr,instr2); strcat(instr, instr2);
} }
/* This function put NES-specific info in the comment block */ /* This function put NES-specific info in the comment block */
void append_nes(char *input, unsigned short arg) { void append_nes(char *input, unsigned short arg) {
switch(arg) { switch(arg) {
case 0x2000: add_nes_str(input,"PPU setup #1"); break; case 0x2000: add_nes_str(input, "PPU setup #1"); break;
case 0x2001: add_nes_str(input,"PPU setup #2"); break; case 0x2001: add_nes_str(input, "PPU setup #2"); break;
case 0x2002: add_nes_str(input,"PPU status"); break; case 0x2002: add_nes_str(input, "PPU status"); break;
case 0x2003: add_nes_str(input,"SPR-RAM address select"); break; case 0x2003: add_nes_str(input, "SPR-RAM address select"); break;
case 0x2004: add_nes_str(input,"SPR-RAM data"); break; case 0x2004: add_nes_str(input, "SPR-RAM data"); break;
case 0x2005: add_nes_str(input,"PPU scroll"); break; case 0x2005: add_nes_str(input, "PPU scroll"); break;
case 0x2006: add_nes_str(input,"VRAM address select"); break; case 0x2006: add_nes_str(input, "VRAM address select"); break;
case 0x2007: add_nes_str(input,"VRAM data"); break; case 0x2007: add_nes_str(input, "VRAM data"); break;
case 0x4000: add_nes_str(input,"Audio -> Square 1"); break; case 0x4000: add_nes_str(input, "Audio -> Square 1"); break;
case 0x4001: add_nes_str(input,"Audio -> Square 1"); break; case 0x4001: add_nes_str(input, "Audio -> Square 1"); break;
case 0x4002: add_nes_str(input,"Audio -> Square 1"); break; case 0x4002: add_nes_str(input, "Audio -> Square 1"); break;
case 0x4003: add_nes_str(input,"Audio -> Square 1"); break; case 0x4003: add_nes_str(input, "Audio -> Square 1"); break;
case 0x4004: add_nes_str(input,"Audio -> Square 2"); break; case 0x4004: add_nes_str(input, "Audio -> Square 2"); break;
case 0x4005: add_nes_str(input,"Audio -> Square 2"); break; case 0x4005: add_nes_str(input, "Audio -> Square 2"); break;
case 0x4006: add_nes_str(input,"Audio -> Square 2"); break; case 0x4006: add_nes_str(input, "Audio -> Square 2"); break;
case 0x4007: add_nes_str(input,"Audio -> Square 2"); break; case 0x4007: add_nes_str(input, "Audio -> Square 2"); break;
case 0x4008: add_nes_str(input,"Audio -> Triangle"); break; case 0x4008: add_nes_str(input, "Audio -> Triangle"); break;
case 0x4009: add_nes_str(input,"Audio -> Triangle"); break; case 0x4009: add_nes_str(input, "Audio -> Triangle"); break;
case 0x400a: add_nes_str(input,"Audio -> Triangle"); break; case 0x400a: add_nes_str(input, "Audio -> Triangle"); break;
case 0x400b: add_nes_str(input,"Audio -> Triangle"); break; case 0x400b: add_nes_str(input, "Audio -> Triangle"); break;
case 0x400c: add_nes_str(input,"Audio -> Noise control reg"); break; case 0x400c: add_nes_str(input, "Audio -> Noise control reg"); break;
case 0x400e: add_nes_str(input,"Audio -> Noise Frequency reg #1"); break; case 0x400e: add_nes_str(input, "Audio -> Noise Frequency reg #1"); break;
case 0x400f: add_nes_str(input,"Audio -> Noise Frequency reg #2"); break; case 0x400f: add_nes_str(input, "Audio -> Noise Frequency reg #2"); break;
case 0x4010: add_nes_str(input,"Audio -> DPCM control"); break; case 0x4010: add_nes_str(input, "Audio -> DPCM control"); break;
case 0x4011: add_nes_str(input,"Audio -> DPCM D/A data"); break; case 0x4011: add_nes_str(input, "Audio -> DPCM D/A data"); break;
case 0x4012: add_nes_str(input,"Audio -> DPCM address"); break; case 0x4012: add_nes_str(input, "Audio -> DPCM address"); break;
case 0x4013: add_nes_str(input,"Audio -> DPCM data length"); break; case 0x4013: add_nes_str(input, "Audio -> DPCM data length"); break;
case 0x4014: add_nes_str(input,"Sprite DMA trigger"); break; case 0x4014: add_nes_str(input, "Sprite DMA trigger"); break;
case 0x4015: add_nes_str(input,"IRQ status / Sound enable"); break; case 0x4015: add_nes_str(input, "IRQ status / Sound enable"); break;
case 0x4016: add_nes_str(input,"Joypad & I/O port for port #1"); break; case 0x4016: add_nes_str(input, "Joypad & I/O port for port #1"); break;
case 0x4017: add_nes_str(input,"Joypad & I/O port for port #2"); break; case 0x4017: add_nes_str(input, "Joypad & I/O port for port #2"); break;
} }
} }
@ -353,9 +353,9 @@ void disassemble(char *output) {
char argument_signed; char argument_signed;
word tmp_word; word tmp_word;
char tmpstr[256],tmpstr2[256],tmpstr3[256]; char tmpstr[256], tmpstr2[256], tmpstr3[256];
int i,j,entry,found = 0; int i, j, entry, found = 0;
opcode = buffer[PC]; opcode = buffer[PC];
@ -368,10 +368,10 @@ void disassemble(char *output) {
if (!found) { if (!found) {
if (hex_output) { if (hex_output) {
sprintf(tmpstr,"$%04X> %02X:\t.byte $%02x\t\t; INVALID OPCODE !!!\n",org+PC,opcode,opcode); sprintf(tmpstr, "$%04X> %02X:\t.byte $%02x\t\t; INVALID OPCODE !!!\n", org+PC, opcode, opcode);
strncpy(output, tmpstr, 254); strncpy(output, tmpstr, 254);
} else { } else {
sprintf(tmpstr,"$%04X\t.byte $%02x\t; INVALID OPCODE !!!\n",org+PC,opcode); sprintf(tmpstr, "$%04X\t.byte $%02x\t; INVALID OPCODE !!!\n", org+PC, opcode);
strncpy(output, tmpstr, 254); strncpy(output, tmpstr, 254);
} }
} else { } else {
@ -380,13 +380,13 @@ void disassemble(char *output) {
PC++; PC++;
tmp_byte1 = buffer[PC]; /* Get immediate value */ tmp_byte1 = buffer[PC]; /* Get immediate value */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s #$%02x\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s #$%02x\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s #$%02x\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s #$%02x\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ABSOL: case ABSOL:
@ -396,16 +396,16 @@ void disassemble(char *output) {
tmp_word.B.h = buffer[PC]; /* Get high byte of address */ tmp_word.B.h = buffer[PC]; /* Get high byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X%02X:\t%s $%02X%02X\t;",org+PC-2,opcode,tmp_word.B.l,tmp_word.B.h,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X> %02X %02X%02X:\t%s $%02X%02X\t;", org+PC-2, opcode, tmp_word.B.l, tmp_word.B.h, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
else else
sprintf(tmpstr,"$%04X\t%s $%02X%02X\t;",org+PC-2,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X\t%s $%02X%02X\t;", org+PC-2, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,tmp_word.W,org+PC-2); if (cycle_counting) append_cycle(tmpstr, entry, tmp_word.W, org+PC-2);
/* Add NES port info if necessary */ /* Add NES port info if necessary */
if (nes_mode) append_nes(tmpstr,tmp_word.W); if (nes_mode) append_nes(tmpstr, tmp_word.W);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ZEROP: case ZEROP:
@ -413,26 +413,26 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get low byte of address */ tmp_byte1 = buffer[PC]; /* Get low byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s $%02X\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s $%02X\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s $%02X\t\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s $%02X\t\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case IMPLI: case IMPLI:
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X:\t%s\t\t;",org+PC,opcode,name_table[opcode_table[entry].name]); sprintf(tmpstr, "$%04X> %02X:\t%s\t\t;", org+PC, opcode, name_table[opcode_table[entry].name]);
else else
sprintf(tmpstr,"$%04X\t%s\t\t;",org+PC,name_table[opcode_table[entry].name]); sprintf(tmpstr, "$%04X\t%s\t\t;", org+PC, name_table[opcode_table[entry].name]);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC,org+PC); if (cycle_counting) append_cycle(tmpstr, entry, org+PC, org+PC);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case INDIA: case INDIA:
@ -442,14 +442,14 @@ void disassemble(char *output) {
tmp_word.B.h = buffer[PC]; /* Get high byte of address */ tmp_word.B.h = buffer[PC]; /* Get high byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X%02X:\t%s ($%02X%02X)\t;",org+PC-2,opcode,tmp_word.B.l,tmp_word.B.h,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X> %02X %02X%02X:\t%s ($%02X%02X)\t;", org+PC-2, opcode, tmp_word.B.l, tmp_word.B.h, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
else else
sprintf(tmpstr,"$%04X\t%s ($%02X%02X)\t;",org+PC-2,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X\t%s ($%02X%02X)\t;", org+PC-2, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,tmp_word.W,org+PC-2); if (cycle_counting) append_cycle(tmpstr, entry, tmp_word.W, org+PC-2);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ABSIX: case ABSIX:
@ -459,16 +459,16 @@ void disassemble(char *output) {
tmp_word.B.h = buffer[PC]; /* Get high byte of address */ tmp_word.B.h = buffer[PC]; /* Get high byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X%02X:\t%s $%02X%02X,X\t;",org+PC-2,opcode,tmp_word.B.l,tmp_word.B.h,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X> %02X %02X%02X:\t%s $%02X%02X,X\t;", org+PC-2, opcode, tmp_word.B.l, tmp_word.B.h, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
else else
sprintf(tmpstr,"$%04X\t%s $%02X%02X,X\t;",org+PC-2,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X\t%s $%02X%02X,X\t;", org+PC-2, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,tmp_word.W,org+PC-2); if (cycle_counting) append_cycle(tmpstr, entry, tmp_word.W, org+PC-2);
/* Add NES port info if necessary */ /* Add NES port info if necessary */
if (nes_mode) append_nes(tmpstr,tmp_word.W); if (nes_mode) append_nes(tmpstr, tmp_word.W);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ABSIY: case ABSIY:
@ -478,16 +478,16 @@ void disassemble(char *output) {
tmp_word.B.h = buffer[PC]; /* Get high byte of address */ tmp_word.B.h = buffer[PC]; /* Get high byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X%02X:\t%s $%02X%02X,Y\t;",org+PC-2,opcode,tmp_word.B.l,tmp_word.B.h,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X> %02X %02X%02X:\t%s $%02X%02X,Y\t;", org+PC-2, opcode, tmp_word.B.l, tmp_word.B.h, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
else else
sprintf(tmpstr,"$%04X\t%s $%02X%02X,Y\t;",org+PC-2,name_table[opcode_table[entry].name],tmp_word.B.h,tmp_word.B.l); sprintf(tmpstr, "$%04X\t%s $%02X%02X,Y\t;", org+PC-2, name_table[opcode_table[entry].name], tmp_word.B.h, tmp_word.B.l);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,tmp_word.W,org+PC-2); if (cycle_counting) append_cycle(tmpstr, entry, tmp_word.W, org+PC-2);
/* Add NES port info if necessary */ /* Add NES port info if necessary */
if (nes_mode) append_nes(tmpstr,tmp_word.W); if (nes_mode) append_nes(tmpstr, tmp_word.W);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ZEPIX: case ZEPIX:
@ -495,14 +495,14 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get low byte of address */ tmp_byte1 = buffer[PC]; /* Get low byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s $%02X,X\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s $%02X,X\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s $%02X,X\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s $%02X,X\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ZEPIY: case ZEPIY:
@ -510,14 +510,14 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get low byte of address */ tmp_byte1 = buffer[PC]; /* Get low byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s $%02X,Y\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s $%02X,Y\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s $%02X,Y\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s $%02X,Y\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case INDIN: case INDIN:
@ -525,14 +525,14 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get low byte of address */ tmp_byte1 = buffer[PC]; /* Get low byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s ($%02X,X)\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s ($%02X,X)\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s ($%02X,X)\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s ($%02X,X)\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ININD: case ININD:
@ -540,14 +540,14 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get low byte of address */ tmp_byte1 = buffer[PC]; /* Get low byte of address */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s ($%02X),Y\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s ($%02X),Y\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], tmp_byte1);
else else
sprintf(tmpstr,"$%04X\t%s ($%02X),Y\t;",org+PC-1,name_table[opcode_table[entry].name],tmp_byte1); sprintf(tmpstr, "$%04X\t%s ($%02X),Y\t;", org+PC-1, name_table[opcode_table[entry].name], tmp_byte1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC-1,org+PC-1); if (cycle_counting) append_cycle(tmpstr, entry, org+PC-1, org+PC-1);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case RELAT: case RELAT:
@ -555,26 +555,26 @@ void disassemble(char *output) {
tmp_byte1 = buffer[PC]; /* Get relative modifier */ tmp_byte1 = buffer[PC]; /* Get relative modifier */
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X %02X:\t%s $%04X\t\t;",org+PC-1,opcode,tmp_byte1,name_table[opcode_table[entry].name],(org+PC)+(signed char)(tmp_byte1)+1); sprintf(tmpstr, "$%04X> %02X %02X:\t%s $%04X\t\t;", org+PC-1, opcode, tmp_byte1, name_table[opcode_table[entry].name], (org+PC)+(signed char)(tmp_byte1)+1);
else else
sprintf(tmpstr,"$%04X\t%s $%04X\t;",org+PC-1,name_table[opcode_table[entry].name],(org+PC)+(signed char)(tmp_byte1)+1); sprintf(tmpstr, "$%04X\t%s $%04X\t;", org+PC-1, name_table[opcode_table[entry].name], (org+PC)+(signed char)(tmp_byte1)+1);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC,org+PC); if (cycle_counting) append_cycle(tmpstr, entry, org+PC, org+PC);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
case ACCUM: case ACCUM:
if (hex_output) if (hex_output)
sprintf(tmpstr,"$%04X> %02X:\t%s A\t\t;",org+PC,opcode,name_table[opcode_table[entry].name]); sprintf(tmpstr, "$%04X> %02X:\t%s A\t\t;", org+PC, opcode, name_table[opcode_table[entry].name]);
else else
sprintf(tmpstr,"$%04X\t%s A\t\t;",org+PC,name_table[opcode_table[entry].name]); sprintf(tmpstr, "$%04X\t%s A\t\t;", org+PC, name_table[opcode_table[entry].name]);
/* Add cycle count if necessary */ /* Add cycle count if necessary */
if (cycle_counting) append_cycle(tmpstr,entry,org+PC,org+PC); if (cycle_counting) append_cycle(tmpstr, entry, org+PC, org+PC);
strncpy(output,tmpstr,254); strncpy(output, tmpstr, 254);
break; break;
default: default:
@ -584,12 +584,12 @@ void disassemble(char *output) {
} }
void version(void) { void version(void) {
fprintf(stderr,"DCC6502 %s (C)1998-2003 Tennessee Carmel-Veilleux\n",VERSION_INFO); fprintf(stderr, "DCC6502 %s (C)1998-2003 Tennessee Carmel-Veilleux\n", VERSION_INFO);
fprintf(stderr,"This is free software. To see the LICENSE, use the -v parameter\n"); fprintf(stderr, "This is free software. To see the LICENSE, use the -v parameter\n");
} }
void usage_helper(char *str) { void usage_helper(char *str) {
fprintf(stderr,"\t%s\n",str); fprintf(stderr, "\t%s\n", str);
} }
void usage(void) { void usage(void) {
@ -600,22 +600,22 @@ void usage(void) {
usage_helper("-n -> Enable NES mode"); usage_helper("-n -> Enable NES mode");
usage_helper("-v -> Get only version information"); usage_helper("-v -> Get only version information");
usage_helper("-c -> Get cycle counting info"); usage_helper("-c -> Get cycle counting info");
fprintf(stderr,"\n"); fprintf(stderr, "\n");
} }
void license(void) { void license(void) {
fprintf(stderr,"(C) 1998-2003 Tennessee Carmel-Veilleux(veilleux@ameth.org)\n"); fprintf(stderr, "(C) 1998-2003 Tennessee Carmel-Veilleux(veilleux@ameth.org)\n");
fprintf(stderr,"This code is offered as FREEware. You cannot modify nor\n"); fprintf(stderr, "This code is offered as FREEware. You cannot modify nor\n");
fprintf(stderr,"distribute modified versions of this software without\n"); fprintf(stderr, "distribute modified versions of this software without\n");
fprintf(stderr,"prior written consent of the author(s). The author shall\n"); fprintf(stderr, "prior written consent of the author(s). The author shall\n");
fprintf(stderr,"NOT be responsible for ANY damage purely physical,\n"); fprintf(stderr, "NOT be responsible for ANY damage purely physical,\n");
fprintf(stderr,"emotional, material and magical to either you or anyone.\n"); fprintf(stderr, "emotional, material and magical to either you or anyone.\n");
} }
unsigned short hex2int (char *str, unsigned short dfl) { unsigned short hex2int (char *str, unsigned short dfl) {
char HEX_digits[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; char HEX_digits[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int i,j; int i, j;
char c,k,shift; char c, k,shift;
unsigned short tmp=0; unsigned short tmp=0;
shift = 0; shift = 0;
@ -628,7 +628,7 @@ unsigned short hex2int (char *str, unsigned short dfl) {
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
if (c == HEX_digits[j]) k = j; if (c == HEX_digits[j]) k = j;
} }
tmp |= ((k&0xf) << shift); tmp |= ((k & 0xf) << shift);
shift += 4; shift += 4;
} }
return tmp; return tmp;
@ -636,22 +636,22 @@ unsigned short hex2int (char *str, unsigned short dfl) {
void set_org(char *str) { void set_org(char *str) {
if (strlen(str) < 6) { if (strlen(str) < 6) {
fprintf(stderr,"WARNING -> %s is not a valid ORG switch, defaulting to $8000\n",str); fprintf(stderr, "WARNING -> %s is not a valid ORG switch, defaulting to $8000\n", str);
org = 0x8000; org = 0x8000;
return; return;
} }
org = hex2int(str,0x8000); org = hex2int(str, 0x8000);
} }
void set_max(char *str) { void set_max(char *str) {
if (strlen(str) != 6) { if (strlen(str) != 6) {
max = 0xFFFF-org; max = 0xFFFF-org;
fprintf(stderr,"WARNING -> %s is not a valid MAX switch, defaulting to $%04X\n",str,max); fprintf(stderr, "WARNING -> %s is not a valid MAX switch, defaulting to $%04X\n", str, max);
return; return;
} }
max = hex2int(str,0xFFFF); max = hex2int(str, 0xFFFF);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -675,7 +675,7 @@ int main(int argc, char *argv[]) {
if (argv[i][0] != '-') { if (argv[i][0] != '-') {
version(); version();
usage(); usage();
fprintf(stderr,"Unrecognized switch: %s\n",argv[i]); fprintf(stderr, "Unrecognized switch: %s\n", argv[i]);
exit(1); exit(1);
} }
switch (argv[i][1]) { switch (argv[i][1]) {
@ -714,7 +714,7 @@ int main(int argc, char *argv[]) {
} }
} else { } else {
if (argv[1][0] != '-') { if (argv[1][0] != '-') {
strncpy(filename,argv[1],511); strncpy(filename, argv[1], 511);
} else { } else {
switch (argv[1][1]) { switch (argv[1][1]) {
case '?': case '?':
@ -738,13 +738,13 @@ int main(int argc, char *argv[]) {
} }
} }
strncpy(filename,argv[argc-1],511); strncpy(filename, argv[argc - 1], 511);
f = fopen(filename,"rb"); f = fopen(filename, "rb");
if (!f) { if (NULL == f) {
version(); version();
fprintf(stderr,"File not found or invalid filename : %s\n",filename); fprintf(stderr, "File not found or invalid filename : %s\n", filename);
exit(1); exit(1);
} }
@ -760,7 +760,7 @@ int main(int argc, char *argv[]) {
PC = 0; PC = 0;
while(((PC + org) < 65535) && (PC <= max) && (PC < i)) { while(((PC + org) < 65535) && (PC <= max) && (PC < i)) {
disassemble(tmpstring); disassemble(tmpstring);
fprintf(stdout,"%s\n",tmpstring); fprintf(stdout, "%s\n", tmpstring);
PC++; PC++;
} }