aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 19:33:27 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 19:33:44 +0100
commitd5d10480fad1711dd69467eff4dff4cba71954f8 (patch)
tree24a0b9122f520d367484dcd45f5a7936f3e0f60d /src/main.c
parent33364fddabb25b2e419a672b80ee1f2bf3e82f68 (diff)
downloadovm-d5d10480fad1711dd69467eff4dff4cba71954f8.tar.gz
ovm-d5d10480fad1711dd69467eff4dff4cba71954f8.tar.bz2
ovm-d5d10480fad1711dd69467eff4dff4cba71954f8.zip
Simple program which assembles instructions then executes them
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index c99ffb8..f66848c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,19 +42,13 @@ int assemble_instructions(inst_t *instructions, size_t number,
return 0;
}
-int main(void)
+int main(int argc, char *argv[])
{
- byte stack_data[256];
- vm_t vm = {0};
- vm_load_stack(&vm, stack_data, ARR_SIZE(stack_data));
- inst_t instructions[] = {
- INST_BPUSH(0xfa), INST_BMOV(0), INST_BPUSH(0xfb),
- INST_BMOV(1), INST_BPUSH(0xfc), INST_BMOV(2),
- INST_BPUSH(0xfd), INST_BMOV(3), INST_BPUSH_REG(3),
- INST_BPUSH_REG(2), INST_BPUSH_REG(1), INST_BPUSH_REG(0),
- };
- vm_load_program(&vm, instructions, ARR_SIZE(instructions));
- for (size_t i = 0; i < ARR_SIZE(instructions); ++i)
- vm_execute(&vm);
+ const char *filename = "out.bin";
+ if (argc >= 2)
+ filename = argv[1];
+ inst_t instructions[] = {INST_HALT};
+ assemble_instructions(instructions, ARR_SIZE(instructions), filename);
+ interpret_bytecode(filename);
return 0;
}