c++/rgb-assembler/commands/GotoCompare.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 23 Dec 2017 23:50:44 +0100
changeset 25 5ce09de7f9b7
parent 20 c++/rgb-assembler/commands/Goto.h@b9ceffdcaf14
child 29 10d6964e7b4a
permissions -rw-r--r--
GOTO_COMPARE in class
     1 #pragma once
     2 
     3 #include <wchar.h>
     4 
     5 #include "../Command.h"
     6 
     7 namespace commands {
     8 
     9 class GotoCompare : public Command {
    10 public:
    11 
    12 	void process(octet_t* memory, address_t& index) override {
    13 		address_t aa = read<address_t>(memory, index);
    14 		address_t ab = read<address_t>(memory, index);
    15 		address_t eq = read<address_t>(memory, index);
    16 		address_t gt = read<address_t>(memory, index);
    17 		address_t lt = read<address_t>(memory, index);
    18 
    19 		octet_t a = read<octet_t>(memory, aa);
    20 		octet_t b = read<octet_t>(memory, ab);
    21 
    22 		if (a == b) index = eq;
    23 		else if (a > b) index = gt;
    24 		else index = lt;
    25 
    26 		wprintf(L"GOTO COMPARE  a = %02X, b = %02X, eq = %d, gt = %d, lt = %d → %d\n", a, b, eq, gt, lt, index);
    27 	}
    28 private:
    29 
    30 };
    31 
    32 }