Implemented graceful FAILURE and PRINT
This commit is contained in:
parent
a51c243088
commit
4963fcfebc
|
@ -30,6 +30,8 @@ Added hex dump printer DUMP and support words to stage3 FORTH
|
||||||
Added DOES> and supporting words, and used it to make VARIABLE, CONSTANT, and DEFER in stage3 FORTH
|
Added DOES> and supporting words, and used it to make VARIABLE, CONSTANT, and DEFER in stage3 FORTH
|
||||||
Added TUCK, MIN, SPACES, :NONAME, FILL, and <> to stage3 FORTH
|
Added TUCK, MIN, SPACES, :NONAME, FILL, and <> to stage3 FORTH
|
||||||
Added LSHIFT and RSHIFT to stage2 FORTH
|
Added LSHIFT and RSHIFT to stage2 FORTH
|
||||||
|
Added PRINT to stage2 FORTH
|
||||||
|
Added Low memory detection to stage2 FORTH and now exits gracefully
|
||||||
|
|
||||||
** Changed
|
** Changed
|
||||||
Minor refactor of stage3 FORTH by reepa
|
Minor refactor of stage3 FORTH by reepa
|
||||||
|
|
|
@ -174,7 +174,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/forth --memory 48K
|
./bin/vm --rom roms/stage1_assembler-2 --tape_01 temp2 --tape_02 roms/forth --memory 48K
|
||||||
|
|
||||||
roms/forth should with the sha256sum of 53619f77736729edc06b79d27d835ada6a4235954c467dd0514e312ec4acf3dc
|
roms/forth should with the sha256sum of 3a4a15691297345ac808ce41fae26d5592cd09d759d2feef88c1ef262ddaa5b8
|
||||||
|
|
||||||
Our forth will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in
|
Our forth will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in
|
||||||
(Otherwise there is no way for a forth fan to have a chance against the lisp in terms of being able to bootstrap something cool)
|
(Otherwise there is no way for a forth fan to have a chance against the lisp in terms of being able to bootstrap something cool)
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
;; Loads contents of tape_01
|
;; Loads contents of tape_01
|
||||||
;; Starts interface until Halted
|
;; Starts interface until Halted
|
||||||
:start
|
:start
|
||||||
|
HAL_MEM ; Get total amount of Memory
|
||||||
|
LOADR R1 @MINIMAL_MEMORY ; Get our Minimal Value
|
||||||
|
CMPSKIP.GE R0 R1 ; Check if we have enough
|
||||||
|
JUMP @FAILED_INITIALIZATION ; If not fail gracefully
|
||||||
LOADR R15 @RETURN_BASE ; Load Base of Return Stack
|
LOADR R15 @RETURN_BASE ; Load Base of Return Stack
|
||||||
LOADR R14 @PARAMETER_BASE ; Load Base of Parameter Stack
|
LOADR R14 @PARAMETER_BASE ; Load Base of Parameter Stack
|
||||||
LOADUI R11 $NEXT ; Get Address of Next
|
LOADUI R11 $NEXT ; Get Address of Next
|
||||||
|
@ -65,6 +69,9 @@
|
||||||
:Cold_Start
|
:Cold_Start
|
||||||
&Quit_Code
|
&Quit_Code
|
||||||
|
|
||||||
|
:MINIMAL_MEMORY
|
||||||
|
'00100000'
|
||||||
|
|
||||||
:RETURN_BASE
|
:RETURN_BASE
|
||||||
'00080000'
|
'00080000'
|
||||||
|
|
||||||
|
@ -74,8 +81,19 @@
|
||||||
:STRING_BASE
|
:STRING_BASE
|
||||||
'000A0000'
|
'000A0000'
|
||||||
|
|
||||||
;; The last function you'll ever need to run
|
;; FAILED_INITIALIZATION
|
||||||
;; HALT
|
:FAILED_INITIALIZATION
|
||||||
|
FALSE R1 ; Set output to TTY
|
||||||
|
LOADUI R2 $FAILED_STRING ; Prepare our Message
|
||||||
|
CALLI R15 @PRINT_Direct ; Print it
|
||||||
|
HALT ; Be done
|
||||||
|
|
||||||
|
:FAILED_STRING
|
||||||
|
"Please provide 1MB or More of Memory for this FORTH to run
|
||||||
|
"
|
||||||
|
|
||||||
|
;; The last function you'll ever need to run
|
||||||
|
;; HALT
|
||||||
:HALT_Text
|
:HALT_Text
|
||||||
"HALT"
|
"HALT"
|
||||||
:HALT_Entry
|
:HALT_Entry
|
||||||
|
@ -1097,9 +1115,9 @@
|
||||||
&ABORT_Code ; Where assembly is Stored
|
&ABORT_Code ; Where assembly is Stored
|
||||||
:ABORT_Code
|
:ABORT_Code
|
||||||
MOVE R2 R1 ; Protect the string pointer and set output to TTY
|
MOVE R2 R1 ; Protect the string pointer and set output to TTY
|
||||||
CALLI R15 @ABORT_PRINT ; Print our unknown
|
CALLI R15 @PRINT_Direct ; Print our unknown
|
||||||
LOADUI R2 $ABORT_String ; Get our string
|
LOADUI R2 $ABORT_String ; Get our string
|
||||||
CALLI R15 @ABORT_PRINT ; Print it
|
CALLI R15 @PRINT_Direct ; Print it
|
||||||
LOADUI R0 10 ; NEWLINE
|
LOADUI R0 10 ; NEWLINE
|
||||||
FPUTC ; Printed
|
FPUTC ; Printed
|
||||||
LOADR R15 @RETURN_BASE ; Load Base of Return Stack
|
LOADR R15 @RETURN_BASE ; Load Base of Return Stack
|
||||||
|
@ -1110,19 +1128,33 @@
|
||||||
:ABORT_String
|
:ABORT_String
|
||||||
" was not defined nor a valid number"
|
" was not defined nor a valid number"
|
||||||
|
|
||||||
:ABORT_PRINT
|
;; PRINT
|
||||||
|
:PRINT_Text
|
||||||
|
"PRINT"
|
||||||
|
:PRINT_Entry
|
||||||
|
&ABORT_Entry ; Pointer to ABORT
|
||||||
|
&PRINT_Text ; Pointer to Name
|
||||||
|
NOP ; Flags
|
||||||
|
&PRINT_Code ; Where assembly is Stored
|
||||||
|
:PRINT_Code
|
||||||
|
POPR R2 R14 ; Load pointer to string
|
||||||
|
CALLI R15 @PRINT_Direct ; Trick to allow direct calls
|
||||||
|
JSR_COROUTINE R11 ; NEXT
|
||||||
|
|
||||||
|
:PRINT_Direct
|
||||||
LOAD8 R0 R2 0 ; Get a byte
|
LOAD8 R0 R2 0 ; Get a byte
|
||||||
ADDUI R2 R2 1 ; Increment to next byte
|
ADDUI R2 R2 1 ; Increment to next byte
|
||||||
CMPSKIPI.NE R0 0 ; If NULL
|
CMPSKIPI.NE R0 0 ; If NULL
|
||||||
RET R15 ; Return to caller
|
RET R15 ; Return to caller
|
||||||
FPUTC ; Write the CHAR
|
FPUTC ; Write the CHAR
|
||||||
JUMP @ABORT_PRINT ; Loop until NULL
|
JUMP @PRINT_Direct ; Loop until NULL
|
||||||
|
|
||||||
|
|
||||||
;; strcmp
|
;; strcmp
|
||||||
:Strcmp_Text
|
:Strcmp_Text
|
||||||
"STRCMP"
|
"STRCMP"
|
||||||
:Strcmp_Entry
|
:Strcmp_Entry
|
||||||
&ABORT_Entry ; Pointer to ABORT
|
&PRINT_Entry ; Pointer to PRINT
|
||||||
&Strcmp_Text ; Pointer to Name
|
&Strcmp_Text ; Pointer to Name
|
||||||
NOP ; Flags
|
NOP ; Flags
|
||||||
&Strcmp_Code ; Where assembly is Stored
|
&Strcmp_Code ; Where assembly is Stored
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT
|
||||||
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX
|
||||||
53619f77736729edc06b79d27d835ada6a4235954c467dd0514e312ec4acf3dc roms/forth
|
3a4a15691297345ac808ce41fae26d5592cd09d759d2feef88c1ef262ddaa5b8 roms/forth
|
||||||
4c146297da8c672955698a82207295b28feb389c9856a2c6ea6a60ce7e84260a roms/lisp
|
4c146297da8c672955698a82207295b28feb389c9856a2c6ea6a60ce7e84260a roms/lisp
|
||||||
2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0
|
2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0
|
||||||
24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET
|
24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET
|
||||||
|
|
Loading…
Reference in New Issue