aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 6f468cb..30abda7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,6 +12,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
typedef uint64_t u64;
typedef uint32_t u32;
@@ -34,6 +35,22 @@ typedef struct
} stack;
} vm_t;
+void vm_push_byte(vm_t *vm, byte b)
+{
+ if (vm->stack.pointer >= VM_STACK_MAX)
+ return;
+ vm->stack.data[vm->stack.pointer++] = b;
+}
+
+void vm_push_word(vm_t *vm, word w)
+{
+ // NOTE: Relies on sizeof measuring in bytes
+ if (vm->stack.pointer + sizeof(w) >= VM_STACK_MAX)
+ return;
+ memcpy(vm->stack.data + vm->stack.pointer, &w, sizeof(w));
+ vm->stack.pointer += sizeof(w);
+}
+
int main(void)
{
puts("Hello, world!");