diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 03:59:34 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-23 03:59:34 +0100 |
commit | aa4a3b86143250ff958ca66e77d6097aff8d42a1 (patch) | |
tree | 114d1ef4da705d758ecf91d36b7a0a1034b53393 | |
parent | b44a61be41e44b415b1293fcbc1f1e8c4ce3373d (diff) | |
download | ovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.tar.gz ovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.tar.bz2 ovm-aa4a3b86143250ff958ca66e77d6097aff8d42a1.zip |
Implemented simple example of a for loop in main
-rw-r--r-- | vm/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); } |