From aa4a3b86143250ff958ca66e77d6097aff8d42a1 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 23 Oct 2023 03:59:34 +0100 Subject: Implemented simple example of a for loop in main --- vm/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'vm') 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); } -- cgit v1.2.3-13-gbd6f