logo!!!! :D (thanks Max)

This commit is contained in:
SpookyDervish
2025-12-20 18:25:53 +11:00
parent b12998afa6
commit 76be037e32
6 changed files with 123 additions and 19 deletions

View File

@@ -3,20 +3,16 @@
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]));
VMBL_Instruction program[] = {
MAKE_INST_PUSH(123),
MAKE_INST_PUSH(0),
MAKE_INST_PUSH(1),
MAKE_INST_DUP(1),
MAKE_INST_DUP(1),
MAKE_INST_ADD,
MAKE_INST_JMP(2),
MAKE_INST_DIV,
};
int main() {
VMBL_State vmblState = {};
VMBL_LoadExecutable(&vmblState, program, sizeof(program));
VMBL_SaveExecutable("fib.vmbl", program, sizeof(program));
//VMBL_LoadExecutable(&vmblState, program, sizeof(program));
//VMBL_SaveExecutable("fib.vmbl", program, sizeof(program));
VMBL_LoadExecutableFromFile(&vmblState, "fib.vmbl");
VMBL_StartVM(&vmblState);

View File

@@ -61,15 +61,18 @@ typedef struct
bool halted;
} VMBL_State;
#define MAKE_INST_PUSH(value) (VMBL_Instruction) { .type = INSTRUCTION_PUSH, .opperands[0] = (value) }
#define MAKE_INST_POP (VMBL_Instruction) { .type = INSTRUCTION_POP, }
#define MAKE_INST_ADD (VMBL_Instruction) { .type = INSTRUCTION_ADD }
#define MAKE_INST_DUP(value) (VMBL_Instruction) { .type = INSTRUCTION_DUPLICATE, .opperands[0] = (value) }
#define MAKE_INST_JMP(value) (VMBL_Instruction) { .type = INSTRUCTION_JUMP , .opperands[0] = (value) }
#define MAKE_INST_HALT (VMBL_Instruction) { .type = INSTRUCTION_HALT }
#define MAKE_INST_EQUAL(stack1, stack2) (VMBL_Instruction) { .type = INSTRUCTION_EQUAL, .opperands[0] = (stack1), .opperands[1] = (stack2) }
#define MAKE_INST_EQUAL_TOP (VMBL_Instruction) { .type = INSTRUCTION_EQUAL_TOP }
#define MAKE_INST_JUMP_CONDITIONAL(value) (VMBL_Instruction) { .type = INSTRUCTION_JUMP_CONDITIONAL, .opperands[0] = (value) }
#define MAKE_INST_PUSH(value) (VMBL_Instruction) { .type = INSTRUCTION_PUSH, .opperands[0] = (value) }
#define MAKE_INST_POP (VMBL_Instruction) { .type = INSTRUCTION_POP }
#define MAKE_INST_ADD (VMBL_Instruction) { .type = INSTRUCTION_ADD }
#define MAKE_INST_SUB (VMBL_Instruction) { .type = INSTRUCTION_SUB }
#define MAKE_INST_MUL (VMBL_Instruction) { .type = INSTRUCTION_MUL }
#define MAKE_INST_DIV (VMBL_Instruction) { .type = INSTRUCTION_DIV }
#define MAKE_INST_DUP(value) (VMBL_Instruction) { .type = INSTRUCTION_DUPLICATE, .opperands[0] = (value) }
#define MAKE_INST_JMP(value) (VMBL_Instruction) { .type = INSTRUCTION_JUMP, .opperands[0] = (value) }
#define MAKE_INST_HALT (VMBL_Instruction) { .type = INSTRUCTION_HALT }
#define MAKE_INST_EQUAL(stack1, stack2) (VMBL_Instruction) { .type = INSTRUCTION_EQUAL, .opperands[0] = (stack1), .opperands[1] = (stack2) }
#define MAKE_INST_EQUAL_TOP (VMBL_Instruction) { .type = INSTRUCTION_EQUAL_TOP }
#define MAKE_INST_JUMP_CONDITIONAL(value) (VMBL_Instruction) { .type = INSTRUCTION_JUMP_CONDITIONAL, .opperands[0] = (value) }
VMBL_Exception VBML_ExecuteInstruction(VMBL_State *vmblState, VMBL_Instruction instruction);
void VMBL_Dump(VMBL_State vmblState, VMBL_Exception exception);