diff --git a/include/instruction_handler.h b/include/instruction_handler.h index f7e253a..d54da92 100644 --- a/include/instruction_handler.h +++ b/include/instruction_handler.h @@ -54,6 +54,11 @@ private: * Handles Chip8 instruction 0x6000 */ static void handle6000(Chip8&, Instruction); + + /** + * Handles Chip8 instruction 0x7000 + */ + static void handle7000(Chip8&, Instruction); public: InstructionHandler(); diff --git a/src/instruction_handler.cpp b/src/instruction_handler.cpp index e13e415..8dac06c 100644 --- a/src/instruction_handler.cpp +++ b/src/instruction_handler.cpp @@ -9,6 +9,7 @@ InstructionHandler::InstructionHandler() { this->handlers[0x4000] = handle4000; this->handlers[0x5000] = handle5000; this->handlers[0x6000] = handle6000; + this->handlers[0x7000] = handle7000; } /** @@ -121,3 +122,13 @@ void InstructionHandler::handle5000(Chip8& chip8, Instruction instruction) { void InstructionHandler::handle6000(Chip8& chip8, Instruction instruction) { chip8.setRegister(instruction.x(), instruction.kk()); } + +/** + * Handles the 0x7XKK Chip8 instruction which is used to add the value KK to register V[x] and set the result in register V[x]. + * + * @param chip8 The Chip8 instance + * @param instruction The Instruction instance + */ +void InstructionHandler::handle7000(Chip8& chip8, Instruction instruction) { + chip8.setRegister(instruction.x(), chip8.getRegister(instruction.x()) + instruction.kk()); +}