Add TSX, TXA and TXS instructions

This commit is contained in:
g1n 2021-10-11 20:48:12 +03:00
parent 05f5bf4dcd
commit 99be8b1568
3 changed files with 23 additions and 2 deletions

View File

@ -28,6 +28,9 @@ typedef unsigned short word; // 16 bit
#define INS_TAX 0xAA // TAX Implied
#define INS_TAY 0xA8 // TAY Implied
#define INS_TSX 0xBA // TSX Implied
#define INS_TXA 0x8A // TXA Implied
#define INS_TXS 0x9A // TXS Implied
#define INS_JSR 0x20 // JSR
#define INS_RTS 0x60 // RTS

View File

@ -127,6 +127,7 @@ void execute() {
cpu.Z = (cpu.Y == 0);
cpu.N = (cpu.Y & 0b1000000) > 0;
break;
case INS_TAX:
cpu.X = cpu.A;
cpu.Z = (cpu.X == 0);
@ -139,7 +140,24 @@ void execute() {
cpu.N = (cpu.Y & 0b1000000) > 0;
cpu.PC++;
break;
case INS_JSR:
case INS_TSX:
cpu.X = cpu.SP;
cpu.Z = (cpu.X == 0);
cpu.N = (cpu.X & 0b1000000) > 0;
cpu.PC++;
break;
case INS_TXA:
cpu.A = cpu.X;
cpu.Z = (cpu.A == 0);
cpu.N = (cpu.A & 0b1000000) > 0;
cpu.PC++;
break;
case INS_TXS:
cpu.SP = cpu.X;
cpu.PC++;
break;
case INS_JSR:
word jsr_addr = fetch_word();
write_word(cpu.PC - 1, cpu.SP);
cpu.SP++;

View File

@ -1 +1 @@
<EFBFBD>Uィ
<EFBFBD>B<EFBFBD>