Browse Source

Emulator: Add opcode $a8/$af

master
Riyyi 2 years ago
parent
commit
af07357812
  1. 23
      src/cpu.cpp
  2. 1
      src/cpu.h

23
src/cpu.cpp

@ -75,6 +75,8 @@ void CPU::update()
case 0x32: ld8(); break; case 0x32: ld8(); break;
case 0x36: ld8(); break; case 0x36: ld8(); break;
case 0x3e: ld8(); break; case 0x3e: ld8(); break;
case 0xa8: xor8(); break;
case 0xaf: xor8(); break;
case 0xc3: jp16(); break; case 0xc3: jp16(); break;
case 0xc6: add(); break; case 0xc6: add(); break;
case 0xcd: call(); break; case 0xcd: call(); break;
@ -116,6 +118,27 @@ void CPU::add()
} }
} }
void CPU::xor8()
{
uint8_t opcode = pcRead();
switch (opcode) {
case 0xa8:
// XOR B, flags: Z 0 0 0
m_nf = m_hf = m_cf = 0;
m_a ^= m_b;
m_zf = m_a == 0;
break;
case 0xaf:
// XOR A, flags: 1 0 0 0
// A^A will always be 0
m_a = m_nf = m_hf = m_cf = 0;
m_zf = 1;
break;
default:
VERIFY_NOT_REACHED();
}
}
void CPU::ld8() void CPU::ld8()
{ {
uint8_t opcode = pcRead(); uint8_t opcode = pcRead();

1
src/cpu.h

@ -25,6 +25,7 @@ public:
// 8-bit // 8-bit
void add(); void add();
void xor8();
// 16-bit // 16-bit

Loading…
Cancel
Save