bug fix !+
[rrq/rrqforth.git] / rrqforth.asm
index 0a3f80198aa5e39f5b6a3afcfb2f35e473131cd7..18009d41bfba8f75f5b7afef2463f89988bf10e6 100644 (file)
@@ -133,7 +133,12 @@ previous_word = 0
        pop rax
        jmp qword [rax]         ; goto code of that FORTH word (64 bit jump)
        
-       WORD p_exit, 'EXIT',fasm
+       WORD p_sysexit, 'EXIT',
+       ;; ( v -- )
+       ;; Terminate RRQFORTH with error code
+       dq sys_exit
+
+       WORD p_return, 'RETURN',fasm
        ;; ( -- ) ( R: addr -- )
        ;; Returns execution to the calling definition as per the
        ;; return stack.
@@ -165,7 +170,7 @@ include 'temp.asm'
 include 'compile.asm'
 
        WORD p_program_version,'PROGRAM_VERSION',dostring
-       STRING 'RRQ Forth version 0.1 - 2021-05-22',10
+       STRING 'RRQ Forth version 0.1 - 2021-06-05',10
 
        WORD p_stdin,'STDIN',dovalue
        ;; Initialised to hold a STREAM for fd 0
@@ -267,7 +272,10 @@ p_process_args_loop:
        je p_process_args_loop
        push rax
        push rax
-       DOFORTH p_strlen, p_load_file, p_drop
+       FORTH
+       dq p_strlen, p_load_file
+       BRANCH 0, p_quit_ERROR
+       ENDFORTH
        jmp p_process_args_loop
 p_process_args_done:
        popr rsi
@@ -291,26 +299,19 @@ last_forth_word:
 p_quit_INITIALIZED:
        ;; Setup INPUT from STDIN
        FORTH
-       dq p_verboseQ
-       dq p_get
+       dq p_verboseQ, p_get
        BRANCH 0,p_quit_EVAL
-       dq p_program_version
-       dq p_tell
+       dq p_program_version, p_tell
 p_quit_EVAL:
        dq p_stdin, p_evaluate_stream
        BRANCH 0,p_quit_ERROR
-       dq p_false
-       dq sys_exit
+       dq p_false, sys_exit
 p_quit_ERROR:
        dq p_literal_string
        STRING 10,'*** Unknown word: '
        dq p_tell
-       dq p_this_word
-       dq p_2get
-       dq p_tell
-       dq p_literal_string
-       STRING 10
-       dq p_tell
+       dq p_this_word, p_2get, p_tell
+       dq p_nl, p_emit
        ENDFORTH
        mov rbp,RS_TOP          ; reset the return stack
        jmp p_quit_INITIALIZED