diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-16 11:32:20 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-16 11:32:20 +0100 |
commit | e7616cdeb615772c07aba6aae506a969ad2546fb (patch) | |
tree | 7890cd59615a89cbde4317570b5ad57a7840723b /src/main.c | |
parent | 7380dd375a31463bc9f0d78305d7e3fbc6e86020 (diff) | |
download | ovm-e7616cdeb615772c07aba6aae506a969ad2546fb.tar.gz ovm-e7616cdeb615772c07aba6aae506a969ad2546fb.tar.bz2 ovm-e7616cdeb615772c07aba6aae506a969ad2546fb.zip |
Made a sample program, loaded into VM and executed
Seems pretty nice to use, and it works according to GDB.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -13,6 +13,7 @@ #include <stdio.h> #include <string.h> +#include "./inst.h" #include "./runtime.h" int main(void) @@ -20,5 +21,14 @@ int main(void) 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); return 0; } |