diff --git a/README.md b/README.md index 1277c20..c19d7c1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ +![Sylt Logo](assets/sylt.png) # VMBL -virtual machine based language lol +- Virtual +- Machine +- Based +- Language -to compile: `gcc src/main.c src/vmbl.c src/exception.c -o VMBL -O3` \ No newline at end of file +But uhh that's the name of the VM itself, the name of the programming language I made is Sylt, named after the German island. + +To compile for Linux: `gcc src/main.c src/vmbl.c src/exception.c -o VMBL -O3` + +## Syntax +### Example "Hello, World!" Program +```kotlin +fun main() { + println("Hello, World!\n") +} +``` \ No newline at end of file diff --git a/assets/sylt.png b/assets/sylt.png new file mode 100644 index 0000000..467f325 Binary files /dev/null and b/assets/sylt.png differ diff --git a/assets/sylt.svg b/assets/sylt.svg new file mode 100644 index 0000000..0a6f93b --- /dev/null +++ b/assets/sylt.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/sylt/hello_world.sylt b/examples/sylt/hello_world.sylt new file mode 100644 index 0000000..78478fb --- /dev/null +++ b/examples/sylt/hello_world.sylt @@ -0,0 +1,3 @@ +fun main() { + println("Hello, World!\n") +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index f3d35ab..8aadbb2 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/vmbl.h b/src/vmbl.h index aee8703..24e869f 100644 --- a/src/vmbl.h +++ b/src/vmbl.h @@ -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);