From 9be2763c40fcaca95b14b8d508555fa2622c4bac Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Fri, 18 Aug 2017 11:41:21 -0400 Subject: [PATCH] Incorporated number? and symbol? into stage2 lisp --- CHANGELOG.org | 1 + bootstrapping Steps.org | 2 +- stage2/lisp.s | 62 +++++++++++++++++++++++++++++++++++++++++ test/SHA256SUMS | 2 +- 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 87e9825..3888ce9 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -42,6 +42,7 @@ Added char? primitive to stage2 lisp Added string? primitive to stage2 lisp Added make_string internal function to stage2 lisp Added list->string primitive to stage2 lisp +Added number? and symbol? to stage2 lisp ** Changed Minor refactor of stage3 FORTH by reepa diff --git a/bootstrapping Steps.org b/bootstrapping Steps.org index 481ac47..d1ca30a 100644 --- a/bootstrapping Steps.org +++ b/bootstrapping Steps.org @@ -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: ./bin/vm --rom roms/stage1_assembler-2 --tape_01 temp2 --tape_02 roms/lisp --memory 48K -roms/lisp should have the sha256sum of 014cfa78c887d844b3855c6d12b50e170d57214f7b8f04853aec544ebd6ba5cb +roms/lisp should have the sha256sum of cb66731da407aae0e9868349b6f727184cab7d4da505bec24e3807e470432d58 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 diff --git a/stage2/lisp.s b/stage2/lisp.s index 82aac76..a1e518e 100644 --- a/stage2/lisp.s +++ b/stage2/lisp.s @@ -1958,6 +1958,54 @@ RET R15 +;; prim_numberp +;; Recieves argslist in R0 +;; Returns #t if NUMBER else NIL +:prim_numberp_String + "number?" +:prim_numberp + CMPSKIPI.NE R0 $NIL ; If NIL Expression + RET R15 ; Just get the Hell out + + LOAD32 R0 R0 4 ; Get ARGS->CAR + LOAD32 R0 R0 0 ; Get ARGS->CAR->TYPE + CMPSKIPI.NE R0 4 ; If NUMBER + JUMP @prim_numberp_0 ; Return TEE + + LOADUI R0 $NIL ; Otherwise return NIL + JUMP @prim_numberp_done + +:prim_numberp_0 + LOADUI R0 $TEE ; Make TEE + +:prim_numberp_done + RET R15 + + +;; prim_symbolp +;; Recieves argslist in R0 +;; Returns #t if SYMBOL else NIL +:prim_symbolp_String + "symbol?" +:prim_symbolp + CMPSKIPI.NE R0 $NIL ; If NIL Expression + RET R15 ; Just get the Hell out + + LOAD32 R0 R0 4 ; Get ARGS->CAR + LOAD32 R0 R0 0 ; Get ARGS->CAR->TYPE + CMPSKIPI.NE R0 8 ; If SYMBOL + JUMP @prim_symbolp_0 ; Return TEE + + LOADUI R0 $NIL ; Otherwise return NIL + JUMP @prim_symbolp_done + +:prim_symbolp_0 + LOADUI R0 $TEE ; Make TEE + +:prim_symbolp_done + RET R15 + + ;; prim_stringp ;; Recieves argslist in R0 ;; Returns #t if CHAR else NIL @@ -2704,6 +2752,20 @@ CALLI R15 @make_sym ; MAKE_SYM CALLI R15 @spinup ; SPINUP + LOADUI R0 $prim_numberp ; Using PRIM_NUMBERP + CALLI R15 @make_prim ; MAKE_PRIM + MOVE R1 R0 ; Put Primitive in correct location + LOADUI R0 $prim_numberp_String ; Using PRIM_NUMBERP_STRING + CALLI R15 @make_sym ; MAKE_SYM + CALLI R15 @spinup ; SPINUP + + LOADUI R0 $prim_symbolp ; Using PRIM_SYMBOLP + CALLI R15 @make_prim ; MAKE_PRIM + MOVE R1 R0 ; Put Primitive in correct location + LOADUI R0 $prim_symbolp_String ; Using PRIM_SYMBOLP_STRING + CALLI R15 @make_sym ; MAKE_SYM + CALLI R15 @spinup ; SPINUP + LOADUI R0 $prim_stringp ; Using PRIM_STRINGP CALLI R15 @make_prim ; MAKE_PRIM MOVE R1 R0 ; Put Primitive in correct location diff --git a/test/SHA256SUMS b/test/SHA256SUMS index b0e0385..a7e9b04 100644 --- a/test/SHA256SUMS +++ b/test/SHA256SUMS @@ -1,7 +1,7 @@ 8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT 59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth -014cfa78c887d844b3855c6d12b50e170d57214f7b8f04853aec544ebd6ba5cb roms/lisp +cb66731da407aae0e9868349b6f727184cab7d4da505bec24e3807e470432d58 roms/lisp 2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0 24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET 0a427b14020354d1c785f5f900677e0059fce8f8d4456e9c19e5528cb17101eb roms/stage0_monitor