save and load compiled vmbl files

This commit is contained in:
SpookyDervish
2025-12-20 13:29:49 +11:00
parent f97ef75445
commit c88a6a993d
6 changed files with 186 additions and 22 deletions

View File

@@ -4,21 +4,20 @@
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]));
VMBL_Instruction program[] = {
MAKE_INST_PUSH(69),
MAKE_INST_PUSH(420),
MAKE_INST_PUSH(0),
MAKE_INST_PUSH(1),
MAKE_INST_DUP(1),
MAKE_INST_DUP(1),
MAKE_INST_ADD,
MAKE_INST_JMP(2)
};
int main() {
VMBL_State vmblState = {};
for (size_t i = 0; i < ARRAY_SIZE(program) i++) {
VMBL_Exception exception = VBML_ExecuteInstruction(&vmblState, program[i]);
if (exception.type != EXCEPTION_NONE) {
VMBL_Dump(vmblState, exception);
return 1;
}
}
VMBL_LoadExecutable(&vmblState, program, sizeof(program));
//VMBL_SaveExecutable("fib.vmbl", program, sizeof(program));
//VMBL_LoadExecutableFromFile(&vmblState, "fib.vmbl");
VMBL_StartVM(&vmblState);
return 0;
}