Implemented simple example of a for loop in main

This commit is contained in:
2023-10-23 03:59:34 +01:00
parent b44a61be41
commit aa4a3b8614

View File

@@ -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);
}