Browse Source

Emulator: Add opcode example

master
Riyyi 2 years ago
parent
commit
6da0184713
  1. 21
      src/cpu.cpp
  2. 2
      src/cpu.h

21
src/cpu.cpp

@ -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
src/cpu.h

@ -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

Loading…
Cancel
Save