c++/rgb-assembler/commands/GotoCompare.h
changeset 25 5ce09de7f9b7
parent 20 b9ceffdcaf14
child 29 10d6964e7b4a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/c++/rgb-assembler/commands/GotoCompare.h	Sat Dec 23 23:50:44 2017 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +#pragma once
     1.5 +
     1.6 +#include <wchar.h>
     1.7 +
     1.8 +#include "../Command.h"
     1.9 +
    1.10 +namespace commands {
    1.11 +
    1.12 +class GotoCompare : public Command {
    1.13 +public:
    1.14 +
    1.15 +	void process(octet_t* memory, address_t& index) override {
    1.16 +		address_t aa = read<address_t>(memory, index);
    1.17 +		address_t ab = read<address_t>(memory, index);
    1.18 +		address_t eq = read<address_t>(memory, index);
    1.19 +		address_t gt = read<address_t>(memory, index);
    1.20 +		address_t lt = read<address_t>(memory, index);
    1.21 +
    1.22 +		octet_t a = read<octet_t>(memory, aa);
    1.23 +		octet_t b = read<octet_t>(memory, ab);
    1.24 +
    1.25 +		if (a == b) index = eq;
    1.26 +		else if (a > b) index = gt;
    1.27 +		else index = lt;
    1.28 +
    1.29 +		wprintf(L"GOTO COMPARE  a = %02X, b = %02X, eq = %d, gt = %d, lt = %d → %d\n", a, b, eq, gt, lt, index);
    1.30 +	}
    1.31 +private:
    1.32 +
    1.33 +};
    1.34 +
    1.35 +}