- [NEW] 6502dis i 6502debugger implementats

- [FIX] font.bmp afegit
- [NEW] Afegides regles de comprobació de memòria en la versió debug de compilació en el lagueirtofile
- [FIX] la rom ha de carregar abans de atari2600::init()
- [NEW] Implementació bàsica del PIA completada.
- [FIX] El framebuffer intern en el mòdul TIA era incorrecte.
- [NEW] Afegits accesors als registres del 6502
- [NEW] m6502::reset()
- [FIX] [6502m] Corregits opcodes amb direccionament implicit: CLC, SEC, PHA, CLI, PLA, SEI, DEY, TXA, TYA, TXS, TAY, TAX, CLV, TSX, INY, DEX, CLD, INX, NOP i SED). Augmentaven el PC una posició de més.
This commit is contained in:
raimon@prometeo committed 2026-09-17 17:43:33 +02:00
1 parent fb5097733d
commit e245410c0a
14 files changed
+381 -446

No files matched your search

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+2 -2
View File
@@ -7,8 +7,8 @@ buildpath = build
exclude = z80* exclude = z80*
[linux_debug] default [linux_debug] default
cppflags = -D DEBUG -g -std=c++20 -Isource cppflags = -D DEBUG -g -std=c++20 -O0 -fsanitize=address -fno-omit-frame-pointer -Isource
libs = -lSDL3 libs = -lSDL3 -fsanitize=address -fno-omit-frame-pointer
executable = atari2600_debug executable = atari2600_debug
sourcepath = source+ sourcepath = source+
buildpath = build buildpath = build
+109 -161
View File
@@ -1,14 +1,14 @@
#include "z80debugger.h" #include "6502debugger.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stdio.h> #include <stdio.h>
#include "msx.h" #include "atari2600.h"
#include "mem.h" #include "mem.h"
#include "z80.h" #include "6502m.h"
#include "z80dis.h" #include "6502dis.h"
#include "display.h" #include "display.h"
#include "ui.h" #include "ui.h"
#include "ui_window.h" #include "ui_window.h"
#include "cassette.h" #include "rom.h"
#define RESIZING_NONE 0 #define RESIZING_NONE 0
#define RESIZING_MEMORY 1 #define RESIZING_MEMORY 1
@@ -16,7 +16,7 @@
#define RESIZING_SYMBOLS 3 #define RESIZING_SYMBOLS 3
#define RESIZING_X 4 #define RESIZING_X 4
namespace z80debugger namespace m6502debugger
{ {
int midx = 58; int midx = 58;
int mem_y = 20; int mem_y = 20;
@@ -37,8 +37,8 @@ namespace z80debugger
uint8_t pos=0; uint8_t pos=0;
} }
uint16_t oAF, oBC, oDE, oHL, oAF2, oBC2, oDE2, oHL2, oIX, oIY, oSP, oPC; uint16_t oPC;
uint8_t oI, oR; uint8_t oA, oX, oY, oS, oP;
bool mem_modified[65536]; //[CHECK] bool mem_modified[65536]; //[CHECK]
@@ -61,7 +61,7 @@ namespace z80debugger
uint16_t cursor = 0; uint16_t cursor = 0;
uint8_t use[7][256]; uint8_t use[256];
uint16_t line_address[256]; uint16_t line_address[256];
uint16_t line_breakpoint_address[256]; uint16_t line_breakpoint_address[256];
@@ -95,7 +95,7 @@ namespace z80debugger
if (e->type == SDL_EVENT_MOUSE_MOTION) { if (e->type == SDL_EVENT_MOUSE_MOTION) {
SDL_ShowCursor(); SDL_ShowCursor();
} }
if (msx::is_paused()) { if (atari2600::is_paused()) {
if ((e->type==SDL_EVENT_WINDOW_SHOWN) || (e->type==SDL_EVENT_WINDOW_EXPOSED)) { if ((e->type==SDL_EVENT_WINDOW_SHOWN) || (e->type==SDL_EVENT_WINDOW_EXPOSED)) {
int w; int h; int w; int h;
SDL_GetWindowSize(win, &w, &h); SDL_GetWindowSize(win, &w, &h);
@@ -187,7 +187,7 @@ namespace z80debugger
// Si pasa per damunt dels bytes que formen el opcode en el desensamblador // Si pasa per damunt dels bytes que formen el opcode en el desensamblador
} else if ((chrx>=19) && (chrx<30) && (chry<mem_y-1) && (chry>0)) { } else if ((chrx>=19) && (chrx<30) && (chry<mem_y-1) && (chry>0)) {
const uint16_t address = line_address[chry-1]; const uint16_t address = line_address[chry-1];
const int opcodesize = z80dis::getOpcodeSize(address); const int opcodesize = m6502dis::getOpcodeSize(address);
const int byte = (chrx-19)/3; const int byte = (chrx-19)/3;
if (byte < opcodesize) { if (byte < opcodesize) {
inspected_value = mem::read(address+byte); inspected_value = mem::read(address+byte);
@@ -203,26 +203,12 @@ namespace z80debugger
inspected_value = mem::read(address); inspected_value = mem::read(address);
refresh(); refresh();
// Si pasa per damunt d'un registre // Si pasa per damunt d'un registre
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==1)) { inspected_value = z80::getAF(); refresh(); } else if ((chrx>=midx+3) && (chrx<midx+5) && (chry==1)) { inspected_value = m6502::getA(); refresh();
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==2)) { inspected_value = z80::getBC(); refresh(); } else if ((chrx>=midx+3) && (chrx<midx+5) && (chry==2)) { inspected_value = m6502::getX(); refresh();
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==3)) { inspected_value = z80::getDE(); refresh(); } else if ((chrx>=midx+3) && (chrx<midx+5) && (chry==3)) { inspected_value = m6502::getY(); refresh();
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==4)) { inspected_value = z80::getHL(); refresh(); } else if ((chrx>=midx+3) && (chrx<midx+5) && (chry==4)) { inspected_value = m6502::getS(); refresh();
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==1)) { inspected_value = z80::getAF(true); refresh(); } else if ((chrx>=midx+3) && (chrx<midx+5) && (chry==5)) { inspected_value = m6502::getP(); refresh();
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==2)) { inspected_value = z80::getBC(true); refresh(); } else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==1)) { inspected_value = m6502::getPC(); refresh();
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==3)) { inspected_value = z80::getDE(true); refresh();
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==4)) { inspected_value = z80::getHL(true); refresh();
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==1)) { inspected_value = z80::getIX(); refresh();
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==2)) { inspected_value = z80::getIY(); refresh();
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==3)) { inspected_value = z80::getSP(); refresh();
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==4)) { inspected_value = z80::getPC(); refresh();
} else if ((chrx>=midx+6) && (chrx<midx+8) && (chry==5)) { inspected_value = mem::read(z80::getBC()); refresh();
} else if ((chrx>=midx+14) && (chrx<midx+16) && (chry==5)) { inspected_value = mem::read(z80::getDE()); refresh();
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==5)) { inspected_value = mem::read(z80::getHL()); refresh();
} else if ((chrx>=midx+17) && (chrx<midx+19) && (chry==6)) { inspected_value = z80::getI(); refresh();
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==6)) { inspected_value = z80::getR(); refresh();
} }
} else { } else {
@@ -282,8 +268,8 @@ namespace z80debugger
if (chrx>=midx+2 && chry>=sym_y+1) { if (chrx>=midx+2 && chry>=sym_y+1) {
const int line = chry-(sym_y+1); const int line = chry-(sym_y+1);
if (line<z80dis::getNumSymbols()) { if (line<m6502dis::getNumSymbols()) {
cursor = z80dis::getSymbolAddress(line); cursor = m6502dis::getSymbolAddress(line);
refresh(); refresh();
} }
} }
@@ -323,7 +309,7 @@ namespace z80debugger
if ( !(tag & MEMTAG_IGNORE) ) tag |= MEMTAG_INST; if ( !(tag & MEMTAG_IGNORE) ) tag |= MEMTAG_INST;
tag |= (!(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST); tag |= (!(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST);
setcursor(z80::getPC()); setcursor(m6502::getPC());
history::store(); history::store();
} }
@@ -373,7 +359,7 @@ namespace z80debugger
void show() void show()
{ {
if (!win) { if (!win) {
win = SDL_CreateWindow("Z80 Debugger", 98*CHR_W, 44*CHR_H, 0/*SDL_WINDOW_RESIZABLE*/); win = SDL_CreateWindow("6502 Debugger", 98*CHR_W, 44*CHR_H, 0/*SDL_WINDOW_RESIZABLE*/);
ren = SDL_CreateRenderer(win, 0); ren = SDL_CreateRenderer(win, 0);
ui::window::registerWindow(SDL_GetWindowID(win), eventHandler); ui::window::registerWindow(SDL_GetWindowID(win), eventHandler);
tex = ui::createtexture(ren); tex = ui::createtexture(ren);
@@ -406,7 +392,7 @@ namespace z80debugger
{ {
//speaker::disable(); //speaker::disable();
//is_paused = true; //is_paused = true;
breakpoints[z80::getPC()] &= ~8; breakpoints[m6502::getPC()] &= ~8;
} }
void stop() void stop()
@@ -447,7 +433,7 @@ namespace z80debugger
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) colors[3]=COLOR_GRAY; if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) colors[3]=COLOR_GRAY;
if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY; if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY;
if (msx::is_paused() && (address == z80::getPC())) { if (atari2600::is_paused() && (address == m6502::getPC())) {
for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW; for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW;
ui::printrect(0,line, midx-2,1, COLOR_BLUE); ui::printrect(0,line, midx-2,1, COLOR_BLUE);
} }
@@ -456,18 +442,18 @@ namespace z80debugger
ui::printtxt(1,line,tohex(address,4), colors[1]); ui::printtxt(1,line,tohex(address,4), colors[1]);
if ( (tag & MEMTAG_INST) || heuristics ) { if ( (tag & MEMTAG_INST) || heuristics ) {
const char *sym = z80dis::getSymbol(address); const char *sym = m6502dis::getSymbol(address);
if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW); if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW);
const int opcodesize = z80dis::getOpcodeSize(address); const int opcodesize = m6502dis::getOpcodeSize(address);
for (int i=0; i<opcodesize; ++i) { for (int i=0; i<opcodesize; ++i) {
const uint8_t tag = tags[address+i]; const uint8_t tag = tags[address+i];
const uint32_t color = !(tag & MEMTAG_KNOWN) ? COLOR_GRAY : (tag & MEMTAG_DATA) ? ( (tag & (MEMTAG_CODE|MEMTAG_INST)) ? COLOR_MAGENTA : COLOR_BLUE ) : COLOR_GREEN; const uint32_t color = !(tag & MEMTAG_KNOWN) ? COLOR_GRAY : (tag & MEMTAG_DATA) ? ( (tag & (MEMTAG_CODE|MEMTAG_INST)) ? COLOR_MAGENTA : COLOR_BLUE ) : COLOR_GREEN;
ui::printrect(19+i*3,line,2,1,color); ui::printrect(19+i*3,line,2,1,color);
} }
ui::printtxt(19,line, z80dis::getOpcode(address), colors[2]); ui::printtxt(19,line, m6502dis::getOpcode(address), colors[2]);
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]); ui::printtxt(31,line, m6502dis::getAsm(address), colors[3]);
} else { } else {
ui::printrect(19,line,2,1,COLOR_GRAY); ui::printrect(19,line,2,1,COLOR_GRAY);
ui::printtxt(19,line, tohex(mem::read(address),2), COLOR_WHITE); ui::printtxt(19,line, tohex(mem::read(address),2), COLOR_WHITE);
@@ -500,7 +486,7 @@ namespace z80debugger
printDissasemblerLine(pc, (num_lines/2)-1, true); printDissasemblerLine(pc, (num_lines/2)-1, true);
for (int i=num_lines/2;i<num_lines;++i) { for (int i=num_lines/2;i<num_lines;++i) {
pos += z80dis::getOpcodeSize(pos); pos += m6502dis::getOpcodeSize(pos);
line_address[i] = pos; line_address[i] = pos;
printDissasemblerLine(pos, i, true); printDissasemblerLine(pos, i, true);
} }
@@ -521,42 +507,29 @@ namespace z80debugger
ui::printtxt(midx+3,0, "REGISTERS:", COLOR_WHITE); ui::printtxt(midx+3,0, "REGISTERS:", COLOR_WHITE);
ui::setoffset(midx+1, 1); ui::setoffset(midx+1, 1);
ui::printtxt(0,0, "AF AF' IX ", COLOR_WHITE); ui::printtxt(0,0, "A ", COLOR_WHITE);
ui::printtxt(0,1, "BC BC' IY ", COLOR_WHITE); ui::printtxt(0,1, "X ", COLOR_WHITE);
ui::printtxt(0,2, "DE DE' SP ", COLOR_WHITE); ui::printtxt(0,2, "Y ", COLOR_WHITE);
ui::printtxt(0,3, "HL HL' PC ", COLOR_WHITE); ui::printtxt(0,3, "S ", COLOR_WHITE);
ui::printtxt(0,4, "(BC) (DE) (HL) ", COLOR_WHITE); ui::printtxt(0,4, "P ", COLOR_WHITE);
ui::printtxt(0,5, " I R ", COLOR_WHITE); ui::printtxt(0,5, " ", COLOR_WHITE);
ui::printtxt(3,0, tohex(z80::getAF(), 4), oAF != z80::getAF() ? COLOR_RED : COLOR_GRAY); ui::printtxt(3,0, tohex(m6502::getA(), 2), oA != m6502::getA() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(11,0, tohex(z80::getAF(true), 4), oAF2 != z80::getAF(true) ? COLOR_RED : COLOR_GRAY); ui::printtxt(19,0, tohex(m6502::getPC(), 4), oPC != m6502::getPC() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(19,0, tohex(z80::getIX(), 4), oIX != z80::getIX() ? COLOR_RED : COLOR_GRAY); ui::printtxt(3,1, tohex(m6502::getX(), 4), oX != m6502::getX() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(3,1, tohex(z80::getBC(), 4), oBC != z80::getBC() ? COLOR_RED : COLOR_GRAY); ui::printtxt(3,2, tohex(m6502::getY(), 4), oY != m6502::getY() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(11,1, tohex(z80::getBC(true), 4), oBC2 != z80::getBC(true) ? COLOR_RED : COLOR_GRAY); ui::printtxt(3,3, tohex(m6502::getS(), 4), oS != m6502::getS() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(19,1, tohex(z80::getIY(), 4), oIY != z80::getIY() ? COLOR_RED : COLOR_GRAY); ui::printtxt(3,4, tohex(m6502::getP(), 4), oP != m6502::getP() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(3,2, tohex(z80::getDE(), 4), oDE != z80::getDE() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(11,2, tohex(z80::getDE(true), 4), oDE2 != z80::getDE(true) ? COLOR_RED : COLOR_GRAY);
ui::printtxt(19,2, tohex(z80::getSP(), 4), oSP != z80::getSP() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(3,3, tohex(z80::getHL(), 4), oHL != z80::getHL() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(11,3, tohex(z80::getHL(true), 4), oHL2 != z80::getHL(true) ? COLOR_RED : COLOR_GRAY);
ui::printtxt(19,3, tohex(z80::getPC(), 4), oPC != z80::getPC() ? COLOR_RED : COLOR_GRAY);
ui::printtxt(16,5, tohex(z80::getI(), 2), oI != z80::getI() ? COLOR_RED : COLOR_GRAY); const uint8_t flags = m6502::getP();
ui::printtxt(21,5, tohex(z80::getR(), 2), oR != z80::getR() ? COLOR_RED : COLOR_GRAY); const uint8_t mod_flags = flags ^ oP;
ui::printtxt(0,5,"N", flags&0x80 ? (mod_flags&0x80 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x80 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(5,4, tohex(mem::read(z80::getBC()), 2), COLOR_GRAY); ui::printtxt(1,5,"V", flags&0x40 ? (mod_flags&0x40 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x40 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(13,4, tohex(mem::read(z80::getDE()), 2), COLOR_GRAY); ui::printtxt(2,5,"-", flags&0x20 ? (mod_flags&0x20 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x20 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(21,4, tohex(mem::read(z80::getHL()), 2), COLOR_GRAY); ui::printtxt(3,5,"B", flags&0x10 ? (mod_flags&0x10 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x10 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(4,5,"D", flags&0x08 ? (mod_flags&0x08 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x08 ? COLOR_BROWN : COLOR_GRAY) );
const uint8_t flags = (z80::getAF() & 0xFF); ui::printtxt(5,5,"I", flags&0x04 ? (mod_flags&0x04 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x04 ? COLOR_BROWN : COLOR_GRAY) );
const uint8_t mod_flags = flags ^ (oAF & 0xFF); ui::printtxt(6,5,"Z", flags&0x02 ? (mod_flags&0x02 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x02 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(0,5,"S", flags&0x80 ? (mod_flags&0x80 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x80 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(1,5,"Z", flags&0x40 ? (mod_flags&0x40 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x40 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(2,5,"X", flags&0x20 ? (mod_flags&0x20 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x20 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(3,5,"H", flags&0x10 ? (mod_flags&0x10 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x10 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(4,5,"Y", flags&0x08 ? (mod_flags&0x08 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x08 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(5,5,"P", flags&0x04 ? (mod_flags&0x04 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x04 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(6,5,"N", flags&0x02 ? (mod_flags&0x02 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x02 ? COLOR_BROWN : COLOR_GRAY) );
ui::printtxt(7,5,"C", flags&0x01 ? (mod_flags&0x01 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x01 ? COLOR_BROWN : COLOR_GRAY) ); ui::printtxt(7,5,"C", flags&0x01 ? (mod_flags&0x01 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x01 ? COLOR_BROWN : COLOR_GRAY) );
@@ -567,10 +540,10 @@ namespace z80debugger
ui::printrect(midx+2,8, 8,1, COLOR_DARK); ui::printrect(midx+2,8, 8,1, COLOR_DARK);
ui::printtxt(midx+3,8, "STACK:", COLOR_WHITE); ui::printtxt(midx+3,8, "STACK:", COLOR_WHITE);
ui::setoffset(midx+1, 9); ui::setoffset(midx+1, 9);
uint16_t sp = z80::getSP();//-(((sym_y-12)>>1)<<1); uint16_t sp = 0x0100 | m6502::getS();//-(((sym_y-12)>>1)<<1);
for (int i=0; i<10; ++i) { for (int i=0; i<10; ++i) {
uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY; uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY;
if (sp == z80::getSP()) { if ((sp & 0xff) == m6502::getS()) {
ui::printrect(0,i,9,1,COLOR_BLUE); ui::printrect(0,i,9,1,COLOR_BLUE);
c1 = c2 = COLOR_YELLOW; c1 = c2 = COLOR_YELLOW;
} }
@@ -692,21 +665,21 @@ namespace z80debugger
ui::printtxt(midx+3,sym_y, "SYMBOLS:", COLOR_WHITE); ui::printtxt(midx+3,sym_y, "SYMBOLS:", COLOR_WHITE);
ui::setoffset(midx+1, sym_y+1); ui::setoffset(midx+1, sym_y+1);
const int num_symbols = z80dis::getNumSymbols(); const int num_symbols = m6502dis::getNumSymbols();
for (int i=0;i<num_symbols;++i) { for (int i=0;i<num_symbols;++i) {
uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE}; uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE};
const uint16_t address = z80dis::getSymbolAddress(i); const uint16_t address = m6502dis::getSymbolAddress(i);
if (address==cursor) { if (address==cursor) {
ui::printrect(0,line,23,1,COLOR_BLUE); ui::printrect(0,line,23,1,COLOR_BLUE);
colors[0]=colors[1]=COLOR_YELLOW; colors[0]=colors[1]=COLOR_YELLOW;
} }
ui::printtxt(1, i, tohex(address,4), colors[0]); ui::printtxt(1, i, tohex(address,4), colors[0]);
ui::printtxt(6, i, z80dis::getSymbol(address), colors[1]); ui::printtxt(6, i, m6502dis::getSymbol(address), colors[1]);
} }
if (!msx::is_paused()) { if (!atari2600::is_paused()) {
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(ren, 0, 0, 0, 128); SDL_SetRenderDrawColor(ren, 0, 0, 0, 128);
int w, h; int w, h;
@@ -719,10 +692,12 @@ namespace z80debugger
for (int i=0; i<65536; ++i) mem_modified[i] = false; for (int i=0; i<65536; ++i) mem_modified[i] = false;
oAF = z80::getAF(); oBC = z80::getBC(); oDE = z80::getDE(); oHL = z80::getHL(); oA = m6502::getA();
oAF2 = z80::getAF(true); oBC2 = z80::getBC(true); oDE2 = z80::getDE(true); oHL2 = z80::getHL(true); oX = m6502::getX();
oIX = z80::getIX(); oIY = z80::getIY(); oSP = z80::getSP(); oPC = z80::getPC(); oY = m6502::getY();
oI = z80::getI(); oR = z80::getR(); oS = m6502::getS();
oP = m6502::getP();
oPC = m6502::getPC();
} }
void sendToConsole(const char* text) void sendToConsole(const char* text)
@@ -817,17 +792,17 @@ namespace z80debugger
getcmd(); getcmd();
if (strcmp(cmd, "s")==0 || strcmp(cmd, "step")==0){ if (strcmp(cmd, "s")==0 || strcmp(cmd, "step")==0){
msx::step(); atari2600::step();
display::redraw(); display::redraw();
} else if (strcmp(cmd, "c")==0 || strcmp(cmd, "cont")==0) { } else if (strcmp(cmd, "c")==0 || strcmp(cmd, "cont")==0) {
msx::resume(); atari2600::resume();
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "reset")==0) { } else if (strcmp(cmd, "r")==0 || strcmp(cmd, "reset")==0) {
msx::init(); atari2600::init();
history::reset(); history::reset();
} else if (strcmp(cmd, "b")==0 || strcmp(cmd, "break")==0) { } else if (strcmp(cmd, "b")==0 || strcmp(cmd, "break")==0) {
getcmd(); getcmd();
if (cmd[0] == 0) { breakpoints[z80::getPC()]=1; return; } if (cmd[0] == 0) { breakpoints[m6502::getPC()]=1; return; }
if (cmd[0] == 'i') { z80::setOption(Z80_OPTION_BREAK_ON_INTERRUPT, !z80::getOption(Z80_OPTION_BREAK_ON_INTERRUPT)); sendToConsoleLog("Break on interrupt."); return; } //if (cmd[0] == 'i') { z80::setOption(Z80_OPTION_BREAK_ON_INTERRUPT, !z80::getOption(Z80_OPTION_BREAK_ON_INTERRUPT)); sendToConsoleLog("Break on interrupt."); return; }
int address = getnum(cmd); int address = getnum(cmd);
if (address<0 || address>65536) { sendToConsoleLog("Illegal break address"); return; } if (address<0 || address>65536) { sendToConsoleLog("Illegal break address"); return; }
getcmd(); getcmd();
@@ -848,7 +823,7 @@ namespace z80debugger
} else if (strcmp(cmd, "d")==0 || strcmp(cmd, "delete")==0) { } else if (strcmp(cmd, "d")==0 || strcmp(cmd, "delete")==0) {
getcmd(); getcmd();
if (strcmp(cmd, "all")==0) { for (int i=0;i<65536;++i) breakpoints[i]=0; return; } if (strcmp(cmd, "all")==0) { for (int i=0;i<65536;++i) breakpoints[i]=0; return; }
if (cmd[0] == 0) { breakpoints[z80::getPC()]=0; return; } if (cmd[0] == 0) { breakpoints[m6502::getPC()]=0; return; }
int address = getnum(cmd); int address = getnum(cmd);
if (address<0 || address>65536) { sendToConsoleLog("Illegal address"); return; } if (address<0 || address>65536) { sendToConsoleLog("Illegal address"); return; }
getcmd(); getcmd();
@@ -881,23 +856,15 @@ namespace z80debugger
char filename[256]; char filename[256];
strcpy(filename, cmd); strcpy(filename, cmd);
loadstate(filename); loadstate(filename);
} else if (strcmp(cmd, "t")==0 || strcmp(cmd, "tape")==0) { } else if (strcmp(cmd, "rom")==0) {
getcmd(); getcmd();
if (strcmp(cmd, "load")==0) { if (strcmp(cmd, "load")==0) {
getcmd(); getcmd();
char filename[256]; char filename[256];
strcpy(filename, cmd); strcpy(filename, cmd);
cassette::load_cas_file(filename); rom::load(filename);
} else if (strcmp(cmd, "play")==0) { atari2600::init();
//zx_tape::play(); history::reset();
}
} else if (strcmp(cmd, "disk")==0) {
getcmd();
if (strcmp(cmd, "load")==0) {
getcmd();
char filename[256];
strcpy(filename, cmd);
//zx_disk::load(filename);
} }
} else if (strcmp(cmd, "poke")==0) { } else if (strcmp(cmd, "poke")==0) {
getcmd(); getcmd();
@@ -911,18 +878,15 @@ namespace z80debugger
int value = mem::read(address); int value = mem::read(address);
char tmp[10]; char tmp[10];
sendToConsoleLog(SDL_itoa(value, tmp, 10)); sendToConsoleLog(SDL_itoa(value, tmp, 10));
} else if (strcmp(cmd, "reg")==0) { // } else if (strcmp(cmd, "reg")==0) {
getcmd(); // getcmd();
if (strcmp(cmd, "f")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[0] = value; } // if (strcmp(cmd, "a")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[0] = value; }
else if (strcmp(cmd, "a")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[1] = value; } // else if (strcmp(cmd, "x")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[1] = value; }
else if (strcmp(cmd, "c")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[2] = value; } // else if (strcmp(cmd, "y")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[2] = value; }
else if (strcmp(cmd, "b")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[3] = value; } // else if (strcmp(cmd, "s")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[3] = value; }
else if (strcmp(cmd, "e")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[4] = value; } // else if (strcmp(cmd, "p")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[4] = value; }
else if (strcmp(cmd, "d")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[5] = value; } // else if (strcmp(cmd, "pc")==0) { getcmd(); int value = getnum(cmd); m6502::getRegs()[24] = value&0xff; z80::getRegs()[25] = (value>>8)&0xff; }
else if (strcmp(cmd, "l")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[6] = value; } // else { sendToConsoleLog("Syntax error: invalid register"); return; }
else if (strcmp(cmd, "h")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[7] = value; }
else if (strcmp(cmd, "pc")==0) { getcmd(); int value = getnum(cmd); z80::getRegs()[24] = value&0xff; z80::getRegs()[25] = (value>>8)&0xff; }
else { sendToConsoleLog("Syntax error: invalid register"); return; }
} else if (strcmp(cmd, "g")==0 || strcmp(cmd, "goto")==0) { } else if (strcmp(cmd, "g")==0 || strcmp(cmd, "goto")==0) {
getcmd(); getcmd();
int address = getnum(cmd); int address = getnum(cmd);
@@ -936,19 +900,19 @@ namespace z80debugger
char tmp[12]; strcpy(tmp, cmd); char tmp[12]; strcpy(tmp, cmd);
getcmd(); getcmd();
if (cmd[0]==0) { if (cmd[0]==0) {
z80dis::setSymbol(z80::getPC(), tmp); m6502dis::setSymbol(m6502::getPC(), tmp);
} else { } else {
int value = getnum(cmd); int value = getnum(cmd);
z80dis::setSymbol(value, tmp); m6502dis::setSymbol(value, tmp);
} }
sendToConsoleLog("Symbol added"); sendToConsoleLog("Symbol added");
} else if (strcmp(cmd, "del")==0) { } else if (strcmp(cmd, "del")==0) {
getcmd(); getcmd();
if (cmd[0]==0) { if (cmd[0]==0) {
z80dis::setSymbol(z80::getPC(), NULL); m6502dis::setSymbol(m6502::getPC(), NULL);
} else { } else {
int value = getnum(cmd); int value = getnum(cmd);
z80dis::setSymbol(value, NULL); m6502dis::setSymbol(value, NULL);
} }
sendToConsoleLog("Symbol removed"); sendToConsoleLog("Symbol removed");
} }
@@ -1006,18 +970,18 @@ namespace z80debugger
uint32_t next() uint32_t next()
{ {
breakpoints[z80::getPC()+z80dis::getOpcodeSize(z80::getPC())] |= 8; breakpoints[m6502::getPC()+m6502dis::getOpcodeSize(m6502::getPC())] |= 8;
const uint32_t t = z80::step(); //const uint32_t t = m6502::step();
cont(); cont();
return t; return 0; //t;
} }
uint32_t stepout() uint32_t stepout()
{ {
z80::setOption(Z80_OPTION_BREAK_ON_RET, true); //z80::setOption(Z80_OPTION_BREAK_ON_RET, true);
const uint32_t t = z80::step(); //const uint32_t t = z80::step();
cont(); //cont();
return t; //return t;
} }
void setmemmodified(const uint16_t addr) void setmemmodified(const uint16_t addr)
@@ -1075,7 +1039,7 @@ namespace z80debugger
void cursorfwd() void cursorfwd()
{ {
cursor += z80dis::getOpcodeSize(cursor); cursor += m6502dis::getOpcodeSize(cursor);
} }
void cursorback() void cursorback()
@@ -1085,53 +1049,37 @@ namespace z80debugger
void useOpcode(const uint8_t opcode, const uint8_t base) void useOpcode(const uint8_t opcode, const uint8_t base)
{ {
if (use[base][opcode]<255) use[base][opcode]++; if (use[opcode]<255) use[opcode]++;
} }
void clearUsedOpcodes() void clearUsedOpcodes()
{ {
for (int i=0; i<7; ++i) { for (int i=0; i<256; ++i) {
for (int j=0; j<256; ++j) { use[i]=0;
use[i][j]=0;
}
} }
} }
void markUsedOpcodes() void markUsedOpcodes()
{ {
for (int i=0; i<7; ++i) { for (int i=0; i<256; ++i) {
for (int j=0; j<256; ++j) { if (use[i]==1) use[i]++;
if (use[i][j]==1) use[i][j]++;
}
} }
} }
const int getNumOpcodesUsed() const int getNumOpcodesUsed()
{ {
int count = 0; int count = 0;
for (int i=0; i<7; ++i) { for (int i=0; i<256; ++i) {
for (int j=0; j<256; ++j) { if (use[i]==1) count++;
if (use[i][j]==1) count++;
}
} }
return count; return count;
} }
void printOpcodesUsed() void printOpcodesUsed()
{ {
for (int i=0; i<7; ++i) { for (int i=0; i<256; ++i) {
for (int j=0; j<256; ++j) { if (use[i]==1) {
if (use[i][j]==1) { printf("%2X\n",i);
switch (i) {
case 1: printf("ED "); break;
case 2: printf("CB "); break;
case 3: printf("DD "); break;
case 4: printf("DD CB "); break;
case 5: printf("FD "); break;
case 6: printf("FD CB "); break;
}
printf("%2X\n",j);
}
} }
} }
} }
@@ -1182,29 +1130,29 @@ namespace z80debugger
void store() void store()
{ {
buffer[++top] = z80::getPC(); buffer[++top] = m6502::getPC();
pos=top; pos=top;
} }
void gototop() void gototop()
{ {
pos = top; pos = top;
z80::setPC(buffer[pos]); //m6502::setPC(buffer[pos]);
cursor = z80::getPC(); cursor = m6502::getPC();
} }
void goforward() void goforward()
{ {
if (pos == top) return; if (pos == top) return;
z80::setPC(buffer[++pos]); //m6502::setPC(buffer[++pos]);
cursor = z80::getPC(); cursor = m6502::getPC();
} }
void goback() void goback()
{ {
if (uint8_t(pos-1) == top) return; if (uint8_t(pos-1) == top) return;
z80::setPC(buffer[--pos]); //m6502::setPC(buffer[--pos]);
cursor = z80::getPC(); cursor = m6502::getPC();
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
namespace z80debugger namespace m6502debugger
{ {
#define MEMTAG_NONE 0x00 #define MEMTAG_NONE 0x00
#define MEMTAG_DATA 0x01 #define MEMTAG_DATA 0x01
+171
View File
@@ -0,0 +1,171 @@
#include "6502dis.h"
#include "6502m.h"
#include "mem.h"
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bits/stdc++.h>
namespace m6502dis
{
char buffer[256];
int opcode_size = 0;
char symbols[65536][15];
std::vector<uint16_t> used_symbols;
// $%04x
// $%02x
// %hhd
const char *base_opcodes[256] = {"BRK ", "ORA ($%02x,X)", "---", "---", "---", "ORA $%02x", "ASL $%02x", "---", "PHP ", "ORA #$%02x", "ASL A", "---", "---", "ORA $%04x", "ASL $%04x", "---", "BPL %hhd", "ORA ($%02x),Y", "---", "---", "---", "ORA $%02x,X", "ASL $%02x,X", "---", "CLC ", "ORA $%04x,Y", "---", "---", "---", "ORA $%04x,X", "ASL $%04x,X", "---", "JSR $%04x", "AND ($%02x,X)", "---", "---", "BIT $%02x", "AND $%02x", "ROL $%02x", "---", "PLP ", "AND #$%02x", "ROL A", "---", "BIT $%04x", "AND $%04x", "ROL $%04x", "---", "BMI %hhd", "AND ($%02x),Y", "---", "---", "---", "AND $%02x,X", "ROL $%02x,X", "---", "SEC ", "AND $%04x,Y", "---", "---", "---", "AND $%04x,X", "ROL $%04x,X", "---", "RTI ", "EOR ($%02x,X)", "---", "---", "---", "EOR $%02x", "LSR $%02x", "---", "PHA ", "EOR #$%02x", "LSR A", "---", "JMP ($%04x)", "EOR $%04x", "LSR $%04x", "---", "BVC %hhd", "EOR ($%02x),Y", "---", "---", "---", "EOR $%02x,X", "LSR $%02x,X", "---", "CLI ", "EOR $%04x,Y", "---", "---", "---", "EOR $%04x,X", "LSR $%04x,X", "---", "RTS ", "ADC ($%02x,X)", "---", "---", "---", "ADC $%02x", "ROR $%02x", "---", "PLA ", "ADC #$%02x", "ROR A", "---", "JMP ($%04x)", "ADC $%04x", "ROR $%04x", "---", "BVS %hhd", "ADC ($%02x),Y", "---", "---", "---", "ADC $%02x,X", "ROR $%02x,X", "---", "SEI ", "ADC $%04x,Y", "---", "---", "---", "ADC $%04x,X", "ROR $%04x,X", "---", "---", "STA ($%02x,X)", "---", "---", "STY $%02x", "STA $%02x", "STX $%02x", "---", "DEY ", "---", "TXA ", "---", "STY $%04x", "STA $%04x", "STX $%04x", "---", "BCC %hhd", "STA ($%02x),Y", "---", "---", "STY $%02x,X", "STA $%02x,X", "STX $%02x,Y", "---", "TYA ", "STA $%04x,Y", "TXS ", "---", "---", "STA $%04x,X", "---", "---", "LDY #$%02x", "LDA ($%02x,X)", "LDX #$%02x", "---", "LDY $%02x", "LDA $%02x", "LDX $%02x", "---", "TAY ", "LDA #$%02x", "TAX ", "---", "LDY $%04x", "LDA $%04x", "LDX $%04x", "---", "BCS %hhd", "LDA ($%02x),Y", "---", "---", "LDY $%02x,X", "LDA $%02x,X", "LDX $%02x,Y", "---", "CLV ", "LDA $%04x,Y", "TSX ", "---", "LDY $%04x,X", "LDA $%04x,X", "LDX $%04x,Y", "---", "CPY #$%02x", "CMP ($%02x,X)", "---", "---", "CPY $%02x", "CMP $%02x", "DEC $%02x", "---", "INY ", "CMP #$%02x", "DEX ", "---", "CPY $%04x", "CMP $%04x", "DEC $%04x", "---", "BNE %hhd", "CMP ($%02x),Y", "---", "---", "---", "CMP $%02x,X", "DEC $%02x,X", "---", "CLD ", "CMP $%04x,Y", "---", "---", "---", "CMP $%04x,X", "DEC $%04x,X", "---", "CPX #$%02x", "SBC ($%02x,X)", "---", "---", "CPX $%02x", "SBC $%02x", "INC $%02x", "---", "INX ", "SBC #$%02x", "NOP ", "---", "CPX $%04x", "SBC $%04x", "INC $%04x", "---", "BEQ %hhd", "SBC ($%02x),Y", "---", "---", "---", "SBC $%02x,X", "INC $%02x,X", "---", "SED ", "SBC $%04x,Y", "---", "---", "---", "SBC $%04x,X", "INC $%04x,X", "---"};
// const char *base_opcodes[256] = {"nop", "ld bc,$%04x", "ld (bc),a", "inc bc", "inc b", "dec b", "ld b,$%02x", "rlca", "ex af,af'", "add hl,bc", "ld a,(bc)", "dec bc", "inc c", "dec c", "ld c,$%02x", "rrca", "djnz $%Xx", "ld de,$%04x", "ld (de),a", "inc de", "inc d", "dec d", "ld d,$%02x", "rla", "jr $%Xx", "add hl,de", "ld a,(de)", "dec de", "inc e", "dec e", "ld e,$%02x", "rra", "jr nz,$%Xx", "ld hl,$%04x", "ld ($%04x),hl", "inc hl", "inc h", "dec h", "ld h,$%02x", "daa", "jr z,$%Xx", "add hl,hl", "ld hl,($%04x)", "dec hl", "inc l", "dec l", "ld l,$%02x", "cpl", "jr nc,$%Xx", "ld sp,$%04x", "ld ($%04x),a", "inc sp", "inc (hl)", "dec (hl)", "ld (hl),$%02x", "scf", "jr c,$%Xx", "add hl,sp", "ld a,($%04x)", "dec sp", "inc a", "dec a", "ld a,$%02x", "ccf", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,h", "ld b,l", "ld b,(hl)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,h", "ld c,l", "ld c,(hl)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,h", "ld d,l", "ld d,(hl)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,h", "ld e,l", "ld e,(hl)", "ld e,a", "ld h,b", "ld h,c", "ld h,d", "ld h,e", "ld h,h", "ld h,l", "ld h,(hl)", "ld h,a", "ld l,b", "ld l,c", "ld l,d", "ld l,e", "ld l,h", "ld l,l", "ld l,(hl)", "ld l,a", "ld (hl),b", "ld (hl),c", "ld (hl),d", "ld (hl),e", "ld (hl),h", "ld (hl),l", "halt", "ld (hl),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,h", "ld a,l", "ld a,(hl)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,h", "add a,l", "add a,(hl)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,h", "adc a,l", "adc a,(hl)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub h", "sub l", "sub (hl)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,h", "sbc a,l", "sbc a,(hl)", "sbc a,a", "and b", "and c", "and d", "and e", "and h", "and l", "and (hl)", "and a", "xor b", "xor c", "xor d", "xor e", "xor h", "xor l", "xor (hl)", "xor a", "or b", "or c", "or d", "or e", "or h", "or l", "or (hl)", "or a", "cp b", "cp c", "cp d", "cp e", "cp h", "cp l", "cp (hl)", "cp a", "ret nz", "pop bc", "jp nz,$%04x", "jp $%04x", "call nz,$%04x", "push bc", "add a,$%02x", "rst 00h", "ret z", "ret", "jp z,$%04x", "_Bit_", "call z,$%04x", "call $%04x", "adc a,$%02x", "rst 08h", "ret nc", "pop de", "jp nc,$%04x", "out ($%02x),a", "call nc,$%04x", "push de", "sub $%02x", "rst 10h", "ret c", "exx", "jp c,$%04x", "in a,($%02x)", "call c,$%04x", "_IX_", "sbc a,$%02x", "rst 18h", "ret po", "pop hl", "jp po,$%04x", "ex (sp),hl", "call po,$%04x", "push hl", "and $%02x", "rst 20h", "ret pe", "jp (hl)", "jp pe,$%04x", "ex de,hl", "call pe,$%04x", "_Misc._", "xor $%02x", "rst 28h", "ret p", "pop af", "jp p,$%04x", "di", "call p,$%04x", "push af", "or $%02x", "rst 30h", "ret m", "ld sp,hl", "jp m,$%04x", "ei", "call m,$%04x", "_IY_", "cp $%02x", "rst 38h"};
// const char *cb_opcodes[256] = {"rlc b", "rlc c", "rlc d", "rlc e", "rlc h", "rlc l", "rlc (hl)", "rlc a", "rrc b", "rrc c", "rrc d", "rrc e", "rrc h", "rrc l", "rrc (hl)", "rrc a", "rl b", "rl c", "rl d", "rl e", "rl h", "rl l", "rl (hl)", "rl a", "rr b", "rr c", "rr d", "rr e", "rr h", "rr l", "rr (hl)", "rr a", "sla b", "sla c", "sla d", "sla e", "sla h", "sla l", "sla (hl)", "sla a", "sra b", "sra c", "sra d", "sra e", "sra h", "sra l", "sra (hl)", "sra a", "sll b", "sll c", "sll d", "sll e", "sll h", "sll l", "sll (hl)", "sll a", "srl b", "srl c", "srl d", "srl e", "srl h", "srl l", "srl (hl)", "srl a", "bit 0,b", "bit 0,c", "bit 0,d", "bit 0,e", "bit 0,h", "bit 0,l", "bit 0,(hl)", "bit 0,a", "bit 1,b", "bit 1,c", "bit 1,d", "bit 1,e", "bit 1,h", "bit 1,l", "bit 1,(hl)", "bit 1,a", "bit 2,b", "bit 2,c", "bit 2,d", "bit 2,e", "bit 2,h", "bit 2,l", "bit 2,(hl)", "bit 2,a", "bit 3,b", "bit 3,c", "bit 3,d", "bit 3,e", "bit 3,h", "bit 3,l", "bit 3,(hl)", "bit 3,a", "bit 4,b", "bit 4,c", "bit 4,d", "bit 4,e", "bit 4,h", "bit 4,l", "bit 4,(hl)", "bit 4,a", "bit 5,b", "bit 5,c", "bit 5,d", "bit 5,e", "bit 5,h", "bit 5,l", "bit 5,(hl)", "bit 5,a", "bit 6,b", "bit 6,c", "bit 6,d", "bit 6,e", "bit 6,h", "bit 6,l", "bit 6,(hl)", "bit 6,a", "bit 7,b", "bit 7,c", "bit 7,d", "bit 7,e", "bit 7,h", "bit 7,l", "bit 7,(hl)", "bit 7,a", "res 0,b", "res 0,c", "res 0,d", "res 0,e", "res 0,h", "res 0,l", "res 0,(hl)", "res 0,a", "res 1,b", "res 1,c", "res 1,d", "res 1,e", "res 1,h", "res 1,l", "res 1,(hl)", "res 1,a", "res 2,b", "res 2,c", "res 2,d", "res 2,e", "res 2,h", "res 2,l", "res 2,(hl)", "res 2,a", "res 3,b", "res 3,c", "res 3,d", "res 3,e", "res 3,h", "res 3,l", "res 3,(hl)", "res 3,a", "res 4,b", "res 4,c", "res 4,d", "res 4,e", "res 4,h", "res 4,l", "res 4,(hl)", "res 4,a", "res 5,b", "res 5,c", "res 5,d", "res 5,e", "res 5,h", "res 5,l", "res 5,(hl)", "res 5,a", "res 6,b", "res 6,c", "res 6,d", "res 6,e", "res 6,h", "res 6,l", "res 6,(hl)", "res 6,a", "res 7,b", "res 7,c", "res 7,d", "res 7,e", "res 7,h", "res 7,l", "res 7,(hl)", "res 7,a", "set 0,b", "set 0,c", "set 0,d", "set 0,e", "set 0,h", "set 0,l", "set 0,(hl)", "set 0,a", "set 1,b", "set 1,c", "set 1,d", "set 1,e", "set 1,h", "set 1,l", "set 1,(hl)", "set 1,a", "set 2,b", "set 2,c", "set 2,d", "set 2,e", "set 2,h", "set 2,l", "set 2,(hl)", "set 2,a", "set 3,b", "set 3,c", "set 3,d", "set 3,e", "set 3,h", "set 3,l", "set 3,(hl)", "set 3,a", "set 4,b", "set 4,c", "set 4,d", "set 4,e", "set 4,h", "set 4,l", "set 4,(hl)", "set 4,a", "set 5,b", "set 5,c", "set 5,d", "set 5,e", "set 5,h", "set 5,l", "set 5,(hl)", "set 5,a", "set 6,b", "set 6,c", "set 6,d", "set 6,e", "set 6,h", "set 6,l", "set 6,(hl)", "set 6,a", "set 7,b", "set 7,c", "set 7,d", "set 7,e", "set 7,h", "set 7,l", "set 7,(hl)", "set 7,a"};
// const char *ix_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add ix,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add ix,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld ix,$%04x", "ld ($%04x),ix", "inc ix", "inc ixh", "dec ixh", "ld ixh,$%02x", "", "", "add ix,ix", "ld ix,($%04x)", "dec ix", "inc ixl", "dec ixl", "ld ixl,$%02x", "", "", "", "", "", "inc (ix+%hhd)", "dec (ix+%hhd)", "ld (ix+%hhd),$%02x", "", "", "add ix,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,ixh", "ld b,ixl", "ld b,(ix+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,ixh", "ld c,ixl", "ld c,(ix+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,ixh", "ld d,ixl", "ld d,(ix+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,ixh", "ld e,ixl", "ld e,(ix+%hhd)", "ld e,a", "ld ixh,b", "ld ixh,c", "ld ixh,d", "ld ixh,e", "ld ixh,ixh", "ld ixh,ixl", "ld h,(ix+%hhd)", "ld ixh,a", "ld ixl,b", "ld ixl,c", "ld ixl,d", "ld ixl,e", "ld ixl,ixh", "ld ixl,ixl", "ld l,(ix+%hhd)", "ld ixl,a", "ld (ix+%hhd),b", "ld (ix+%hhd),c", "ld (ix+%hhd),d", "ld (ix+%hhd),e", "ld (ix+%hhd),h", "ld (ix+%hhd),l", "", "ld (ix+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,ixh", "ld a,ixl", "ld a,(ix+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,ixh", "add a,ixl", "add a,(ix+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,ixh", "adc a,ixl", "adc a,(ix+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub ixh", "sub ixl", "sub (ix+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,ixh", "sbc a,ixl", "sbc a,(ix+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and ixh", "and ixl", "and (ix+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor ixh", "xor ixl", "xor (ix+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or ixh", "or ixl", "or (ix+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp ixh", "cp ixl", "cp (ix+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IX Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop ix", "", "ex (sp),ix", "", "push ix", "", "", "", "jp (ix)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,ix", "", "", "", "", "", ""};
// const char *ix_bit_opcodes[256] = {"rlc (ix+%hhd),b", "rlc (ix+%hhd),c", "rlc (ix+%hhd),d", "rlc (ix+%hhd),e", "rlc (ix+%hhd),h", "rlc (ix+%hhd),l", "rlc (ix+%hhd)", "rlc (ix+%hhd),a", "rrc (ix+%hhd),b", "rrc (ix+%hhd),c", "rrc (ix+%hhd),d", "rrc (ix+%hhd),e", "rrc (ix+%hhd),h", "rrc (ix+%hhd),l", "rrc (ix+%hhd)", "rrc (ix+%hhd),a", "rl (ix+%hhd),b", "rl (ix+%hhd),c", "rl (ix+%hhd),d", "rl (ix+%hhd),e", "rl (ix+%hhd),h", "rl (ix+%hhd),l", "rl (ix+%hhd)", "rl (ix+%hhd),a", "rr (ix+%hhd),b", "rr (ix+%hhd),c", "rr (ix+%hhd),d", "rr (ix+%hhd),e", "rr (ix+%hhd),h", "rr (ix+%hhd),l", "rr (ix+%hhd)", "rr (ix+%hhd),a", "sla (ix+%hhd),b", "sla (ix+%hhd),c", "sla (ix+%hhd),d", "sla (ix+%hhd),e", "sla (ix+%hhd),h", "sla (ix+%hhd),l", "sla (ix+%hhd)", "sla (ix+%hhd),a", "sra (ix+%hhd),b", "sra (ix+%hhd),c", "sra (ix+%hhd),d", "sra (ix+%hhd),e", "sra (ix+%hhd),h", "sra (ix+%hhd),l", "sra (ix+%hhd)", "sra (ix+%hhd),a", "sll (ix+%hhd),b", "sll (ix+%hhd),c", "sll (ix+%hhd),d", "sll (ix+%hhd),e", "sll (ix+%hhd),h", "sll (ix+%hhd),l", "sll (ix+%hhd)", "sll (ix+%hhd),a", "srl (ix+%hhd),b", "srl (ix+%hhd),c", "srl (ix+%hhd),d", "srl (ix+%hhd),e", "srl (ix+%hhd),h", "srl (ix+%hhd),l", "srl (ix+%hhd)", "srl (ix+%hhd),a", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "res 0,(ix+%hhd),b", "res 0,(ix+%hhd),c", "res 0,(ix+%hhd),d", "res 0,(ix+%hhd),e", "res 0,(ix+%hhd),h", "res 0,(ix+%hhd),l", "res 0,(ix+%hhd)", "res 0,(ix+%hhd),a", "res 1,(ix+%hhd),b", "res 1,(ix+%hhd),c", "res 1,(ix+%hhd),d", "res 1,(ix+%hhd),e", "res 1,(ix+%hhd),h", "res 1,(ix+%hhd),l", "res 1,(ix+%hhd)", "res 1,(ix+%hhd),a", "res 2,(ix+%hhd),b", "res 2,(ix+%hhd),c", "res 2,(ix+%hhd),d", "res 2,(ix+%hhd),e", "res 2,(ix+%hhd),h", "res 2,(ix+%hhd),l", "res 2,(ix+%hhd)", "res 2,(ix+%hhd),a", "res 3,(ix+%hhd),b", "res 3,(ix+%hhd),c", "res 3,(ix+%hhd),d", "res 3,(ix+%hhd),e", "res 3,(ix+%hhd),h", "res 3,(ix+%hhd),l", "res 3,(ix+%hhd)", "res 3,(ix+%hhd),a", "res 4,(ix+%hhd),b", "res 4,(ix+%hhd),c", "res 4,(ix+%hhd),d", "res 4,(ix+%hhd),e", "res 4,(ix+%hhd),h", "res 4,(ix+%hhd),l", "res 4,(ix+%hhd)", "res 4,(ix+%hhd),a", "res 5,(ix+%hhd),b", "res 5,(ix+%hhd),c", "res 5,(ix+%hhd),d", "res 5,(ix+%hhd),e", "res 5,(ix+%hhd),h", "res 5,(ix+%hhd),l", "res 5,(ix+%hhd)", "res 5,(ix+%hhd),a", "res 6,(ix+%hhd),b", "res 6,(ix+%hhd),c", "res 6,(ix+%hhd),d", "res 6,(ix+%hhd),e", "res 6,(ix+%hhd),h", "res 6,(ix+%hhd),l", "res 6,(ix+%hhd)", "res 6,(ix+%hhd),a", "res 7,(ix+%hhd),b", "res 7,(ix+%hhd),c", "res 7,(ix+%hhd),d", "res 7,(ix+%hhd),e", "res 7,(ix+%hhd),h", "res 7,(ix+%hhd),l", "res 7,(ix+%hhd)", "res 7,(ix+%hhd),a", "set 0,(ix+%hhd),b", "set 0,(ix+%hhd),c", "set 0,(ix+%hhd),d", "set 0,(ix+%hhd),e", "set 0,(ix+%hhd),h", "set 0,(ix+%hhd),l", "set 0,(ix+%hhd)", "set 0,(ix+%hhd),a", "set 1,(ix+%hhd),b", "set 1,(ix+%hhd),c", "set 1,(ix+%hhd),d", "set 1,(ix+%hhd),e", "set 1,(ix+%hhd),h", "set 1,(ix+%hhd),l", "set 1,(ix+%hhd)", "set 1,(ix+%hhd),a", "set 2,(ix+%hhd),b", "set 2,(ix+%hhd),c", "set 2,(ix+%hhd),d", "set 2,(ix+%hhd),e", "set 2,(ix+%hhd),h", "set 2,(ix+%hhd),l", "set 2,(ix+%hhd)", "set 2,(ix+%hhd),a", "set 3,(ix+%hhd),b", "set 3,(ix+%hhd),c", "set 3,(ix+%hhd),d", "set 3,(ix+%hhd),e", "set 3,(ix+%hhd),h", "set 3,(ix+%hhd),l", "set 3,(ix+%hhd)", "set 3,(ix+%hhd),a", "set 4,(ix+%hhd),b", "set 4,(ix+%hhd),c", "set 4,(ix+%hhd),d", "set 4,(ix+%hhd),e", "set 4,(ix+%hhd),h", "set 4,(ix+%hhd),l", "set 4,(ix+%hhd)", "set 4,(ix+%hhd),a", "set 5,(ix+%hhd),b", "set 5,(ix+%hhd),c", "set 5,(ix+%hhd),d", "set 5,(ix+%hhd),e", "set 5,(ix+%hhd),h", "set 5,(ix+%hhd),l", "set 5,(ix+%hhd)", "set 5,(ix+%hhd),a", "set 6,(ix+%hhd),b", "set 6,(ix+%hhd),c", "set 6,(ix+%hhd),d", "set 6,(ix+%hhd),e", "set 6,(ix+%hhd),h", "set 6,(ix+%hhd),l", "set 6,(ix+%hhd)", "set 6,(ix+%hhd),a", "set 7,(ix+%hhd),b", "set 7,(ix+%hhd),c", "set 7,(ix+%hhd),d", "set Line truncated
// const char *misc_opcodes[128] = {"in b,(c)", "out (c),b", "sbc hl,bc", "ld ($%04x),bc", "neg", "retn", "im 0", "ld i,a", "in c,(c)", "out (c),c", "adc hl,bc", "ld bc,($%04x)", "mlt bc", "reti", "", "ld r,a", "in d,(c)", "out (c),d", "sbc hl,de", "ld ($%04x),de", "", "", "im 1", "ld a,i", "in e,(c)", "out (c),e", "adc hl,de", "ld de,($%04x)", "mlt de", "", "im 2", "ld a,r", "in h,(c)", "out (c),h", "sbc hl,hl", "ld ($%04x),hl", "tst $%02x", "", "", "rrd", "in l,(c)", "out (c),l", "adc hl,hl", "ld hl,($%04x)", "mlt hl", "", "", "rld", "in (c)", "out (c),0", "sbc hl,sp", "ld ($%04x),sp", "tstio $%02x", "", "slp", "", "in a,(c)", "out (c),a", "adc hl,sp", "ld sp,($%04x)", "mlt sp", "", "", "", "", "", "", "otim", "", "", "", "", "", "", "", "otdm", "", "", "", "", "", "", "", "otimr", "", "", "", "", "", "", "", "otdmr", "", "", "", "", "ldi", "cpi", "ini", "outi", "", "", "", "", "ldd", "cpd", "ind", "outd", "", "", "", "", "ldir", "cpir", "inir", "otir", "", "", "", "", "lddr", "cpdr", "indr", "otdr", "", "", "", ""};
// const char *iy_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add iy,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add iy,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld iy,$%04x", "ld ($%04x),iy", "inc iy", "inc iyh", "dec iyh", "ld iyh,$%02x", "", "", "add iy,iy", "ld iy,($%04x)", "dec iy", "inc iyl", "dec iyl", "ld iyl,$%02x", "", "", "", "", "", "inc (iy+%hhd)", "dec (iy+%hhd)", "ld (iy+%hhd),$%02x", "", "", "add iy,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,iyh", "ld b,iyl", "ld b,(iy+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,iyh", "ld c,iyl", "ld c,(iy+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,iyh", "ld d,iyl", "ld d,(iy+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,iyh", "ld e,iyl", "ld e,(iy+%hhd)", "ld e,a", "ld iyh,b", "ld iyh,c", "ld iyh,d", "ld iyh,e", "ld iyh,iyh", "ld iyh,iyl", "ld h,(iy+%hhd)", "ld iyh,a", "ld iyl,b", "ld iyl,c", "ld iyl,d", "ld iyl,e", "ld iyl,iyh", "ld iyl,iyl", "ld l,(iy+%hhd)", "ld iyl,a", "ld (iy+%hhd),b", "ld (iy+%hhd),c", "ld (iy+%hhd),d", "ld (iy+%hhd),e", "ld (iy+%hhd),h", "ld (iy+%hhd),l", "", "ld (iy+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,iyh", "ld a,iyl", "ld a,(iy+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,iyh", "add a,iyl", "add a,(iy+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,iyh", "adc a,iyl", "adc a,(iy+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub iyh", "sub iyl", "sub (iy+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,iyh", "sbc a,iyl", "sbc a,(iy+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and iyh", "and iyl", "and (iy+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor iyh", "xor iyl", "xor (iy+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or iyh", "or iyl", "or (iy+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp iyh", "cp iyl", "cp (iy+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IY Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop iy", "", "ex (sp),iy", "", "push iy", "", "", "", "jp (iy)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,iy", "", "", "", "", "", ""};
// const char *iy_bit_opcodes[256] = {"rlc (iy+%hhd),b", "rlc (iy+%hhd),c", "rlc (iy+%hhd),d", "rlc (iy+%hhd),e", "rlc (iy+%hhd),h", "rlc (iy+%hhd),l", "rlc (iy+%hhd)", "rlc (iy+%hhd),a", "rrc (iy+%hhd),b", "rrc (iy+%hhd),c", "rrc (iy+%hhd),d", "rrc (iy+%hhd),e", "rrc (iy+%hhd),h", "rrc (iy+%hhd),l", "rrc (iy+%hhd)", "rrc (iy+%hhd),a", "rl (iy+%hhd),b", "rl (iy+%hhd),c", "rl (iy+%hhd),d", "rl (iy+%hhd),e", "rl (iy+%hhd),h", "rl (iy+%hhd),l", "rl (iy+%hhd)", "rl (iy+%hhd),a", "rr (iy+%hhd),b", "rr (iy+%hhd),c", "rr (iy+%hhd),d", "rr (iy+%hhd),e", "rr (iy+%hhd),h", "rr (iy+%hhd),l", "rr (iy+%hhd)", "rr (iy+%hhd),a", "sla (iy+%hhd),b", "sla (iy+%hhd),c", "sla (iy+%hhd),d", "sla (iy+%hhd),e", "sla (iy+%hhd),h", "sla (iy+%hhd),l", "sla (iy+%hhd)", "sla (iy+%hhd),a", "sra (iy+%hhd),b", "sra (iy+%hhd),c", "sra (iy+%hhd),d", "sra (iy+%hhd),e", "sra (iy+%hhd),h", "sra (iy+%hhd),l", "sra (iy+%hhd)", "sra (iy+%hhd),a", "sll (iy+%hhd),b", "sll (iy+%hhd),c", "sll (iy+%hhd),d", "sll (iy+%hhd),e", "sll (iy+%hhd),h", "sll (iy+%hhd),l", "sll (iy+%hhd)", "sll (iy+%hhd),a", "srl (iy+%hhd),b", "srl (iy+%hhd),c", "srl (iy+%hhd),d", "srl (iy+%hhd),e", "srl (iy+%hhd),h", "srl (iy+%hhd),l", "srl (iy+%hhd)", "srl (iy+%hhd),a", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "res 0,(iy+%hhd),b", "res 0,(iy+%hhd),c", "res 0,(iy+%hhd),d", "res 0,(iy+%hhd),e", "res 0,(iy+%hhd),h", "res 0,(iy+%hhd),l", "res 0,(iy+%hhd)", "res 0,(iy+%hhd),a", "res 1,(iy+%hhd),b", "res 1,(iy+%hhd),c", "res 1,(iy+%hhd),d", "res 1,(iy+%hhd),e", "res 1,(iy+%hhd),h", "res 1,(iy+%hhd),l", "res 1,(iy+%hhd)", "res 1,(iy+%hhd),a", "res 2,(iy+%hhd),b", "res 2,(iy+%hhd),c", "res 2,(iy+%hhd),d", "res 2,(iy+%hhd),e", "res 2,(iy+%hhd),h", "res 2,(iy+%hhd),l", "res 2,(iy+%hhd)", "res 2,(iy+%hhd),a", "res 3,(iy+%hhd),b", "res 3,(iy+%hhd),c", "res 3,(iy+%hhd),d", "res 3,(iy+%hhd),e", "res 3,(iy+%hhd),h", "res 3,(iy+%hhd),l", "res 3,(iy+%hhd)", "res 3,(iy+%hhd),a", "res 4,(iy+%hhd),b", "res 4,(iy+%hhd),c", "res 4,(iy+%hhd),d", "res 4,(iy+%hhd),e", "res 4,(iy+%hhd),h", "res 4,(iy+%hhd),l", "res 4,(iy+%hhd)", "res 4,(iy+%hhd),a", "res 5,(iy+%hhd),b", "res 5,(iy+%hhd),c", "res 5,(iy+%hhd),d", "res 5,(iy+%hhd),e", "res 5,(iy+%hhd),h", "res 5,(iy+%hhd),l", "res 5,(iy+%hhd)", "res 5,(iy+%hhd),a", "res 6,(iy+%hhd),b", "res 6,(iy+%hhd),c", "res 6,(iy+%hhd),d", "res 6,(iy+%hhd),e", "res 6,(iy+%hhd),h", "res 6,(iy+%hhd),l", "res 6,(iy+%hhd)", "res 6,(iy+%hhd),a", "res 7,(iy+%hhd),b", "res 7,(iy+%hhd),c", "res 7,(iy+%hhd),d", "res 7,(iy+%hhd),e", "res 7,(iy+%hhd),h", "res 7,(iy+%hhd),l", "res 7,(iy+%hhd)", "res 7,(iy+%hhd),a", "set 0,(iy+%hhd),b", "set 0,(iy+%hhd),c", "set 0,(iy+%hhd),d", "set 0,(iy+%hhd),e", "set 0,(iy+%hhd),h", "set 0,(iy+%hhd),l", "set 0,(iy+%hhd)", "set 0,(iy+%hhd),a", "set 1,(iy+%hhd),b", "set 1,(iy+%hhd),c", "set 1,(iy+%hhd),d", "set 1,(iy+%hhd),e", "set 1,(iy+%hhd),h", "set 1,(iy+%hhd),l", "set 1,(iy+%hhd)", "set 1,(iy+%hhd),a", "set 2,(iy+%hhd),b", "set 2,(iy+%hhd),c", "set 2,(iy+%hhd),d", "set 2,(iy+%hhd),e", "set 2,(iy+%hhd),h", "set 2,(iy+%hhd),l", "set 2,(iy+%hhd)", "set 2,(iy+%hhd),a", "set 3,(iy+%hhd),b", "set 3,(iy+%hhd),c", "set 3,(iy+%hhd),d", "set 3,(iy+%hhd),e", "set 3,(iy+%hhd),h", "set 3,(iy+%hhd),l", "set 3,(iy+%hhd)", "set 3,(iy+%hhd),a", "set 4,(iy+%hhd),b", "set 4,(iy+%hhd),c", "set 4,(iy+%hhd),d", "set 4,(iy+%hhd),e", "set 4,(iy+%hhd),h", "set 4,(iy+%hhd),l", "set 4,(iy+%hhd)", "set 4,(iy+%hhd),a", "set 5,(iy+%hhd),b", "set 5,(iy+%hhd),c", "set 5,(iy+%hhd),d", "set 5,(iy+%hhd),e", "set 5,(iy+%hhd),h", "set 5,(iy+%hhd),l", "set 5,(iy+%hhd)", "set 5,(iy+%hhd),a", "set 6,(iy+%hhd),b", "set 6,(iy+%hhd),c", "set 6,(iy+%hhd),d", "set 6,(iy+%hhd),e", "set 6,(iy+%hhd),h", "set 6,(iy+%hhd),l", "set 6,(iy+%hhd)", "set 6,(iy+%hhd),a", "set 7,(iy+%hhd),b", "set 7,(iy+%hhd),c", "set 7,(iy+%hhd),d", "set Line truncated
void loadSymbols()
{
used_symbols.clear();
for (int i=0; i<65536; ++i) symbols[i][0] = 0;
FILE *f = fopen("symbols.txt", "r");
while (true) {
uint16_t address;
char tmp[15];
const int result = fscanf(f, "%x %s", &address, tmp);
if (result != 2) break;
strcpy(symbols[address], tmp);
used_symbols.push_back(address);
}
fclose(f);
}
void saveSymbols()
{
FILE *f = fopen("symbols.txt", "w");
for (auto sym_addr : used_symbols)
{
fprintf(f, "0x%x %s\n", sym_addr, symbols[sym_addr]);
}
fclose(f);
}
const char *getBase(const uint16_t pos)
{
opcode_size=1;
return base_opcodes[mem::read(pos)];
}
void printOpcode(const uint16_t pos)
{
char hex[4];
for (int i=0; i<4;++i)
{
if (opcode_size>i)
sprintf(hex, "%02x ", mem::read(pos+i));
else
sprintf(hex, " ");
strcat(buffer, hex);
}
}
const char *getAsm(const uint16_t pos)
{
opcode_size = 0;
char base[256];
strcpy(buffer, getBase(pos));
if (strstr(buffer, "4x"))
{
opcode_size+=2;
const uint8_t memvalue = mem::read(pos);
const uint16_t word = mem::read(pos+1) + (mem::read(pos+2)<<8);
if (symbols[word][0]!=0) {
char *p = strstr(buffer, "$");
(*p)='%'; p++;
(*p)='s'; p++;
while (*(p-1) != 0) {
*p = *(p+3);
p++;
}
strcpy(base, buffer);
sprintf(buffer, base, symbols[word]);
} else {
strcpy(base, buffer);
sprintf(buffer, base, word);
}
}
if (strstr(buffer, "2x"))
{
opcode_size+=1;
strcpy(base, buffer);
sprintf(buffer, base, mem::read(pos+1));
}
if (strstr(buffer, "hhd")) {
opcode_size+=1;
strcpy(base, buffer);
sprintf(buffer, base, (int8_t)mem::read(pos+1));
}
return buffer;
}
const char *getOpcode(const uint16_t pos)
{
opcode_size = 0;
buffer[0]=0;
const char *base = getBase(pos);
if (strstr(base, "4x")) opcode_size+=2;
if (strstr(base, "2x")) opcode_size+=1;
if (strstr(base, "hh")) opcode_size+=1;
printOpcode(pos);
return buffer;
}
const int getOpcodeSize(const uint16_t pos)
{
opcode_size = 0;
const char *base = getBase(pos);
if (strstr(base, "4x")) opcode_size+=2;
if (strstr(base, "2x")) opcode_size+=1;
if (strstr(base, "hh")) opcode_size+=1;
return opcode_size;
}
const char *getSymbol(const uint16_t pos)
{
return symbols[pos];
}
void setSymbol(const uint16_t pos, const char *sym)
{
if (sym) {
strcpy(symbols[pos], sym);
} else {
symbols[pos][0] = 0;
}
used_symbols.clear();
for (int i=0; i<65536; ++i) if (symbols[i][0]!=0) used_symbols.push_back(i);
saveSymbols();
}
const int getNumSymbols()
{
return used_symbols.size();
}
const uint16_t getSymbolAddress(const int pos)
{
return used_symbols[pos];
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
#include <stdint.h> #include <stdint.h>
namespace z80dis namespace m6502dis
{ {
void loadSymbols(); void loadSymbols();
void saveSymbols(); void saveSymbols();
+33 -21
View File
@@ -36,6 +36,11 @@ namespace m6502
uint16_t exec_PC; uint16_t exec_PC;
uint16_t getPC() { return exec_PC; } uint16_t getPC() { return exec_PC; }
uint8_t getA() { return rA; }
uint8_t getX() { return rX; }
uint8_t getY() { return rY; }
uint8_t getS() { return rS; }
uint8_t getP() { return rP; }
// Explicit 16-bit accessors prevent UB and stay host-endian safe // Explicit 16-bit accessors prevent UB and stay host-endian safe
inline uint16_t get_PC() { return (uint16_t)rPC_lo | ((uint16_t)rPC_hi << 8); } inline uint16_t get_PC() { return (uint16_t)rPC_lo | ((uint16_t)rPC_hi << 8); }
@@ -114,7 +119,7 @@ namespace m6502
/* 0x15 ORA zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0x15 ORA zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0x16 ASL zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x16 ASL zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x17 --- */ { miFetchOpcode }, /* 0x17 --- */ { miFetchOpcode },
/* 0x18 CLC */ { miFetchOperandLo, miFetchOpcode }, /* 0x18 CLC */ { miFakeFetchOperand, miFetchOpcode },
/* 0x19 ORA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0x19 ORA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0x1A --- */ { miFetchOpcode }, /* 0x1A --- */ { miFetchOpcode },
/* 0x1B --- */ { miFetchOpcode }, /* 0x1B --- */ { miFetchOpcode },
@@ -148,7 +153,7 @@ namespace m6502
/* 0x35 AND zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0x35 AND zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0x36 ROL zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x36 ROL zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x37 --- */ { miFetchOpcode }, /* 0x37 --- */ { miFetchOpcode },
/* 0x38 SEC */ { miFetchOperandLo, miFetchOpcode }, /* 0x38 SEC */ { miFakeFetchOperand, miFetchOpcode },
/* 0x39 AND abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0x39 AND abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0x3A --- */ { miFetchOpcode }, /* 0x3A --- */ { miFetchOpcode },
/* 0x3B --- */ { miFetchOpcode }, /* 0x3B --- */ { miFetchOpcode },
@@ -165,7 +170,7 @@ namespace m6502
/* 0x45 EOR zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0x45 EOR zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0x46 LSR zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x46 LSR zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x47 --- */ { miFetchOpcode }, /* 0x47 --- */ { miFetchOpcode },
/* 0x48 PHA */ { miFetchOperandLo, miPushA, miFetchOpcode }, /* 0x48 PHA */ { miFakeFetchOperand, miPushA, miFetchOpcode },
/* 0x49 EOR imm */ { miFetchOperandLo, miFetchOpcode }, /* 0x49 EOR imm */ { miFetchOperandLo, miFetchOpcode },
/* 0x4A LSR A */ { miFakeFetchOperand, miFetchOpcode }, /* 0x4A LSR A */ { miFakeFetchOperand, miFetchOpcode },
/* 0x4B --- */ { miFetchOpcode }, /* 0x4B --- */ { miFetchOpcode },
@@ -182,7 +187,7 @@ namespace m6502
/* 0x55 EOR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0x55 EOR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0x56 LSR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x56 LSR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x57 --- */ { miFetchOpcode }, /* 0x57 --- */ { miFetchOpcode },
/* 0x58 CLI */ { miFetchOperandLo, miFetchOpcode }, /* 0x58 CLI */ { miFakeFetchOperand, miFetchOpcode },
/* 0x59 EOR abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0x59 EOR abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0x5A --- */ { miFetchOpcode }, /* 0x5A --- */ { miFetchOpcode },
/* 0x5B --- */ { miFetchOpcode }, /* 0x5B --- */ { miFetchOpcode },
@@ -199,7 +204,7 @@ namespace m6502
/* 0x65 ADC zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0x65 ADC zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0x66 ROR zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x66 ROR zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x67 --- */ { miFetchOpcode }, /* 0x67 --- */ { miFetchOpcode },
/* 0x68 PLA */ { miFetchOperandLo, miFakeFetchOperand, miPullA, miFetchOpcode }, /* 0x68 PLA */ { miFakeFetchOperand, miFakeFetchOperand, miPullA, miFetchOpcode },
/* 0x69 ADC imm */ { miFetchOperandLo, miFetchOpcode }, /* 0x69 ADC imm */ { miFetchOperandLo, miFetchOpcode },
/* 0x6A ROR A */ { miFakeFetchOperand, miFetchOpcode }, /* 0x6A ROR A */ { miFakeFetchOperand, miFetchOpcode },
/* 0x6B --- */ { miFetchOpcode }, /* 0x6B --- */ { miFetchOpcode },
@@ -216,7 +221,7 @@ namespace m6502
/* 0x75 ADC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0x75 ADC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0x76 ROR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0x76 ROR zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0x77 --- */ { miFetchOpcode }, /* 0x77 --- */ { miFetchOpcode },
/* 0x78 SEI */ { miFetchOperandLo, miFetchOpcode }, /* 0x78 SEI */ { miFakeFetchOperand, miFetchOpcode },
/* 0x79 ADC abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0x79 ADC abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0x7A --- */ { miFetchOpcode }, /* 0x7A --- */ { miFetchOpcode },
/* 0x7B --- */ { miFetchOpcode }, /* 0x7B --- */ { miFetchOpcode },
@@ -233,9 +238,9 @@ namespace m6502
/* 0x85 STA zpg */ { miFetchOperandLo, miWriteRegister, miFetchOpcode }, /* 0x85 STA zpg */ { miFetchOperandLo, miWriteRegister, miFetchOpcode },
/* 0x86 STX zpg */ { miFetchOperandLo, miWriteRegister, miFetchOpcode }, /* 0x86 STX zpg */ { miFetchOperandLo, miWriteRegister, miFetchOpcode },
/* 0x87 --- */ { miFetchOpcode }, /* 0x87 --- */ { miFetchOpcode },
/* 0x88 DEY */ { miFetchOperandLo, miFetchOpcode }, /* 0x88 DEY */ { miFakeFetchOperand, miFetchOpcode },
/* 0x89 --- */ { miFetchOpcode }, /* 0x89 --- */ { miFetchOpcode },
/* 0x8A TXA */ { miFetchOperandLo, miFetchOpcode }, /* 0x8A TXA */ { miFakeFetchOperand, miFetchOpcode },
/* 0x8B --- */ { miFetchOpcode }, /* 0x8B --- */ { miFetchOpcode },
/* 0x8C STY abs */ { miFetchOperandLo, miFetchOperandHi, miWriteRegister, miFetchOpcode }, /* 0x8C STY abs */ { miFetchOperandLo, miFetchOperandHi, miWriteRegister, miFetchOpcode },
/* 0x8D STA abs */ { miFetchOperandLo, miFetchOperandHi, miWriteRegister, miFetchOpcode }, /* 0x8D STA abs */ { miFetchOperandLo, miFetchOperandHi, miWriteRegister, miFetchOpcode },
@@ -250,9 +255,9 @@ namespace m6502
/* 0x95 STA zpg,X */ { miFetchOperandLo, miIndexX, miWriteRegister, miFetchOpcode }, /* 0x95 STA zpg,X */ { miFetchOperandLo, miIndexX, miWriteRegister, miFetchOpcode },
/* 0x96 STX zpg,X */ { miFetchOperandLo, miIndexX, miWriteRegister, miFetchOpcode }, /* 0x96 STX zpg,X */ { miFetchOperandLo, miIndexX, miWriteRegister, miFetchOpcode },
/* 0x97 --- */ { miFetchOpcode }, /* 0x97 --- */ { miFetchOpcode },
/* 0x98 TYA */ { miFetchOperandLo, miFetchOpcode }, /* 0x98 TYA */ { miFakeFetchOperand, miFetchOpcode },
/* 0x99 STA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddress, miWriteRegister, miFetchOpcode }, /* 0x99 STA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddress, miWriteRegister, miFetchOpcode },
/* 0x9A TXS */ { miFetchOperandLo, miFetchOpcode }, /* 0x9A TXS */ { miFakeFetchOperand, miFetchOpcode },
/* 0x9B --- */ { miFetchOpcode }, /* 0x9B --- */ { miFetchOpcode },
/* 0x9C --- */ { miFetchOpcode }, /* 0x9C --- */ { miFetchOpcode },
/* 0x9D STA abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddress, miWriteRegister, miFetchOpcode }, /* 0x9D STA abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddress, miWriteRegister, miFetchOpcode },
@@ -267,9 +272,9 @@ namespace m6502
/* 0xA5 LDA zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0xA5 LDA zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0xA6 LDX zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0xA6 LDX zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0xA7 --- */ { miFetchOpcode }, /* 0xA7 --- */ { miFetchOpcode },
/* 0xA8 TAY */ { miFetchOperandLo, miFetchOpcode }, /* 0xA8 TAY */ { miFakeFetchOperand, miFetchOpcode },
/* 0xA9 LDA imm */ { miFetchOperandLo, miFetchOpcode }, /* 0xA9 LDA imm */ { miFetchOperandLo, miFetchOpcode },
/* 0xAA TAX */ { miFetchOperandLo, miFetchOpcode }, /* 0xAA TAX */ { miFakeFetchOperand, miFetchOpcode },
/* 0xAB --- */ { miFetchOpcode }, /* 0xAB --- */ { miFetchOpcode },
/* 0xAC LDY abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xAC LDY abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
/* 0xAD LDA abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xAD LDA abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
@@ -284,9 +289,9 @@ namespace m6502
/* 0xB5 LDA zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0xB5 LDA zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0xB6 LDX zpg,Y */ { miFetchOperandLo, miIndexY, miReadAddress, miFetchOpcode }, /* 0xB6 LDX zpg,Y */ { miFetchOperandLo, miIndexY, miReadAddress, miFetchOpcode },
/* 0xB7 --- */ { miFetchOpcode }, /* 0xB7 --- */ { miFetchOpcode },
/* 0xB8 CLV */ { miFetchOperandLo, miFetchOpcode }, /* 0xB8 CLV */ { miFakeFetchOperand, miFetchOpcode },
/* 0xB9 LDA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0xB9 LDA abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0xBA TSX */ { miFetchOperandLo, miFetchOpcode }, /* 0xBA TSX */ { miFakeFetchOperand, miFetchOpcode },
/* 0xBB --- */ { miFetchOpcode }, /* 0xBB --- */ { miFetchOpcode },
/* 0xBC LDY abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0xBC LDY abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0xBD LDA abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0xBD LDA abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
@@ -301,9 +306,9 @@ namespace m6502
/* 0xC5 CMP zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0xC5 CMP zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0xC6 DEC zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0xC6 DEC zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0xC7 --- */ { miFetchOpcode }, /* 0xC7 --- */ { miFetchOpcode },
/* 0xC8 INY */ { miFetchOperandLo, miFetchOpcode }, /* 0xC8 INY */ { miFakeFetchOperand, miFetchOpcode },
/* 0xC9 CMP imm */ { miFetchOperandLo, miFetchOpcode }, /* 0xC9 CMP imm */ { miFetchOperandLo, miFetchOpcode },
/* 0xCA DEX */ { miFetchOperandLo, miFetchOpcode }, /* 0xCA DEX */ { miFakeFetchOperand, miFetchOpcode },
/* 0xCB --- */ { miFetchOpcode }, /* 0xCB --- */ { miFetchOpcode },
/* 0xCC CPY abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xCC CPY abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
/* 0xCD CMP abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xCD CMP abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
@@ -318,7 +323,7 @@ namespace m6502
/* 0xD5 CMP zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0xD5 CMP zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0xD6 DEC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0xD6 DEC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0xD7 --- */ { miFetchOpcode }, /* 0xD7 --- */ { miFetchOpcode },
/* 0xD8 CLD */ { miFetchOperandLo, miFetchOpcode }, /* 0xD8 CLD */ { miFakeFetchOperand, miFetchOpcode },
/* 0xD9 CMP abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0xD9 CMP abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0xDA --- */ { miFetchOpcode }, /* 0xDA --- */ { miFetchOpcode },
/* 0xDB --- */ { miFetchOpcode }, /* 0xDB --- */ { miFetchOpcode },
@@ -335,9 +340,9 @@ namespace m6502
/* 0xE5 SBC zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode }, /* 0xE5 SBC zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
/* 0xE6 INC zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0xE6 INC zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0xE7 --- */ { miFetchOpcode }, /* 0xE7 --- */ { miFetchOpcode },
/* 0xE8 INX */ { miFetchOperandLo, miFetchOpcode }, /* 0xE8 INX */ { miFakeFetchOperand, miFetchOpcode },
/* 0xE9 SBC imm */ { miFetchOperandLo, miFetchOpcode }, /* 0xE9 SBC imm */ { miFetchOperandLo, miFetchOpcode },
/* 0xEA NOP */ { miFetchOpcode }, /* 0xEA NOP */ { miFakeFetchOperand },
/* 0xEB --- */ { miFetchOpcode }, /* 0xEB --- */ { miFetchOpcode },
/* 0xEC CPX abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xEC CPX abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
/* 0xED SBC abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode }, /* 0xED SBC abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
@@ -352,7 +357,7 @@ namespace m6502
/* 0xF5 SBC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode }, /* 0xF5 SBC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miFetchOpcode },
/* 0xF6 INC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode }, /* 0xF6 INC zpg,X */ { miFetchOperandLo, miIndexX, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
/* 0xF7 --- */ { miFetchOpcode }, /* 0xF7 --- */ { miFetchOpcode },
/* 0xF8 SED */ { miFetchOperandLo, miFetchOpcode }, /* 0xF8 SED */ { miFakeFetchOperand, miFetchOpcode },
/* 0xF9 SBC abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode }, /* 0xF9 SBC abs,Y */ { miFetchOperandLo, miFetchOperandHiAndIndexY, miReadAddressAndSkip, miReadAddress, miFetchOpcode },
/* 0xFA --- */ { miFetchOpcode }, /* 0xFA --- */ { miFetchOpcode },
/* 0xFB --- */ { miFetchOpcode }, /* 0xFB --- */ { miFetchOpcode },
@@ -598,7 +603,14 @@ namespace m6502
void reset() void reset()
{ {
rPC_lo = mem::read(0xfffc);
rPC_hi = mem::read(0xfffd);
exec_PC = get_PC();
rS = 0xfd;
rP = 0x34;
rA = 0;
rX = 0;
rY = 0;
} }
void interrupt(uint8_t type) void interrupt(uint8_t type)
+5
View File
@@ -7,5 +7,10 @@ namespace m6502
void interrupt(uint8_t type); void interrupt(uint8_t type);
bool tick(); bool tick();
uint8_t getA();
uint8_t getX();
uint8_t getY();
uint8_t getS();
uint8_t getP();
uint16_t getPC(); uint16_t getPC();
} }
+5 -4
View File
@@ -6,7 +6,7 @@
#include "display.h" #include "display.h"
#include "speaker.h" #include "speaker.h"
//#include "keyboard.h" //#include "keyboard.h"
//#include "z80debugger.h" #include "6502debugger.h"
#define NTSC_CLOCK 1193182.0f #define NTSC_CLOCK 1193182.0f
#define PAL_CLOCK 1182298.0f #define PAL_CLOCK 1182298.0f
@@ -30,7 +30,6 @@ namespace atari2600
speaker::init(NTSC_CLOCK); speaker::init(NTSC_CLOCK);
speaker::register_source(tia::audio::get_sample0); speaker::register_source(tia::audio::get_sample0);
speaker::register_source(tia::audio::get_sample1); speaker::register_source(tia::audio::get_sample1);
//speaker::register_source(keyboard::get_sample);
} }
void quit() void quit()
@@ -38,11 +37,13 @@ namespace atari2600
should_exit = true; should_exit = true;
} }
int ppc = 0;
void step() void step()
{ {
//uint8_t t_states; //uint8_t t_states;
//uint16_t pc = m6502::getPC(); uint16_t pc = m6502::getPC();
ppc += pc;
m6502debugger::onInstructionExecute(pc);
// if (z80debugger::isbreak(pc, 9)) { // if (z80debugger::isbreak(pc, 9)) {
// msx::pause(); // msx::pause();
// z80debugger::show(); // z80debugger::show();
+2 -2
View File
@@ -3,7 +3,7 @@
#include "tia.h" #include "tia.h"
#include "atari2600.h" #include "atari2600.h"
#include "ui_window.h" #include "ui_window.h"
//#include "z80debugger.h" #include "6502debugger.h"
#include "ui.h" #include "ui.h"
namespace display namespace display
@@ -68,7 +68,7 @@ namespace display
if (e->type == SDL_EVENT_KEY_DOWN) { if (e->type == SDL_EVENT_KEY_DOWN) {
const SDL_Scancode &key = e->key.scancode; const SDL_Scancode &key = e->key.scancode;
switch (key) { switch (key) {
case SDL_SCANCODE_F8: atari2600::pause(); /*z80debugger::show();*/ break; case SDL_SCANCODE_F8: atari2600::pause(); m6502debugger::show(); break;
case SDL_SCANCODE_F12: if (atari2600::is_paused()) atari2600::resume(); else atari2600::pause(); break; case SDL_SCANCODE_F12: if (atari2600::is_paused()) atari2600::resume(); else atari2600::pause(); break;
case SDL_SCANCODE_Q: if (e->key.mod & SDL_KMOD_CTRL) { return false; break; } case SDL_SCANCODE_Q: if (e->key.mod & SDL_KMOD_CTRL) { return false; break; }
default: break; default: break;
+6 -5
View File
@@ -3,20 +3,21 @@
#include "rom.h" #include "rom.h"
#include "ui.h" #include "ui.h"
#include "ui_window.h" #include "ui_window.h"
#include "6502debugger.h"
//#include "z80debugger.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
atari2600::init();
if (argc > 1) { if (argc > 1) {
rom::load(argv[1]); rom::load(argv[1]);
} else { } else {
rom::load("combat.bin"); rom::load("combat.bin");
} }
atari2600::init();
atari2600::pause();
m6502debugger::show();
int wait = 16; int wait = 16;
SDL_Event e; SDL_Event e;
while (!atari2600::is_quitting()) { while (!atari2600::is_quitting()) {
@@ -31,7 +32,7 @@ int main(int argc, char *argv[]) {
if (e.type == SDL_EVENT_KEY_DOWN) { if (e.type == SDL_EVENT_KEY_DOWN) {
if (atari2600::is_paused()) { if (atari2600::is_paused()) {
switch (e.key.scancode) { switch (e.key.scancode) {
case SDL_SCANCODE_F10: atari2600::step(); /*z80debugger::refresh();*/ break; case SDL_SCANCODE_F10: atari2600::step(); m6502debugger::refresh(); break;
} }
} }
} }
+45 -7
View File
@@ -3,8 +3,11 @@
namespace pia namespace pia
{ {
uint8_t ram[128]; uint8_t ram[128];
uint8_t INTIM; bool timer_interrupt = false;
uint8_t TIMINT; uint8_t timer_value = 0;
uint16_t prescaler = 0;
uint16_t divider = 0;
bool timer_underflow = false;
void reset() void reset()
{ {
@@ -13,7 +16,22 @@ namespace pia
void tick() void tick()
{ {
prescaler++;
if (!timer_underflow) {
if (prescaler >= divider) {
prescaler = 0;
if (timer_value == 0) {
timer_underflow = true;
timer_interrupt = true;
timer_value = 0xff;
} else {
timer_value--;
}
}
} else {
timer_value--;
}
} }
uint8_t read(uint16_t address) uint8_t read(uint16_t address)
@@ -22,21 +40,21 @@ namespace pia
if ( (address & 0x04) ) { if ( (address & 0x04) ) {
// Timer functions // Timer functions
if (address & 0x01) { if (address & 0x01) {
uint8_t flags = TIMINT; uint8_t flags = timer_interrupt ? 0x80 : 0x00;
TIMINT &= ~0x80; // resetejem el flag timer_interrupt = false;
return flags; return flags;
} else { } else {
return INTIM; return timer_value;
} }
} else { } else {
// I/O Ports // I/O Ports
switch( address & 0x03) { switch( address & 0x03) {
case 0x00: // [TODO] SWCHA case 0x00: // [TODO] SWCHA
return 0x00; return 0xff;
case 0x01: // [TODO] DDRA case 0x01: // [TODO] DDRA
return 0x00; return 0x00;
case 0x02: // [TODO] SWCHB case 0x02: // [TODO] SWCHB
return 0x00; return 0x03;
case 0x03: // [TODO] DDRB case 0x03: // [TODO] DDRB
return 0x00; return 0x00;
default: default:
@@ -56,12 +74,32 @@ namespace pia
// Timer functions // Timer functions
switch( address & 0x03) { switch( address & 0x03) {
case 0x00: // [TODO] TIM1T case 0x00: // [TODO] TIM1T
divider = 1;
timer_value = value;
prescaler = 0;
timer_underflow = false;
timer_interrupt = false;
break; break;
case 0x01: // [TODO] TIM8T case 0x01: // [TODO] TIM8T
divider = 8;
timer_value = value;
prescaler = 0;
timer_underflow = false;
timer_interrupt = false;
break; break;
case 0x02: // [TODO] TIM64T case 0x02: // [TODO] TIM64T
divider = 64;
timer_value = value;
prescaler = 0;
timer_underflow = false;
timer_interrupt = false;
break; break;
case 0x03: // [TODO] TIM1024T case 0x03: // [TODO] TIM1024T
divider = 1024;
timer_value = value;
prescaler = 0;
timer_underflow = false;
timer_interrupt = false;
break; break;
} }
} else { } else {
+1 -1
View File
@@ -99,7 +99,7 @@ namespace tia
uint16_t current_scanline = 0; uint16_t current_scanline = 0;
bool rdy_low = false; bool rdy_low = false;
uint8_t framebuffer[160][192]; uint8_t framebuffer[192][160];
void reset() void reset()
{ {
-241
View File
@@ -1,241 +0,0 @@
#include "z80dis.h"
#include "z80.h"
#include "mem.h"
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bits/stdc++.h>
namespace z80dis
{
char buffer[256];
int opcode_size = 0;
char symbols[65536][15];
std::vector<uint16_t> used_symbols;
// $%04x
// $%02x
// %hhd
const char *base_opcodes[256] = {"nop", "ld bc,$%04x", "ld (bc),a", "inc bc", "inc b", "dec b", "ld b,$%02x", "rlca", "ex af,af'", "add hl,bc", "ld a,(bc)", "dec bc", "inc c", "dec c", "ld c,$%02x", "rrca", "djnz $%Xx", "ld de,$%04x", "ld (de),a", "inc de", "inc d", "dec d", "ld d,$%02x", "rla", "jr $%Xx", "add hl,de", "ld a,(de)", "dec de", "inc e", "dec e", "ld e,$%02x", "rra", "jr nz,$%Xx", "ld hl,$%04x", "ld ($%04x),hl", "inc hl", "inc h", "dec h", "ld h,$%02x", "daa", "jr z,$%Xx", "add hl,hl", "ld hl,($%04x)", "dec hl", "inc l", "dec l", "ld l,$%02x", "cpl", "jr nc,$%Xx", "ld sp,$%04x", "ld ($%04x),a", "inc sp", "inc (hl)", "dec (hl)", "ld (hl),$%02x", "scf", "jr c,$%Xx", "add hl,sp", "ld a,($%04x)", "dec sp", "inc a", "dec a", "ld a,$%02x", "ccf", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,h", "ld b,l", "ld b,(hl)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,h", "ld c,l", "ld c,(hl)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,h", "ld d,l", "ld d,(hl)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,h", "ld e,l", "ld e,(hl)", "ld e,a", "ld h,b", "ld h,c", "ld h,d", "ld h,e", "ld h,h", "ld h,l", "ld h,(hl)", "ld h,a", "ld l,b", "ld l,c", "ld l,d", "ld l,e", "ld l,h", "ld l,l", "ld l,(hl)", "ld l,a", "ld (hl),b", "ld (hl),c", "ld (hl),d", "ld (hl),e", "ld (hl),h", "ld (hl),l", "halt", "ld (hl),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,h", "ld a,l", "ld a,(hl)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,h", "add a,l", "add a,(hl)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,h", "adc a,l", "adc a,(hl)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub h", "sub l", "sub (hl)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,h", "sbc a,l", "sbc a,(hl)", "sbc a,a", "and b", "and c", "and d", "and e", "and h", "and l", "and (hl)", "and a", "xor b", "xor c", "xor d", "xor e", "xor h", "xor l", "xor (hl)", "xor a", "or b", "or c", "or d", "or e", "or h", "or l", "or (hl)", "or a", "cp b", "cp c", "cp d", "cp e", "cp h", "cp l", "cp (hl)", "cp a", "ret nz", "pop bc", "jp nz,$%04x", "jp $%04x", "call nz,$%04x", "push bc", "add a,$%02x", "rst 00h", "ret z", "ret", "jp z,$%04x", "_Bit_", "call z,$%04x", "call $%04x", "adc a,$%02x", "rst 08h", "ret nc", "pop de", "jp nc,$%04x", "out ($%02x),a", "call nc,$%04x", "push de", "sub $%02x", "rst 10h", "ret c", "exx", "jp c,$%04x", "in a,($%02x)", "call c,$%04x", "_IX_", "sbc a,$%02x", "rst 18h", "ret po", "pop hl", "jp po,$%04x", "ex (sp),hl", "call po,$%04x", "push hl", "and $%02x", "rst 20h", "ret pe", "jp (hl)", "jp pe,$%04x", "ex de,hl", "call pe,$%04x", "_Misc._", "xor $%02x", "rst 28h", "ret p", "pop af", "jp p,$%04x", "di", "call p,$%04x", "push af", "or $%02x", "rst 30h", "ret m", "ld sp,hl", "jp m,$%04x", "ei", "call m,$%04x", "_IY_", "cp $%02x", "rst 38h"};
const char *cb_opcodes[256] = {"rlc b", "rlc c", "rlc d", "rlc e", "rlc h", "rlc l", "rlc (hl)", "rlc a", "rrc b", "rrc c", "rrc d", "rrc e", "rrc h", "rrc l", "rrc (hl)", "rrc a", "rl b", "rl c", "rl d", "rl e", "rl h", "rl l", "rl (hl)", "rl a", "rr b", "rr c", "rr d", "rr e", "rr h", "rr l", "rr (hl)", "rr a", "sla b", "sla c", "sla d", "sla e", "sla h", "sla l", "sla (hl)", "sla a", "sra b", "sra c", "sra d", "sra e", "sra h", "sra l", "sra (hl)", "sra a", "sll b", "sll c", "sll d", "sll e", "sll h", "sll l", "sll (hl)", "sll a", "srl b", "srl c", "srl d", "srl e", "srl h", "srl l", "srl (hl)", "srl a", "bit 0,b", "bit 0,c", "bit 0,d", "bit 0,e", "bit 0,h", "bit 0,l", "bit 0,(hl)", "bit 0,a", "bit 1,b", "bit 1,c", "bit 1,d", "bit 1,e", "bit 1,h", "bit 1,l", "bit 1,(hl)", "bit 1,a", "bit 2,b", "bit 2,c", "bit 2,d", "bit 2,e", "bit 2,h", "bit 2,l", "bit 2,(hl)", "bit 2,a", "bit 3,b", "bit 3,c", "bit 3,d", "bit 3,e", "bit 3,h", "bit 3,l", "bit 3,(hl)", "bit 3,a", "bit 4,b", "bit 4,c", "bit 4,d", "bit 4,e", "bit 4,h", "bit 4,l", "bit 4,(hl)", "bit 4,a", "bit 5,b", "bit 5,c", "bit 5,d", "bit 5,e", "bit 5,h", "bit 5,l", "bit 5,(hl)", "bit 5,a", "bit 6,b", "bit 6,c", "bit 6,d", "bit 6,e", "bit 6,h", "bit 6,l", "bit 6,(hl)", "bit 6,a", "bit 7,b", "bit 7,c", "bit 7,d", "bit 7,e", "bit 7,h", "bit 7,l", "bit 7,(hl)", "bit 7,a", "res 0,b", "res 0,c", "res 0,d", "res 0,e", "res 0,h", "res 0,l", "res 0,(hl)", "res 0,a", "res 1,b", "res 1,c", "res 1,d", "res 1,e", "res 1,h", "res 1,l", "res 1,(hl)", "res 1,a", "res 2,b", "res 2,c", "res 2,d", "res 2,e", "res 2,h", "res 2,l", "res 2,(hl)", "res 2,a", "res 3,b", "res 3,c", "res 3,d", "res 3,e", "res 3,h", "res 3,l", "res 3,(hl)", "res 3,a", "res 4,b", "res 4,c", "res 4,d", "res 4,e", "res 4,h", "res 4,l", "res 4,(hl)", "res 4,a", "res 5,b", "res 5,c", "res 5,d", "res 5,e", "res 5,h", "res 5,l", "res 5,(hl)", "res 5,a", "res 6,b", "res 6,c", "res 6,d", "res 6,e", "res 6,h", "res 6,l", "res 6,(hl)", "res 6,a", "res 7,b", "res 7,c", "res 7,d", "res 7,e", "res 7,h", "res 7,l", "res 7,(hl)", "res 7,a", "set 0,b", "set 0,c", "set 0,d", "set 0,e", "set 0,h", "set 0,l", "set 0,(hl)", "set 0,a", "set 1,b", "set 1,c", "set 1,d", "set 1,e", "set 1,h", "set 1,l", "set 1,(hl)", "set 1,a", "set 2,b", "set 2,c", "set 2,d", "set 2,e", "set 2,h", "set 2,l", "set 2,(hl)", "set 2,a", "set 3,b", "set 3,c", "set 3,d", "set 3,e", "set 3,h", "set 3,l", "set 3,(hl)", "set 3,a", "set 4,b", "set 4,c", "set 4,d", "set 4,e", "set 4,h", "set 4,l", "set 4,(hl)", "set 4,a", "set 5,b", "set 5,c", "set 5,d", "set 5,e", "set 5,h", "set 5,l", "set 5,(hl)", "set 5,a", "set 6,b", "set 6,c", "set 6,d", "set 6,e", "set 6,h", "set 6,l", "set 6,(hl)", "set 6,a", "set 7,b", "set 7,c", "set 7,d", "set 7,e", "set 7,h", "set 7,l", "set 7,(hl)", "set 7,a"};
const char *ix_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add ix,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add ix,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld ix,$%04x", "ld ($%04x),ix", "inc ix", "inc ixh", "dec ixh", "ld ixh,$%02x", "", "", "add ix,ix", "ld ix,($%04x)", "dec ix", "inc ixl", "dec ixl", "ld ixl,$%02x", "", "", "", "", "", "inc (ix+%hhd)", "dec (ix+%hhd)", "ld (ix+%hhd),$%02x", "", "", "add ix,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,ixh", "ld b,ixl", "ld b,(ix+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,ixh", "ld c,ixl", "ld c,(ix+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,ixh", "ld d,ixl", "ld d,(ix+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,ixh", "ld e,ixl", "ld e,(ix+%hhd)", "ld e,a", "ld ixh,b", "ld ixh,c", "ld ixh,d", "ld ixh,e", "ld ixh,ixh", "ld ixh,ixl", "ld h,(ix+%hhd)", "ld ixh,a", "ld ixl,b", "ld ixl,c", "ld ixl,d", "ld ixl,e", "ld ixl,ixh", "ld ixl,ixl", "ld l,(ix+%hhd)", "ld ixl,a", "ld (ix+%hhd),b", "ld (ix+%hhd),c", "ld (ix+%hhd),d", "ld (ix+%hhd),e", "ld (ix+%hhd),h", "ld (ix+%hhd),l", "", "ld (ix+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,ixh", "ld a,ixl", "ld a,(ix+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,ixh", "add a,ixl", "add a,(ix+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,ixh", "adc a,ixl", "adc a,(ix+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub ixh", "sub ixl", "sub (ix+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,ixh", "sbc a,ixl", "sbc a,(ix+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and ixh", "and ixl", "and (ix+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor ixh", "xor ixl", "xor (ix+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or ixh", "or ixl", "or (ix+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp ixh", "cp ixl", "cp (ix+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IX Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop ix", "", "ex (sp),ix", "", "push ix", "", "", "", "jp (ix)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,ix", "", "", "", "", "", ""};
const char *ix_bit_opcodes[256] = {"rlc (ix+%hhd),b", "rlc (ix+%hhd),c", "rlc (ix+%hhd),d", "rlc (ix+%hhd),e", "rlc (ix+%hhd),h", "rlc (ix+%hhd),l", "rlc (ix+%hhd)", "rlc (ix+%hhd),a", "rrc (ix+%hhd),b", "rrc (ix+%hhd),c", "rrc (ix+%hhd),d", "rrc (ix+%hhd),e", "rrc (ix+%hhd),h", "rrc (ix+%hhd),l", "rrc (ix+%hhd)", "rrc (ix+%hhd),a", "rl (ix+%hhd),b", "rl (ix+%hhd),c", "rl (ix+%hhd),d", "rl (ix+%hhd),e", "rl (ix+%hhd),h", "rl (ix+%hhd),l", "rl (ix+%hhd)", "rl (ix+%hhd),a", "rr (ix+%hhd),b", "rr (ix+%hhd),c", "rr (ix+%hhd),d", "rr (ix+%hhd),e", "rr (ix+%hhd),h", "rr (ix+%hhd),l", "rr (ix+%hhd)", "rr (ix+%hhd),a", "sla (ix+%hhd),b", "sla (ix+%hhd),c", "sla (ix+%hhd),d", "sla (ix+%hhd),e", "sla (ix+%hhd),h", "sla (ix+%hhd),l", "sla (ix+%hhd)", "sla (ix+%hhd),a", "sra (ix+%hhd),b", "sra (ix+%hhd),c", "sra (ix+%hhd),d", "sra (ix+%hhd),e", "sra (ix+%hhd),h", "sra (ix+%hhd),l", "sra (ix+%hhd)", "sra (ix+%hhd),a", "sll (ix+%hhd),b", "sll (ix+%hhd),c", "sll (ix+%hhd),d", "sll (ix+%hhd),e", "sll (ix+%hhd),h", "sll (ix+%hhd),l", "sll (ix+%hhd)", "sll (ix+%hhd),a", "srl (ix+%hhd),b", "srl (ix+%hhd),c", "srl (ix+%hhd),d", "srl (ix+%hhd),e", "srl (ix+%hhd),h", "srl (ix+%hhd),l", "srl (ix+%hhd)", "srl (ix+%hhd),a", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "res 0,(ix+%hhd),b", "res 0,(ix+%hhd),c", "res 0,(ix+%hhd),d", "res 0,(ix+%hhd),e", "res 0,(ix+%hhd),h", "res 0,(ix+%hhd),l", "res 0,(ix+%hhd)", "res 0,(ix+%hhd),a", "res 1,(ix+%hhd),b", "res 1,(ix+%hhd),c", "res 1,(ix+%hhd),d", "res 1,(ix+%hhd),e", "res 1,(ix+%hhd),h", "res 1,(ix+%hhd),l", "res 1,(ix+%hhd)", "res 1,(ix+%hhd),a", "res 2,(ix+%hhd),b", "res 2,(ix+%hhd),c", "res 2,(ix+%hhd),d", "res 2,(ix+%hhd),e", "res 2,(ix+%hhd),h", "res 2,(ix+%hhd),l", "res 2,(ix+%hhd)", "res 2,(ix+%hhd),a", "res 3,(ix+%hhd),b", "res 3,(ix+%hhd),c", "res 3,(ix+%hhd),d", "res 3,(ix+%hhd),e", "res 3,(ix+%hhd),h", "res 3,(ix+%hhd),l", "res 3,(ix+%hhd)", "res 3,(ix+%hhd),a", "res 4,(ix+%hhd),b", "res 4,(ix+%hhd),c", "res 4,(ix+%hhd),d", "res 4,(ix+%hhd),e", "res 4,(ix+%hhd),h", "res 4,(ix+%hhd),l", "res 4,(ix+%hhd)", "res 4,(ix+%hhd),a", "res 5,(ix+%hhd),b", "res 5,(ix+%hhd),c", "res 5,(ix+%hhd),d", "res 5,(ix+%hhd),e", "res 5,(ix+%hhd),h", "res 5,(ix+%hhd),l", "res 5,(ix+%hhd)", "res 5,(ix+%hhd),a", "res 6,(ix+%hhd),b", "res 6,(ix+%hhd),c", "res 6,(ix+%hhd),d", "res 6,(ix+%hhd),e", "res 6,(ix+%hhd),h", "res 6,(ix+%hhd),l", "res 6,(ix+%hhd)", "res 6,(ix+%hhd),a", "res 7,(ix+%hhd),b", "res 7,(ix+%hhd),c", "res 7,(ix+%hhd),d", "res 7,(ix+%hhd),e", "res 7,(ix+%hhd),h", "res 7,(ix+%hhd),l", "res 7,(ix+%hhd)", "res 7,(ix+%hhd),a", "set 0,(ix+%hhd),b", "set 0,(ix+%hhd),c", "set 0,(ix+%hhd),d", "set 0,(ix+%hhd),e", "set 0,(ix+%hhd),h", "set 0,(ix+%hhd),l", "set 0,(ix+%hhd)", "set 0,(ix+%hhd),a", "set 1,(ix+%hhd),b", "set 1,(ix+%hhd),c", "set 1,(ix+%hhd),d", "set 1,(ix+%hhd),e", "set 1,(ix+%hhd),h", "set 1,(ix+%hhd),l", "set 1,(ix+%hhd)", "set 1,(ix+%hhd),a", "set 2,(ix+%hhd),b", "set 2,(ix+%hhd),c", "set 2,(ix+%hhd),d", "set 2,(ix+%hhd),e", "set 2,(ix+%hhd),h", "set 2,(ix+%hhd),l", "set 2,(ix+%hhd)", "set 2,(ix+%hhd),a", "set 3,(ix+%hhd),b", "set 3,(ix+%hhd),c", "set 3,(ix+%hhd),d", "set 3,(ix+%hhd),e", "set 3,(ix+%hhd),h", "set 3,(ix+%hhd),l", "set 3,(ix+%hhd)", "set 3,(ix+%hhd),a", "set 4,(ix+%hhd),b", "set 4,(ix+%hhd),c", "set 4,(ix+%hhd),d", "set 4,(ix+%hhd),e", "set 4,(ix+%hhd),h", "set 4,(ix+%hhd),l", "set 4,(ix+%hhd)", "set 4,(ix+%hhd),a", "set 5,(ix+%hhd),b", "set 5,(ix+%hhd),c", "set 5,(ix+%hhd),d", "set 5,(ix+%hhd),e", "set 5,(ix+%hhd),h", "set 5,(ix+%hhd),l", "set 5,(ix+%hhd)", "set 5,(ix+%hhd),a", "set 6,(ix+%hhd),b", "set 6,(ix+%hhd),c", "set 6,(ix+%hhd),d", "set 6,(ix+%hhd),e", "set 6,(ix+%hhd),h", "set 6,(ix+%hhd),l", "set 6,(ix+%hhd)", "set 6,(ix+%hhd),a", "set 7,(ix+%hhd),b", "set 7,(ix+%hhd),c", "set 7,(ix+%hhd),d", "set 7,Line truncated
const char *misc_opcodes[128] = {"in b,(c)", "out (c),b", "sbc hl,bc", "ld ($%04x),bc", "neg", "retn", "im 0", "ld i,a", "in c,(c)", "out (c),c", "adc hl,bc", "ld bc,($%04x)", "mlt bc", "reti", "", "ld r,a", "in d,(c)", "out (c),d", "sbc hl,de", "ld ($%04x),de", "", "", "im 1", "ld a,i", "in e,(c)", "out (c),e", "adc hl,de", "ld de,($%04x)", "mlt de", "", "im 2", "ld a,r", "in h,(c)", "out (c),h", "sbc hl,hl", "ld ($%04x),hl", "tst $%02x", "", "", "rrd", "in l,(c)", "out (c),l", "adc hl,hl", "ld hl,($%04x)", "mlt hl", "", "", "rld", "in (c)", "out (c),0", "sbc hl,sp", "ld ($%04x),sp", "tstio $%02x", "", "slp", "", "in a,(c)", "out (c),a", "adc hl,sp", "ld sp,($%04x)", "mlt sp", "", "", "", "", "", "", "otim", "", "", "", "", "", "", "", "otdm", "", "", "", "", "", "", "", "otimr", "", "", "", "", "", "", "", "otdmr", "", "", "", "", "ldi", "cpi", "ini", "outi", "", "", "", "", "ldd", "cpd", "ind", "outd", "", "", "", "", "ldir", "cpir", "inir", "otir", "", "", "", "", "lddr", "cpdr", "indr", "otdr", "", "", "", ""};
const char *iy_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add iy,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add iy,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld iy,$%04x", "ld ($%04x),iy", "inc iy", "inc iyh", "dec iyh", "ld iyh,$%02x", "", "", "add iy,iy", "ld iy,($%04x)", "dec iy", "inc iyl", "dec iyl", "ld iyl,$%02x", "", "", "", "", "", "inc (iy+%hhd)", "dec (iy+%hhd)", "ld (iy+%hhd),$%02x", "", "", "add iy,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,iyh", "ld b,iyl", "ld b,(iy+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,iyh", "ld c,iyl", "ld c,(iy+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,iyh", "ld d,iyl", "ld d,(iy+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,iyh", "ld e,iyl", "ld e,(iy+%hhd)", "ld e,a", "ld iyh,b", "ld iyh,c", "ld iyh,d", "ld iyh,e", "ld iyh,iyh", "ld iyh,iyl", "ld h,(iy+%hhd)", "ld iyh,a", "ld iyl,b", "ld iyl,c", "ld iyl,d", "ld iyl,e", "ld iyl,iyh", "ld iyl,iyl", "ld l,(iy+%hhd)", "ld iyl,a", "ld (iy+%hhd),b", "ld (iy+%hhd),c", "ld (iy+%hhd),d", "ld (iy+%hhd),e", "ld (iy+%hhd),h", "ld (iy+%hhd),l", "", "ld (iy+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,iyh", "ld a,iyl", "ld a,(iy+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,iyh", "add a,iyl", "add a,(iy+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,iyh", "adc a,iyl", "adc a,(iy+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub iyh", "sub iyl", "sub (iy+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,iyh", "sbc a,iyl", "sbc a,(iy+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and iyh", "and iyl", "and (iy+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor iyh", "xor iyl", "xor (iy+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or iyh", "or iyl", "or (iy+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp iyh", "cp iyl", "cp (iy+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IY Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop iy", "", "ex (sp),iy", "", "push iy", "", "", "", "jp (iy)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,iy", "", "", "", "", "", ""};
const char *iy_bit_opcodes[256] = {"rlc (iy+%hhd),b", "rlc (iy+%hhd),c", "rlc (iy+%hhd),d", "rlc (iy+%hhd),e", "rlc (iy+%hhd),h", "rlc (iy+%hhd),l", "rlc (iy+%hhd)", "rlc (iy+%hhd),a", "rrc (iy+%hhd),b", "rrc (iy+%hhd),c", "rrc (iy+%hhd),d", "rrc (iy+%hhd),e", "rrc (iy+%hhd),h", "rrc (iy+%hhd),l", "rrc (iy+%hhd)", "rrc (iy+%hhd),a", "rl (iy+%hhd),b", "rl (iy+%hhd),c", "rl (iy+%hhd),d", "rl (iy+%hhd),e", "rl (iy+%hhd),h", "rl (iy+%hhd),l", "rl (iy+%hhd)", "rl (iy+%hhd),a", "rr (iy+%hhd),b", "rr (iy+%hhd),c", "rr (iy+%hhd),d", "rr (iy+%hhd),e", "rr (iy+%hhd),h", "rr (iy+%hhd),l", "rr (iy+%hhd)", "rr (iy+%hhd),a", "sla (iy+%hhd),b", "sla (iy+%hhd),c", "sla (iy+%hhd),d", "sla (iy+%hhd),e", "sla (iy+%hhd),h", "sla (iy+%hhd),l", "sla (iy+%hhd)", "sla (iy+%hhd),a", "sra (iy+%hhd),b", "sra (iy+%hhd),c", "sra (iy+%hhd),d", "sra (iy+%hhd),e", "sra (iy+%hhd),h", "sra (iy+%hhd),l", "sra (iy+%hhd)", "sra (iy+%hhd),a", "sll (iy+%hhd),b", "sll (iy+%hhd),c", "sll (iy+%hhd),d", "sll (iy+%hhd),e", "sll (iy+%hhd),h", "sll (iy+%hhd),l", "sll (iy+%hhd)", "sll (iy+%hhd),a", "srl (iy+%hhd),b", "srl (iy+%hhd),c", "srl (iy+%hhd),d", "srl (iy+%hhd),e", "srl (iy+%hhd),h", "srl (iy+%hhd),l", "srl (iy+%hhd)", "srl (iy+%hhd),a", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "res 0,(iy+%hhd),b", "res 0,(iy+%hhd),c", "res 0,(iy+%hhd),d", "res 0,(iy+%hhd),e", "res 0,(iy+%hhd),h", "res 0,(iy+%hhd),l", "res 0,(iy+%hhd)", "res 0,(iy+%hhd),a", "res 1,(iy+%hhd),b", "res 1,(iy+%hhd),c", "res 1,(iy+%hhd),d", "res 1,(iy+%hhd),e", "res 1,(iy+%hhd),h", "res 1,(iy+%hhd),l", "res 1,(iy+%hhd)", "res 1,(iy+%hhd),a", "res 2,(iy+%hhd),b", "res 2,(iy+%hhd),c", "res 2,(iy+%hhd),d", "res 2,(iy+%hhd),e", "res 2,(iy+%hhd),h", "res 2,(iy+%hhd),l", "res 2,(iy+%hhd)", "res 2,(iy+%hhd),a", "res 3,(iy+%hhd),b", "res 3,(iy+%hhd),c", "res 3,(iy+%hhd),d", "res 3,(iy+%hhd),e", "res 3,(iy+%hhd),h", "res 3,(iy+%hhd),l", "res 3,(iy+%hhd)", "res 3,(iy+%hhd),a", "res 4,(iy+%hhd),b", "res 4,(iy+%hhd),c", "res 4,(iy+%hhd),d", "res 4,(iy+%hhd),e", "res 4,(iy+%hhd),h", "res 4,(iy+%hhd),l", "res 4,(iy+%hhd)", "res 4,(iy+%hhd),a", "res 5,(iy+%hhd),b", "res 5,(iy+%hhd),c", "res 5,(iy+%hhd),d", "res 5,(iy+%hhd),e", "res 5,(iy+%hhd),h", "res 5,(iy+%hhd),l", "res 5,(iy+%hhd)", "res 5,(iy+%hhd),a", "res 6,(iy+%hhd),b", "res 6,(iy+%hhd),c", "res 6,(iy+%hhd),d", "res 6,(iy+%hhd),e", "res 6,(iy+%hhd),h", "res 6,(iy+%hhd),l", "res 6,(iy+%hhd)", "res 6,(iy+%hhd),a", "res 7,(iy+%hhd),b", "res 7,(iy+%hhd),c", "res 7,(iy+%hhd),d", "res 7,(iy+%hhd),e", "res 7,(iy+%hhd),h", "res 7,(iy+%hhd),l", "res 7,(iy+%hhd)", "res 7,(iy+%hhd),a", "set 0,(iy+%hhd),b", "set 0,(iy+%hhd),c", "set 0,(iy+%hhd),d", "set 0,(iy+%hhd),e", "set 0,(iy+%hhd),h", "set 0,(iy+%hhd),l", "set 0,(iy+%hhd)", "set 0,(iy+%hhd),a", "set 1,(iy+%hhd),b", "set 1,(iy+%hhd),c", "set 1,(iy+%hhd),d", "set 1,(iy+%hhd),e", "set 1,(iy+%hhd),h", "set 1,(iy+%hhd),l", "set 1,(iy+%hhd)", "set 1,(iy+%hhd),a", "set 2,(iy+%hhd),b", "set 2,(iy+%hhd),c", "set 2,(iy+%hhd),d", "set 2,(iy+%hhd),e", "set 2,(iy+%hhd),h", "set 2,(iy+%hhd),l", "set 2,(iy+%hhd)", "set 2,(iy+%hhd),a", "set 3,(iy+%hhd),b", "set 3,(iy+%hhd),c", "set 3,(iy+%hhd),d", "set 3,(iy+%hhd),e", "set 3,(iy+%hhd),h", "set 3,(iy+%hhd),l", "set 3,(iy+%hhd)", "set 3,(iy+%hhd),a", "set 4,(iy+%hhd),b", "set 4,(iy+%hhd),c", "set 4,(iy+%hhd),d", "set 4,(iy+%hhd),e", "set 4,(iy+%hhd),h", "set 4,(iy+%hhd),l", "set 4,(iy+%hhd)", "set 4,(iy+%hhd),a", "set 5,(iy+%hhd),b", "set 5,(iy+%hhd),c", "set 5,(iy+%hhd),d", "set 5,(iy+%hhd),e", "set 5,(iy+%hhd),h", "set 5,(iy+%hhd),l", "set 5,(iy+%hhd)", "set 5,(iy+%hhd),a", "set 6,(iy+%hhd),b", "set 6,(iy+%hhd),c", "set 6,(iy+%hhd),d", "set 6,(iy+%hhd),e", "set 6,(iy+%hhd),h", "set 6,(iy+%hhd),l", "set 6,(iy+%hhd)", "set 6,(iy+%hhd),a", "set 7,(iy+%hhd),b", "set 7,(iy+%hhd),c", "set 7,(iy+%hhd),d", "set 7,Line truncated
// const char *base_opcodes[256] = {"nop", "ld bc,$%04x", "ld (bc),a", "inc bc", "inc b", "dec b", "ld b,$%02x", "rlca", "ex af,af'", "add hl,bc", "ld a,(bc)", "dec bc", "inc c", "dec c", "ld c,$%02x", "rrca", "djnz %hhd", "ld de,$%04x", "ld (de),a", "inc de", "inc d", "dec d", "ld d,$%02x", "rla", "jr %hhd", "add hl,de", "ld a,(de)", "dec de", "inc e", "dec e", "ld e,$%02x", "rra", "jr nz,%hhd", "ld hl,$%04x", "ld ($%04x),hl", "inc hl", "inc h", "dec h", "ld h,$%02x", "daa", "jr z,%hhd", "add hl,hl", "ld hl,($%04x)", "dec hl", "inc l", "dec l", "ld l,$%02x", "cpl", "jr nc,%hhd", "ld sp,$%04x", "ld ($%04x),a", "inc sp", "inc (hl)", "dec (hl)", "ld (hl),$%02x", "scf", "jr c,%hhd", "add hl,sp", "ld a,($%04x)", "dec sp", "inc a", "dec a", "ld a,$%02x", "ccf", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,h", "ld b,l", "ld b,(hl)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,h", "ld c,l", "ld c,(hl)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,h", "ld d,l", "ld d,(hl)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,h", "ld e,l", "ld e,(hl)", "ld e,a", "ld h,b", "ld h,c", "ld h,d", "ld h,e", "ld h,h", "ld h,l", "ld h,(hl)", "ld h,a", "ld l,b", "ld l,c", "ld l,d", "ld l,e", "ld l,h", "ld l,l", "ld l,(hl)", "ld l,a", "ld (hl),b", "ld (hl),c", "ld (hl),d", "ld (hl),e", "ld (hl),h", "ld (hl),l", "halt", "ld (hl),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,h", "ld a,l", "ld a,(hl)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,h", "add a,l", "add a,(hl)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,h", "adc a,l", "adc a,(hl)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub h", "sub l", "sub (hl)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,h", "sbc a,l", "sbc a,(hl)", "sbc a,a", "and b", "and c", "and d", "and e", "and h", "and l", "and (hl)", "and a", "xor b", "xor c", "xor d", "xor e", "xor h", "xor l", "xor (hl)", "xor a", "or b", "or c", "or d", "or e", "or h", "or l", "or (hl)", "or a", "cp b", "cp c", "cp d", "cp e", "cp h", "cp l", "cp (hl)", "cp a", "ret nz", "pop bc", "jp nz,$%04x", "jp $%04x", "call nz,$%04x", "push bc", "add a,$%02x", "rst 00h", "ret z", "ret", "jp z,$%04x", "_Bit_", "call z,$%04x", "call $%04x", "adc a,$%02x", "rst 08h", "ret nc", "pop de", "jp nc,$%04x", "out ($%02x),a", "call nc,$%04x", "push de", "sub $%02x", "rst 10h", "ret c", "exx", "jp c,$%04x", "in a,($%02x)", "call c,$%04x", "_IX_", "sbc a,$%02x", "rst 18h", "ret po", "pop hl", "jp po,$%04x", "ex (sp),hl", "call po,$%04x", "push hl", "and $%02x", "rst 20h", "ret pe", "jp (hl)", "jp pe,$%04x", "ex de,hl", "call pe,$%04x", "_Misc._", "xor $%02x", "rst 28h", "ret p", "pop af", "jp p,$%04x", "di", "call p,$%04x", "push af", "or $%02x", "rst 30h", "ret m", "ld sp,hl", "jp m,$%04x", "ei", "call m,$%04x", "_IY_", "cp $%02x", "rst 38h"};
// const char *cb_opcodes[256] = {"rlc b", "rlc c", "rlc d", "rlc e", "rlc h", "rlc l", "rlc (hl)", "rlc a", "rrc b", "rrc c", "rrc d", "rrc e", "rrc h", "rrc l", "rrc (hl)", "rrc a", "rl b", "rl c", "rl d", "rl e", "rl h", "rl l", "rl (hl)", "rl a", "rr b", "rr c", "rr d", "rr e", "rr h", "rr l", "rr (hl)", "rr a", "sla b", "sla c", "sla d", "sla e", "sla h", "sla l", "sla (hl)", "sla a", "sra b", "sra c", "sra d", "sra e", "sra h", "sra l", "sra (hl)", "sra a", "sll b", "sll c", "sll d", "sll e", "sll h", "sll l", "sll (hl)", "sll a", "srl b", "srl c", "srl d", "srl e", "srl h", "srl l", "srl (hl)", "srl a", "bit 0,b", "bit 0,c", "bit 0,d", "bit 0,e", "bit 0,h", "bit 0,l", "bit 0,(hl)", "bit 0,a", "bit 1,b", "bit 1,c", "bit 1,d", "bit 1,e", "bit 1,h", "bit 1,l", "bit 1,(hl)", "bit 1,a", "bit 2,b", "bit 2,c", "bit 2,d", "bit 2,e", "bit 2,h", "bit 2,l", "bit 2,(hl)", "bit 2,a", "bit 3,b", "bit 3,c", "bit 3,d", "bit 3,e", "bit 3,h", "bit 3,l", "bit 3,(hl)", "bit 3,a", "bit 4,b", "bit 4,c", "bit 4,d", "bit 4,e", "bit 4,h", "bit 4,l", "bit 4,(hl)", "bit 4,a", "bit 5,b", "bit 5,c", "bit 5,d", "bit 5,e", "bit 5,h", "bit 5,l", "bit 5,(hl)", "bit 5,a", "bit 6,b", "bit 6,c", "bit 6,d", "bit 6,e", "bit 6,h", "bit 6,l", "bit 6,(hl)", "bit 6,a", "bit 7,b", "bit 7,c", "bit 7,d", "bit 7,e", "bit 7,h", "bit 7,l", "bit 7,(hl)", "bit 7,a", "res 0,b", "res 0,c", "res 0,d", "res 0,e", "res 0,h", "res 0,l", "res 0,(hl)", "res 0,a", "res 1,b", "res 1,c", "res 1,d", "res 1,e", "res 1,h", "res 1,l", "res 1,(hl)", "res 1,a", "res 2,b", "res 2,c", "res 2,d", "res 2,e", "res 2,h", "res 2,l", "res 2,(hl)", "res 2,a", "res 3,b", "res 3,c", "res 3,d", "res 3,e", "res 3,h", "res 3,l", "res 3,(hl)", "res 3,a", "res 4,b", "res 4,c", "res 4,d", "res 4,e", "res 4,h", "res 4,l", "res 4,(hl)", "res 4,a", "res 5,b", "res 5,c", "res 5,d", "res 5,e", "res 5,h", "res 5,l", "res 5,(hl)", "res 5,a", "res 6,b", "res 6,c", "res 6,d", "res 6,e", "res 6,h", "res 6,l", "res 6,(hl)", "res 6,a", "res 7,b", "res 7,c", "res 7,d", "res 7,e", "res 7,h", "res 7,l", "res 7,(hl)", "res 7,a", "set 0,b", "set 0,c", "set 0,d", "set 0,e", "set 0,h", "set 0,l", "set 0,(hl)", "set 0,a", "set 1,b", "set 1,c", "set 1,d", "set 1,e", "set 1,h", "set 1,l", "set 1,(hl)", "set 1,a", "set 2,b", "set 2,c", "set 2,d", "set 2,e", "set 2,h", "set 2,l", "set 2,(hl)", "set 2,a", "set 3,b", "set 3,c", "set 3,d", "set 3,e", "set 3,h", "set 3,l", "set 3,(hl)", "set 3,a", "set 4,b", "set 4,c", "set 4,d", "set 4,e", "set 4,h", "set 4,l", "set 4,(hl)", "set 4,a", "set 5,b", "set 5,c", "set 5,d", "set 5,e", "set 5,h", "set 5,l", "set 5,(hl)", "set 5,a", "set 6,b", "set 6,c", "set 6,d", "set 6,e", "set 6,h", "set 6,l", "set 6,(hl)", "set 6,a", "set 7,b", "set 7,c", "set 7,d", "set 7,e", "set 7,h", "set 7,l", "set 7,(hl)", "set 7,a"};
// const char *ix_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add ix,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add ix,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld ix,$%04x", "ld ($%04x),ix", "inc ix", "inc ixh", "dec ixh", "ld ixh,$%02x", "", "", "add ix,ix", "ld ix,($%04x)", "dec ix", "inc ixl", "dec ixl", "ld ixl,$%02x", "", "", "", "", "", "inc (ix+%hhd)", "dec (ix+%hhd)", "ld (ix+%hhd),$%02x", "", "", "add ix,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,ixh", "ld b,ixl", "ld b,(ix+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,ixh", "ld c,ixl", "ld c,(ix+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,ixh", "ld d,ixl", "ld d,(ix+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,ixh", "ld e,ixl", "ld e,(ix+%hhd)", "ld e,a", "ld ixh,b", "ld ixh,c", "ld ixh,d", "ld ixh,e", "ld ixh,ixh", "ld ixh,ixl", "ld h,(ix+%hhd)", "ld ixh,a", "ld ixl,b", "ld ixl,c", "ld ixl,d", "ld ixl,e", "ld ixl,ixh", "ld ixl,ixl", "ld l,(ix+%hhd)", "ld ixl,a", "ld (ix+%hhd),b", "ld (ix+%hhd),c", "ld (ix+%hhd),d", "ld (ix+%hhd),e", "ld (ix+%hhd),h", "ld (ix+%hhd),l", "", "ld (ix+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,ixh", "ld a,ixl", "ld a,(ix+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,ixh", "add a,ixl", "add a,(ix+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,ixh", "adc a,ixl", "adc a,(ix+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub ixh", "sub ixl", "sub (ix+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,ixh", "sbc a,ixl", "sbc a,(ix+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and ixh", "and ixl", "and (ix+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor ixh", "xor ixl", "xor (ix+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or ixh", "or ixl", "or (ix+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp ixh", "cp ixl", "cp (ix+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IX Bit_", "", "", "", "", "", "pop ix", "", "ex (sp),ix", "", "push ix", "", "", "", "jp (ix)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,ix", "", "", "", "", "", ""};
// const char *ix_bit_opcodes[256] = {"rlc (ix+%hhd),b", "rlc (ix+%hhd),c", "rlc (ix+%hhd),d", "rlc (ix+%hhd),e", "rlc (ix+%hhd),h", "rlc (ix+%hhd),l", "rlc (ix+%hhd)", "rlc (ix+%hhd),a", "rrc (ix+%hhd),b", "rrc (ix+%hhd),c", "rrc (ix+%hhd),d", "rrc (ix+%hhd),e", "rrc (ix+%hhd),h", "rrc (ix+%hhd),l", "rrc (ix+%hhd)", "rrc (ix+%hhd),a", "rl (ix+%hhd),b", "rl (ix+%hhd),c", "rl (ix+%hhd),d", "rl (ix+%hhd),e", "rl (ix+%hhd),h", "rl (ix+%hhd),l", "rl (ix+%hhd)", "rl (ix+%hhd),a", "rr (ix+%hhd),b", "rr (ix+%hhd),c", "rr (ix+%hhd),d", "rr (ix+%hhd),e", "rr (ix+%hhd),h", "rr (ix+%hhd),l", "rr (ix+%hhd)", "rr (ix+%hhd),a", "sla (ix+%hhd),b", "sla (ix+%hhd),c", "sla (ix+%hhd),d", "sla (ix+%hhd),e", "sla (ix+%hhd),h", "sla (ix+%hhd),l", "sla (ix+%hhd)", "sla (ix+%hhd),a", "sra (ix+%hhd),b", "sra (ix+%hhd),c", "sra (ix+%hhd),d", "sra (ix+%hhd),e", "sra (ix+%hhd),h", "sra (ix+%hhd),l", "sra (ix+%hhd)", "sra (ix+%hhd),a", "sll (ix+%hhd),b", "sll (ix+%hhd),c", "sll (ix+%hhd),d", "sll (ix+%hhd),e", "sll (ix+%hhd),h", "sll (ix+%hhd),l", "sll (ix+%hhd)", "sll (ix+%hhd),a", "srl (ix+%hhd),b", "srl (ix+%hhd),c", "srl (ix+%hhd),d", "srl (ix+%hhd),e", "srl (ix+%hhd),h", "srl (ix+%hhd),l", "srl (ix+%hhd)", "srl (ix+%hhd),a", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 0,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 1,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 2,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 3,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 4,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 5,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 6,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "bit 7,(ix+%hhd)", "res 0,(ix+%hhd),b", "res 0,(ix+%hhd),c", "res 0,(ix+%hhd),d", "res 0,(ix+%hhd),e", "res 0,(ix+%hhd),h", "res 0,(ix+%hhd),l", "res 0,(ix+%hhd)", "res 0,(ix+%hhd),a", "res 1,(ix+%hhd),b", "res 1,(ix+%hhd),c", "res 1,(ix+%hhd),d", "res 1,(ix+%hhd),e", "res 1,(ix+%hhd),h", "res 1,(ix+%hhd),l", "res 1,(ix+%hhd)", "res 1,(ix+%hhd),a", "res 2,(ix+%hhd),b", "res 2,(ix+%hhd),c", "res 2,(ix+%hhd),d", "res 2,(ix+%hhd),e", "res 2,(ix+%hhd),h", "res 2,(ix+%hhd),l", "res 2,(ix+%hhd)", "res 2,(ix+%hhd),a", "res 3,(ix+%hhd),b", "res 3,(ix+%hhd),c", "res 3,(ix+%hhd),d", "res 3,(ix+%hhd),e", "res 3,(ix+%hhd),h", "res 3,(ix+%hhd),l", "res 3,(ix+%hhd)", "res 3,(ix+%hhd),a", "res 4,(ix+%hhd),b", "res 4,(ix+%hhd),c", "res 4,(ix+%hhd),d", "res 4,(ix+%hhd),e", "res 4,(ix+%hhd),h", "res 4,(ix+%hhd),l", "res 4,(ix+%hhd)", "res 4,(ix+%hhd),a", "res 5,(ix+%hhd),b", "res 5,(ix+%hhd),c", "res 5,(ix+%hhd),d", "res 5,(ix+%hhd),e", "res 5,(ix+%hhd),h", "res 5,(ix+%hhd),l", "res 5,(ix+%hhd)", "res 5,(ix+%hhd),a", "res 6,(ix+%hhd),b", "res 6,(ix+%hhd),c", "res 6,(ix+%hhd),d", "res 6,(ix+%hhd),e", "res 6,(ix+%hhd),h", "res 6,(ix+%hhd),l", "res 6,(ix+%hhd)", "res 6,(ix+%hhd),a", "res 7,(ix+%hhd),b", "res 7,(ix+%hhd),c", "res 7,(ix+%hhd),d", "res 7,(ix+%hhd),e", "res 7,(ix+%hhd),h", "res 7,(ix+%hhd),l", "res 7,(ix+%hhd)", "res 7,(ix+%hhd),a", "set 0,(ix+%hhd),b", "set 0,(ix+%hhd),c", "set 0,(ix+%hhd),d", "set 0,(ix+%hhd),e", "set 0,(ix+%hhd),h", "set 0,(ix+%hhd),l", "set 0,(ix+%hhd)", "set 0,(ix+%hhd),a", "set 1,(ix+%hhd),b", "set 1,(ix+%hhd),c", "set 1,(ix+%hhd),d", "set 1,(ix+%hhd),e", "set 1,(ix+%hhd),h", "set 1,(ix+%hhd),l", "set 1,(ix+%hhd)", "set 1,(ix+%hhd),a", "set 2,(ix+%hhd),b", "set 2,(ix+%hhd),c", "set 2,(ix+%hhd),d", "set 2,(ix+%hhd),e", "set 2,(ix+%hhd),h", "set 2,(ix+%hhd),l", "set 2,(ix+%hhd)", "set 2,(ix+%hhd),a", "set 3,(ix+%hhd),b", "set 3,(ix+%hhd),c", "set 3,(ix+%hhd),d", "set 3,(ix+%hhd),e", "set 3,(ix+%hhd),h", "set 3,(ix+%hhd),l", "set 3,(ix+%hhd)", "set 3,(ix+%hhd),a", "set 4,(ix+%hhd),b", "set 4,(ix+%hhd),c", "set 4,(ix+%hhd),d", "set 4,(ix+%hhd),e", "set 4,(ix+%hhd),h", "set 4,(ix+%hhd),l", "set 4,(ix+%hhd)", "set 4,(ix+%hhd),a", "set 5,(ix+%hhd),b", "set 5,(ix+%hhd),c", "set 5,(ix+%hhd),d", "set 5,(ix+%hhd),e", "set 5,(ix+%hhd),h", "set 5,(ix+%hhd),l", "set 5,(ix+%hhd)", "set 5,(ix+%hhd),a", "set 6,(ix+%hhd),b", "set 6,(ix+%hhd),c", "set 6,(ix+%hhd),d", "set 6,(ix+%hhd),e", "set 6,(ix+%hhd),h", "set 6,(ix+%hhd),l", "set 6,(ix+%hhd)", "set 6,(ix+%hhd),a", "set 7,(ix+%hhd),b", "set 7,(ix+%hhd),c", "set 7,(ix+%hhd),d", "set Line truncated
// const char *misc_opcodes[128] = {"in b,(c)", "out (c),b", "sbc hl,bc", "ld ($%04x),bc", "neg", "retn", "im 0", "ld i,a", "in c,(c)", "out (c),c", "adc hl,bc", "ld bc,($%04x)", "mlt bc", "reti", "", "ld r,a", "in d,(c)", "out (c),d", "sbc hl,de", "ld ($%04x),de", "", "", "im 1", "ld a,i", "in e,(c)", "out (c),e", "adc hl,de", "ld de,($%04x)", "mlt de", "", "im 2", "ld a,r", "in h,(c)", "out (c),h", "sbc hl,hl", "ld ($%04x),hl", "tst $%02x", "", "", "rrd", "in l,(c)", "out (c),l", "adc hl,hl", "ld hl,($%04x)", "mlt hl", "", "", "rld", "in (c)", "out (c),0", "sbc hl,sp", "ld ($%04x),sp", "tstio $%02x", "", "slp", "", "in a,(c)", "out (c),a", "adc hl,sp", "ld sp,($%04x)", "mlt sp", "", "", "", "", "", "", "otim", "", "", "", "", "", "", "", "otdm", "", "", "", "", "", "", "", "otimr", "", "", "", "", "", "", "", "otdmr", "", "", "", "", "ldi", "cpi", "ini", "outi", "", "", "", "", "ldd", "cpd", "ind", "outd", "", "", "", "", "ldir", "cpir", "inir", "otir", "", "", "", "", "lddr", "cpdr", "indr", "otdr", "", "", "", ""};
// const char *iy_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,$%02x", "", "", "add iy,bc", "", "", "inc c", "dec c", "ld c,$%02x", "", "", "", "", "", "inc d", "dec d", "ld d,$%02x", "", "", "add iy,de", "", "", "inc e", "dec e", "ld e,$%02x", "", "", "ld iy,$%04x", "ld ($%04x),iy", "inc iy", "inc iyh", "dec iyh", "ld iyh,$%02x", "", "", "add iy,iy", "ld iy,($%04x)", "dec iy", "inc iyl", "dec iyl", "ld iyl,$%02x", "", "", "", "", "", "inc (iy+%hhd)", "dec (iy+%hhd)", "ld (iy+%hhd),$%02x", "", "", "add iy,sp", "", "", "inc a", "dec a", "ld a,$%02x", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,iyh", "ld b,iyl", "ld b,(iy+%hhd)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,iyh", "ld c,iyl", "ld c,(iy+%hhd)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,iyh", "ld d,iyl", "ld d,(iy+%hhd)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,iyh", "ld e,iyl", "ld e,(iy+%hhd)", "ld e,a", "ld iyh,b", "ld iyh,c", "ld iyh,d", "ld iyh,e", "ld iyh,iyh", "ld iyh,iyl", "ld h,(iy+%hhd)", "ld iyh,a", "ld iyl,b", "ld iyl,c", "ld iyl,d", "ld iyl,e", "ld iyl,iyh", "ld iyl,iyl", "ld l,(iy+%hhd)", "ld iyl,a", "ld (iy+%hhd),b", "ld (iy+%hhd),c", "ld (iy+%hhd),d", "ld (iy+%hhd),e", "ld (iy+%hhd),h", "ld (iy+%hhd),l", "", "ld (iy+%hhd),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,iyh", "ld a,iyl", "ld a,(iy+%hhd)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,iyh", "add a,iyl", "add a,(iy+%hhd)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,iyh", "adc a,iyl", "adc a,(iy+%hhd)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub iyh", "sub iyl", "sub (iy+%hhd)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,iyh", "sbc a,iyl", "sbc a,(iy+%hhd)", "sbc a,a", "and b", "and c", "and d", "and e", "and iyh", "and iyl", "and (iy+%hhd)", "and a", "xor b", "xor c", "xor d", "xor e", "xor iyh", "xor iyl", "xor (iy+%hhd)", "xor a", "or b", "or c", "or d", "or e", "or iyh", "or iyl", "or (iy+%hhd)", "or a", "cp b", "cp c", "cp d", "cp e", "cp iyh", "cp iyl", "cp (iy+%hhd)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IY Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop iy", "", "ex (sp),iy", "", "push iy", "", "", "", "jp (iy)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,iy", "", "", "", "", "", ""};
// const char *iy_bit_opcodes[256] = {"rlc (iy+%hhd),b", "rlc (iy+%hhd),c", "rlc (iy+%hhd),d", "rlc (iy+%hhd),e", "rlc (iy+%hhd),h", "rlc (iy+%hhd),l", "rlc (iy+%hhd)", "rlc (iy+%hhd),a", "rrc (iy+%hhd),b", "rrc (iy+%hhd),c", "rrc (iy+%hhd),d", "rrc (iy+%hhd),e", "rrc (iy+%hhd),h", "rrc (iy+%hhd),l", "rrc (iy+%hhd)", "rrc (iy+%hhd),a", "rl (iy+%hhd),b", "rl (iy+%hhd),c", "rl (iy+%hhd),d", "rl (iy+%hhd),e", "rl (iy+%hhd),h", "rl (iy+%hhd),l", "rl (iy+%hhd)", "rl (iy+%hhd),a", "rr (iy+%hhd),b", "rr (iy+%hhd),c", "rr (iy+%hhd),d", "rr (iy+%hhd),e", "rr (iy+%hhd),h", "rr (iy+%hhd),l", "rr (iy+%hhd)", "rr (iy+%hhd),a", "sla (iy+%hhd),b", "sla (iy+%hhd),c", "sla (iy+%hhd),d", "sla (iy+%hhd),e", "sla (iy+%hhd),h", "sla (iy+%hhd),l", "sla (iy+%hhd)", "sla (iy+%hhd),a", "sra (iy+%hhd),b", "sra (iy+%hhd),c", "sra (iy+%hhd),d", "sra (iy+%hhd),e", "sra (iy+%hhd),h", "sra (iy+%hhd),l", "sra (iy+%hhd)", "sra (iy+%hhd),a", "sll (iy+%hhd),b", "sll (iy+%hhd),c", "sll (iy+%hhd),d", "sll (iy+%hhd),e", "sll (iy+%hhd),h", "sll (iy+%hhd),l", "sll (iy+%hhd)", "sll (iy+%hhd),a", "srl (iy+%hhd),b", "srl (iy+%hhd),c", "srl (iy+%hhd),d", "srl (iy+%hhd),e", "srl (iy+%hhd),h", "srl (iy+%hhd),l", "srl (iy+%hhd)", "srl (iy+%hhd),a", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 0,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 1,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 2,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 3,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 4,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 5,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 6,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "bit 7,(iy+%hhd)", "res 0,(iy+%hhd),b", "res 0,(iy+%hhd),c", "res 0,(iy+%hhd),d", "res 0,(iy+%hhd),e", "res 0,(iy+%hhd),h", "res 0,(iy+%hhd),l", "res 0,(iy+%hhd)", "res 0,(iy+%hhd),a", "res 1,(iy+%hhd),b", "res 1,(iy+%hhd),c", "res 1,(iy+%hhd),d", "res 1,(iy+%hhd),e", "res 1,(iy+%hhd),h", "res 1,(iy+%hhd),l", "res 1,(iy+%hhd)", "res 1,(iy+%hhd),a", "res 2,(iy+%hhd),b", "res 2,(iy+%hhd),c", "res 2,(iy+%hhd),d", "res 2,(iy+%hhd),e", "res 2,(iy+%hhd),h", "res 2,(iy+%hhd),l", "res 2,(iy+%hhd)", "res 2,(iy+%hhd),a", "res 3,(iy+%hhd),b", "res 3,(iy+%hhd),c", "res 3,(iy+%hhd),d", "res 3,(iy+%hhd),e", "res 3,(iy+%hhd),h", "res 3,(iy+%hhd),l", "res 3,(iy+%hhd)", "res 3,(iy+%hhd),a", "res 4,(iy+%hhd),b", "res 4,(iy+%hhd),c", "res 4,(iy+%hhd),d", "res 4,(iy+%hhd),e", "res 4,(iy+%hhd),h", "res 4,(iy+%hhd),l", "res 4,(iy+%hhd)", "res 4,(iy+%hhd),a", "res 5,(iy+%hhd),b", "res 5,(iy+%hhd),c", "res 5,(iy+%hhd),d", "res 5,(iy+%hhd),e", "res 5,(iy+%hhd),h", "res 5,(iy+%hhd),l", "res 5,(iy+%hhd)", "res 5,(iy+%hhd),a", "res 6,(iy+%hhd),b", "res 6,(iy+%hhd),c", "res 6,(iy+%hhd),d", "res 6,(iy+%hhd),e", "res 6,(iy+%hhd),h", "res 6,(iy+%hhd),l", "res 6,(iy+%hhd)", "res 6,(iy+%hhd),a", "res 7,(iy+%hhd),b", "res 7,(iy+%hhd),c", "res 7,(iy+%hhd),d", "res 7,(iy+%hhd),e", "res 7,(iy+%hhd),h", "res 7,(iy+%hhd),l", "res 7,(iy+%hhd)", "res 7,(iy+%hhd),a", "set 0,(iy+%hhd),b", "set 0,(iy+%hhd),c", "set 0,(iy+%hhd),d", "set 0,(iy+%hhd),e", "set 0,(iy+%hhd),h", "set 0,(iy+%hhd),l", "set 0,(iy+%hhd)", "set 0,(iy+%hhd),a", "set 1,(iy+%hhd),b", "set 1,(iy+%hhd),c", "set 1,(iy+%hhd),d", "set 1,(iy+%hhd),e", "set 1,(iy+%hhd),h", "set 1,(iy+%hhd),l", "set 1,(iy+%hhd)", "set 1,(iy+%hhd),a", "set 2,(iy+%hhd),b", "set 2,(iy+%hhd),c", "set 2,(iy+%hhd),d", "set 2,(iy+%hhd),e", "set 2,(iy+%hhd),h", "set 2,(iy+%hhd),l", "set 2,(iy+%hhd)", "set 2,(iy+%hhd),a", "set 3,(iy+%hhd),b", "set 3,(iy+%hhd),c", "set 3,(iy+%hhd),d", "set 3,(iy+%hhd),e", "set 3,(iy+%hhd),h", "set 3,(iy+%hhd),l", "set 3,(iy+%hhd)", "set 3,(iy+%hhd),a", "set 4,(iy+%hhd),b", "set 4,(iy+%hhd),c", "set 4,(iy+%hhd),d", "set 4,(iy+%hhd),e", "set 4,(iy+%hhd),h", "set 4,(iy+%hhd),l", "set 4,(iy+%hhd)", "set 4,(iy+%hhd),a", "set 5,(iy+%hhd),b", "set 5,(iy+%hhd),c", "set 5,(iy+%hhd),d", "set 5,(iy+%hhd),e", "set 5,(iy+%hhd),h", "set 5,(iy+%hhd),l", "set 5,(iy+%hhd)", "set 5,(iy+%hhd),a", "set 6,(iy+%hhd),b", "set 6,(iy+%hhd),c", "set 6,(iy+%hhd),d", "set 6,(iy+%hhd),e", "set 6,(iy+%hhd),h", "set 6,(iy+%hhd),l", "set 6,(iy+%hhd)", "set 6,(iy+%hhd),a", "set 7,(iy+%hhd),b", "set 7,(iy+%hhd),c", "set 7,(iy+%hhd),d", "set Line truncated
// const char *base_opcodes[256] = {"nop", "ld bc,NN", "ld (bc),a", "inc bc", "inc b", "dec b", "ld b,N", "rlca", "ex af,af'", "add hl,bc", "ld a,(bc)", "dec bc", "inc c", "dec c", "ld c,N", "rrca", "djnz D", "ld de,NN", "ld (de),a", "inc de", "inc d", "dec d", "ld d,N", "rla", "jr D", "add hl,de", "ld a,(de)", "dec de", "inc e", "dec e", "ld e,N", "rra", "jr nz,D", "ld hl,NN", "ld (NN),hl", "inc hl", "inc h", "dec h", "ld h,N", "daa", "jr z,D", "add hl,hl", "ld hl,(NN)", "dec hl", "inc l", "dec l", "ld l,N", "cpl", "jr nc,D", "ld sp,NN", "ld (NN),a", "inc sp", "inc (hl)", "dec (hl)", "ld (hl),N", "scf", "jr c,D", "add hl,sp", "ld a,(NN)", "dec sp", "inc a", "dec a", "ld a,N", "ccf", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,h", "ld b,l", "ld b,(hl)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,h", "ld c,l", "ld c,(hl)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,h", "ld d,l", "ld d,(hl)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,h", "ld e,l", "ld e,(hl)", "ld e,a", "ld h,b", "ld h,c", "ld h,d", "ld h,e", "ld h,h", "ld h,l", "ld h,(hl)", "ld h,a", "ld l,b", "ld l,c", "ld l,d", "ld l,e", "ld l,h", "ld l,l", "ld l,(hl)", "ld l,a", "ld (hl),b", "ld (hl),c", "ld (hl),d", "ld (hl),e", "ld (hl),h", "ld (hl),l", "halt", "ld (hl),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,h", "ld a,l", "ld a,(hl)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,h", "add a,l", "add a,(hl)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,h", "adc a,l", "adc a,(hl)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub h", "sub l", "sub (hl)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,h", "sbc a,l", "sbc a,(hl)", "sbc a,a", "and b", "and c", "and d", "and e", "and h", "and l", "and (hl)", "and a", "xor b", "xor c", "xor d", "xor e", "xor h", "xor l", "xor (hl)", "xor a", "or b", "or c", "or d", "or e", "or h", "or l", "or (hl)", "or a", "cp b", "cp c", "cp d", "cp e", "cp h", "cp l", "cp (hl)", "cp a", "ret nz", "pop bc", "jp nz,NN", "jp NN", "call nz,NN", "push bc", "add a,N", "rst 00h", "ret z", "ret", "jp z,NN", "_Bit_", "call z,NN", "call NN", "adc a,N", "rst 08h", "ret nc", "pop de", "jp nc,NN", "out (N),a", "call nc,NN", "push de", "sub N", "rst 10h", "ret c", "exx", "jp c,NN", "in a,(N)", "call c,NN", "_IX_", "sbc a,N", "rst 18h", "ret po", "pop hl", "jp po,NN", "ex (sp),hl", "call po,NN", "push hl", "and N", "rst 20h", "ret pe", "jp (hl)", "jp pe,NN", "ex de,hl", "call pe,NN", "_Misc._", "xor N", "rst 28h", "ret p", "pop af", "jp p,NN", "di", "call p,NN", "push af", "or N", "rst 30h", "ret m", "ld sp,hl", "jp m,NN", "ei", "call m,NN", "_IY_", "cp N", "rst 38h"};
// const char *cb_opcodes[256] = {"rlc b", "rlc c", "rlc d", "rlc e", "rlc h", "rlc l", "rlc (hl)", "rlc a", "rrc b", "rrc c", "rrc d", "rrc e", "rrc h", "rrc l", "rrc (hl)", "rrc a", "rl b", "rl c", "rl d", "rl e", "rl h", "rl l", "rl (hl)", "rl a", "rr b", "rr c", "rr d", "rr e", "rr h", "rr l", "rr (hl)", "rr a", "sla b", "sla c", "sla d", "sla e", "sla h", "sla l", "sla (hl)", "sla a", "sra b", "sra c", "sra d", "sra e", "sra h", "sra l", "sra (hl)", "sra a", "sll b", "sll c", "sll d", "sll e", "sll h", "sll l", "sll (hl)", "sll a", "srl b", "srl c", "srl d", "srl e", "srl h", "srl l", "srl (hl)", "srl a", "bit 0,b", "bit 0,c", "bit 0,d", "bit 0,e", "bit 0,h", "bit 0,l", "bit 0,(hl)", "bit 0,a", "bit 1,b", "bit 1,c", "bit 1,d", "bit 1,e", "bit 1,h", "bit 1,l", "bit 1,(hl)", "bit 1,a", "bit 2,b", "bit 2,c", "bit 2,d", "bit 2,e", "bit 2,h", "bit 2,l", "bit 2,(hl)", "bit 2,a", "bit 3,b", "bit 3,c", "bit 3,d", "bit 3,e", "bit 3,h", "bit 3,l", "bit 3,(hl)", "bit 3,a", "bit 4,b", "bit 4,c", "bit 4,d", "bit 4,e", "bit 4,h", "bit 4,l", "bit 4,(hl)", "bit 4,a", "bit 5,b", "bit 5,c", "bit 5,d", "bit 5,e", "bit 5,h", "bit 5,l", "bit 5,(hl)", "bit 5,a", "bit 6,b", "bit 6,c", "bit 6,d", "bit 6,e", "bit 6,h", "bit 6,l", "bit 6,(hl)", "bit 6,a", "bit 7,b", "bit 7,c", "bit 7,d", "bit 7,e", "bit 7,h", "bit 7,l", "bit 7,(hl)", "bit 7,a", "res 0,b", "res 0,c", "res 0,d", "res 0,e", "res 0,h", "res 0,l", "res 0,(hl)", "res 0,a", "res 1,b", "res 1,c", "res 1,d", "res 1,e", "res 1,h", "res 1,l", "res 1,(hl)", "res 1,a", "res 2,b", "res 2,c", "res 2,d", "res 2,e", "res 2,h", "res 2,l", "res 2,(hl)", "res 2,a", "res 3,b", "res 3,c", "res 3,d", "res 3,e", "res 3,h", "res 3,l", "res 3,(hl)", "res 3,a", "res 4,b", "res 4,c", "res 4,d", "res 4,e", "res 4,h", "res 4,l", "res 4,(hl)", "res 4,a", "res 5,b", "res 5,c", "res 5,d", "res 5,e", "res 5,h", "res 5,l", "res 5,(hl)", "res 5,a", "res 6,b", "res 6,c", "res 6,d", "res 6,e", "res 6,h", "res 6,l", "res 6,(hl)", "res 6,a", "res 7,b", "res 7,c", "res 7,d", "res 7,e", "res 7,h", "res 7,l", "res 7,(hl)", "res 7,a", "set 0,b", "set 0,c", "set 0,d", "set 0,e", "set 0,h", "set 0,l", "set 0,(hl)", "set 0,a", "set 1,b", "set 1,c", "set 1,d", "set 1,e", "set 1,h", "set 1,l", "set 1,(hl)", "set 1,a", "set 2,b", "set 2,c", "set 2,d", "set 2,e", "set 2,h", "set 2,l", "set 2,(hl)", "set 2,a", "set 3,b", "set 3,c", "set 3,d", "set 3,e", "set 3,h", "set 3,l", "set 3,(hl)", "set 3,a", "set 4,b", "set 4,c", "set 4,d", "set 4,e", "set 4,h", "set 4,l", "set 4,(hl)", "set 4,a", "set 5,b", "set 5,c", "set 5,d", "set 5,e", "set 5,h", "set 5,l", "set 5,(hl)", "set 5,a", "set 6,b", "set 6,c", "set 6,d", "set 6,e", "set 6,h", "set 6,l", "set 6,(hl)", "set 6,a", "set 7,b", "set 7,c", "set 7,d", "set 7,e", "set 7,h", "set 7,l", "set 7,(hl)", "set 7,a"};
// const char *ix_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,N", "", "", "add ix,bc", "", "", "inc c", "dec c", "ld c,N", "", "", "", "", "", "inc d", "dec d", "ld d,N", "", "", "add ix,de", "", "", "inc e", "dec e", "ld e,N", "", "", "ld ix,NN", "ld (NN),ix", "inc ix", "inc ixh", "dec ixh", "ld ixh,N", "", "", "add ix,ix", "ld ix,(NN)", "dec ix", "inc ixl", "dec ixl", "ld ixl,N", "", "", "", "", "", "inc (ix+D)", "dec (ix+D)", "ld (ix+D),N", "", "", "add ix,sp", "", "", "inc a", "dec a", "ld a,N", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,ixh", "ld b,ixl", "ld b,(ix+D)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,ixh", "ld c,ixl", "ld c,(ix+D)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,ixh", "ld d,ixl", "ld d,(ix+D)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,ixh", "ld e,ixl", "ld e,(ix+D)", "ld e,a", "ld ixh,b", "ld ixh,c", "ld ixh,d", "ld ixh,e", "ld ixh,ixh", "ld ixh,ixl", "ld h,(ix+D)", "ld ixh,a", "ld ixl,b", "ld ixl,c", "ld ixl,d", "ld ixl,e", "ld ixl,ixh", "ld ixl,ixl", "ld l,(ix+D)", "ld ixl,a", "ld (ix+D),b", "ld (ix+D),c", "ld (ix+D),d", "ld (ix+D),e", "ld (ix+D),h", "ld (ix+D),l", "", "ld (ix+D),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,ixh", "ld a,ixl", "ld a,(ix+D)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,ixh", "add a,ixl", "add a,(ix+D)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,ixh", "adc a,ixl", "adc a,(ix+D)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub ixh", "sub ixl", "sub (ix+D)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,ixh", "sbc a,ixl", "sbc a,(ix+D)", "sbc a,a", "and b", "and c", "and d", "and e", "and ixh", "and ixl", "and (ix+D)", "and a", "xor b", "xor c", "xor d", "xor e", "xor ixh", "xor ixl", "xor (ix+D)", "xor a", "or b", "or c", "or d", "or e", "or ixh", "or ixl", "or (ix+D)", "or a", "cp b", "cp c", "cp d", "cp e", "cp ixh", "cp ixl", "cp (ix+D)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IX Bit_", "", "", "", "", "", "pop ix", "", "ex (sp),ix", "", "push ix", "", "", "", "jp (ix)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,ix", "", "", "", "", "", ""};
// const char *ix_bit_opcodes[256] = {"rlc (ix+D),b", "rlc (ix+D),c", "rlc (ix+D),d", "rlc (ix+D),e", "rlc (ix+D),h", "rlc (ix+D),l", "rlc (ix+D)", "rlc (ix+D),a", "rrc (ix+D),b", "rrc (ix+D),c", "rrc (ix+D),d", "rrc (ix+D),e", "rrc (ix+D),h", "rrc (ix+D),l", "rrc (ix+D)", "rrc (ix+D),a", "rl (ix+D),b", "rl (ix+D),c", "rl (ix+D),d", "rl (ix+D),e", "rl (ix+D),h", "rl (ix+D),l", "rl (ix+D)", "rl (ix+D),a", "rr (ix+D),b", "rr (ix+D),c", "rr (ix+D),d", "rr (ix+D),e", "rr (ix+D),h", "rr (ix+D),l", "rr (ix+D)", "rr (ix+D),a", "sla (ix+D),b", "sla (ix+D),c", "sla (ix+D),d", "sla (ix+D),e", "sla (ix+D),h", "sla (ix+D),l", "sla (ix+D)", "sla (ix+D),a", "sra (ix+D),b", "sra (ix+D),c", "sra (ix+D),d", "sra (ix+D),e", "sra (ix+D),h", "sra (ix+D),l", "sra (ix+D)", "sra (ix+D),a", "sll (ix+D),b", "sll (ix+D),c", "sll (ix+D),d", "sll (ix+D),e", "sll (ix+D),h", "sll (ix+D),l", "sll (ix+D)", "sll (ix+D),a", "srl (ix+D),b", "srl (ix+D),c", "srl (ix+D),d", "srl (ix+D),e", "srl (ix+D),h", "srl (ix+D),l", "srl (ix+D)", "srl (ix+D),a", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 0,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 1,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 2,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 3,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 4,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 5,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 6,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "bit 7,(ix+D)", "res 0,(ix+D),b", "res 0,(ix+D),c", "res 0,(ix+D),d", "res 0,(ix+D),e", "res 0,(ix+D),h", "res 0,(ix+D),l", "res 0,(ix+D)", "res 0,(ix+D),a", "res 1,(ix+D),b", "res 1,(ix+D),c", "res 1,(ix+D),d", "res 1,(ix+D),e", "res 1,(ix+D),h", "res 1,(ix+D),l", "res 1,(ix+D)", "res 1,(ix+D),a", "res 2,(ix+D),b", "res 2,(ix+D),c", "res 2,(ix+D),d", "res 2,(ix+D),e", "res 2,(ix+D),h", "res 2,(ix+D),l", "res 2,(ix+D)", "res 2,(ix+D),a", "res 3,(ix+D),b", "res 3,(ix+D),c", "res 3,(ix+D),d", "res 3,(ix+D),e", "res 3,(ix+D),h", "res 3,(ix+D),l", "res 3,(ix+D)", "res 3,(ix+D),a", "res 4,(ix+D),b", "res 4,(ix+D),c", "res 4,(ix+D),d", "res 4,(ix+D),e", "res 4,(ix+D),h", "res 4,(ix+D),l", "res 4,(ix+D)", "res 4,(ix+D),a", "res 5,(ix+D),b", "res 5,(ix+D),c", "res 5,(ix+D),d", "res 5,(ix+D),e", "res 5,(ix+D),h", "res 5,(ix+D),l", "res 5,(ix+D)", "res 5,(ix+D),a", "res 6,(ix+D),b", "res 6,(ix+D),c", "res 6,(ix+D),d", "res 6,(ix+D),e", "res 6,(ix+D),h", "res 6,(ix+D),l", "res 6,(ix+D)", "res 6,(ix+D),a", "res 7,(ix+D),b", "res 7,(ix+D),c", "res 7,(ix+D),d", "res 7,(ix+D),e", "res 7,(ix+D),h", "res 7,(ix+D),l", "res 7,(ix+D)", "res 7,(ix+D),a", "set 0,(ix+D),b", "set 0,(ix+D),c", "set 0,(ix+D),d", "set 0,(ix+D),e", "set 0,(ix+D),h", "set 0,(ix+D),l", "set 0,(ix+D)", "set 0,(ix+D),a", "set 1,(ix+D),b", "set 1,(ix+D),c", "set 1,(ix+D),d", "set 1,(ix+D),e", "set 1,(ix+D),h", "set 1,(ix+D),l", "set 1,(ix+D)", "set 1,(ix+D),a", "set 2,(ix+D),b", "set 2,(ix+D),c", "set 2,(ix+D),d", "set 2,(ix+D),e", "set 2,(ix+D),h", "set 2,(ix+D),l", "set 2,(ix+D)", "set 2,(ix+D),a", "set 3,(ix+D),b", "set 3,(ix+D),c", "set 3,(ix+D),d", "set 3,(ix+D),e", "set 3,(ix+D),h", "set 3,(ix+D),l", "set 3,(ix+D)", "set 3,(ix+D),a", "set 4,(ix+D),b", "set 4,(ix+D),c", "set 4,(ix+D),d", "set 4,(ix+D),e", "set 4,(ix+D),h", "set 4,(ix+D),l", "set 4,(ix+D)", "set 4,(ix+D),a", "set 5,(ix+D),b", "set 5,(ix+D),c", "set 5,(ix+D),d", "set 5,(ix+D),e", "set 5,(ix+D),h", "set 5,(ix+D),l", "set 5,(ix+D)", "set 5,(ix+D),a", "set 6,(ix+D),b", "set 6,(ix+D),c", "set 6,(ix+D),d", "set 6,(ix+D),e", "set 6,(ix+D),h", "set 6,(ix+D),l", "set 6,(ix+D)", "set 6,(ix+D),a", "set 7,(ix+D),b", "set 7,(ix+D),c", "set 7,(ix+D),d", "set 7,(ix+D),e", "set 7,(ix+D),h", "set 7,(ix+D),l", "set 7,(ix+D)", "set 7,(ix+D),a"};
// const char *misc_opcodes[128] = {"in b,(c)", "out (c),b", "sbc hl,bc", "ld (NN),bc", "neg", "retn", "im 0", "ld i,a", "in c,(c)", "out (c),c", "adc hl,bc", "ld bc,(NN)", "mlt bc", "reti", "", "ld r,a", "in d,(c)", "out (c),d", "sbc hl,de", "ld (NN),de", "", "", "im 1", "ld a,i", "in e,(c)", "out (c),e", "adc hl,de", "ld de,(NN)", "mlt de", "", "im 2", "ld a,r", "in h,(c)", "out (c),h", "sbc hl,hl", "ld (NN),hl", "tst N", "", "", "rrd", "in l,(c)", "out (c),l", "adc hl,hl", "ld hl,(NN)", "mlt hl", "", "", "rld", "in (c)", "out (c),0", "sbc hl,sp", "ld (NN),sp", "tstio N", "", "slp", "", "in a,(c)", "out (c),a", "adc hl,sp", "ld sp,(NN)", "mlt sp", "", "", "", "", "", "", "otim", "", "", "", "", "", "", "", "otdm", "", "", "", "", "", "", "", "otimr", "", "", "", "", "", "", "", "otdmr", "", "", "", "", "ldi", "cpi", "ini", "outi", "", "", "", "", "ldd", "cpd", "ind", "outd", "", "", "", "", "ldir", "cpir", "inir", "otir", "", "", "", "", "lddr", "cpdr", "indr", "otdr", "", "", "", ""};
// const char *iy_opcodes[256] = {"", "", "", "", "inc b", "dec b", "ld b,N", "", "", "add iy,bc", "", "", "inc c", "dec c", "ld c,N", "", "", "", "", "", "inc d", "dec d", "ld d,N", "", "", "add iy,de", "", "", "inc e", "dec e", "ld e,N", "", "", "ld iy,NN", "ld (NN),iy", "inc iy", "inc iyh", "dec iyh", "ld iyh,N", "", "", "add iy,iy", "ld iy,(NN)", "dec iy", "inc iyl", "dec iyl", "ld iyl,N", "", "", "", "", "", "inc (iy+D)", "dec (iy+D)", "ld (iy+D),N", "", "", "add iy,sp", "", "", "inc a", "dec a", "ld a,N", "", "ld b,b", "ld b,c", "ld b,d", "ld b,e", "ld b,iyh", "ld b,iyl", "ld b,(iy+D)", "ld b,a", "ld c,b", "ld c,c", "ld c,d", "ld c,e", "ld c,iyh", "ld c,iyl", "ld c,(iy+D)", "ld c,a", "ld d,b", "ld d,c", "ld d,d", "ld d,e", "ld d,iyh", "ld d,iyl", "ld d,(iy+D)", "ld d,a", "ld e,b", "ld e,c", "ld e,d", "ld e,e", "ld e,iyh", "ld e,iyl", "ld e,(iy+D)", "ld e,a", "ld iyh,b", "ld iyh,c", "ld iyh,d", "ld iyh,e", "ld iyh,iyh", "ld iyh,iyl", "ld h,(iy+D)", "ld iyh,a", "ld iyl,b", "ld iyl,c", "ld iyl,d", "ld iyl,e", "ld iyl,iyh", "ld iyl,iyl", "ld l,(iy+D)", "ld iyl,a", "ld (iy+D),b", "ld (iy+D),c", "ld (iy+D),d", "ld (iy+D),e", "ld (iy+D),h", "ld (iy+D),l", "", "ld (iy+D),a", "ld a,b", "ld a,c", "ld a,d", "ld a,e", "ld a,iyh", "ld a,iyl", "ld a,(iy+D)", "ld a,a", "add a,b", "add a,c", "add a,d", "add a,e", "add a,iyh", "add a,iyl", "add a,(iy+D)", "add a,a", "adc a,b", "adc a,c", "adc a,d", "adc a,e", "adc a,iyh", "adc a,iyl", "adc a,(iy+D)", "adc a,a", "sub b", "sub c", "sub d", "sub e", "sub iyh", "sub iyl", "sub (iy+D)", "sub a", "sbc a,b", "sbc a,c", "sbc a,d", "sbc a,e", "sbc a,iyh", "sbc a,iyl", "sbc a,(iy+D)", "sbc a,a", "and b", "and c", "and d", "and e", "and iyh", "and iyl", "and (iy+D)", "and a", "xor b", "xor c", "xor d", "xor e", "xor iyh", "xor iyl", "xor (iy+D)", "xor a", "or b", "or c", "or d", "or e", "or iyh", "or iyl", "or (iy+D)", "or a", "cp b", "cp c", "cp d", "cp e", "cp iyh", "cp iyl", "cp (iy+D)", "cp a", "", "", "", "", "", "", "", "", "", "", "", "_IY Bit_", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pop iy", "", "ex (sp),iy", "", "push iy", "", "", "", "jp (iy)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "ld sp,iy", "", "", "", "", "", ""};
// const char *iy_bit_opcodes[256] = {"rlc (iy+D),b", "rlc (iy+D),c", "rlc (iy+D),d", "rlc (iy+D),e", "rlc (iy+D),h", "rlc (iy+D),l", "rlc (iy+D)", "rlc (iy+D),a", "rrc (iy+D),b", "rrc (iy+D),c", "rrc (iy+D),d", "rrc (iy+D),e", "rrc (iy+D),h", "rrc (iy+D),l", "rrc (iy+D)", "rrc (iy+D),a", "rl (iy+D),b", "rl (iy+D),c", "rl (iy+D),d", "rl (iy+D),e", "rl (iy+D),h", "rl (iy+D),l", "rl (iy+D)", "rl (iy+D),a", "rr (iy+D),b", "rr (iy+D),c", "rr (iy+D),d", "rr (iy+D),e", "rr (iy+D),h", "rr (iy+D),l", "rr (iy+D)", "rr (iy+D),a", "sla (iy+D),b", "sla (iy+D),c", "sla (iy+D),d", "sla (iy+D),e", "sla (iy+D),h", "sla (iy+D),l", "sla (iy+D)", "sla (iy+D),a", "sra (iy+D),b", "sra (iy+D),c", "sra (iy+D),d", "sra (iy+D),e", "sra (iy+D),h", "sra (iy+D),l", "sra (iy+D)", "sra (iy+D),a", "sll (iy+D),b", "sll (iy+D),c", "sll (iy+D),d", "sll (iy+D),e", "sll (iy+D),h", "sll (iy+D),l", "sll (iy+D)", "sll (iy+D),a", "srl (iy+D),b", "srl (iy+D),c", "srl (iy+D),d", "srl (iy+D),e", "srl (iy+D),h", "srl (iy+D),l", "srl (iy+D)", "srl (iy+D),a", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 0,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 1,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 2,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 3,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 4,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 5,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 6,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "bit 7,(iy+D)", "res 0,(iy+D),b", "res 0,(iy+D),c", "res 0,(iy+D),d", "res 0,(iy+D),e", "res 0,(iy+D),h", "res 0,(iy+D),l", "res 0,(iy+D)", "res 0,(iy+D),a", "res 1,(iy+D),b", "res 1,(iy+D),c", "res 1,(iy+D),d", "res 1,(iy+D),e", "res 1,(iy+D),h", "res 1,(iy+D),l", "res 1,(iy+D)", "res 1,(iy+D),a", "res 2,(iy+D),b", "res 2,(iy+D),c", "res 2,(iy+D),d", "res 2,(iy+D),e", "res 2,(iy+D),h", "res 2,(iy+D),l", "res 2,(iy+D)", "res 2,(iy+D),a", "res 3,(iy+D),b", "res 3,(iy+D),c", "res 3,(iy+D),d", "res 3,(iy+D),e", "res 3,(iy+D),h", "res 3,(iy+D),l", "res 3,(iy+D)", "res 3,(iy+D),a", "res 4,(iy+D),b", "res 4,(iy+D),c", "res 4,(iy+D),d", "res 4,(iy+D),e", "res 4,(iy+D),h", "res 4,(iy+D),l", "res 4,(iy+D)", "res 4,(iy+D),a", "res 5,(iy+D),b", "res 5,(iy+D),c", "res 5,(iy+D),d", "res 5,(iy+D),e", "res 5,(iy+D),h", "res 5,(iy+D),l", "res 5,(iy+D)", "res 5,(iy+D),a", "res 6,(iy+D),b", "res 6,(iy+D),c", "res 6,(iy+D),d", "res 6,(iy+D),e", "res 6,(iy+D),h", "res 6,(iy+D),l", "res 6,(iy+D)", "res 6,(iy+D),a", "res 7,(iy+D),b", "res 7,(iy+D),c", "res 7,(iy+D),d", "res 7,(iy+D),e", "res 7,(iy+D),h", "res 7,(iy+D),l", "res 7,(iy+D)", "res 7,(iy+D),a", "set 0,(iy+D),b", "set 0,(iy+D),c", "set 0,(iy+D),d", "set 0,(iy+D),e", "set 0,(iy+D),h", "set 0,(iy+D),l", "set 0,(iy+D)", "set 0,(iy+D),a", "set 1,(iy+D),b", "set 1,(iy+D),c", "set 1,(iy+D),d", "set 1,(iy+D),e", "set 1,(iy+D),h", "set 1,(iy+D),l", "set 1,(iy+D)", "set 1,(iy+D),a", "set 2,(iy+D),b", "set 2,(iy+D),c", "set 2,(iy+D),d", "set 2,(iy+D),e", "set 2,(iy+D),h", "set 2,(iy+D),l", "set 2,(iy+D)", "set 2,(iy+D),a", "set 3,(iy+D),b", "set 3,(iy+D),c", "set 3,(iy+D),d", "set 3,(iy+D),e", "set 3,(iy+D),h", "set 3,(iy+D),l", "set 3,(iy+D)", "set 3,(iy+D),a", "set 4,(iy+D),b", "set 4,(iy+D),c", "set 4,(iy+D),d", "set 4,(iy+D),e", "set 4,(iy+D),h", "set 4,(iy+D),l", "set 4,(iy+D)", "set 4,(iy+D),a", "set 5,(iy+D),b", "set 5,(iy+D),c", "set 5,(iy+D),d", "set 5,(iy+D),e", "set 5,(iy+D),h", "set 5,(iy+D),l", "set 5,(iy+D)", "set 5,(iy+D),a", "set 6,(iy+D),b", "set 6,(iy+D),c", "set 6,(iy+D),d", "set 6,(iy+D),e", "set 6,(iy+D),h", "set 6,(iy+D),l", "set 6,(iy+D)", "set 6,(iy+D),a", "set 7,(iy+D),b", "set 7,(iy+D),c", "set 7,(iy+D),d", "set 7,(iy+D),e", "set 7,(iy+D),h", "set 7,(iy+D),l", "set 7,(iy+D)", "set 7,(iy+D),a"};
void loadSymbols()
{
used_symbols.clear();
for (int i=0; i<65536; ++i) symbols[i][0] = 0;
FILE *f = fopen("symbols.txt", "r");
while (true) {
uint16_t address;
char tmp[15];
const int result = fscanf(f, "%x %s", &address, tmp);
if (result != 2) break;
strcpy(symbols[address], tmp);
used_symbols.push_back(address);
}
fclose(f);
}
void saveSymbols()
{
FILE *f = fopen("symbols.txt", "w");
for (auto sym_addr : used_symbols)
{
fprintf(f, "0x%x %s\n", sym_addr, symbols[sym_addr]);
}
fclose(f);
}
const char *getBase(const uint16_t pos)
{
if (mem::read(pos) == 0xCB) {
opcode_size=2;
return cb_opcodes[mem::read(pos+1)];
} else if (mem::read(pos) == 0xDD) {
if (mem::read(pos+1) == 0xCB) {
opcode_size=4;
return ix_bit_opcodes[mem::read(pos+3)];
} else {
opcode_size=2;
return ix_opcodes[mem::read(pos+1)];
}
} else if (mem::read(pos) == 0xED) {
opcode_size=2;
return misc_opcodes[(mem::read(pos+1))-64];
} else if (mem::read(pos) == 0xFD) {
if (mem::read(pos+1) == 0xCB) {
opcode_size=4;
return iy_bit_opcodes[mem::read(pos+3)];
} else {
opcode_size=2;
return iy_opcodes[mem::read(pos+1)];
}
} else {
opcode_size=1;
return base_opcodes[mem::read(pos)];
}
}
void printOpcode(const uint16_t pos)
{
char hex[4];
for (int i=0; i<4;++i)
{
if (opcode_size>i)
sprintf(hex, "%02x ", mem::read(pos+i));
else
sprintf(hex, " ");
strcat(buffer, hex);
}
}
const char *getAsm(const uint16_t pos)
{
opcode_size = 0;
char base[256];
strcpy(buffer, getBase(pos));
if (strstr(buffer, "4x"))
{
opcode_size+=2;
const uint8_t memvalue = mem::read(pos);
const uint16_t address = pos + ((memvalue==0xFD) || (memvalue==0xDD) || (memvalue==0xED)?2:1);
const uint16_t word = mem::read(address) + (mem::read(address+1)<<8);
if (symbols[word][0]!=0) {
char *p = strstr(buffer, "$");
(*p)='%'; p++;
(*p)='s'; p++;
while (*(p-1) != 0) {
*p = *(p+3);
p++;
}
strcpy(base, buffer);
sprintf(buffer, base, symbols[word]);
} else {
strcpy(base, buffer);
sprintf(buffer, base, word);
}
}
if (strstr(buffer, "2x") && strstr(buffer, "hhd"))
{
opcode_size = 4;
strcpy(base, buffer);
sprintf(buffer, base, mem::read(pos+2), (int8_t)mem::read(pos+3));
return buffer;
}
if (strstr(buffer, "2x"))
{
opcode_size+=1;
strcpy(base, buffer);
sprintf(buffer, base, mem::read(pos+1));
}
if (strstr(buffer, "Xx"))
{
strcpy(base, buffer);
*strstr(base, "Xx") = '4';
opcode_size+=1;
if (opcode_size>4) {
opcode_size=4;
sprintf(buffer, base, pos + opcode_size + (int8_t)mem::read(pos+2));
} else {
sprintf(buffer, base, pos + opcode_size + (int8_t)mem::read(pos+1));
}
}
if (strstr(buffer, "hhd")) {
opcode_size+=1;
strcpy(base, buffer);
if (opcode_size>4) {
opcode_size=4;
sprintf(buffer, base, (int8_t)mem::read(pos+3));
} else {
sprintf(buffer, base, (int8_t)mem::read(pos+2));
}
}
return buffer;
}
const char *getOpcode(const uint16_t pos)
{
opcode_size = 0;
buffer[0]=0;
const char *base = getBase(pos);
if (strstr(base, "4x")) opcode_size+=2;
if (strstr(base, "2x")) opcode_size+=1;
if (strstr(base, "Xx")) opcode_size+=1;
if (strstr(base, "hh")) opcode_size+=1;
if (opcode_size>4) opcode_size=4;
printOpcode(pos);
return buffer;
}
const int getOpcodeSize(const uint16_t pos)
{
opcode_size = 0;
const char *base = getBase(pos);
if (strstr(base, "4x")) opcode_size+=2;
if (strstr(base, "2x")) opcode_size+=1;
if (strstr(base, "Xx")) opcode_size+=1;
if (strstr(base, "hh")) opcode_size+=1;
if (opcode_size>4) opcode_size=4;
return opcode_size;
}
const char *getSymbol(const uint16_t pos)
{
return symbols[pos];
}
void setSymbol(const uint16_t pos, const char *sym)
{
if (sym) {
strcpy(symbols[pos], sym);
} else {
symbols[pos][0] = 0;
}
used_symbols.clear();
for (int i=0; i<65536; ++i) if (symbols[i][0]!=0) used_symbols.push_back(i);
saveSymbols();
}
const int getNumSymbols()
{
return used_symbols.size();
}
const uint16_t getSymbolAddress(const int pos)
{
return used_symbols[pos];
}
}