aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 03:59:34 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 03:59:34 +0100
commitaa4a3b86143250ff958ca66e77d6097aff8d42a1 (patch)
tree114d1ef4da705d758ecf91d36b7a0a1034b53393
parentb44a61be41e44b415b1293fcbc1f1e8c4ce3373d (diff)
downloadovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.tar.gz
ovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.tar.bz2
ovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.zip
Implemented simple example of a for loop in main
-rw-r--r--vm/main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/vm/main.c b/vm/main.c
index 005b61e..db9e313 100644
--- a/vm/main.c
+++ b/vm/main.c
@@ -56,7 +56,16 @@ int main(int argc, char *argv[])
const char *filename = "out.bin";
if (argc >= 2)
filename = argv[1];
- inst_t instructions[] = {INST_HALT};
+
+ inst_t instructions[] = {
+ INST_PUSH(BYTE, 0), INST_MOV(BYTE, 0),
+
+ INST_PUSH_REG(BYTE, 0), INST_PUSH(BYTE, 1), INST_PLUS(BYTE),
+ INST_MOV(BYTE, 0),
+
+ INST_PUSH_REG(BYTE, 0), INST_PUSH(BYTE, 5), INST_EQ(BYTE),
+ INST_NOT(BYTE), INST_JUMP_IF(BYTE, 2), INST_HALT,
+ };
assemble_instructions(instructions, ARR_SIZE(instructions), filename);
return interpret_bytecode(filename);
}