diff --git a/CHANGELOG.org b/CHANGELOG.org index a400d23..2480aa7 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -36,6 +36,7 @@ Added Low memory detection to stage2 Lisp and now exists gracefully Improved ISA Notes about M0 and hex2 to help bootstrappers Added rain1's new user forth starting script, which is not actually required for bootstrapping but rather convenience Added Most primitive raw string support to stage2 lisp +Added integer->char and char->integer to stage2 lisp ** Changed Minor refactor of stage3 FORTH by reepa diff --git a/bootstrapping Steps.org b/bootstrapping Steps.org index 1006871..153eac6 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 ab9b52c1557c044e912fe099f82a1a8f66f065d86e8840403f10a2a90b8e3f73 +roms/lisp should have the sha256sum of 12da90f95363e93769c5be2034845eb34db56bc92d6726f19cc0953ecbb5fa34 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 891992a..0b6ecd2 100644 --- a/stage2/lisp.s +++ b/stage2/lisp.s @@ -2140,6 +2140,50 @@ RET R15 +;; prim_integer_to_char +;; Recieves a list in R0 +;; Converts all integers to ASCII +:prim_integer_to_char_String + "integer->char" +:prim_integer_to_char + CMPSKIPI.NE R0 $NIL ; If NIL Expression + RET R15 ; Just get the Hell out + + PUSHR R1 R15 ; Protect R1 + PUSHR R2 R15 ; Protect R2 + LOADUI R2 128 ; Using Type CHAR + LOAD32 R0 R0 4 ; Get ARGS->CAR + LOAD32 R1 R0 0 ; Get ARGS->CAR->TYPE + CMPSKIPI.NE R1 4 ; If Type INT + STORE32 R2 R0 0 ; Update ARGS->CAR->TYPE + + POPR R2 R15 ; Restore R2 + POPR R1 R15 ; Restore R1 + RET R15 + + +;; prim_char_to_integer +;; Recieves a list in R0 +;; Converts all integers to ASCII +:prim_char_to_integer_String + "char->integer" +:prim_char_to_integer + CMPSKIPI.NE R0 $NIL ; If NIL Expression + RET R15 ; Just get the Hell out + + PUSHR R1 R15 ; Protect R1 + PUSHR R2 R15 ; Protect R2 + LOADUI R2 4 ; Using Type INT + LOAD32 R0 R0 4 ; Get ARGS->CAR + LOAD32 R1 R0 0 ; Get ARGS->CAR->TYPE + CMPSKIPI.NE R1 128 ; If Type CHAR + STORE32 R2 R0 0 ; Update ARGS->CAR->TYPE + + POPR R2 R15 ; Restore R2 + POPR R1 R15 ; Restore R1 + RET R15 + + ;; prim_halt ;; Simply HALTS :prim_halt_String @@ -2541,6 +2585,20 @@ CALLI R15 @make_sym ; MAKE_SYM CALLI R15 @spinup ; SPINUP + LOADUI R0 $prim_integer_to_char ; Using PRIM_INTEGER_TO_CHAR + CALLI R15 @make_prim ; MAKE_PRIM + MOVE R1 R0 ; Put Primitive in correct location + LOADUI R0 $prim_integer_to_char_String ; Using PRIM_INTEGER_TO_CHAR_STRING + CALLI R15 @make_sym ; MAKE_SYM + CALLI R15 @spinup ; SPINUP + + LOADUI R0 $prim_char_to_integer ; Using PRIM_CHAR_TO_INTEGER + CALLI R15 @make_prim ; MAKE_PRIM + MOVE R1 R0 ; Put Primitive in correct location + LOADUI R0 $prim_char_to_integer_String ; Using PRIM_CHAR_TO_INTEGER_STRING + CALLI R15 @make_sym ; MAKE_SYM + CALLI R15 @spinup ; SPINUP + LOADUI R0 $prim_halt ; Using PRIM_HALT CALLI R15 @make_prim ; MAKE_PRIM MOVE R1 R0 ; Put Primitive in correct location diff --git a/test/SHA256SUMS b/test/SHA256SUMS index 94f9ab1..eb8559a 100644 --- a/test/SHA256SUMS +++ b/test/SHA256SUMS @@ -1,7 +1,7 @@ 8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT 59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth -ab9b52c1557c044e912fe099f82a1a8f66f065d86e8840403f10a2a90b8e3f73 roms/lisp +12da90f95363e93769c5be2034845eb34db56bc92d6726f19cc0953ecbb5fa34 roms/lisp 2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0 24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET 0a427b14020354d1c785f5f900677e0059fce8f8d4456e9c19e5528cb17101eb roms/stage0_monitor