GOTO
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 21 Dec 2017 17:06:39 +0100
changeset 31dd99de3b178
parent 2 b5cf9c841efc
child 4 b589459129a9
GOTO
c++/rgb-assembler/rgb-assembler.cpp
     1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp	Thu Dec 21 16:18:23 2017 +0100
     1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp	Thu Dec 21 17:06:39 2017 +0100
     1.3 @@ -20,15 +20,15 @@
     1.4   */
     1.5  command_t readCommand(command_t * memory, address_t &index) {
     1.6  	// TODO: map higher memory to static hardcoded areas or peripherals
     1.7 -	command_t value = memory[index];
     1.8 -	index += sizeof (value);
     1.9 -	return value;
    1.10 +	command_t * value = reinterpret_cast<command_t*> (memory + index);
    1.11 +	index += sizeof (*value);
    1.12 +	return *value;
    1.13  }
    1.14  
    1.15  address_t readAddress(command_t * memory, address_t &index) {
    1.16 -	address_t value = memory[index];
    1.17 -	index += sizeof (value);
    1.18 -	return value;
    1.19 +	address_t * value = reinterpret_cast<address_t*> (memory + index);
    1.20 +	index += sizeof (*value);
    1.21 +	return *value;
    1.22  }
    1.23  
    1.24  void writeMemoryChar(command_t(&memory)[MEMORY_SIZE], address_t &index, const int value) {
    1.25 @@ -53,14 +53,21 @@
    1.26  		writeCommand(memory, a, CMD_SLEEP);
    1.27  		writeCommand(memory, a, CMD_SLEEP);
    1.28  		writeCommand(memory, a, CMD_SLEEP);
    1.29 +		writeCommand(memory, a, CMD_GOTO);
    1.30 +		writeCommand(memory, a, 8);
    1.31 +		writeCommand(memory, a, 0);
    1.32 +		writeCommand(memory, a, 1);
    1.33 +		writeCommand(memory, a, 1);
    1.34 +		writeCommand(memory, a, CMD_SLEEP);
    1.35  		writeCommand(memory, a, CMD_END);
    1.36  	}
    1.37  
    1.38  
    1.39  
    1.40  	for (address_t i = 0; i < MEMORY_SIZE;) {
    1.41 +		wprintf(L"command %d = ", i);
    1.42  		command_t ch = readCommand(memory, i);
    1.43 -		wprintf(L"command %d = %d\n", i, ch);
    1.44 +		wprintf(L"%d\n", ch);
    1.45  
    1.46  		string command;
    1.47