commen editing
[rrq/rrqforth.git] / stdio.asm
index f94b0cca194c707463e267dabecac247a7fb772f..5767d8b8258be3c1b11fd92d67832ce6245cbfa6 100644 (file)
--- a/stdio.asm
+++ b/stdio.asm
@@ -70,6 +70,14 @@ p_stream_MEM:
        push rax
        jmp exit
 
+       WORD p_clear_stream,'CLEAR-STREAM',fasm
+       ;; ( stream -- )
+       ;; Clear buffer of input stream
+       pop rax
+       mov rbx,qword [rax+16]  ; copy fill
+       mov qword [rax+24],rbx  ; into current
+       next
+       
 ;;; ========================================
 ;;; Stream reading
 ;;; READ-STREAM-CHAR ( stream -- ch )
@@ -164,3 +172,44 @@ p_read_word_nomore:
        pop rax
        popr rsi
        next
+
+       WORD p_tell,'TELL',fasm
+       ;; ( chars* n -- )
+       ;; Write n bytes from chars* to stdout
+       pushr rsi
+       pop rbx
+       pop rax
+       push 1
+       push rax
+       push rbx
+       DOFORTH sys_write
+       pop rax
+       popr rsi
+       next
+
+p_emit_buffer: dq 0
+       
+       WORD p_emit,'EMIT',fasm
+       ;; ( c -- )
+       ;; Write byte to stdout
+       pushr rsi
+       pop rax
+       mov [p_emit_buffer],al
+       push 1
+       push p_emit_buffer
+       push 1
+       DOFORTH sys_write
+       pop rax
+        popr rsi
+       next
+
+       WORD p_nl,'NL',dovalue
+       ;; ( -- c )
+       ;; Pushes a newline character on the stack
+       dq 10
+
+       WORD p_sp,'SP',dovalue
+       ;; ( -- c )
+       ;; Pushes a space character on the stack
+       dq 10
+