This commit is contained in:
able 2024-05-03 12:24:03 -05:00
commit d44f3f30c8
5 changed files with 113 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build/*

1
build.sh Normal file
View file

@ -0,0 +1 @@
./build/hbas < lasp.S > build/lasp.hbf

81
lasp.S Normal file
View file

@ -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 "'"

21
license.md Normal file
View file

@ -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.

9
readme.md Normal file
View file

@ -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