diff --git a/decoder.cpp b/decoder.cpp index 48c0aa6..ad322b2 100644 --- a/decoder.cpp +++ b/decoder.cpp @@ -28,7 +28,28 @@ int InstructionDecoder::decode_and_execute(uint8_t opcode) printf("In decode and execute: op: %x, pc: %x\n", opcode, cpu->pc); // todo: single byte instructions + if((opcode & 0x8) == 0x8) // 0b1000 + { + + } + else if((opcode & 0xA) == 0xA) // 0b1010 + { + + } + // todo: BRK, JSR abs, RTI, RTS + switch(opcode) + { + case 0x0: // BRK + break; + case 0x20: // JSR abs + break; + case 0x40: // RTI + break; + case 0x60: // RTS + break; + } + // The conditional branch instructions all have the form xxy10000 // they use relative addressing @@ -43,6 +64,7 @@ int InstructionDecoder::decode_and_execute(uint8_t opcode) } } // form aaabbbcc instruction + // todo: perhaps make this more specific than just else else { decode_aaabbbcc(opcode); diff --git a/runrom.cpp b/runrom.cpp index 58ef716..fafe08c 100644 --- a/runrom.cpp +++ b/runrom.cpp @@ -25,10 +25,8 @@ int main(int argc, char**argv) // create and init state machine Famicom * nes = new Famicom(buffer); - /* engine to iterate through buffer, - call opcode->f() for each opcode passed in */ - /* so this is iterating over the prgrom, which I believe contains the instructions... */ + /* so this is iterating over the prgrom */ while (nes->getpc() < PRGROMSTART+nes->cart->prgromsize) { //printf("%x : %x\n", nes->getpc(), fsize); diff --git a/tests/systemtests.h b/tests/systemtests.h index d2d1079..84816d1 100644 --- a/tests/systemtests.h +++ b/tests/systemtests.h @@ -123,7 +123,12 @@ class TestDecoder : public CppUnit::TestFixture void setUp(); void test_branching(); void test_aaabbbcc(); - void test_singlebyte(); + void test_singlebyte0x8(); + void test_singlebyte0xa(); + void test_brk(); + void test_rti(); + void test_jsrabs(); + void test_rts(); }; CPPUNIT_TEST_SUITE_REGISTRATION( TestDecoder );