--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+
+#include "opcodes.h"
+
+uint16_t regs[256];
+uint16_t mem[65536];
+
+uint16_t stack[256];
+uint8_t stack_pointer;
+
+uint16_t current_instruction = 0; // entry location
+bool halted = false;
+uint8_t halted_reason = 0;
+
+uint64_t instruction_counter = 0;
+
+
+
+void load_mem()
+{
+ mem[0] = (uint16_t)4 << 8 | 0;
+ mem[1] = 1234;
+
+ mem[2] = (uint16_t)4 << 8 | 1;
+ mem[3] = 1000;
+
+ mem[6] = (uint16_t)1 << 8 | 0;
+ mem[7] = (uint16_t)1 << 8 | 0;
+
+ mem[8] = (uint16_t)9 << 8 | 0;
+ mem[9] = 0;
+}
+
+
+
+int main(int argc, char *argv[])
+{
+ load_mem();
+ while(!halted)
+ {
+ uint8_t arg1 = (uint8_t)mem[current_instruction];
+ uint8_t instruction = (uint8_t)(mem[current_instruction] >> 8);
+ uint8_t arg3 = (uint8_t)mem[current_instruction + 1];
+ uint8_t arg2 = (uint8_t)(mem[current_instruction + 1] >> 8);
+ printf("Executing at 0x%04x; Instruction number %ld\r", current_instruction, instruction_counter);
+ fflush(stdout);
+ (*opcodes[instruction]) (arg1, arg2, arg3);
+ instruction_counter++;
+ }
+ printf("Execution halted: cause %d\n", halted_reason);
+
+}