diff -r f049c3d3244d -r b997cbf9e30b c++/rgb-assembler/commands/GotoCompare.h --- a/c++/rgb-assembler/commands/GotoCompare.h Sun Dec 24 00:47:34 2017 +0100 +++ b/c++/rgb-assembler/commands/GotoCompare.h Mon Dec 25 00:24:07 2017 +0100 @@ -27,24 +27,31 @@ class GotoCompare : public Command { public: - void process(octet_t* memory, address_t& index) override { - address_t aa = read(memory, index); - address_t ab = read(memory, index); - address_t eq = read(memory, index); - address_t gt = read(memory, index); - address_t lt = read(memory, index); + void process(Memory &memory) override { + address_t aa = memory.read(); + address_t ab = memory.read(); + address_t eq = memory.read(); + address_t gt = memory.read(); + address_t lt = memory.read(); - octet_t a = read(memory, aa); - octet_t b = read(memory, ab); + address_t originalAddress = memory.getIndex(); + // TODO: add to Memory methods read(address_t) and write(address_t, T) + memory.setIndex(aa); + octet_t a = memory.read(); + memory.setIndex(ab); + octet_t b = memory.read(); + memory.setIndex(originalAddress); + + address_t index; if (a == b) index = eq; else if (a > b) index = gt; else index = lt; + memory.setIndex(index); + wprintf(L"GOTO COMPARE a = %02X, b = %02X, eq = %d, gt = %d, lt = %d → %d\n", a, b, eq, gt, lt, index); } -private: - }; }