diff --git a/README.md b/README.md deleted file mode 100644 index 209e5f0..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# undar-lang - -A statically-typed permacomputing-oriented language for the purpose of creating 3D programs that work on constrained systems, retro consoles, and the web. \ No newline at end of file diff --git a/README.org b/README.org new file mode 100644 index 0000000..72ee99c --- /dev/null +++ b/README.org @@ -0,0 +1,58 @@ +#+TITLE: Undâr Programming Language + +#+BEGIN_SRC +[ᚢ ᛫ ᛫ ᛫ + ᛫ ᚾ ᛫ ᛫ + ᛫ ᛫ ᛞ ᛫ + ᛫ ᛫ ᛫ ᚱ] +#+END_SRC + +* Philosophy + +Undâr conforms to permacomputing principles. + +Permacomputing as defined by the [[https://wiki.xxiivv.com/site/permacomputing.html][xxiivv wiki]]: "permacomputing encourages the maximization of hardware lifespan, minimization of energy usage and focuses on the use of already available computational resources. +it values maintenance and refactoring of systems to keep them efficient, instead of planned obsolescence, permacomputing practices planned longevity. +it is about using computation only when it has a strengthening effect on ecosystems." + +Undâr is designed to ensure that programs will last indefinitly, but it is likely they will only last 'a very long time'. + +The VM specification is the core of the language. It should be able to fit on a napkin and be able to be implemented in a weekend. + +This implementation of the VM is written in freestanding C89 to maximize the chance that obscure C compilers will be able to compile it. + +Once the VM is implemented it can be integrated into a architecutre specific code. + +Undâr is intended to run on anything with a C compiler. From constrained systems like: retro consoles, microcontrollers to the web using emscripten. + +* Getting Started + +** + +** Build (linux version) + +#+BEGIN_SRC sh +git clone https://git.alfrescocavern.com/zongor/undar-lang.git +cd undar-lang && ./build +#+END_SRC + +* Roadmap + +[[./ROADMAP.org][Compiler, Plex, Immidate mode GUI, Constructive solid geometry, Tunnels, Actor model]] + +* License + +[[./LICENSE][GPLv3]] + +* Inspirations + +- [[https://plan9.io/][Plan 9]] : 9P, Unified I/O, Tunnels. +- [[https://en.wikipedia.org/wiki/Lisp_(programming_language)][Lisp]] : REPL, introspection. +- [[https://fortran-lang.org/][Fortran]] : Array semantics. +- [[https://en.wikipedia.org/wiki/C_(programming_language)][C]] / [[https://ziglang.org/][Zig]] : Efficentcy, simplicity. +- [[https://lua.org][Lua]] - Friendly syntax, portable, and minimalism. +- [[https://www.craftinginterpreters.com/the-lox-language.html][Lox]] - The start of my programming language creation journey. +- [[https://wiki.xxiivv.com/site/uxn.html][Uxn]] - Major inspiration, espeically around the design for devices. +- [[http://duskos.org/][Dusk OS]] - A much better system for doing permacomputing. +- [[https://doc.cat-v.org/inferno/4th_edition/dis_VM_specification][Dis VM]] - Ideas on VM structure +- Retro Systems - N64, PS1, Mac Classic, Windows 95, Especially Classic MacOS UI esthetics diff --git a/ROADMAP.org b/ROADMAP.org new file mode 100644 index 0000000..c0e4a7a --- /dev/null +++ b/ROADMAP.org @@ -0,0 +1,2 @@ +#+TITLE Project Roadmap + diff --git a/SPECIFICATION.org b/SPECIFICATION.org new file mode 100644 index 0000000..066983d --- /dev/null +++ b/SPECIFICATION.org @@ -0,0 +1 @@ +#+TITLE Project Specification diff --git a/arch/linux/gui/main.c b/arch/linux/gui/main.c new file mode 100644 index 0000000..e69de29 diff --git a/arch/linux/tui/main.c b/arch/linux/tui/main.c new file mode 100644 index 0000000..e69de29 diff --git a/arch/web/main.c b/arch/web/main.c new file mode 100644 index 0000000..e69de29 diff --git a/build b/build new file mode 100644 index 0000000..13f4793 --- /dev/null +++ b/build @@ -0,0 +1,2 @@ +#!/bin/sh + diff --git a/imgs/convert.sh b/imgs/convert.sh new file mode 100755 index 0000000..5394537 --- /dev/null +++ b/imgs/convert.sh @@ -0,0 +1,3 @@ +#!/bin/sh +magick -background none -density 384 undar.svg -define icon:auto-resize favicon.ico +magick -background none -density 100 undar.svg -define icon:auto-resize undar.png \ No newline at end of file diff --git a/imgs/favicon.ico b/imgs/favicon.ico new file mode 100644 index 0000000..7a815a8 Binary files /dev/null and b/imgs/favicon.ico differ diff --git a/imgs/undar.png b/imgs/undar.png new file mode 100644 index 0000000..cb50d0b Binary files /dev/null and b/imgs/undar.png differ diff --git a/imgs/undar.svg b/imgs/undar.svg new file mode 100644 index 0000000..4e34255 --- /dev/null +++ b/imgs/undar.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + diff --git a/libc.c b/libc.c new file mode 100644 index 0000000..bee9c11 --- /dev/null +++ b/libc.c @@ -0,0 +1,68 @@ +#include "libc.h" + +void mcpy(u8 *to, const u8 *from, u32 length) { + u32 i; + if (to == nil || from == nil) return; + for (i = 0; i < length; i++) { + to[i] = from[i]; + } + return; +} + +i32 scpy(char *to, const char *from, u32 length) { + u32 i; + if (to == nil || from == nil) return -1; + if (length == 0) {return 0;} + for (i = 0; i < length - 1 && from[i] != '\0'; i++) { + to[i] = from[i]; + } + to[i] = '\0'; + return 0; +} + +bool seq(const char *s1, const char *s2) { + if (s1 == nil && s2 == nil) return true; + if (s1 == nil || s2 == nil) return false; + + while (*s1 && *s2) { + if (*s1 != *s2) return false; + s1++; + s2++; + } + + return (*s1 == '\0' && *s2 == '\0'); +} + +bool sleq(const char *s1, const char *s2, u32 length) { + u32 i; + if (s1 == nil && s2 == nil) return true; + if (s1 == nil || s2 == nil) return false; + + i = 0; + while (i < length && *s1 && *s2) { + if (*s1 != *s2) return false; + s1++; + s2++; + i++; + } + if (i == length) return true; + return (*s1 == '\0' && *s2 == '\0'); +} + +u32 slen(const char *str) { + u32 i; + if (str == nil) {return 0;} + for (i = 0; str[i] != '\0'; i++) { + ; + } + return i; +} + +u32 snlen(const char *str, u32 max_len) { + u32 i; + if (str == nil) {return 0;} + for (i = 0; i < max_len && str[i] != '\0'; i++) { + ; + } + return i; +} diff --git a/libc.h b/libc.h new file mode 100644 index 0000000..89d702e --- /dev/null +++ b/libc.h @@ -0,0 +1,33 @@ +#ifndef UNDAR_LIBC_H +#define UNDAR_LIBC_H + +#include +#include + +typedef uint8_t u8; +typedef int8_t i8; +typedef uint16_t u16; +typedef int16_t i16; +typedef uint32_t u32; +typedef int32_t i32; +typedef float f32; + +#define true 1 +#define false 0 +#define bool u8 + +#define nil NULL + +#define USED(x) ((void)(x)) + +#define AS_INT(v) ((i32)(v)) +#define AS_NAT(v) ((u32)(v)) + +void mcpy(u8 *dest, const u8 *src, u32 n); +i32 scpy(char* to, const char *from, u32 length); +bool seq(const char *s1, const char *s2); +bool sleq(const char *s1, const char *s2, u32 length); +u32 slen(const char *str); +u32 snlen(const char *str, u32 max_len); + +#endif diff --git a/vm.c b/vm.c new file mode 100644 index 0000000..e69de29 diff --git a/vm.h b/vm.h new file mode 100644 index 0000000..9ea32e8 --- /dev/null +++ b/vm.h @@ -0,0 +1,22 @@ +#ifndef UNDAR_VM_H +#define UNDAR_VM_H + +#include "libc.h" + +typedef enum { + NOOP, +} Opcode; + +typedef struct vm_s VM; + +#define MEM_SIZE 65536 + +struct vm_s { + u32 pc; + u8 mem[MEM_SIZE]; +}; + +bool init_vm(VM *vm); +bool step_vm(VM *vm); + +#endif