9 typedef uint16_t address_t;
10 typedef uint8_t command_t;
12 const address_t MEMORY_SIZE = 1024;
14 const command_t CMD_GOTO = 100;
15 const command_t CMD_SLEEP = 101;
16 const command_t CMD_END = 102;
19 * Reads the command on given position in memory and increments the index (position).
21 command_t readCommand(command_t(&memory)[MEMORY_SIZE], address_t &index) {
22 // TODO: map higher memory to static hardcoded areas or peripherals
23 return memory[index++];
26 void writeMemoryChar(command_t(&memory)[MEMORY_SIZE], address_t &index, const int value) {
27 memory[index] = value;
30 void writeMemoryChar(command_t* memory[], address_t &index, const command_t value) {
31 *memory[index] = value;
34 int main(int argc, char* argv[]) {
36 setlocale(LC_ALL, "");
39 command_t memory[MEMORY_SIZE] = {
45 address_t memorySize = sizeof (memory) / sizeof (*memory);
48 for (address_t i = 0; i < memorySize;) {
49 command_t ch = readCommand(memory, i);
50 wprintf(L"command %d = %d\n", i, ch);
56 command.append("GOTO");
59 command.append("SLEEP");
62 command.append("END");
68 if (!command.empty()) {
69 wprintf(L"\t%s\n", command.c_str());
75 wprintf(L"all done\n");