1
0
mirror of https://github.com/jborza/emu6502.git synced 2024-06-08 07:29:32 +00:00

fixed word output in disassembler

This commit is contained in:
jborza 2019-04-14 01:50:46 +02:00
parent 8b46ab4537
commit 8ddf9bf8ff
2 changed files with 29 additions and 3 deletions

25
disassembler.c Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "types.h"
#include "opcodes.h"
void disassemble_6502(byte* buffer, word pc) {
printf("%04d ", pc);
byte* code = &buffer[pc];
switch (*code) {
case 0x00: printf("BRK"); break;
case ORA_IND_X: printf("ORA ($%02x,X)", code[1]); break;
case ORA_IND_Y: printf("ORA ($%02x),Y", code[1]); break;
case ORA_ZP: printf("ORA $%02x", code[1]); break;
case ORA_IMM: printf("ORA #$%02x", code[1]); break;
case ORA_ZP_X: printf("ORA $%02x,X", code[1]); break;
case ORA_ABS: printf("ORA $%02x%02x", code[2], code[1]); break;
case ORA_ABS_X: printf("ORA $%02x%02x,X", code[2], code[1]); break;
case ORA_ABS_Y: printf("ORA $%02x%02x,Y", code[2], code[1]); break;
case LDA_IMM: printf("LDA #$%02x", code[1]); break;
case 0xEA: printf("NOP"); break;
default:
printf("UNKNOWN %02x", *code);
}
printf("\n");
}

View File

@ -1,7 +1,6 @@
#pragma once
#define NOP 0x00
#define LXI 0x01
#define BRK 0x00
#define ORA_IMM 0x09
#define ORA_ZP 0x05
#define ORA_ZP_X 0x15
@ -9,4 +8,6 @@
#define ORA_ABS_X 0x1D
#define ORA_ABS_Y 0x19
#define ORA_IND_X 0x01
#define ORA_IND_Y 0x11
#define ORA_IND_Y 0x11
#define NOP 0xEA
#define LDA_IMM 0xA9