1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp Sat Dec 23 23:24:51 2017 +0100
1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp Sat Dec 23 23:34:21 2017 +0100
1.3 @@ -112,18 +112,25 @@
1.4 write<command_t>(memory, a, CMD_END);
1.5 }
1.6
1.7 + unordered_map<command_t, shared_ptr < Command>> commands = {
1.8 + {CMD_GOTO, make_shared<commands::Goto>()},
1.9 + };
1.10 +
1.11 for (address_t i = 0; i < MEMORY_SIZE;) {
1.12 wprintf(L"command %*d = ", 4, i);
1.13 command_t command = read<command_t>(memory, i);
1.14 wprintf(L"%02X ", command);
1.15
1.16 + shared_ptr<Command> cx = commands[command];
1.17 +
1.18 + if (cx) {
1.19 + cx->process(memory, i);
1.20 + continue;
1.21 + } else {
1.22 + // TODO: wprintf(L"invalid command\n");
1.23 + }
1.24 +
1.25 switch (command) {
1.26 - case CMD_GOTO:
1.27 - {
1.28 - i = read<address_t>(memory, i);
1.29 - wprintf(L"GOTO %*d\n", 5, i);
1.30 - break;
1.31 - }
1.32 case CMD_SLEEP:
1.33 {
1.34 sleep_t delay = read<sleep_t>(memory, i);