END in class
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 23 Dec 2017 23:45:27 +0100
changeset 23e85d2bfaff73
parent 22 cb2055cdc2f0
child 24 e24883b00180
END in class
c++/rgb-assembler/commands/End.h
c++/rgb-assembler/nbproject/configurations.xml
c++/rgb-assembler/rgb-assembler.cpp
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/c++/rgb-assembler/commands/End.h	Sat Dec 23 23:45:27 2017 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +#pragma once
     1.5 +
     1.6 +#include <wchar.h>
     1.7 +#include <chrono>
     1.8 +#include <thread>
     1.9 +
    1.10 +#include "../Command.h"
    1.11 +#include "../memory.h"
    1.12 +
    1.13 +using namespace std;
    1.14 +
    1.15 +namespace commands {
    1.16 +
    1.17 +class End : public Command {
    1.18 +public:
    1.19 +
    1.20 +	void process(octet_t* memory, address_t& index) override {
    1.21 +		wprintf(L"END\n");
    1.22 +		index = MEMORY_SIZE;
    1.23 +	}
    1.24 +private:
    1.25 +
    1.26 +};
    1.27 +
    1.28 +}
     2.1 --- a/c++/rgb-assembler/nbproject/configurations.xml	Sat Dec 23 23:42:46 2017 +0100
     2.2 +++ b/c++/rgb-assembler/nbproject/configurations.xml	Sat Dec 23 23:45:27 2017 +0100
     2.3 @@ -5,6 +5,7 @@
     2.4                     displayName="Header Files"
     2.5                     projectFiles="true">
     2.6        <itemPath>Command.h</itemPath>
     2.7 +      <itemPath>commands/End.h</itemPath>
     2.8        <itemPath>commands/Goto.h</itemPath>
     2.9        <itemPath>commands/Sleep.h</itemPath>
    2.10        <itemPath>memory.h</itemPath>
    2.11 @@ -47,6 +48,8 @@
    2.12        </compileType>
    2.13        <item path="Command.h" ex="false" tool="3" flavor2="0">
    2.14        </item>
    2.15 +      <item path="commands/End.h" ex="false" tool="3" flavor2="0">
    2.16 +      </item>
    2.17        <item path="commands/Goto.h" ex="false" tool="3" flavor2="0">
    2.18        </item>
    2.19        <item path="commands/Sleep.h" ex="false" tool="3" flavor2="0">
    2.20 @@ -81,6 +84,8 @@
    2.21        </compileType>
    2.22        <item path="Command.h" ex="false" tool="3" flavor2="0">
    2.23        </item>
    2.24 +      <item path="commands/End.h" ex="false" tool="3" flavor2="0">
    2.25 +      </item>
    2.26        <item path="commands/Goto.h" ex="false" tool="3" flavor2="0">
    2.27        </item>
    2.28        <item path="commands/Sleep.h" ex="false" tool="3" flavor2="0">
     3.1 --- a/c++/rgb-assembler/rgb-assembler.cpp	Sat Dec 23 23:42:46 2017 +0100
     3.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp	Sat Dec 23 23:45:27 2017 +0100
     3.3 @@ -10,6 +10,7 @@
     3.4  #include "Command.h"
     3.5  #include "commands/Goto.h"
     3.6  #include "commands/Sleep.h"
     3.7 +#include "commands/End.h"
     3.8  
     3.9  using namespace std;
    3.10  
    3.11 @@ -114,6 +115,7 @@
    3.12  	unordered_map<command_t, shared_ptr < Command>> commands = {
    3.13  		{CMD_GOTO, make_shared<commands::Goto>()},
    3.14  		{CMD_SLEEP, make_shared<commands::Sleep>()},
    3.15 +		{CMD_END, make_shared<commands::End>()},
    3.16  	};
    3.17  
    3.18  	for (address_t i = 0; i < MEMORY_SIZE;) {
    3.19 @@ -170,12 +172,6 @@
    3.20  				wprintf(L"GOTO COMPARE  a = %02X, b = %02X, eq = %d, gt = %d, lt = %d → %d\n", a, b, eq, gt, lt, i);
    3.21  				break;
    3.22  			}
    3.23 -			case CMD_END:
    3.24 -			{
    3.25 -				wprintf(L"END\n");
    3.26 -				i = MEMORY_SIZE;
    3.27 -				break;
    3.28 -			}
    3.29  			default:
    3.30  			{
    3.31  				wprintf(L"invalid command\n");