# HG changeset patch # User František Kučera # Date 1513865857 -3600 # Node ID ac1c16f0ebcd210666f239ab57680d1a6fa16a75 # Parent ee60ce4d8af502fd34e2a4ab031fdeb03941f94c increment index in th read function diff -r ee60ce4d8af5 -r ac1c16f0ebcd c++/rgb-assembler/rgb-assembler.cpp --- a/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 13:30:54 2017 +0100 +++ b/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 15:17:37 2017 +0100 @@ -15,16 +15,19 @@ const command_t CMD_SLEEP = 101; const command_t CMD_END = 102; -command_t readCommand(command_t (&memory)[MEMORY_SIZE], const address_t index) { +/** + * Reads the command on given position in memory and increments the index (position). + */ +command_t readCommand(command_t(&memory)[MEMORY_SIZE], address_t &index) { // TODO: map higher memory to static hardcoded areas or peripherals - return memory[index]; + return memory[index++]; } -void writeMemoryChar(command_t (&memory)[MEMORY_SIZE], const address_t index, const int value) { +void writeMemoryChar(command_t(&memory)[MEMORY_SIZE], address_t &index, const int value) { memory[index] = value; } -void writeMemoryChar(command_t* memory[], const address_t index, const command_t value) { +void writeMemoryChar(command_t* memory[], address_t &index, const command_t value) { *memory[index] = value; } @@ -42,7 +45,7 @@ address_t memorySize = sizeof (memory) / sizeof (*memory); - for (address_t i = 0; i < memorySize; i++) { + for (address_t i = 0; i < memorySize;) { command_t ch = readCommand(memory, i); wprintf(L"command %d = %d\n", i, ch);