diff -r 000000000000 -r ee60ce4d8af5 c++/rgb-assembler/rgb-assembler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/rgb-assembler/rgb-assembler.cpp Thu Dec 21 13:30:54 2017 +0100 @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include + +using namespace std; + +typedef uint16_t address_t; +typedef uint8_t command_t; + +const address_t MEMORY_SIZE = 1024; + +const command_t CMD_GOTO = 100; +const command_t CMD_SLEEP = 101; +const command_t CMD_END = 102; + +command_t readCommand(command_t (&memory)[MEMORY_SIZE], const address_t index) { + // TODO: map higher memory to static hardcoded areas or peripherals + return memory[index]; +} + +void writeMemoryChar(command_t (&memory)[MEMORY_SIZE], const address_t index, const int value) { + memory[index] = value; +} + +void writeMemoryChar(command_t* memory[], const address_t index, const command_t value) { + *memory[index] = value; +} + +int main(int argc, char* argv[]) { + + setlocale(LC_ALL, ""); + + + command_t memory[MEMORY_SIZE] = { + CMD_SLEEP, + CMD_SLEEP, + CMD_SLEEP, + CMD_END, + }; + address_t memorySize = sizeof (memory) / sizeof (*memory); + + + for (address_t i = 0; i < memorySize; i++) { + command_t ch = readCommand(memory, i); + wprintf(L"command %d = %d\n", i, ch); + + string command; + + switch (ch) { + case CMD_GOTO: + command.append("GOTO"); + break; + case CMD_SLEEP: + command.append("SLEEP"); + break; + case CMD_END: + command.append("END"); + i = memorySize; + break; + + } + + if (!command.empty()) { + wprintf(L"\t%s\n", command.c_str()); + } + } + + + + wprintf(L"all done\n"); + return 0; +} +