Implemented basic raw string support in stage2 lisp, many more
enhancements required to make it fully useful
This commit is contained in:
parent
5b302ba9d0
commit
f3f8ec5a32
|
@ -35,6 +35,7 @@ Added Low memory detection to stage2 FORTH and now exits gracefully
|
||||||
Added Low memory detection to stage2 Lisp and now exists gracefully
|
Added Low memory detection to stage2 Lisp and now exists gracefully
|
||||||
Improved ISA Notes about M0 and hex2 to help bootstrappers
|
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 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
|
||||||
|
|
||||||
** 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 b386b0e08250421a4d7eb14817b4c3359aef52d7773b3667bb1caaa933cbfe66
|
roms/lisp should have the sha256sum of ab9b52c1557c044e912fe099f82a1a8f66f065d86e8840403f10a2a90b8e3f73
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
;;
|
;;
|
||||||
;; Type maps to the following values
|
;; Type maps to the following values
|
||||||
;; FREE = 1, MARKED = (1 << 1),INT = (1 << 2),SYM = (1 << 3),
|
;; FREE = 1, MARKED = (1 << 1),INT = (1 << 2),SYM = (1 << 3),
|
||||||
;; CONS = (1 << 4),PROC = (1 << 5),PRIMOP = (1 << 6),ASCII = (1 << 7)
|
;; CONS = (1 << 4),PROC = (1 << 5),PRIMOP = (1 << 6),ASCII = (1 << 7), STRING = (1 << 8)
|
||||||
|
|
||||||
;; CONS space: End of program -> 1MB (0x100000)
|
;; CONS space: End of program -> 1MB (0x100000)
|
||||||
;; HEAP space: 1MB -> 1.5MB (0x180000)
|
;; HEAP space: 1MB -> 1.5MB (0x180000)
|
||||||
|
@ -139,10 +139,22 @@
|
||||||
CMPSKIPI.G R3 32 ; If control character or SPACE
|
CMPSKIPI.G R3 32 ; If control character or SPACE
|
||||||
JUMP @tokenize_append ; Stop
|
JUMP @tokenize_append ; Stop
|
||||||
|
|
||||||
|
CMPSKIPI.NE R3 34 ; If raw string
|
||||||
|
JUMP @tokenize_string ; Process that whole thing
|
||||||
|
|
||||||
;; Walk further down string
|
;; Walk further down string
|
||||||
ADDUI R4 R4 1 ; Next char
|
ADDUI R4 R4 1 ; Next char
|
||||||
JUMP @tokenize_loop ; And try again
|
JUMP @tokenize_loop ; And try again
|
||||||
|
|
||||||
|
:tokenize_string
|
||||||
|
;; Walk further down string
|
||||||
|
ADDUI R4 R4 1 ; Next char
|
||||||
|
LOADXU8 R3 R1 R4 ; Get char
|
||||||
|
CMPSKIPI.NE R3 34 ; If Found matching quote
|
||||||
|
JUMP @tokenize_append ; Stop
|
||||||
|
|
||||||
|
JUMP @tokenize_string ; And try again
|
||||||
|
|
||||||
:tokenize_append
|
:tokenize_append
|
||||||
FALSE R3 ; NULL terminate
|
FALSE R3 ; NULL terminate
|
||||||
STOREX8 R3 R1 R4 ; Found Token
|
STOREX8 R3 R1 R4 ; Found Token
|
||||||
|
@ -289,7 +301,7 @@
|
||||||
LOADU8 R2 R1 0 ; Get first Char
|
LOADU8 R2 R1 0 ; Get first Char
|
||||||
|
|
||||||
CMPSKIPI.E R2 39 ; If Not Quote Char
|
CMPSKIPI.E R2 39 ; If Not Quote Char
|
||||||
JUMP @atom_integer ; Move to next type
|
JUMP @atom_string ; Move to next type
|
||||||
|
|
||||||
;; When dealing with a quote
|
;; When dealing with a quote
|
||||||
ADDUI R1 R1 1 ; Move past quote Char
|
ADDUI R1 R1 1 ; Move past quote Char
|
||||||
|
@ -303,6 +315,21 @@
|
||||||
MOVE R1 R0 ; Put What is being returned into R1
|
MOVE R1 R0 ; Put What is being returned into R1
|
||||||
JUMP @atom_done ; We are done
|
JUMP @atom_done ; We are done
|
||||||
|
|
||||||
|
:atom_string
|
||||||
|
CMPSKIPI.E R2 34 ; If Not Double quote
|
||||||
|
JUMP @atom_integer ; Move to next type
|
||||||
|
|
||||||
|
;; a->string = a->string + 1
|
||||||
|
ADDUI R1 R1 1 ; Move past quote Char
|
||||||
|
STORE32 R1 R0 4 ; And write to CAR
|
||||||
|
|
||||||
|
;; a->type = STRING
|
||||||
|
LOADUI R1 256 ; Using STRING
|
||||||
|
STORE32 R1 R0 0 ; Set type to Integer
|
||||||
|
|
||||||
|
COPY R1 R0 ; Put the cell we were given in the right place
|
||||||
|
JUMP @atom_done ; We are done
|
||||||
|
|
||||||
:atom_integer
|
:atom_integer
|
||||||
COPY R2 R1 ; Preserve String pointer
|
COPY R2 R1 ; Preserve String pointer
|
||||||
SWAP R0 R1 ; Put string Pointer in R0
|
SWAP R0 R1 ; Put string Pointer in R0
|
||||||
|
@ -496,6 +523,9 @@
|
||||||
CMPSKIPI.G R0 32 ; If SPACE or below
|
CMPSKIPI.G R0 32 ; If SPACE or below
|
||||||
JUMP @Readline_1
|
JUMP @Readline_1
|
||||||
|
|
||||||
|
CMPSKIPI.NE R0 34 ; Look for double quote
|
||||||
|
JUMP @Readline_string ; Keep looping until then
|
||||||
|
|
||||||
CMPSKIPI.NE R0 59 ; If LINE Comment (;)
|
CMPSKIPI.NE R0 59 ; If LINE Comment (;)
|
||||||
JUMP @Readline_0 ; Drop until the end of Line
|
JUMP @Readline_0 ; Drop until the end of Line
|
||||||
|
|
||||||
|
@ -520,6 +550,25 @@
|
||||||
|
|
||||||
JUMP @Readline_0 ; Otherwise Keep Looping
|
JUMP @Readline_0 ; Otherwise Keep Looping
|
||||||
|
|
||||||
|
;; Deal with strings
|
||||||
|
:Readline_string
|
||||||
|
STOREX8 R0 R2 R3 ; Append to String
|
||||||
|
ADDUI R3 R3 1 ; Increment Size
|
||||||
|
FGETC ; Get a Byte
|
||||||
|
|
||||||
|
CMPSKIPI.NE R0 13 ; Deal with CR
|
||||||
|
LOADUI R0 10 ; Convert to LF
|
||||||
|
|
||||||
|
CMPSKIPI.NE R13 0 ; Don't display unless TTY
|
||||||
|
FPUTC ; Display the Char we just pressed
|
||||||
|
|
||||||
|
CMPSKIPI.E R0 34 ; Look for double quote
|
||||||
|
JUMP @Readline_string ; Keep looping until then
|
||||||
|
|
||||||
|
STOREX8 R0 R2 R3 ; Append to String
|
||||||
|
ADDUI R3 R3 1 ; Increment Size
|
||||||
|
JUMP @Readline_loop ; Resume
|
||||||
|
|
||||||
;; Deal with Whitespace and Control Chars
|
;; Deal with Whitespace and Control Chars
|
||||||
:Readline_1
|
:Readline_1
|
||||||
CMPSKIPI.NE R4 0 ; IF Depth 0
|
CMPSKIPI.NE R4 0 ; IF Depth 0
|
||||||
|
@ -672,6 +721,9 @@
|
||||||
CMPSKIPI.NE R2 128 ; If ASCII
|
CMPSKIPI.NE R2 128 ; If ASCII
|
||||||
JUMP @writeobj_ASCII ; Print the Char
|
JUMP @writeobj_ASCII ; Print the Char
|
||||||
|
|
||||||
|
CMPSKIPI.NE R2 256 ; If STRING
|
||||||
|
JUMP @writeobj_STRING ; Print the String
|
||||||
|
|
||||||
;; What the hell is that???
|
;; What the hell is that???
|
||||||
LOADUI R0 $writeobj_Error
|
LOADUI R0 $writeobj_Error
|
||||||
FALSE R1
|
FALSE R1
|
||||||
|
@ -740,6 +792,11 @@
|
||||||
CALLI R15 @Print_String ; Write it to output
|
CALLI R15 @Print_String ; Write it to output
|
||||||
JUMP @writeobj_done ; Be Done
|
JUMP @writeobj_done ; Be Done
|
||||||
|
|
||||||
|
:writeobj_STRING
|
||||||
|
LOAD32 R0 R3 4 ; Get HEAD->CAR
|
||||||
|
CALLI R15 @Print_String ; Write it to output
|
||||||
|
JUMP @writeobj_done ; Be Done
|
||||||
|
|
||||||
:writeobj_ASCII
|
:writeobj_ASCII
|
||||||
LOADU8 R0 R3 7 ; Using bottom 8 bits of HEAD->CAR
|
LOADU8 R0 R3 7 ; Using bottom 8 bits of HEAD->CAR
|
||||||
FPUTC ; We write our desired output
|
FPUTC ; We write our desired output
|
||||||
|
@ -1152,8 +1209,12 @@
|
||||||
|
|
||||||
:eval_ascii
|
:eval_ascii
|
||||||
CMPSKIPI.E R4 128 ; If EXP->TYPE is NOT ASCII
|
CMPSKIPI.E R4 128 ; If EXP->TYPE is NOT ASCII
|
||||||
JUMP @eval_error ; Move onto next Case
|
JUMP @eval_string ; Move onto next Case
|
||||||
|
JUMP @eval_done
|
||||||
|
|
||||||
|
:eval_string
|
||||||
|
CMPSKIPI.E R4 256 ; If EXP->TYPE is NOT ASCII
|
||||||
|
JUMP @eval_error ; Move onto next Case
|
||||||
JUMP @eval_done
|
JUMP @eval_done
|
||||||
|
|
||||||
:eval_error
|
:eval_error
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
||||||
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
||||||
d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth
|
d7967248be71937d4fa1f38319a5a8473a842b1f6806b977e5fb184565bde0a4 roms/forth
|
||||||
b386b0e08250421a4d7eb14817b4c3359aef52d7773b3667bb1caaa933cbfe66 roms/lisp
|
ab9b52c1557c044e912fe099f82a1a8f66f065d86e8840403f10a2a90b8e3f73 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