Release 0.0.9
This commit is contained in:
parent
9be2763c40
commit
c06faa77e0
|
@ -43,6 +43,8 @@ Added string? primitive to stage2 lisp
|
||||||
Added make_string internal function to stage2 lisp
|
Added make_string internal function to stage2 lisp
|
||||||
Added list->string primitive to stage2 lisp
|
Added list->string primitive to stage2 lisp
|
||||||
Added number? and symbol? to stage2 lisp
|
Added number? and symbol? to stage2 lisp
|
||||||
|
Added apply to stage2 lisp
|
||||||
|
Imported ascension.scm library
|
||||||
|
|
||||||
** Changed
|
** Changed
|
||||||
Minor refactor of stage3 FORTH by reepa
|
Minor refactor of stage3 FORTH by reepa
|
||||||
|
|
|
@ -152,7 +152,7 @@ Then we use our M0 Line macro assembler to convert our assembly into hex2 format
|
||||||
Then we need to assemble that hex into our desired program:
|
Then we need to assemble that hex into our desired program:
|
||||||
./bin/vm --rom roms/stage1_assembler-2 --tape_01 temp2 --tape_02 roms/lisp --memory 48K
|
./bin/vm --rom roms/stage1_assembler-2 --tape_01 temp2 --tape_02 roms/lisp --memory 48K
|
||||||
|
|
||||||
roms/lisp should have the sha256sum of cb66731da407aae0e9868349b6f727184cab7d4da505bec24e3807e470432d58
|
roms/lisp should have the sha256sum of 7c3887f791999aa9c1b8415d8e5be93afcf916b505296d9da7bd7a22531a84b5
|
||||||
|
|
||||||
Our lisp will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in.
|
Our lisp will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in.
|
||||||
It is recommended to run with no less than 4MB of Memory
|
It is recommended to run with no less than 4MB of Memory
|
||||||
|
|
|
@ -1447,9 +1447,29 @@
|
||||||
RET R15
|
RET R15
|
||||||
|
|
||||||
|
|
||||||
;; nullp
|
;; prim_apply
|
||||||
;; Recieves a CELL in R0
|
;; Recieves arglist in R0
|
||||||
;; Returns NIL if not NIL or TEE if NIL
|
;; Returns result of applying ARGS->CAR to ARGS->CDR->CAR
|
||||||
|
:prim_apply_String
|
||||||
|
"apply"
|
||||||
|
:prim_apply
|
||||||
|
CMPSKIPI.NE R0 $NIL ; If NIL Expression
|
||||||
|
RET R15 ; Just get the Hell out
|
||||||
|
PUSHR R1 R15 ; Protect R1
|
||||||
|
|
||||||
|
LOAD32 R1 R0 8 ; Get ARGS->CDR
|
||||||
|
LOAD32 R1 R1 4 ; Get ARGS->CDR->CAR
|
||||||
|
LOAD32 R0 R0 4 ; Get ARGS->CAR
|
||||||
|
CALLI R15 @apply ; Use backing function
|
||||||
|
|
||||||
|
;; Cleanup
|
||||||
|
POPR R1 R15 ; Restore R1
|
||||||
|
RET R15
|
||||||
|
|
||||||
|
|
||||||
|
;; nullp
|
||||||
|
;; Recieves a CELL in R0
|
||||||
|
;; Returns NIL if not NIL or TEE if NIL
|
||||||
:nullp_String
|
:nullp_String
|
||||||
"null?"
|
"null?"
|
||||||
:nullp
|
:nullp
|
||||||
|
@ -2640,6 +2660,13 @@
|
||||||
CALLI R15 @spinup ; SPINUP
|
CALLI R15 @spinup ; SPINUP
|
||||||
|
|
||||||
;; Add Primitive Specials
|
;; Add Primitive Specials
|
||||||
|
LOADUI R0 $prim_apply ; Using PRIM_APPLY
|
||||||
|
CALLI R15 @make_prim ; MAKE_PRIM
|
||||||
|
MOVE R1 R0 ; Put Primitive in correct location
|
||||||
|
LOADUI R0 $prim_apply_String ; Using PRIM_APPLY_STRING
|
||||||
|
CALLI R15 @make_sym ; MAKE_SYM
|
||||||
|
CALLI R15 @spinup ; SPINUP
|
||||||
|
|
||||||
LOADUI R0 $nullp ; Using NULLP
|
LOADUI R0 $nullp ; Using NULLP
|
||||||
CALLI R15 @make_prim ; MAKE_PRIM
|
CALLI R15 @make_prim ; MAKE_PRIM
|
||||||
MOVE R1 R0 ; Put Primitive in correct location
|
MOVE R1 R0 ; Put Primitive in correct location
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
;; Copyright (C) 2017 Jeremiah Orians
|
||||||
|
;; This file is part of stage0.
|
||||||
|
;;
|
||||||
|
;; stage0 is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; stage0 is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;; 2 level car/cdr
|
||||||
|
(define caar (lambda (x) (car (car x))))
|
||||||
|
(define cadr (lambda (x) (car (cdr x))))
|
||||||
|
(define cdar (lambda (x) (cdr (car x))))
|
||||||
|
(define cddr (lambda (x) (cdr (cdr x))))
|
||||||
|
|
||||||
|
; 3 level car/cdr
|
||||||
|
(define caaar (lambda (x) (car (car (car x)))))
|
||||||
|
(define caadr (lambda (x) (car (car (cdr x)))))
|
||||||
|
(define cadar (lambda (x) (car (cdr (car x)))))
|
||||||
|
(define caddr (lambda (x) (car (cdr (cdr x)))))
|
||||||
|
(define cdaar (lambda (x) (cdr (car (car x)))))
|
||||||
|
(define cdadr (lambda (x) (cdr (car (cdr x)))))
|
||||||
|
(define cddar (lambda (x) (cdr (cdr (car x)))))
|
||||||
|
(define cdddr (lambda (x) (cdr (cdr (cdr x)))))
|
||||||
|
|
||||||
|
; 4 level car/cdr
|
||||||
|
(define caaaar (lambda (x) (car (car (car (car x))))))
|
||||||
|
(define caaadr (lambda (x) (car (car (car (cdr x))))))
|
||||||
|
(define caadar (lambda (x) (car (car (cdr (car x))))))
|
||||||
|
(define caaddr (lambda (x) (car (car (cdr (cdr x))))))
|
||||||
|
(define cadaar (lambda (x) (car (cdr (car (car x))))))
|
||||||
|
(define cadadr (lambda (x) (car (cdr (car (cdr x))))))
|
||||||
|
(define caddar (lambda (x) (car (cdr (cdr (car x))))))
|
||||||
|
(define cadddr (lambda (x) (car (cdr (cdr (cdr x))))))
|
||||||
|
(define cdaaar (lambda (x) (cdr (car (car (car x))))))
|
||||||
|
(define cdaadr (lambda (x) (cdr (car (car (cdr x))))))
|
||||||
|
(define cdadar (lambda (x) (cdr (car (cdr (car x))))))
|
||||||
|
(define cdaddr (lambda (x) (cdr (car (cdr (cdr x))))))
|
||||||
|
(define cddaar (lambda (x) (cdr (cdr (car (car x))))))
|
||||||
|
(define cddadr (lambda (x) (cdr (cdr (car (cdr x))))))
|
||||||
|
(define cdddar (lambda (x) (cdr (cdr (cdr (car x))))))
|
||||||
|
(define cddddr (lambda (x) (cdr (cdr (cdr (cdr x))))))
|
||||||
|
|
||||||
|
; Append
|
||||||
|
(define append
|
||||||
|
(lambda (x y)
|
||||||
|
(cond
|
||||||
|
((null? x) y)
|
||||||
|
(#t (cons (car x) (append (cdr x) y))))))
|
||||||
|
(define string-append (lambda (x y) (list->string (append (string->list x) (string->list y)))))
|
||||||
|
|
||||||
|
; Assoc
|
||||||
|
(define assoc
|
||||||
|
(lambda (x y)
|
||||||
|
(cond
|
||||||
|
((string=? (caar y) x) (car y))
|
||||||
|
(#t (assoc x (cdr y))))))
|
||||||
|
|
||||||
|
; Get-index
|
||||||
|
(define get-index
|
||||||
|
(lambda (number list)
|
||||||
|
(if (null? list)
|
||||||
|
nil
|
||||||
|
(if (= 0 number)
|
||||||
|
(car list)
|
||||||
|
(get-index (- number 1) (cdr list))))))
|
||||||
|
|
||||||
|
; Reverse
|
||||||
|
(define reverse
|
||||||
|
(lambda (l)
|
||||||
|
(begin
|
||||||
|
(define reving
|
||||||
|
(lambda (list result)
|
||||||
|
(cond
|
||||||
|
((null? list) result)
|
||||||
|
((list? list) (reving (cdr list) (cons (car list) result)))
|
||||||
|
(#t (cons list result)))))
|
||||||
|
(reving l nil))))
|
||||||
|
|
||||||
|
; Map
|
||||||
|
(define map
|
||||||
|
(lambda (f l)
|
||||||
|
(if (null? l)
|
||||||
|
nil
|
||||||
|
(cons (f (car l)) (map f (cdr l))))))
|
||||||
|
|
||||||
|
; Filter
|
||||||
|
(define filter
|
||||||
|
(lambda (p l)
|
||||||
|
(if (null? l)
|
||||||
|
nil
|
||||||
|
(if (p (car l))
|
||||||
|
(cons (car l) (filter p (cdr l)))
|
||||||
|
(filter p (cdr l))))))
|
||||||
|
|
||||||
|
; Folds
|
||||||
|
(define fold-right
|
||||||
|
(lambda (f a l)
|
||||||
|
(if (null? l)
|
||||||
|
a
|
||||||
|
(f (car l) (fold-right f a (cdr l))))))
|
||||||
|
(define fold-left
|
||||||
|
(lambda (f a xs)
|
||||||
|
(if (null? xs)
|
||||||
|
a
|
||||||
|
(fold-left f (f a (car xs)) (cdr xs)))))
|
||||||
|
|
||||||
|
; char functions
|
||||||
|
(define numeric-char? (lambda (ch) (if (and (char? ch) (<= 48 ch 57)) #t nil)))
|
||||||
|
(define digit->number (lambda (d) (if (and (char? d) (<= 48 d 57)) (- d 48) nil)))
|
||||||
|
|
||||||
|
; length functions
|
||||||
|
(define length (lambda (l) (if (null? l) 0 (+ 1 (length (cdr l))))))
|
||||||
|
(define string-length (lambda (s) (length (string->list s))))
|
||||||
|
|
||||||
|
; More generic comparision
|
||||||
|
(define eq?
|
||||||
|
(lambda (a b)
|
||||||
|
(cond
|
||||||
|
((string? a) (if (string? b) (string=? a b) nil))
|
||||||
|
((char? a) (if (char? b) (= a b) nil))
|
||||||
|
(#t (= a b)))))
|
||||||
|
"ascension has successfully loaded"
|
|
@ -1,7 +1,7 @@
|
||||||
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
||||||
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
||||||
d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth
|
d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth
|
||||||
cb66731da407aae0e9868349b6f727184cab7d4da505bec24e3807e470432d58 roms/lisp
|
7c3887f791999aa9c1b8415d8e5be93afcf916b505296d9da7bd7a22531a84b5 roms/lisp
|
||||||
2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0
|
2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0
|
||||||
24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET
|
24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET
|
||||||
0a427b14020354d1c785f5f900677e0059fce8f8d4456e9c19e5528cb17101eb roms/stage0_monitor
|
0a427b14020354d1c785f5f900677e0059fce8f8d4456e9c19e5528cb17101eb roms/stage0_monitor
|
||||||
|
|
Loading…
Reference in New Issue