implement STZ zpg and PHX

This commit is contained in:
Brad Grantham 2018-08-06 00:36:23 -07:00
parent 7d346a06b3
commit e938af1349
2 changed files with 30 additions and 19 deletions

View File

@ -1454,14 +1454,14 @@ struct CPU6502
/* 0x3- */ 2, 5, -1, -1, -1, 4, 6, -1, 2, 4, 2, -1, -1, 4, 7, -1,
/* 0x4- */ 6, 6, -1, -1, -1, 3, 5, -1, 3, 2, 2, -1, 3, 4, 6, -1,
/* 0x5- */ 2, 5, -1, -1, -1, 4, 6, -1, 2, 4, -1, -1, -1, 4, 7, -1,
/* 0x6- */ 6, 6, -1, -1, -1, 3, 5, -1, 4, 2, 2, -1, 5, 4, 6, -1,
/* 0x6- */ 6, 6, -1, -1, 3, 3, 5, -1, 4, 2, 2, -1, 5, 4, 6, -1,
/* 0x7- */ 2, 5, 5, -1, -1, 4, 6, -1, 2, 4, -1, -1, -1, 4, 7, -1,
/* 0x8- */ 2, 6, -1, -1, 3, 3, 3, -1, 2, -1, 2, -1, 4, 4, 4, -1,
/* 0x9- */ 2, 6, 5, -1, 4, 4, 4, -1, 2, 5, 2, -1, 4, 5, -1, -1,
/* 0xA- */ 2, 6, 2, -1, 3, 3, 3, -1, 2, 2, 2, -1, 4, 4, 4, -1,
/* 0xB- */ 2, 5, 5, -1, 4, 4, 4, -1, 2, 4, 2, -1, 4, 4, 4, -1,
/* 0xC- */ 2, 6, -1, -1, 3, 3, 5, -1, 2, 2, 2, -1, 4, 4, 3, -1,
/* 0xD- */ 2, 5, -1, -1, -1, 4, 6, -1, 2, 4, -1, -1, -1, 4, 7, -1,
/* 0xD- */ 2, 5, -1, -1, -1, 4, 6, -1, 2, 4, 3, -1, -1, 4, 7, -1,
/* 0xE- */ 2, 6, -1, -1, 3, 3, 5, -1, 2, 2, 2, -1, 4, 4, 6, -1,
/* 0xF- */ 2, 5, -1, -1, -1, 4, 6, -1, 2, 4, -1, -1, -1, 4, 7, -1,
};
@ -2172,6 +2172,11 @@ struct CPU6502
break;
}
case 0xDA: { // PHX
stack_push(bus, x);
break;
}
case 0x01: { // ORA (ind, X)
unsigned char zpg = (read_pc_inc(bus) + x) & 0xFF;
int addr = bus.read(zpg) + bus.read((zpg + 1) & 0xFF) * 256;
@ -2719,6 +2724,12 @@ struct CPU6502
break;
}
case 0x64: { // STZ zpg
unsigned char zpg = read_pc_inc(bus);
bus.write(zpg, 0);
break;
}
case 0x8E: { // STX abs
int addr = read_pc_inc(bus) + read_pc_inc(bus) * 256;
bus.write(addr, x);

View File

@ -31,7 +31,7 @@ tuple<int, string> disassemble_6502(int address, const unsigned char* buffer)
"DEC","DEX","DEY","EOR","INC","INX","INY","JMP","JSR","LDA", // 2
"LDX","LDY","LSR","NOP","ORA","PHA","PHP","PLA","PLP","ROL", // 3
"ROR","ROT","RTI","RTS","SBC","SEC","SED","SEI","STA","STX", // 4
"STY","TAX","TAY","TSX","TXA","TXS","TYA","STZ","???"}; // 5
"STY","TAX","TAY","TSX","TXA","TXS","TYA","STZ","PHX","???"};// 5
// This is a lookup of the text formating required for mode output, plus one entry to distinguish relative mode
static const char *modes[9][2]={{"",""},{"#",""},{"",",X"},{"",",Y"},{"(",",X)"},{"(","),Y"},{"(",")"},{"A",""},{"",""}};
@ -40,22 +40,22 @@ tuple<int, string> disassemble_6502(int address, const unsigned char* buffer)
static const int opcode_props[256][3] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
// ******** -------- ******** -------- ******** -------- ******** -------- ******** -------- ******** -------- ******** -------- ******** --------
{1,10,0},{2,34,4},{1,58,0},{1,58,0},{1,58,0},{2,34,0},{2,2,0}, {1,58,0},{1,36,0},{2,34,1},{1,2,7}, {1,58,0},{1,58,0},{3,34,0},{3,2,0}, {1,58,0}, // 0
{2,9,8}, {2,34,5},{1,58,0},{1,58,0},{1,58,0},{2,34,2},{2,2,2}, {1,58,0},{1,13,0},{3,34,3},{1,58,0},{1,58,0},{1,58,0},{3,34,2},{3,2,2}, {1,58,0}, // 1
{3,28,0},{2,1,4}, {1,58,0},{1,58,0},{2,6,0}, {2,1,0}, {2,39,0},{1,58,0},{1,38,0},{2,1,1}, {1,39,7},{1,58,0},{3,6,0}, {3,1,0}, {3,39,0},{1,58,0}, // 2
{2,7,8}, {2,1,5}, {1,58,0},{1,58,0},{1,58,0},{2,1,2}, {2,39,2},{1,58,0},{1,45,0},{3,1,3}, {1,58,0},{1,58,0},{1,58,0},{3,1,2}, {3,39,2},{1,58,0}, // 3
{1,42,0},{2,23,4},{1,58,0},{1,58,0},{1,58,0},{2,23,0},{2,32,0},{1,58,0},{1,35,0},{2,23,1},{1,32,7},{1,58,0},{3,27,0},{3,23,0},{3,32,0},{1,58,0}, // 4
{2,11,8},{2,23,5},{1,58,0},{1,58,0},{1,58,0},{2,23,2},{2,32,2},{1,58,0},{1,15,0},{3,23,3},{1,58,0},{1,58,0},{1,58,0},{3,23,2},{3,32,2},{1,58,0}, // 5
{1,43,0},{2,0,4}, {1,58,0},{1,58,0},{1,58,0},{2,0,0}, {2,40,0},{1,58,0},{1,37,0},{2,0,1}, {1,41,7},{1,58,0},{3,27,6},{3,0,0}, {3,40,0},{1,58,0}, // 6
{2,12,8},{2,0,5}, {1,58,0},{1,58,0},{1,58,0},{2,0,2}, {2,40,2},{1,58,0},{1,47,0},{3,0,3}, {1,58,0},{1,58,0},{1,58,0},{3,0,2}, {3,40,2},{1,58,0}, // 7
{1,58,0},{2,48,4},{1,58,0},{1,58,0},{2,50,0},{2,48,0},{2,49,0},{1,58,0},{1,22,0},{1,58,0},{1,54,0},{1,58,0},{3,50,0},{3,48,0},{3,49,0},{1,58,0}, // 8
{2,3,8}, {2,48,5},{1,58,0},{1,58,0},{2,50,2},{2,48,2},{2,49,3},{1,58,0},{1,56,0},{3,48,3},{1,55,0},{1,58,0},{3,57,0},{3,48,2},{1,58,0},{1,58,0}, // 9
{2,31,1},{2,29,4},{2,30,1},{1,58,0},{2,31,0},{2,29,0},{2,30,0},{1,58,0},{1,52,0},{2,29,1},{1,51,0},{1,58,0},{3,31,0},{3,29,0},{3,30,0},{1,58,0}, // A
{2,4,8}, {2,29,5},{1,58,0},{1,58,0},{2,31,2},{2,29,2},{2,30,3},{1,58,0},{1,16,0},{3,29,3},{1,53,0},{1,58,0},{3,31,2},{3,29,2},{3,30,3},{1,58,0}, // B
{2,19,1},{2,17,4},{1,58,0},{1,58,0},{2,19,0},{2,17,0},{2,20,0},{1,58,0},{1,26,0},{2,17,1},{1,21,0},{1,58,0},{3,19,0},{3,17,0},{3,20,0},{1,58,0}, // C
{2,8,8}, {2,17,5},{1,58,0},{1,58,0},{1,58,0},{2,17,2},{2,20,2},{1,58,0},{1,14,0},{3,17,3},{1,58,0},{1,58,0},{1,58,0},{3,17,2},{3,20,2},{1,58,0}, // D
{2,18,1},{2,44,4},{1,58,0},{1,58,0},{2,18,0},{2,44,0},{2,24,0},{1,58,0},{1,25,0},{2,44,1},{1,33,0},{1,58,0},{3,18,0},{3,44,0},{3,24,0},{1,58,0}, // E
{2,5,8}, {2,44,5},{1,58,0},{1,58,0},{1,58,0},{2,44,2},{2,24,2},{1,58,0},{1,46,0},{3,44,3},{1,58,0},{1,58,0},{1,58,0},{3,44,2},{3,24,2},{1,58,0} // F
{1,10,0},{2,34,4},{1,59,0},{1,59,0},{1,59,0},{2,34,0},{2,2,0}, {1,59,0},{1,36,0},{2,34,1},{1,2,7}, {1,59,0},{1,59,0},{3,34,0},{3,2,0}, {1,59,0}, // 0
{2,9,8}, {2,34,5},{1,59,0},{1,59,0},{1,59,0},{2,34,2},{2,2,2}, {1,59,0},{1,13,0},{3,34,3},{1,59,0},{1,59,0},{1,59,0},{3,34,2},{3,2,2}, {1,59,0}, // 1
{3,28,0},{2,1,4}, {1,59,0},{1,59,0},{2,6,0}, {2,1,0}, {2,39,0},{1,59,0},{1,38,0},{2,1,1}, {1,39,7},{1,59,0},{3,6,0}, {3,1,0}, {3,39,0},{1,59,0}, // 2
{2,7,8}, {2,1,5}, {1,59,0},{1,59,0},{1,59,0},{2,1,2}, {2,39,2},{1,59,0},{1,45,0},{3,1,3}, {1,59,0},{1,59,0},{1,59,0},{3,1,2}, {3,39,2},{1,59,0}, // 3
{1,42,0},{2,23,4},{1,59,0},{1,59,0},{1,59,0},{2,23,0},{2,32,0},{1,59,0},{1,35,0},{2,23,1},{1,32,7},{1,59,0},{3,27,0},{3,23,0},{3,32,0},{1,59,0}, // 4
{2,11,8},{2,23,5},{1,59,0},{1,59,0},{1,59,0},{2,23,2},{2,32,2},{1,59,0},{1,15,0},{3,23,3},{1,59,0},{1,59,0},{1,59,0},{3,23,2},{3,32,2},{1,59,0}, // 5
{1,43,0},{2,0,4}, {1,59,0},{1,59,0},{2,57,0},{2,0,0}, {2,40,0},{1,59,0},{1,37,0},{2,0,1}, {1,41,7},{1,59,0},{3,27,6},{3,0,0}, {3,40,0},{1,59,0}, // 6
{2,12,8},{2,0,5}, {1,59,0},{1,59,0},{1,59,0},{2,0,2}, {2,40,2},{1,59,0},{1,47,0},{3,0,3}, {1,59,0},{1,59,0},{1,59,0},{3,0,2}, {3,40,2},{1,59,0}, // 7
{1,59,0},{2,48,4},{1,59,0},{1,59,0},{2,50,0},{2,48,0},{2,49,0},{1,59,0},{1,22,0},{1,59,0},{1,54,0},{1,59,0},{3,50,0},{3,48,0},{3,49,0},{1,59,0}, // 8
{2,3,8}, {2,48,5},{1,59,0},{1,59,0},{2,50,2},{2,48,2},{2,49,3},{1,59,0},{1,56,0},{3,48,3},{1,55,0},{1,59,0},{3,57,0},{3,48,2},{1,59,0},{1,59,0}, // 9
{2,31,1},{2,29,4},{2,30,1},{1,59,0},{2,31,0},{2,29,0},{2,30,0},{1,59,0},{1,52,0},{2,29,1},{1,51,0},{1,59,0},{3,31,0},{3,29,0},{3,30,0},{1,59,0}, // A
{2,4,8}, {2,29,5},{1,59,0},{1,59,0},{2,31,2},{2,29,2},{2,30,3},{1,59,0},{1,16,0},{3,29,3},{1,53,0},{1,59,0},{3,31,2},{3,29,2},{3,30,3},{1,59,0}, // B
{2,19,1},{2,17,4},{1,59,0},{1,59,0},{2,19,0},{2,17,0},{2,20,0},{1,59,0},{1,26,0},{2,17,1},{1,21,0},{1,59,0},{3,19,0},{3,17,0},{3,20,0},{1,59,0}, // C
{2,8,8}, {2,17,5},{1,59,0},{1,59,0},{1,59,0},{2,17,2},{2,20,2},{1,59,0},{1,14,0},{3,17,3},{1,58,0},{1,59,0},{1,59,0},{3,17,2},{3,20,2},{1,59,0}, // D
{2,18,1},{2,44,4},{1,59,0},{1,59,0},{2,18,0},{2,44,0},{2,24,0},{1,59,0},{1,25,0},{2,44,1},{1,33,0},{1,59,0},{3,18,0},{3,44,0},{3,24,0},{1,59,0}, // E
{2,5,8}, {2,44,5},{1,59,0},{1,59,0},{1,59,0},{2,44,2},{2,24,2},{1,59,0},{1,46,0},{3,44,3},{1,59,0},{1,59,0},{1,59,0},{3,44,2},{3,24,2},{1,59,0} // F
};
paramcount = 0;