1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 13:30:54 2017 +0100
1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 15:17:37 2017 +0100
1.3 @@ -15,16 +15,19 @@
1.4 const command_t CMD_SLEEP = 101;
1.5 const command_t CMD_END = 102;
1.6
1.7 -command_t readCommand(command_t (&memory)[MEMORY_SIZE], const address_t index) {
1.8 +/**
1.9 + * Reads the command on given position in memory and increments the index (position).
1.10 + */
1.11 +command_t readCommand(command_t(&memory)[MEMORY_SIZE], address_t &index) {
1.12 // TODO: map higher memory to static hardcoded areas or peripherals
1.13 - return memory[index];
1.14 + return memory[index++];
1.15 }
1.16
1.17 -void writeMemoryChar(command_t (&memory)[MEMORY_SIZE], const address_t index, const int value) {
1.18 +void writeMemoryChar(command_t(&memory)[MEMORY_SIZE], address_t &index, const int value) {
1.19 memory[index] = value;
1.20 }
1.21
1.22 -void writeMemoryChar(command_t* memory[], const address_t index, const command_t value) {
1.23 +void writeMemoryChar(command_t* memory[], address_t &index, const command_t value) {
1.24 *memory[index] = value;
1.25 }
1.26
1.27 @@ -42,7 +45,7 @@
1.28 address_t memorySize = sizeof (memory) / sizeof (*memory);
1.29
1.30
1.31 - for (address_t i = 0; i < memorySize; i++) {
1.32 + for (address_t i = 0; i < memorySize;) {
1.33 command_t ch = readCommand(memory, i);
1.34 wprintf(L"command %d = %d\n", i, ch);
1.35