diff -r 5ce09de7f9b7 -r 47ee91579133 c++/rgb-assembler/commands/IncrementDecrement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/rgb-assembler/commands/IncrementDecrement.h Sun Dec 24 00:08:55 2017 +0100 @@ -0,0 +1,35 @@ +#pragma once + +#include +#include +#include + +#include "../Command.h" +#include "../memory.h" + +using namespace std; + +namespace commands { + +class IncrementDecrement : public Command { +public: + + IncrementDecrement(const bool increment) { + this->increment = increment; + } + + void process(octet_t* memory, address_t& index) override { + address_t address = read(memory, index); + address_t address_r = address; + address_t address_w = address_r; + octet_t value = read(memory, address_r); + value = increment ? value + 1 : value - 1; + write(memory, address_w, value); + wprintf(L"%sCREMENT %*d → %02X\n", (increment ? "IN" : "DE"), 5, address, value); + } +private: + bool increment; + +}; + +}