avoid dropping first character
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Tue, 18 May 2021 01:46:51 +0000 (11:46 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Tue, 18 May 2021 01:46:51 +0000 (11:46 +1000)
stdio.asm

index ae3e08eaa64a5c3b72e1152bce4161da7a8b8f17..fed8eda38df2fffa598e11bb4f8d7c8d4a26b19e 100644 (file)
--- a/stdio.asm
+++ b/stdio.asm
@@ -108,6 +108,7 @@ p_read_stream_char.CHAR:
        push qword p_line_buffer_DFA
        push qword 0
        push rax
+
 p_read_word_skipblanks:        
        FORTH
        dq p_dup
@@ -118,7 +119,13 @@ p_read_word_skipblanks:
        jl p_read_word_nomore
        cmp bl,' '
        jle p_read_word_skipblanks
+
 p_read_word_readword:
+       ;; ( buffer length stream )
+       mov rax,qword [rsp+16]
+       mov rcx,qword [rsp+8]
+       mov [rax+rcx],bl
+       inc qword [rsp+8]
        FORTH
        dq p_dup
        dq p_read_stream_char
@@ -127,13 +134,8 @@ p_read_word_readword:
        cmp bl,0
        jl p_read_word_nomore
        cmp bl,' '
-       jle p_read_word_nomore
-       ;; ( buffer length stream )
-       mov rax,qword [rsp+16]
-       mov rcx,qword [rsp+8]
-       mov [rax+rcx],bl
-       inc qword [rsp+8]
-       jmp p_read_word_readword
+       jg p_read_word_readword
+
 p_read_word_nomore:
        pop rax
        popr rsi