Emulator: Add opcode example

This commit is contained in:
Riyyi
2022-08-18 02:29:08 +02:00
parent de2237fac2
commit 6da0184713
2 changed files with 23 additions and 0 deletions
+21
View File
@@ -24,3 +24,24 @@ void CPU::update()
Emu::the().writeMemory("RAM", 123, 42); Emu::the().writeMemory("RAM", 123, 42);
printf("fff"); printf("fff");
} }
void CPU::add(uint8_t byte, uint8_t immediate)
{
switch (byte) {
case 0xc6: // ADD A,d8
// program_counter += 2;
// clock += 8;
// Flags: Z0HC
m_z = (m_af >> 8) + immediate == 0;
m_n = 0;
m_h = (m_af >> 8) + immediate > 16;
m_c = (m_af >> 8) + immediate > 255;
// A = A + r
m_af = m_af + (immediate << 8);
break;
default:
break;
}
}
+2
View File
@@ -20,6 +20,8 @@ public:
// 8-bit Arithmetic and Logic Instructions // 8-bit Arithmetic and Logic Instructions
void add(uint8_t byte, uint8_t immediate = 0);
// 16-bit Arithmetic Instructions // 16-bit Arithmetic Instructions
// Bit Operations Instructions // Bit Operations Instructions