aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 21b31c2..7740d52 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,12 +3,19 @@
#include "fvm.h"
+static void printnum(struct fvm *vm) {
+ int64_t n = fvm_pop(vm);
+ printf("%lld\n", n);
+}
+
int main(int argc, char **argv) {
struct fvm vm;
if (argc < 2) {
fprintf(stderr, "Usage: fvm <program-file>\n");
return -1;
}
+ vm.syscall_table = malloc(256 * sizeof(fvm_syscall_fn_t));
+ vm.syscall_table[1] = &printnum;
FILE* fp = fopen(argv[1], "rb");
if (fp == NULL) {
fprintf(stderr, "Failed to open file.\n");