From 229d04b9cd45562848f638fbb7cf95e9c8f5a8bf Mon Sep 17 00:00:00 2001 From: Daniel Loffgren Date: Thu, 17 Sep 2015 04:20:15 +0000 Subject: [PATCH] Use dis6502_printAnnotatedInstruction from libdis6502, instead of having a resident copy of the implementation git-svn-id: svn+ssh://svn.phoenixbox.net/svn/apple1/trunk@25 64f78de7-aa59-e511-a0e8-0002a5492df0 --- Makefile | 2 +- apple1/main.c | 32 +++----------------------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index d021427..656f9df 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROG= a1 -SRCS= apple1/main.c apple1/pia.c +SRCS= apple1/main.c apple1/pia.c v6502/v6502/log.c V6502_PREFIX= v6502 LIBV6502_DIR= $(V6502_PREFIX)/v6502 diff --git a/apple1/main.c b/apple1/main.c index 101fd21..448e2b2 100644 --- a/apple1/main.c +++ b/apple1/main.c @@ -12,6 +12,7 @@ #include "pia.h" #include #include +#include #define ROM_START 0xF000 #define ROM_SIZE 0x00FF @@ -46,34 +47,6 @@ uint8_t romMirrorCallback(struct _v6502_memory *memory, uint16_t offset, int tra return memory->bytes[offset % ROM_SIZE]; } -static int printSingleInstruction(FILE *output, v6502_cpu *cpu, uint16_t address) { - char instruction[MAX_INSTRUCTION_LEN]; - int instructionLength; - dis6502_stringForInstruction(instruction, MAX_INSTRUCTION_LEN, cpu->memory->bytes[address], cpu->memory->bytes[address + 2], cpu->memory->bytes[address + 1]); - instructionLength = v6502_instructionLengthForOpcode(cpu->memory->bytes[address]); - - fprintf(output, "0x%04x: ", address); - - switch (instructionLength) { - case 1: { - fprintf(output, "%02x ", cpu->memory->bytes[address]); - } break; - case 2: { - fprintf(output, "%02x %02x ", cpu->memory->bytes[address], cpu->memory->bytes[address + 1]); - } break; - case 3: { - fprintf(output, "%02x %02x %02x", cpu->memory->bytes[address], cpu->memory->bytes[address + 1], cpu->memory->bytes[address + 2]); - } break; - default: { - fprintf(output, " "); - } break; - } - - fprintf(output, " - %s\r\n", instruction); - - return instructionLength; -} - int main(int argc, const char * argv[]) { int faulted = 0; @@ -100,7 +73,8 @@ int main(int argc, const char * argv[]) FILE *asmfile = fopen("runtime.s", "w"); while (!faulted) { v6502_step(cpu); - printSingleInstruction(asmfile, cpu, cpu->pc); + dis6502_printAnnotatedInstruction(asmfile, cpu, cpu->pc); + v6502_printCpuState(asmfile, cpu); } fclose(asmfile);