commit d44f3f30c87c0a55ea8eaec0df7ad9742e8729c9 Author: able Date: Fri May 3 12:24:03 2024 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ed706 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..973dd84 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +./build/hbas < lasp.S > build/lasp.hbf diff --git a/lasp.S b/lasp.S new file mode 100644 index 0000000..4bb3c4d --- /dev/null +++ b/lasp.S @@ -0,0 +1,81 @@ +; r12 will be the char of the value of the current ptr +li64 r12, 0 +; r13 will be the offset into the lisp_expr label +li64 r13, 0 +;; r253 will be the offset from the stack pointer specified by the spec to be r254 +li64 r253, 0 + + +ldr r12, r13, lisp, 1 + +loop: + ; zero r15 + li64 r15, 0 + + ; Check if the char is a ( + li64 r15, 0x28 + ; if equal jump to open_paren + jeq r12, r15, open_paren + + ; check if the char is ) + li64 r15, 0x29 + ; if equal jump to closed_paren + jeq r12, r15, closed_paren + + ; move the char into r2 + cp r2, r12 + ; push the char onto the stack + jmp push_u64_stack + + jmp loop + +tx + + +;; push r2 into the stack +push_u64_stack: + ;; store r2 -> r254 + r253 with size 8 + st r2, r254, r253, 8 + li64 r252, 8 + add64 r253, r253, r252 + jmp inc_ptr_ld_char + + +;; pop the head of the stack into r2 +pop_u64_stack: + ;; load r2 <- r254 + r253 with size 8 + ld r2, r254, r253, 8 + li64 r252, 8 + sub64 r253, r253, r252 + ; jmp inc_ptr_ld_char + +inc_ptr_ld_char: + ; inc ptr + addi64 r13, r13, 1 + ; load next char + ldr r12, r13, lisp, 1 + jmp loop + +open_paren: + jmp inc_ptr_ld_char + +closed_paren: + un + +eval_stack: + jmp pop_u64_stack + jmp panic + +panic: + tx + +lisp: + .db "(+ 1 2 3 4 5 6 7 8 9 10)" + .db "(define a (λ () (+ 1 2 3)))" + .db "(a)" + +builtin_lambda: + .db "λ" + +builtin_quote: + .db "'" \ No newline at end of file diff --git a/license.md b/license.md new file mode 100644 index 0000000..f8fbe34 --- /dev/null +++ b/license.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Able + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..ed0e885 --- /dev/null +++ b/readme.md @@ -0,0 +1,9 @@ +# Lasp +Lasp is a lisp interpreter inplemented in htasm for the purpose of running simple lisp expressions on ableOS. + +## How to use? +compile https://github.com/m1el/holey-toys and move hbas into the build dir + +run ./build.sh + +then move lasp.hbf onto an ableOS disk image \ No newline at end of file