1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 17:06:39 2017 +0100
1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 17:18:22 2017 +0100
1.3 @@ -21,13 +21,13 @@
1.4 command_t readCommand(command_t * memory, address_t &index) {
1.5 // TODO: map higher memory to static hardcoded areas or peripherals
1.6 command_t * value = reinterpret_cast<command_t*> (memory + index);
1.7 - index += sizeof (*value);
1.8 + index += sizeof (*value) / sizeof (command_t);
1.9 return *value;
1.10 }
1.11
1.12 address_t readAddress(command_t * memory, address_t &index) {
1.13 address_t * value = reinterpret_cast<address_t*> (memory + index);
1.14 - index += sizeof (*value);
1.15 + index += sizeof (*value) / sizeof (command_t);
1.16 return *value;
1.17 }
1.18
1.19 @@ -39,7 +39,14 @@
1.20 // command_t * m = (command_t*) (memory + index);
1.21 command_t * m = reinterpret_cast<command_t*> (memory + index);
1.22 *m = value;
1.23 - index += sizeof (value);
1.24 + index += sizeof (value) / sizeof (command_t);
1.25 +}
1.26 +
1.27 +void writeAddress(command_t * memory, address_t &index, const address_t value) {
1.28 + // command_t * m = (command_t*) (memory + index);
1.29 + address_t * m = reinterpret_cast<address_t*> (memory + index);
1.30 + *m = value;
1.31 + index += sizeof (value) / sizeof (command_t);
1.32 }
1.33
1.34 int main(int argc, char* argv[]) {
1.35 @@ -54,8 +61,7 @@
1.36 writeCommand(memory, a, CMD_SLEEP);
1.37 writeCommand(memory, a, CMD_SLEEP);
1.38 writeCommand(memory, a, CMD_GOTO);
1.39 - writeCommand(memory, a, 8);
1.40 - writeCommand(memory, a, 0);
1.41 + writeAddress(memory, a, 8);
1.42 writeCommand(memory, a, 1);
1.43 writeCommand(memory, a, 1);
1.44 writeCommand(memory, a, CMD_SLEEP);