Add DEX and DEY instructions

This commit is contained in:
g1n 2021-10-15 14:27:10 +03:00
parent 287bd31a90
commit 702c02383c
2 changed files with 15 additions and 0 deletions

View File

@ -41,6 +41,9 @@ typedef unsigned short word; // 16 bit
#define INS_INX 0xE8 // INX Implied
#define INS_INY 0xC8 // INY Implied
#define INS_DEX 0xCA // DEX Implied
#define INS_DEY 0x88 // DEY Implied
struct MEMORY {
byte memory[MAX_MEMORY];
};

View File

@ -175,6 +175,7 @@ void execute() {
break;
case INS_NOP:
break;
case INS_INX:
cpu.X++;
cpu.Z = (cpu.X == 0);
@ -185,6 +186,17 @@ void execute() {
cpu.Z = (cpu.Y == 0);
cpu.N = (cpu.Y & 0b1000000) > 0;
break;
case INS_DEX:
cpu.X--;
cpu.Z = (cpu.X == 0);
cpu.N = (cpu.X & 0b1000000) > 0;
break;
case INS_DEY:
cpu.Y--;
cpu.Z = (cpu.Y == 0);
cpu.N = (cpu.Y & 0b1000000) > 0;
break;
case 0x00: // EOF
return;
default: